Re: [PATCH v4 2/9] KVM: TDX: Check if there is valid exit infos based on vp_enter_ret

Xiaoyao Li <[email protected]>
Newsgroups dev.linux.lists.linux-coco,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 8/20/2026 12:39 AM, Edgecombe, Rick P wrote:
> On Wed, 2026-08-19 at 17:48 +0800, Xiaoyao Li wrote:
>> Check if there is valid exit info based on vp_enter_ret instead of relying
>> on the clobbered Exit Reason, in tdx_get_exit_info().
>>
>> Current KVM uses "Exit Reason is not equal to the synthesized invalid
>> Exit Reason, -1u," as the condition to identify there is a real TD Exit
>> and valid exit infos.  However, there is one issue with this approach:
>> KVM updates the Exit Reason to the synthesized invalid Exit Reason for
>> real EPT MISCONFIG as well.  This is a false positive for real EPT
>> MISCONFIG, which has valid exit infos.
>>
>> Though the issue can be addressed by changing the handling for real EPT
>> MISCONFIG to not update the Exit Reason to the synthesized one, relying
>> on the clobbered Exit Reason itself is brittle.  Instead, check
>> vp_enter_ret directly to identify if it is a valid Exit Reason.
>>
>> Fixes: da407fe45908 ("KVM: TDX: Handle EPT violation/misconfig exit")
>> Cc: [email protected]
>> Suggested-by: Sean Christopherson <[email protected]>
>> Signed-off-by: Xiaoyao Li <[email protected]>
>> ---
> 
> This series has grown unfortunately, and I wasn't able to catch up on the
> threads from yesterday. Can we really not put this one in the non-stable patches
> at the end? Or maybe you can explain why it's needed?

It was suggested[1] (or requested) by Sean.

I agree that it's not mandatory for enabling Bus Lock VM exit for TDX. 
But considering that without this patch, both patch 3 and patch 4 need 
to change the line

	if (*reason != -1u)

in tdx_get_exit_info(), which brings unnecessary code churn. And given 
the patch number needs to increase anyway in this v4. So I just put this 
patch in to make patch 3 and patch 4 simpler.

[1] https://lore.kernel.org/all/[email protected]/

> Also "KVM: VMX: Preserve negative return value in vmx_handle_exit() with bus
> lock detected"?

It was suggested[2] by Sean.

(Since there are discussions happening in the cover letter thread about 
it. Let's continue the discussion there.)

[2] https://lore.kernel.org/all/[email protected]/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.