Re: [PATCH v4 2/9] KVM: TDX: Check if there is valid exit infos based on vp_enter_ret
From: Xiaoyao Li
Date: Wed Aug 19 2026 - 21:53:27 EST
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: stable@xxxxxxxxxxxxxxx
Suggested-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Signed-off-by: Xiaoyao Li <xiaoyao.li@xxxxxxxxx>
---
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/an0N0vHwsYEqjpRe@xxxxxxxxxx/
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/an0KokdtSXE2GmM1@xxxxxxxxxx/