Re: [PATCH 2/5] KVM: TDX: Exit with MEMORY_FAULT on unexpected pending S-EPT Violation
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Date: 2025-07-29 22:27:53
Also in:
kvm, kvmarm, lkml
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Date: 2025-07-29 22:27:53
Also in:
kvm, kvmarm, lkml
On Tue, 2025-07-29 at 12:33 -0700, Sean Christopherson wrote:
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 3e0d4edee849..c2ef03f39c32 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c@@ -1937,10 +1937,8 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu)if (vt_is_tdx_private_gpa(vcpu->kvm, gpa)) { if (tdx_is_sept_violation_unexpected_pending(vcpu)) { - pr_warn("Guest access before accepting 0x%llx on vCPU %d\n", - gpa, vcpu->vcpu_id); - kvm_vm_dead(vcpu->kvm); - return -EIO; + kvm_prepare_memory_fault_exit(vcpu, gpa, 0, true, false, true); + return -EFAULT; } /* * Always treat SEPT violations as write faults. Ignore the
The vm_dead was added because mirror EPT will KVM_BUG_ON() if there is an attempt to set the mirror EPT entry when it is already present. And the unaccepted memory access will trigger an EPT violation for a mirror PTE that is already set. I think this is a better solution irrespective of the vm_dead changes. Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com> But hmm, tangentially related, but Yan do we have a similar problem with KVM_PRE_FAULT_MEMORY after we started setting pre_fault_allowed during TD finalization?