kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: Use thread debug register storage instead of kvm specific data
@ 2009-09-01  9:44 Avi Kivity
  2009-09-01  9:47 ` Avi Kivity
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Avi Kivity @ 2009-09-01  9:44 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, Jan Kiszka

Instead of saving the debug registers from the processor to a kvm data
structure, rely in the debug registers stored in the thread structure.
This allows us not to save dr6 and dr7.

Reduces lightweight vmexit cost by 350 cycles, or 11 percent.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/include/asm/kvm_host.h |    3 ---
 arch/x86/kvm/x86.c              |   22 +++++++---------------
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 6046e6f..45226f0 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -362,9 +362,6 @@ struct kvm_vcpu_arch {
 	u32 pat;
 
 	int switch_db_regs;
-	unsigned long host_db[KVM_NR_DB_REGS];
-	unsigned long host_dr6;
-	unsigned long host_dr7;
 	unsigned long db[KVM_NR_DB_REGS];
 	unsigned long dr6;
 	unsigned long dr7;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 891234b..9e3acbd 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3627,14 +3627,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 
 	kvm_guest_enter();
 
-	get_debugreg(vcpu->arch.host_dr6, 6);
-	get_debugreg(vcpu->arch.host_dr7, 7);
 	if (unlikely(vcpu->arch.switch_db_regs)) {
-		get_debugreg(vcpu->arch.host_db[0], 0);
-		get_debugreg(vcpu->arch.host_db[1], 1);
-		get_debugreg(vcpu->arch.host_db[2], 2);
-		get_debugreg(vcpu->arch.host_db[3], 3);
-
 		set_debugreg(0, 7);
 		set_debugreg(vcpu->arch.eff_db[0], 0);
 		set_debugreg(vcpu->arch.eff_db[1], 1);
@@ -3645,15 +3638,14 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
 	trace_kvm_entry(vcpu->vcpu_id);
 	kvm_x86_ops->run(vcpu);
 
-	if (unlikely(vcpu->arch.switch_db_regs)) {
-		set_debugreg(0, 7);
-		set_debugreg(vcpu->arch.host_db[0], 0);
-		set_debugreg(vcpu->arch.host_db[1], 1);
-		set_debugreg(vcpu->arch.host_db[2], 2);
-		set_debugreg(vcpu->arch.host_db[3], 3);
+	if (unlikely(vcpu->arch.switch_db_regs || test_thread_flag(TIF_DEBUG))) {
+		set_debugreg(current->thread.debugreg0, 0);
+		set_debugreg(current->thread.debugreg1, 1);
+		set_debugreg(current->thread.debugreg2, 2);
+		set_debugreg(current->thread.debugreg3, 3);
+		set_debugreg(current->thread.debugreg6, 6);
+		set_debugreg(current->thread.debugreg7, 7);
 	}
-	set_debugreg(vcpu->arch.host_dr6, 6);
-	set_debugreg(vcpu->arch.host_dr7, 7);
 
 	set_bit(KVM_REQ_KICK, &vcpu->requests);
 	local_irq_enable();
-- 
1.6.4.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2009-09-06 12:49 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-01  9:44 [PATCH] KVM: Use thread debug register storage instead of kvm specific data Avi Kivity
2009-09-01  9:47 ` Avi Kivity
2009-09-01 18:12   ` Andrew Theurer
2009-09-01 18:23     ` Avi Kivity
2009-09-04 14:48       ` Andrew Theurer
2009-09-04 15:30         ` Brian Jackson
2009-09-04 16:08           ` Andrew Theurer
2009-09-04 17:04             ` Brian Jackson
2009-09-05 11:34               ` Vadim Rozenfeld
2009-09-06 12:49                 ` Yan Vugenfirer
2009-09-06  8:21         ` Avi Kivity
2009-09-01 10:42 ` Jan Kiszka
2009-09-01 11:08   ` Jan Kiszka
2009-09-01 11:16   ` Avi Kivity
2009-09-01 11:21     ` Avi Kivity
2009-09-01 13:31     ` Jan Kiszka
2009-09-01 13:39       ` Avi Kivity
2009-09-01 11:22 ` Marcelo Tosatti
2009-09-01 11:28   ` Jan Kiszka
2009-09-01 11:32     ` Marcelo Tosatti
2009-09-01 11:35       ` Avi Kivity
2009-09-01 11:33     ` Jan Kiszka
2009-09-01 11:43       ` Avi Kivity
2009-09-01 11:45         ` Jan Kiszka
2009-09-01 11:56           ` Avi Kivity
2009-09-01 12:01             ` Jan Kiszka
2009-09-01 12:02               ` Avi Kivity
2009-09-01 12:27                 ` Avi Kivity
2009-09-01 11:34   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).