aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@web.de>2009-10-02 18:31:21 -0400
committerAvi Kivity <avi@redhat.com>2009-12-03 02:32:14 -0500
commit355be0b9300579e02275d7d19374806a974ce622 (patch)
treefaa52bac7a0d1d83c7a0a8f1bec01088b77a68fb /arch/x86/kvm/vmx.c
parent201d945bcfb0d53e67c9c081f7c28532eb4669c7 (diff)
KVM: x86: Refactor guest debug IOCTL handling
Much of so far vendor-specific code for setting up guest debug can actually be handled by the generic code. This also fixes a minor deficit in the SVM part /wrt processing KVM_GUESTDBG_ENABLE. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 97f4265cda38..70020e505c22 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1096,30 +1096,14 @@ static void vmx_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
1096 } 1096 }
1097} 1097}
1098 1098
1099static int set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_guest_debug *dbg) 1099static void set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_guest_debug *dbg)
1100{ 1100{
1101 int old_debug = vcpu->guest_debug;
1102 unsigned long flags;
1103
1104 vcpu->guest_debug = dbg->control;
1105 if (!(vcpu->guest_debug & KVM_GUESTDBG_ENABLE))
1106 vcpu->guest_debug = 0;
1107
1108 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) 1101 if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)
1109 vmcs_writel(GUEST_DR7, dbg->arch.debugreg[7]); 1102 vmcs_writel(GUEST_DR7, dbg->arch.debugreg[7]);
1110 else 1103 else
1111 vmcs_writel(GUEST_DR7, vcpu->arch.dr7); 1104 vmcs_writel(GUEST_DR7, vcpu->arch.dr7);
1112 1105
1113 flags = vmcs_readl(GUEST_RFLAGS);
1114 if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
1115 flags |= X86_EFLAGS_TF | X86_EFLAGS_RF;
1116 else if (old_debug & KVM_GUESTDBG_SINGLESTEP)
1117 flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_RF);
1118 vmcs_writel(GUEST_RFLAGS, flags);
1119
1120 update_exception_bitmap(vcpu); 1106 update_exception_bitmap(vcpu);
1121
1122 return 0;
1123} 1107}
1124 1108
1125static __init int cpu_has_kvm_support(void) 1109static __init int cpu_has_kvm_support(void)