static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type)
{
- int r = EMULATE_DONE;
-
++vcpu->stat.insn_emulation_fail;
trace_kvm_emulate_insn_failed(vcpu);
if (emulation_type & EMULTYPE_NO_UD_ON_FAIL)
return EMULATE_FAIL;
+ kvm_queue_exception(vcpu, UD_VECTOR);
+
if (!is_guest_mode(vcpu) && kvm_x86_ops->get_cpl(vcpu) == 0) {
vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
vcpu->run->internal.ndata = 0;
- r = EMULATE_USER_EXIT;
+ return EMULATE_USER_EXIT;
}
- kvm_queue_exception(vcpu, UD_VECTOR);
-
- return r;
+ return EMULATE_DONE;
}
static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2,