diff mbox series

[v3,3/7] KVM: x86: Unprotect & retry before unhandleable vectoring check

Message ID 20241217181458.68690-4-iorlov@amazon.com
State New
Headers show
Series Enhance event delivery error handling | expand

Commit Message

Ivan Orlov Dec. 17, 2024, 6:14 p.m. UTC
Try to unprotect and retry the instruction execution before checking for
unhandleable vectoring. If there is a write to a shadowed page table
when vectoring an event, KVM should be able to unprotect the gfn and
retry the instruction execution without returning an error to userspace.

This ensures that the subsequent patches won't make KVM exit to
userspace when handling an intercepted #PF during vectoring without
checking whether unprotect & retry is possible.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Ivan Orlov <iorlov@amazon.com>
---
V1 -> V2:
- This patch wasn't included in V1.
V2 -> V3:
- This patch wasn't included in V2.

 arch/x86/kvm/x86.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 849a6fc364b3..26faacc99c4c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -9107,6 +9107,10 @@  int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
 		if (r == X86EMUL_RETRY_INSTR || r == X86EMUL_PROPAGATE_FAULT)
 			return 1;
 
+		if (kvm_unprotect_and_retry_on_failure(vcpu, cr2_or_gpa,
+						       emulation_type))
+			return 1;
+
 		if (r == X86EMUL_UNHANDLEABLE_VECTORING) {
 			kvm_prepare_event_vectoring_exit(vcpu, cr2_or_gpa);
 			return 0;