]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/x86/kvm/vmx.c
KVM: inject #UD if instruction emulation fails and exit to userspace
[net-next-2.6.git] / arch / x86 / kvm / vmx.c
index 59893173425107289599fb472503d6a78157f1e5..a82cfa1e2a4054ae9b09d679e13e71ce9617f802 100644 (file)
@@ -3070,7 +3070,7 @@ static int handle_io(struct kvm_vcpu *vcpu)
        ++vcpu->stat.io_exits;
 
        if (string || in)
-               return !(emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DO_MMIO);
+               return emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DONE;
 
        port = exit_qualification >> 16;
        size = (exit_qualification & 7) + 1;
@@ -3327,22 +3327,7 @@ static int handle_wbinvd(struct kvm_vcpu *vcpu)
 
 static int handle_apic_access(struct kvm_vcpu *vcpu)
 {
-       unsigned long exit_qualification;
-       enum emulation_result er;
-       unsigned long offset;
-
-       exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
-       offset = exit_qualification & 0xffful;
-
-       er = emulate_instruction(vcpu, 0, 0, 0);
-
-       if (er !=  EMULATE_DONE) {
-               printk(KERN_ERR
-                      "Fail to handle apic access vmexit! Offset is 0x%lx\n",
-                      offset);
-               return -ENOEXEC;
-       }
-       return 1;
+       return emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DONE;
 }
 
 static int handle_task_switch(struct kvm_vcpu *vcpu)
@@ -3554,13 +3539,8 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
                        goto out;
                }
 
-               if (err != EMULATE_DONE) {
-                       vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
-                       vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
-                       vcpu->run->internal.ndata = 0;
-                       ret = 0;
-                       goto out;
-               }
+               if (err != EMULATE_DONE)
+                       return 0;
 
                if (signal_pending(current))
                        goto out;