]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86/mmu: Move event re-injection unprotect+retry into common path
authorSean Christopherson <seanjc@google.com>
Sat, 31 Aug 2024 00:15:29 +0000 (17:15 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 10 Sep 2024 03:16:29 +0000 (20:16 -0700)
commitb299c273c06f005976cdc1b9e9299d492527607e
treea30a6c3b5eb8f31d70cc476b7db4134d001de196
parent29e495bdf847ac6ad0e0d03e5db39a3ed9f12858
KVM: x86/mmu: Move event re-injection unprotect+retry into common path

Move the event re-injection unprotect+retry logic into
kvm_mmu_write_protect_fault(), i.e. unprotect and retry if and only if
the #PF actually hit a write-protected gfn.  Note, there is a small
possibility that the gfn was unprotected by a different tasking between
hitting the #PF and acquiring mmu_lock, but in that case, KVM will resume
the guest immediately anyways because KVM will treat the fault as spurious.

As a bonus, unprotecting _after_ handling the page fault also addresses the
case where the installing a SPTE to handle fault encounters a shadowed PTE,
i.e. *creates* a read-only SPTE.

Opportunstically add a comment explaining what on earth the intent of the
code is, as based on the changelog from commit 577bdc496614 ("KVM: Avoid
instruction emulation when event delivery is pending").

Link: https://lore.kernel.org/r/20240831001538.336683-15-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c