]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: x86: Move error handling inside free_external_spt()
authorSean Christopherson <seanjc@google.com>
Sat, 9 May 2026 07:57:30 +0000 (15:57 +0800)
committerSean Christopherson <seanjc@google.com>
Thu, 28 May 2026 00:19:21 +0000 (17:19 -0700)
commitb35bda696e4416a01a064ccb5e67bca03132d8ec
treef382d6d0ad444b03ea0486b8a7b5857096fc21d4
parent0cef26b537ffa963d719c529f8ff604c1db505fd
KVM: x86: Move error handling inside free_external_spt()

Move the logic for TDX's specific need to leak pages when reclaim
fails inside the free_external_spt() op, so this can be done in TDX
specific code and not the generic MMU.

Do this by passing in "sp" instead of the external page table pointer.
This way, TDX code can set sp->external_spt to NULL. Since the error is now
handled internally in TDX code (by triggering KVM_BUG_ON() or
TDX_BUG_ON_3(), which warn and stop the VM on any error), change the op to
return void. This way it also operates like a normal free in that success
is guaranteed from the caller's perspective.

Opportunistically, drop the unused level and gfn args while adjusting the
sp arg.

[ Rick: Re-wrote log and massaged op name ]
Co-developed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
[ Yan: Updated patch log/function comment, dropped unused param in op ]
Co-developed-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Link: https://patch.msgid.link/20260509075730.4354-1-yan.y.zhao@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/kvm-x86-ops.h
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/tdp_mmu.c
arch/x86/kvm/vmx/tdx.c