aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/x86.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f7a78c62ab87..ad3809df7d0a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -801,6 +801,17 @@ unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu)
801} 801}
802EXPORT_SYMBOL_GPL(kvm_get_cr8); 802EXPORT_SYMBOL_GPL(kvm_get_cr8);
803 803
804static void kvm_update_dr0123(struct kvm_vcpu *vcpu)
805{
806 int i;
807
808 if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) {
809 for (i = 0; i < KVM_NR_DB_REGS; i++)
810 vcpu->arch.eff_db[i] = vcpu->arch.db[i];
811 vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD;
812 }
813}
814
804static void kvm_update_dr6(struct kvm_vcpu *vcpu) 815static void kvm_update_dr6(struct kvm_vcpu *vcpu)
805{ 816{
806 if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) 817 if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP))
@@ -3150,6 +3161,7 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
3150 return -EINVAL; 3161 return -EINVAL;
3151 3162
3152 memcpy(vcpu->arch.db, dbgregs->db, sizeof(vcpu->arch.db)); 3163 memcpy(vcpu->arch.db, dbgregs->db, sizeof(vcpu->arch.db));
3164 kvm_update_dr0123(vcpu);
3153 vcpu->arch.dr6 = dbgregs->dr6; 3165 vcpu->arch.dr6 = dbgregs->dr6;
3154 kvm_update_dr6(vcpu); 3166 kvm_update_dr6(vcpu);
3155 vcpu->arch.dr7 = dbgregs->dr7; 3167 vcpu->arch.dr7 = dbgregs->dr7;
@@ -6323,6 +6335,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
6323 set_debugreg(vcpu->arch.eff_db[2], 2); 6335 set_debugreg(vcpu->arch.eff_db[2], 2);
6324 set_debugreg(vcpu->arch.eff_db[3], 3); 6336 set_debugreg(vcpu->arch.eff_db[3], 3);
6325 set_debugreg(vcpu->arch.dr6, 6); 6337 set_debugreg(vcpu->arch.dr6, 6);
6338 vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
6326 } 6339 }
6327 6340
6328 trace_kvm_entry(vcpu->vcpu_id); 6341 trace_kvm_entry(vcpu->vcpu_id);
@@ -7104,6 +7117,7 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu)
7104 kvm_clear_exception_queue(vcpu); 7117 kvm_clear_exception_queue(vcpu);
7105 7118
7106 memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db)); 7119 memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db));
7120 kvm_update_dr0123(vcpu);
7107 vcpu->arch.dr6 = DR6_INIT; 7121 vcpu->arch.dr6 = DR6_INIT;
7108 kvm_update_dr6(vcpu); 7122 kvm_update_dr6(vcpu);
7109 vcpu->arch.dr7 = DR7_FIXED_1; 7123 vcpu->arch.dr7 = DR7_FIXED_1;