Skip to content

Commit 23ffe4b

Browse files
committed
KVM: nVMX: Add a sanity check that nested PML Full stems from EPT Violations
Add a WARN_ON_ONCE() sanity check to verify that a nested PML Full VM-Exit is only synthesized when the original VM-Exit from L2 was an EPT Violation. While KVM can fallthrough to kvm_mmu_do_page_fault() if an EPT Misconfig occurs on a stale MMIO SPTE, KVM should not treat the access as a write (there isn't enough information to know *what* the access was), i.e. KVM should never try to insert a PML entry in that case. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent a946607 commit 23ffe4b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ static void nested_ept_inject_page_fault(struct kvm_vcpu *vcpu,
416416
vm_exit_reason = EXIT_REASON_PML_FULL;
417417
vmx->nested.pml_full = false;
418418

419+
/*
420+
* It should be impossible to trigger a nested PML Full VM-Exit
421+
* for anything other than an EPT Violation from L2. KVM *can*
422+
* trigger nEPT page fault injection in response to an EPT
423+
* Misconfig, e.g. if the MMIO SPTE was stale and L1's EPT
424+
* tables also changed, but KVM should not treat EPT Misconfig
425+
* VM-Exits as writes.
426+
*/
427+
WARN_ON_ONCE(vmx->exit_reason.basic != EXIT_REASON_EPT_VIOLATION);
428+
419429
/*
420430
* PML Full and EPT Violation VM-Exits both use bit 12 to report
421431
* "NMI unblocking due to IRET", i.e. the bit can be propagated

0 commit comments

Comments
 (0)