KVM: VMX: Do not skip the instruction if handle_dr injects a fault
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 18 Dec 2013 18:16:24 +0000 (19:16 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 20 Dec 2013 18:20:39 +0000 (19:20 +0100)
If kvm_get_dr or kvm_set_dr reports that it raised a fault, we must not
advance the instruction pointer. Otherwise the exception will hit the
wrong instruction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c

index 31eb5776d854e7dcecc4e0fb7255ce44e19b0432..9cc54842ae1426aecd1f48b6ff8f4737e18e186b 100644 (file)
@@ -5137,10 +5137,14 @@ static int handle_dr(struct kvm_vcpu *vcpu)
        reg = DEBUG_REG_ACCESS_REG(exit_qualification);
        if (exit_qualification & TYPE_MOV_FROM_DR) {
                unsigned long val;
-               if (!kvm_get_dr(vcpu, dr, &val))
-                       kvm_register_write(vcpu, reg, val);
+
+               if (kvm_get_dr(vcpu, dr, &val))
+                       return 1;
+               kvm_register_write(vcpu, reg, val);
        } else
-               kvm_set_dr(vcpu, dr, vcpu->arch.regs[reg]);
+               if (kvm_set_dr(vcpu, dr, vcpu->arch.regs[reg]))
+                       return 1;
+
        skip_emulated_instruction(vcpu);
        return 1;
 }