Skip to contentSkip to conversation

KVM: nVMX: Do not emulate #UD while in guest mode

PATCH Applied Jan Kiszka 2 participants 2 messages Mar 9, 2015 – Mar 13, 2015

Subsystems (3)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 KVM: nVMX: Do not emulate #UD while in guest mode

While in L2, leave all #UD to L2 and do not try to emulate it. If L1 is interested in doing this, it reports its interest via the exception bitmap, and we never get into handle_exception of L0 anyway.

---

Noticed while wondering where the vmmcall of a misconfigured L2 went on an Intel box: to nowhere. This bug caused a spurious fixup, and the emulator bug did not even let it trigger a vmcall vmexit.

 arch/x86/kvm/vmx.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kvm/vmx.c +4 -0
index f7b20b4..fa0627c 100644
@@ -5065,6 +5065,10 @@ static int handle_exception(struct kvm_vcpu *vcpu)
 	}
 
 	if (is_invalid_opcode(intr_info)) {
+		if (is_guest_mode(vcpu)) {
+			kvm_queue_exception(vcpu, UD_VECTOR);
+			return 1;
+		}
 		er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
 		if (er != EMULATE_DONE)
 			kvm_queue_exception(vcpu, UD_VECTOR);
Signature · 1 line
2.1.4
#1 lore raw
Quoted 10 lines · Jan Kiszka

While in L2, leave all #UD to L2 and do not try to emulate it. If L1 is interested in doing this, it reports its interest via the exception bitmap, and we never get into handle_exception of L0 anyway.

---

Noticed while wondering where the vmmcall of a misconfigured L2 went on an Intel box: to nowhere. This bug caused a spurious fixup, and the emulator bug did not even let it trigger a vmcall vmexit.

Applied, thanks.