]> git.ipfire.org Git - thirdparty/linux.git/commit
KVM: TDX: Do not retry locally when the retry is caused by invalid memslot
authorSean Christopherson <seanjc@google.com>
Fri, 22 Aug 2025 07:05:23 +0000 (15:05 +0800)
committerSean Christopherson <seanjc@google.com>
Wed, 10 Sep 2025 19:06:35 +0000 (12:06 -0700)
commit2bc2694fe20bf06eb73524426e3f4581d7b28923
tree2860cff897d4e46784ef494a274f00b3751c1d94
parent3ccbf6f47098f5d5e247d1b7739d0fd90802187b
KVM: TDX: Do not retry locally when the retry is caused by invalid memslot

Avoid local retries within the TDX EPT violation handler if a retry is
triggered by faulting in an invalid memslot, indicating that the memslot
is undergoing a removal process.  Faulting in a GPA from an invalid
memslot will never succeed, and holding SRCU prevents memslot deletion
from succeeding, i.e. retrying when the memslot is being actively deleted
will lead to (breakable) deadlock.

Opportunistically export kvm_vcpu_gfn_to_memslot() to allow for a per-vCPU
lookup (which, strictly speaking, is unnecessary since TDX doesn't support
SMM, but aligns the TDX code with the MMU code).

Fixes: b0327bb2e7e0 ("KVM: TDX: Retry locally in TDX EPT violation handler on RET_PF_RETRY")
Reported-by: Reinette Chatre <reinette.chatre@intel.com>
Closes: https://lore.kernel.org/all/20250519023737.30360-1-yan.y.zhao@intel.com
[Yan: Wrote patch log, comment, fixed a minor error, function export]
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Link: https://lore.kernel.org/r/20250822070523.26495-1-yan.y.zhao@intel.com
[sean: massage changelog, relocate and tweak comment]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/tdx.c
virt/kvm/kvm_main.c