]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - arch/x86/kvm/svm.c
KVM: x86: Exit to userspace on emulation skip failure
[linux.git] / arch / x86 / kvm / svm.c
index 04fe21849b6e46adcc7dc4f7b32bea3541bf6cea..fc40052fa3347b925fde792c9d2b1f796b3c895c 100644 (file)
@@ -2768,17 +2768,19 @@ static int gp_interception(struct vcpu_svm *svm)
 {
        struct kvm_vcpu *vcpu = &svm->vcpu;
        u32 error_code = svm->vmcb->control.exit_info_1;
-       int er;
 
        WARN_ON_ONCE(!enable_vmware_backdoor);
 
-       er = kvm_emulate_instruction(vcpu,
-               EMULTYPE_VMWARE | EMULTYPE_NO_UD_ON_FAIL);
-       if (er == EMULATE_USER_EXIT)
-               return 0;
-       else if (er != EMULATE_DONE)
+       /*
+        * VMware backdoor emulation on #GP interception only handles IN{S},
+        * OUT{S}, and RDPMC, none of which generate a non-zero error code.
+        */
+       if (error_code) {
                kvm_queue_exception_e(vcpu, GP_VECTOR, error_code);
-       return 1;
+               return 1;
+       }
+       return kvm_emulate_instruction(vcpu, EMULTYPE_VMWARE_GP) !=
+                                               EMULATE_USER_EXIT;
 }
 
 static bool is_erratum_383(void)
@@ -3883,8 +3885,8 @@ static int task_switch_interception(struct vcpu_svm *svm)
            int_type == SVM_EXITINTINFO_TYPE_SOFT ||
            (int_type == SVM_EXITINTINFO_TYPE_EXEPT &&
             (int_vec == OF_VECTOR || int_vec == BP_VECTOR))) {
-               if (skip_emulated_instruction(&svm->vcpu) != EMULATE_DONE)
-                       goto fail;
+               if (skip_emulated_instruction(&svm->vcpu) == EMULATE_USER_EXIT)
+                       return 0;
        }
 
        if (int_type != SVM_EXITINTINFO_TYPE_SOFT)
@@ -7099,13 +7101,6 @@ static int svm_unregister_enc_region(struct kvm *kvm,
        return ret;
 }
 
-static int nested_enable_evmcs(struct kvm_vcpu *vcpu,
-                                  uint16_t *vmcs_version)
-{
-       /* Intel-only feature */
-       return -ENODEV;
-}
-
 static bool svm_need_emulation_on_page_fault(struct kvm_vcpu *vcpu)
 {
        unsigned long cr4 = kvm_read_cr4(vcpu);
@@ -7311,7 +7306,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .mem_enc_reg_region = svm_register_enc_region,
        .mem_enc_unreg_region = svm_unregister_enc_region,
 
-       .nested_enable_evmcs = nested_enable_evmcs,
+       .nested_enable_evmcs = NULL,
        .nested_get_evmcs_version = NULL,
 
        .need_emulation_on_page_fault = svm_need_emulation_on_page_fault,