[tip:perf/core] hw-breakpoints: Wrap in the KVM breakpoint active state check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  59d8eb53ea9947db7cad8ebc31b0fb54f23a9851
Gitweb:     http://git.kernel.org/tip/59d8eb53ea9947db7cad8ebc31b0fb54f23a9851
Author:     Frederic Weisbecker <fweisbec@xxxxxxxxx>
AuthorDate: Tue, 10 Nov 2009 11:03:12 +0100
Committer:  Frederic Weisbecker <fweisbec@xxxxxxxxx>
CommitDate: Tue, 10 Nov 2009 11:23:43 +0100

hw-breakpoints: Wrap in the KVM breakpoint active state check

Wrap in the cpu dr7 check that tells if we have active
breakpoints that need to be restored in the cpu.

This wrapper makes the check more self-explainable and also
reusable for any further other uses.

Reported-by: Jan Kiszka <jan.kiszka@xxxxxx>
Signed-off-by: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Cc: Avi Kivity <avi@xxxxxxxxxx>
Cc: "K. Prasad" <prasad@xxxxxxxxxxxxxxxxxx>
---
 arch/x86/include/asm/debugreg.h |    5 +++++
 arch/x86/kvm/x86.c              |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h
index f1b673f..0f6e92a 100644
--- a/arch/x86/include/asm/debugreg.h
+++ b/arch/x86/include/asm/debugreg.h
@@ -89,6 +89,11 @@ static inline void hw_breakpoint_disable(void)
 	set_debugreg(0UL, 3);
 }
 
+static inline int hw_breakpoint_active(void)
+{
+	return __get_cpu_var(dr7) & DR_GLOBAL_ENABLE_MASK;
+}
+
 extern void aout_dump_debugregs(struct user *dump);
 
 #ifdef CONFIG_KVM
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 22dee7a..3817220 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3651,7 +3651,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	 * care about the messed up debug address registers. But if
 	 * we have some of them active, restore the old state.
 	 */
-	if (__get_cpu_var(dr7) & DR_GLOBAL_ENABLE_MASK)
+	if (hw_breakpoint_active())
 		hw_breakpoint_restore();
 
 	set_bit(KVM_REQ_KICK, &vcpu->requests);
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux