]> git.hungrycats.org Git - linux/commitdiff
KVM: TDX: Stuff exit_reason with UNDEFINED on wait_for_sept_zap return
authorXiaoyao Li <xiaoyao.li@intel.com>
Wed, 19 Aug 2026 09:48:59 +0000 (17:48 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:49 +0000 (12:10 -0500)
commit e5f1d62c59aea4f270773de1bf6e8867f5b1124c upstream.

Forcefully update the exit_reason to KVM's "standard" EXIT_REASON_UNDEFINED
if tdx_vcpu_run() bails without trying to run the vCPU because KVM needs to
wait for an in-progress S-EPT zap to complete.  This avoids handling the
previous exit multiple times due to a stale exit_reason.

Fixes: 4b2abc49712b ("KVM: TDX: Kick off vCPUs when SEAMCALL is busy during TD page removal")
Cc: stable@vger.kernel.org
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://patch.msgid.link/20260819094903.3060020-6-xiaoyao.li@intel.com
[sean: use EXIT_REASON_UNDEFINED, drop comment about bits 31:16]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/vmx/tdx.c

index e8451f68948299bbe70fdf18809df0278ff3e2a9..a2c1ae0ec4b66c94f802fa6b5ffaaab42c6d9ba5 100644 (file)
@@ -1081,8 +1081,16 @@ fastpath_t tdx_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags)
         * allowing vCPU entry to avoid contention with tdh_vp_enter() and
         * TDCALLs.
         */
-       if (unlikely(READ_ONCE(to_kvm_tdx(vcpu->kvm)->wait_for_sept_zap)))
+       if (unlikely(READ_ONCE(to_kvm_tdx(vcpu->kvm)->wait_for_sept_zap))) {
+               /*
+                * The vCPU never entered the guest, but this looks like a
+                * handled exit to the caller.  Synthesize an invalid exit
+                * reason so the previous exit's stale value isn't consumed
+                * a second time.
+                */
+               vt->exit_reason.full = EXIT_REASON_UNDEFINED;
                return EXIT_FASTPATH_EXIT_HANDLED;
+       }
 
        trace_kvm_entry(vcpu, run_flags & KVM_RUN_FORCE_IMMEDIATE_EXIT);