Skip to content

Commit 70e4da7

Browse files
committed
KVM: x86: fix root cause for missed hardware breakpoints
Commit 172b238 ("KVM: x86: fix missed hardware breakpoints", 2016-02-10) worked around a case where the debug registers are not loaded correctly on preemption and on the first entry to KVM_RUN. However, Xiao Guangrong pointed out that the root cause must be that KVM_DEBUGREG_BP_ENABLED is not being set correctly. This can indeed happen due to the lazy debug exit mechanism, which does not call kvm_update_dr7. Fix it by replacing the existing loop (more or less equivalent to kvm_update_dr0123) with calls to all the kvm_update_dr* functions. Cc: stable@vger.kernel.org # 4.1+ Fixes: 172b238 Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 0fb00d3 commit 70e4da7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27522752
}
27532753

27542754
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
2755-
vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD;
27562755
}
27572756

27582757
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
@@ -6619,12 +6618,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
66196618
* KVM_DEBUGREG_WONT_EXIT again.
66206619
*/
66216620
if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {
6622-
int i;
6623-
66246621
WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
66256622
kvm_x86_ops->sync_dirty_debug_regs(vcpu);
6626-
for (i = 0; i < KVM_NR_DB_REGS; i++)
6627-
vcpu->arch.eff_db[i] = vcpu->arch.db[i];
6623+
kvm_update_dr0123(vcpu);
6624+
kvm_update_dr6(vcpu);
6625+
kvm_update_dr7(vcpu);
6626+
vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
66286627
}
66296628

66306629
/*

0 commit comments

Comments
 (0)