aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-09-01 09:06:25 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 11:11:06 -0400
commite8a48342e9bc1c65ffe4bb3b3ac964e726dbd4c0 (patch)
treea669d0c24552f924ad7d1ee463ceb823a60bdd30 /arch/x86/kvm
parent3d53c27d05950390712f92c5ad1604c60190ed64 (diff)
KVM: VMX: Conditionally reload debug register 6
Only reload debug register 6 if we're running with the guest's debug registers. Saves around 150 cycles from the guest lightweight exit path. dr6 contains a couple of bits that are updated on #DB, so intercept that unconditionally and update those bits then. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index eec04129402f..f482100eff87 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -540,10 +540,12 @@ static void update_exception_bitmap(struct kvm_vcpu *vcpu)
540 eb = (1u << PF_VECTOR) | (1u << UD_VECTOR) | (1u << MC_VECTOR); 540 eb = (1u << PF_VECTOR) | (1u << UD_VECTOR) | (1u << MC_VECTOR);
541 if (!vcpu->fpu_active) 541 if (!vcpu->fpu_active)
542 eb |= 1u << NM_VECTOR; 542 eb |= 1u << NM_VECTOR;
543 /*
544 * Unconditionally intercept #DB so we can maintain dr6 without
545 * reading it every exit.
546 */
547 eb |= 1u << DB_VECTOR;
543 if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) { 548 if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
544 if (vcpu->guest_debug &
545 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
546 eb |= 1u << DB_VECTOR;
547 if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) 549 if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
548 eb |= 1u << BP_VECTOR; 550 eb |= 1u << BP_VECTOR;
549 } 551 }
@@ -3632,7 +3634,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3632 */ 3634 */
3633 vmcs_writel(HOST_CR0, read_cr0()); 3635 vmcs_writel(HOST_CR0, read_cr0());
3634 3636
3635 set_debugreg(vcpu->arch.dr6, 6); 3637 if (vcpu->arch.switch_db_regs)
3638 set_debugreg(vcpu->arch.dr6, 6);
3636 3639
3637 asm( 3640 asm(
3638 /* Store host registers */ 3641 /* Store host registers */
@@ -3734,7 +3737,8 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
3734 | (1 << VCPU_EXREG_PDPTR)); 3737 | (1 << VCPU_EXREG_PDPTR));
3735 vcpu->arch.regs_dirty = 0; 3738 vcpu->arch.regs_dirty = 0;
3736 3739
3737 get_debugreg(vcpu->arch.dr6, 6); 3740 if (vcpu->arch.switch_db_regs)
3741 get_debugreg(vcpu->arch.dr6, 6);
3738 3742
3739 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD); 3743 vmx->idt_vectoring_info = vmcs_read32(IDT_VECTORING_INFO_FIELD);
3740 if (vmx->rmode.irq.pending) 3744 if (vmx->rmode.irq.pending)