summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu/tdp_iter.h
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2024-05-18 02:04:25 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2024-05-23 18:27:26 +0200
commit837d557aba6b816985141ddbeb7649444ed26d3b (patch)
treefbae9dffb641230fb789cb25335acd07af307220 /arch/x86/kvm/mmu/tdp_iter.h
parentKVM: nVMX: Always handle #VEs in L0 (never forward #VEs from L2 to L1) (diff)
downloadlinux-837d557aba6b816985141ddbeb7649444ed26d3b.tar.xz
linux-837d557aba6b816985141ddbeb7649444ed26d3b.zip
KVM: x86/mmu: Add sanity checks that KVM doesn't create EPT #VE SPTEs
Assert that KVM doesn't set a SPTE to a value that could trigger an EPT Violation #VE on a non-MMIO SPTE, e.g. to help detect bugs even without KVM_INTEL_PROVE_VE enabled, and to help debug actual #VE failures. Note, this will run afoul of TDX support, which needs to reflect emulated MMIO accesses into the guest as #VEs (which was the whole point of adding EPT Violation #VE support in KVM). The obvious fix for that is to exempt MMIO SPTEs, but that's annoyingly difficult now that is_mmio_spte() relies on a per-VM value. However, resolving that conundrum is a future problem, whereas getting KVM_INTEL_PROVE_VE healthy is a current problem. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20240518000430.1118488-5-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r--arch/x86/kvm/mmu/tdp_iter.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu/tdp_iter.h b/arch/x86/kvm/mmu/tdp_iter.h
index fae559559a80..2880fd392e0c 100644
--- a/arch/x86/kvm/mmu/tdp_iter.h
+++ b/arch/x86/kvm/mmu/tdp_iter.h
@@ -21,11 +21,13 @@ static inline u64 kvm_tdp_mmu_read_spte(tdp_ptep_t sptep)
static inline u64 kvm_tdp_mmu_write_spte_atomic(tdp_ptep_t sptep, u64 new_spte)
{
+ KVM_MMU_WARN_ON(is_ept_ve_possible(new_spte));
return xchg(rcu_dereference(sptep), new_spte);
}
static inline void __kvm_tdp_mmu_write_spte(tdp_ptep_t sptep, u64 new_spte)
{
+ KVM_MMU_WARN_ON(is_ept_ve_possible(new_spte));
WRITE_ONCE(*rcu_dereference(sptep), new_spte);
}