Commit b299c27
committed
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 577bdc4 ("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>1 parent 29e495b commit b299c27
1 file changed
Lines changed: 9 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2743 | 2743 | | |
2744 | 2744 | | |
2745 | 2745 | | |
2746 | | - | |
2747 | | - | |
2748 | | - | |
2749 | | - | |
2750 | | - | |
2751 | | - | |
2752 | | - | |
2753 | | - | |
2754 | | - | |
2755 | | - | |
2756 | | - | |
2757 | | - | |
2758 | | - | |
2759 | | - | |
2760 | | - | |
2761 | | - | |
2762 | | - | |
2763 | 2746 | | |
2764 | 2747 | | |
2765 | 2748 | | |
| |||
4630 | 4613 | | |
4631 | 4614 | | |
4632 | 4615 | | |
4633 | | - | |
4634 | | - | |
4635 | 4616 | | |
4636 | 4617 | | |
4637 | 4618 | | |
| |||
6037 | 6018 | | |
6038 | 6019 | | |
6039 | 6020 | | |
6040 | | - | |
6041 | | - | |
| 6021 | + | |
| 6022 | + | |
| 6023 | + | |
| 6024 | + | |
| 6025 | + | |
| 6026 | + | |
| 6027 | + | |
| 6028 | + | |
| 6029 | + | |
6042 | 6030 | | |
6043 | 6031 | | |
6044 | 6032 | | |
| |||
0 commit comments