aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2010-01-20 12:20:20 -0500
committerMarcelo Tosatti <mtosatti@redhat.com>2010-03-01 10:36:01 -0500
commitf2483415293b180945da707e7dbe74e5daa72651 (patch)
tree0c8d5e8ec02ae6f06f1dd1cf68d36e2a9fce6287
parentb60d513c32e2ddc8b3e9e1465b94913d44d19810 (diff)
KVM: VMX: Fix exceptions of mov to dr
Injecting GP without an error code is a bad idea (causes unhandled guest exits). Moreover, we must not skip the instruction if we injected an exception. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 516084f3c6d8..9727773f24b7 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3045,6 +3045,7 @@ static int handle_dr(struct kvm_vcpu *vcpu)
3045 unsigned long val; 3045 unsigned long val;
3046 int dr, reg; 3046 int dr, reg;
3047 3047
3048 /* Do not handle if the CPL > 0, will trigger GP on re-entry */
3048 if (!kvm_require_cpl(vcpu, 0)) 3049 if (!kvm_require_cpl(vcpu, 0))
3049 return 1; 3050 return 1;
3050 dr = vmcs_readl(GUEST_DR7); 3051 dr = vmcs_readl(GUEST_DR7);
@@ -3099,20 +3100,22 @@ static int handle_dr(struct kvm_vcpu *vcpu)
3099 vcpu->arch.eff_db[dr] = val; 3100 vcpu->arch.eff_db[dr] = val;
3100 break; 3101 break;
3101 case 4 ... 5: 3102 case 4 ... 5:
3102 if (kvm_read_cr4_bits(vcpu, X86_CR4_DE)) 3103 if (kvm_read_cr4_bits(vcpu, X86_CR4_DE)) {
3103 kvm_queue_exception(vcpu, UD_VECTOR); 3104 kvm_queue_exception(vcpu, UD_VECTOR);
3105 return 1;
3106 }
3104 break; 3107 break;
3105 case 6: 3108 case 6:
3106 if (val & 0xffffffff00000000ULL) { 3109 if (val & 0xffffffff00000000ULL) {
3107 kvm_queue_exception(vcpu, GP_VECTOR); 3110 kvm_inject_gp(vcpu, 0);
3108 break; 3111 return 1;
3109 } 3112 }
3110 vcpu->arch.dr6 = (val & DR6_VOLATILE) | DR6_FIXED_1; 3113 vcpu->arch.dr6 = (val & DR6_VOLATILE) | DR6_FIXED_1;
3111 break; 3114 break;
3112 case 7: 3115 case 7:
3113 if (val & 0xffffffff00000000ULL) { 3116 if (val & 0xffffffff00000000ULL) {
3114 kvm_queue_exception(vcpu, GP_VECTOR); 3117 kvm_inject_gp(vcpu, 0);
3115 break; 3118 return 1;
3116 } 3119 }
3117 vcpu->arch.dr7 = (val & DR7_VOLATILE) | DR7_FIXED_1; 3120 vcpu->arch.dr7 = (val & DR7_VOLATILE) | DR7_FIXED_1;
3118 if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) { 3121 if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) {