[Devel,RHEL7,COMMIT] ms/KVM: x86: fix root cause for missed hardware breakpoints

Submitted by Konstantin Khorenko on Aug. 5, 2016, 3:01 p.m.


Message ID 201608051501.u75F13OU004567@finist_cl7.x64_64.work.ct
State New
Series "kvm: fixes for debug register updates"
Headers show

Commit Message

Konstantin Khorenko Aug. 5, 2016, 3:01 p.m.
The commit is pushed to "branch-rh7-3.10.0-327.22.2.vz7.16.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.22.2.vz7.16.2
commit ea70778786a3ff9211a3fa674f6ff40cb133a73b
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Fri Aug 5 19:01:03 2016 +0400

    ms/KVM: x86: fix root cause for missed hardware breakpoints
    Commit 172b2386ed16 ("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*
    Cc: stable@vger.kernel.org   # 4.1+
    Fixes: 172b2386ed16a9143d9a456aae5ec87275c61489
    Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 70e4da7a8ff62f2775337b705f45c804bb450454)
    Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
 arch/x86/kvm/x86.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c906f88..6461a83 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6512,12 +6512,12 @@  static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 	if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {
-		int i;
 		WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
-		for (i = 0; i < KVM_NR_DB_REGS; i++)
-			vcpu->arch.eff_db[i] = vcpu->arch.db[i];
+		kvm_update_dr0123(vcpu);
+		kvm_update_dr6(vcpu);
+		kvm_update_dr7(vcpu);
+		vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;