kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
@ 2012-08-12 13:12 Gleb Natapov
  2012-08-12 13:22 ` Avi Kivity
  2012-08-13 22:07 ` Marcelo Tosatti
  0 siblings, 2 replies; 7+ messages in thread
From: Gleb Natapov @ 2012-08-12 13:12 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

MSR_IA32_DEBUGCTLMSR is zeroed on VMEXIT. Restore it to the correct
value.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index cc8ad98..d0f4bec 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6222,6 +6222,7 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
 static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 {
 	struct vcpu_vmx *vmx = to_vmx(vcpu);
+	unsigned long debugctlmsr;
 
 	if (is_guest_mode(vcpu) && !vmx->nested.nested_run_pending) {
 		struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
@@ -6261,6 +6262,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 		vmx_set_interrupt_shadow(vcpu, 0);
 
 	atomic_switch_perf_msrs(vmx);
+	debugctlmsr = get_debugctlmsr();
 
 	vmx->__launched = vmx->loaded_vmcs->launched;
 	asm(
@@ -6362,6 +6364,10 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
 #endif
 	      );
 
+	/* MSR_IA32_DEBUGCTLMSR is zeroed on vmexit. Restore it if needed */
+	if (debugctlmsr)
+		update_debugctlmsr(debugctlmsr);
+
 #ifndef CONFIG_X86_64
 	/*
 	 * The sysexit path does not restore ds/es, so we must set them to
--
			Gleb.

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

* Re: [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
  2012-08-12 13:12 [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT Gleb Natapov
@ 2012-08-12 13:22 ` Avi Kivity
  2012-08-12 13:25   ` Gleb Natapov
  2012-08-13 22:07 ` Marcelo Tosatti
  1 sibling, 1 reply; 7+ messages in thread
From: Avi Kivity @ 2012-08-12 13:22 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

On 08/12/2012 04:12 PM, Gleb Natapov wrote:
> MSR_IA32_DEBUGCTLMSR is zeroed on VMEXIT. Restore it to the correct
> value.
> 
> @@ -6222,6 +6222,7 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
>  static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
>  {
>  	struct vcpu_vmx *vmx = to_vmx(vcpu);
> +	unsigned long debugctlmsr;
>  
>  	if (is_guest_mode(vcpu) && !vmx->nested.nested_run_pending) {
>  		struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
> @@ -6261,6 +6262,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
>  		vmx_set_interrupt_shadow(vcpu, 0);
>  
>  	atomic_switch_perf_msrs(vmx);
> +	debugctlmsr = get_debugctlmsr();

How expensive is this?  We may want a follow-on patch to cache it in a
per-cpu variable.



-- 
error compiling committee.c: too many arguments to function

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

* Re: [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
  2012-08-12 13:22 ` Avi Kivity
@ 2012-08-12 13:25   ` Gleb Natapov
  2012-08-12 13:40     ` Avi Kivity
  0 siblings, 1 reply; 7+ messages in thread
From: Gleb Natapov @ 2012-08-12 13:25 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, mtosatti

On Sun, Aug 12, 2012 at 04:22:59PM +0300, Avi Kivity wrote:
> On 08/12/2012 04:12 PM, Gleb Natapov wrote:
> > MSR_IA32_DEBUGCTLMSR is zeroed on VMEXIT. Restore it to the correct
> > value.
> > 
> > @@ -6222,6 +6222,7 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx)
> >  static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
> >  {
> >  	struct vcpu_vmx *vmx = to_vmx(vcpu);
> > +	unsigned long debugctlmsr;
> >  
> >  	if (is_guest_mode(vcpu) && !vmx->nested.nested_run_pending) {
> >  		struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
> > @@ -6261,6 +6262,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
> >  		vmx_set_interrupt_shadow(vcpu, 0);
> >  
> >  	atomic_switch_perf_msrs(vmx);
> > +	debugctlmsr = get_debugctlmsr();
> 
> How expensive is this?  We may want a follow-on patch to cache it in a
> per-cpu variable.
> 
I have patches ready. I couldn't measure any overhead of the
rdmsr(MSR_IA32_DEBUGCTLMSR).

--
			Gleb.

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

* Re: [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
  2012-08-12 13:25   ` Gleb Natapov
@ 2012-08-12 13:40     ` Avi Kivity
  2012-08-12 17:28       ` Gleb Natapov
  0 siblings, 1 reply; 7+ messages in thread
From: Avi Kivity @ 2012-08-12 13:40 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

On 08/12/2012 04:25 PM, Gleb Natapov wrote:

>> How expensive is this?  We may want a follow-on patch to cache it in a
>> per-cpu variable.
>> 
> I have patches ready. I couldn't measure any overhead of the
> rdmsr(MSR_IA32_DEBUGCTLMSR).
> 

Do you mean while running kvm?  How about just running it in a loop?


-- 
error compiling committee.c: too many arguments to function

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

* Re: [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
  2012-08-12 13:40     ` Avi Kivity
@ 2012-08-12 17:28       ` Gleb Natapov
  2012-08-13  7:55         ` Avi Kivity
  0 siblings, 1 reply; 7+ messages in thread
From: Gleb Natapov @ 2012-08-12 17:28 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm, mtosatti

On Sun, Aug 12, 2012 at 04:40:48PM +0300, Avi Kivity wrote:
> On 08/12/2012 04:25 PM, Gleb Natapov wrote:
> 
> >> How expensive is this?  We may want a follow-on patch to cache it in a
> >> per-cpu variable.
> >> 
> > I have patches ready. I couldn't measure any overhead of the
> > rdmsr(MSR_IA32_DEBUGCTLMSR).
> > 
> 
> Do you mean while running kvm?  How about just running it in a loop?
> 
No, I mean running it in a loop. Loop with or without
rdmsr(MSR_IA32_DEBUGCTLMSR) takes the same time as measured by rdtsc.


--
			Gleb.

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

* Re: [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
  2012-08-12 17:28       ` Gleb Natapov
@ 2012-08-13  7:55         ` Avi Kivity
  0 siblings, 0 replies; 7+ messages in thread
From: Avi Kivity @ 2012-08-13  7:55 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

On 08/12/2012 08:28 PM, Gleb Natapov wrote:
> On Sun, Aug 12, 2012 at 04:40:48PM +0300, Avi Kivity wrote:
>> On 08/12/2012 04:25 PM, Gleb Natapov wrote:
>> 
>> >> How expensive is this?  We may want a follow-on patch to cache it in a
>> >> per-cpu variable.
>> >> 
>> > I have patches ready. I couldn't measure any overhead of the
>> > rdmsr(MSR_IA32_DEBUGCTLMSR).
>> > 
>> 
>> Do you mean while running kvm?  How about just running it in a loop?
>> 
> No, I mean running it in a loop. Loop with or without
> rdmsr(MSR_IA32_DEBUGCTLMSR) takes the same time as measured by rdtsc.

Ok, good.


-- 
error compiling committee.c: too many arguments to function

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

* Re: [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT
  2012-08-12 13:12 [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT Gleb Natapov
  2012-08-12 13:22 ` Avi Kivity
@ 2012-08-13 22:07 ` Marcelo Tosatti
  1 sibling, 0 replies; 7+ messages in thread
From: Marcelo Tosatti @ 2012-08-13 22:07 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, avi

On Sun, Aug 12, 2012 at 04:12:29PM +0300, Gleb Natapov wrote:
> MSR_IA32_DEBUGCTLMSR is zeroed on VMEXIT. Restore it to the correct
> value.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

Applied, thanks.


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

end of thread, other threads:[~2012-08-13 22:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-12 13:12 [PATCH] KVM: vmx: restore MSR_IA32_DEBUGCTLMSR after VMEXIT Gleb Natapov
2012-08-12 13:22 ` Avi Kivity
2012-08-12 13:25   ` Gleb Natapov
2012-08-12 13:40     ` Avi Kivity
2012-08-12 17:28       ` Gleb Natapov
2012-08-13  7:55         ` Avi Kivity
2012-08-13 22:07 ` Marcelo Tosatti

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).