Skip to content

Commit 5c9cfc4

Browse files
iorlov-devsean-jc
authored andcommitted
KVM: x86: Add emulation status for unhandleable exception vectoring
Add emulation status for unhandleable vectoring, i.e. when KVM can't emulate an instruction because emulation was triggered on an exit that occurred while the CPU was vectoring an event. Such a situation can occur if guest sets the IDT descriptor base to point to MMIO region, and triggers an exception after that. Exit to userspace with event delivery error when KVM can't emulate an instruction when vectoring an event. Signed-off-by: Ivan Orlov <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: massage changelog and X86EMUL_UNHANDLEABLE_VECTORING comment] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 11c98fa commit 5c9cfc4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

arch/x86/kvm/kvm_emulate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ struct x86_instruction_info {
8888
#define X86EMUL_CMPXCHG_FAILED 4 /* cmpxchg did not see expected value */
8989
#define X86EMUL_IO_NEEDED 5 /* IO is needed to complete emulation */
9090
#define X86EMUL_INTERCEPTED 6 /* Intercepted by nested VMCB/VMCS */
91+
/* Emulation during event vectoring is unhandleable. */
92+
#define X86EMUL_UNHANDLEABLE_VECTORING 7
9193

9294
/* x86-specific emulation flags */
9395
#define X86EMUL_F_WRITE BIT(0)

arch/x86/kvm/x86.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9098,6 +9098,11 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
90989098
if (r == X86EMUL_RETRY_INSTR || r == X86EMUL_PROPAGATE_FAULT)
90999099
return 1;
91009100

9101+
if (r == X86EMUL_UNHANDLEABLE_VECTORING) {
9102+
kvm_prepare_event_vectoring_exit(vcpu, cr2_or_gpa);
9103+
return 0;
9104+
}
9105+
91019106
WARN_ON_ONCE(r != X86EMUL_UNHANDLEABLE);
91029107
return handle_emulation_failure(vcpu, emulation_type);
91039108
}

0 commit comments

Comments
 (0)