]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - arch/x86/kvm/svm.c
KVM: vmx: Unavailable DR4/5 is checked before CPL
[mirror_ubuntu-bionic-kernel.git] / arch / x86 / kvm / svm.c
index 65510f624dfe2a42571bc22e73d8755a23e801e5..d4f3aaa2df7c6eb01de4470c8bb432039633e54d 100644 (file)
@@ -2999,7 +2999,6 @@ static int dr_interception(struct vcpu_svm *svm)
 {
        int reg, dr;
        unsigned long val;
-       int err;
 
        if (svm->vcpu.guest_debug == 0) {
                /*
@@ -3019,12 +3018,15 @@ static int dr_interception(struct vcpu_svm *svm)
        dr = svm->vmcb->control.exit_code - SVM_EXIT_READ_DR0;
 
        if (dr >= 16) { /* mov to DRn */
+               if (!kvm_require_dr(&svm->vcpu, dr - 16))
+                       return 1;
                val = kvm_register_read(&svm->vcpu, reg);
                kvm_set_dr(&svm->vcpu, dr - 16, val);
        } else {
-               err = kvm_get_dr(&svm->vcpu, dr, &val);
-               if (!err)
-                       kvm_register_write(&svm->vcpu, reg, val);
+               if (!kvm_require_dr(&svm->vcpu, dr))
+                       return 1;
+               kvm_get_dr(&svm->vcpu, dr, &val);
+               kvm_register_write(&svm->vcpu, reg, val);
        }
 
        skip_emulated_instruction(&svm->vcpu);
@@ -3251,7 +3253,7 @@ static int wrmsr_interception(struct vcpu_svm *svm)
        msr.host_initiated = false;
 
        svm->next_rip = kvm_rip_read(&svm->vcpu) + 2;
-       if (svm_set_msr(&svm->vcpu, &msr)) {
+       if (kvm_set_msr(&svm->vcpu, &msr)) {
                trace_kvm_msr_write_ex(ecx, data);
                kvm_inject_gp(&svm->vcpu, 0);
        } else {
@@ -3551,9 +3553,9 @@ static int handle_exit(struct kvm_vcpu *vcpu)
 
        if (exit_code >= ARRAY_SIZE(svm_exit_handlers)
            || !svm_exit_handlers[exit_code]) {
-               kvm_run->exit_reason = KVM_EXIT_UNKNOWN;
-               kvm_run->hw.hardware_exit_reason = exit_code;
-               return 0;
+               WARN_ONCE(1, "vmx: unexpected exit reason 0x%x\n", exit_code);
+               kvm_queue_exception(vcpu, UD_VECTOR);
+               return 1;
        }
 
        return svm_exit_handlers[exit_code](svm);