Commit 47ef3ef
KVM: VMX: Handle event vectoring error in check_emulate_instruction()
Move handling of emulation during event vectoring, which KVM doesn't
support, into VMX's check_emulate_instruction(), so that KVM detects
all unsupported emulation, not just cached emulated MMIO (EPT misconfig).
E.g. on emulated MMIO that isn't cached (EPT Violation) or occurs with
legacy shadow paging (#PF).
Rejecting emulation on other sources of emulation also fixes a largely
theoretical flaw (thanks to the "unprotect and retry" logic), where KVM
could incorrectly inject a #DF:
1. CPU executes an instruction and hits a #GP
2. While vectoring the #GP, a shadow #PF occurs
3. On the #PF VM-Exit, KVM re-injects #GP
4. KVM emulates because of the write-protected page
5. KVM "successfully" emulates and also detects the #GP
6. KVM synthesizes a #GP, and since #GP has already been injected,
incorrectly escalates to a #DF.
Fix the comment about EMULTYPE_PF as this flag doesn't necessarily
mean MMIO anymore: it can also be set due to the write protection
violation.
Note, handle_ept_misconfig() checks vmx_check_emulate_instruction() before
attempting emulation of any kind.
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Ivan Orlov <iorlov@amazon.com>
Link: https://lore.kernel.org/r/20241217181458.68690-5-iorlov@amazon.com
[sean: massage changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 704fc60 commit 47ef3ef
2 files changed
Lines changed: 16 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2032 | 2032 | | |
2033 | 2033 | | |
2034 | 2034 | | |
2035 | | - | |
2036 | | - | |
| 2035 | + | |
| 2036 | + | |
2037 | 2037 | | |
2038 | 2038 | | |
2039 | 2039 | | |
| |||
2068 | 2068 | | |
2069 | 2069 | | |
2070 | 2070 | | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
2071 | 2076 | | |
2072 | 2077 | | |
2073 | 2078 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1705 | 1705 | | |
1706 | 1706 | | |
1707 | 1707 | | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
1708 | 1714 | | |
1709 | 1715 | | |
1710 | 1716 | | |
| |||
6540 | 6546 | | |
6541 | 6547 | | |
6542 | 6548 | | |
6543 | | - | |
6544 | | - | |
6545 | | - | |
6546 | | - | |
6547 | | - | |
6548 | | - | |
6549 | | - | |
6550 | 6549 | | |
6551 | 6550 | | |
6552 | 6551 | | |
6553 | 6552 | | |
6554 | 6553 | | |
6555 | 6554 | | |
6556 | | - | |
6557 | | - | |
6558 | | - | |
6559 | | - | |
6560 | | - | |
6561 | | - | |
6562 | | - | |
| 6555 | + | |
| 6556 | + | |
| 6557 | + | |
6563 | 6558 | | |
6564 | 6559 | | |
6565 | 6560 | | |
| |||
0 commit comments