public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: do not #GP on perf MSR writes when vPMU is disabled
@ 2012-01-15 12:17 Gleb Natapov
  2012-01-17 11:24 ` Marcelo Tosatti
  0 siblings, 1 reply; 4+ messages in thread
From: Gleb Natapov @ 2012-01-15 12:17 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

Return to behaviour perf MSR had before introducing vPMU in case vPMU
is disabled. Some guests access those registers unconditionally and do
not expect it to fail.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c95ca2d..9c912f0b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1495,6 +1495,8 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
 
 int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 {
+	bool pr = false;
+
 	switch (msr) {
 	case MSR_EFER:
 		return set_efer(vcpu, data);
@@ -1635,6 +1637,18 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 		pr_unimpl(vcpu, "unimplemented perfctr wrmsr: "
 			"0x%x data 0x%llx\n", msr, data);
 		break;
+	case MSR_P6_PERFCTR0:
+	case MSR_P6_PERFCTR1:
+		pr = true;
+	case MSR_P6_EVNTSEL0:
+	case MSR_P6_EVNTSEL1:
+		if (kvm_pmu_msr(vcpu, msr))
+			return kvm_pmu_set_msr(vcpu, msr, data);
+
+		if (pr || data != 0)
+			pr_unimpl(vcpu, "disabled perfctr wrmsr: "
+				"0x%x data 0x%llx\n", msr, data);
+		break;
 	case MSR_K7_CLK_CTL:
 		/*
 		 * Ignore all writes to this no longer documented MSR.
@@ -1845,6 +1859,14 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 	case MSR_FAM10H_MMIO_CONF_BASE:
 		data = 0;
 		break;
+	case MSR_P6_PERFCTR0:
+	case MSR_P6_PERFCTR1:
+	case MSR_P6_EVNTSEL0:
+	case MSR_P6_EVNTSEL1:
+		if (kvm_pmu_msr(vcpu, msr))
+			return kvm_pmu_get_msr(vcpu, msr, pdata);
+		data = 0;
+		break;
 	case MSR_IA32_UCODE_REV:
 		data = 0x100000000ULL;
 		break;
--
			Gleb.

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

* Re: [PATCH] KVM: do not #GP on perf MSR writes when vPMU is disabled
  2012-01-15 12:17 [PATCH] KVM: do not #GP on perf MSR writes when vPMU is disabled Gleb Natapov
@ 2012-01-17 11:24 ` Marcelo Tosatti
  2012-01-24 14:28   ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Marcelo Tosatti @ 2012-01-17 11:24 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, avi

On Sun, Jan 15, 2012 at 02:17:22PM +0200, Gleb Natapov wrote:
> Return to behaviour perf MSR had before introducing vPMU in case vPMU
> is disabled. Some guests access those registers unconditionally and do
> not expect it to fail.
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

Applied, thanks.


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

* Re: [PATCH] KVM: do not #GP on perf MSR writes when vPMU is disabled
  2012-01-17 11:24 ` Marcelo Tosatti
@ 2012-01-24 14:28   ` Avi Kivity
  2012-01-24 16:02     ` Gleb Natapov
  0 siblings, 1 reply; 4+ messages in thread
From: Avi Kivity @ 2012-01-24 14:28 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Gleb Natapov, kvm

On 01/17/2012 01:24 PM, Marcelo Tosatti wrote:
> On Sun, Jan 15, 2012 at 02:17:22PM +0200, Gleb Natapov wrote:
> > Return to behaviour perf MSR had before introducing vPMU in case vPMU
> > is disabled. Some guests access those registers unconditionally and do
> > not expect it to fail.
> > 
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
>
> Applied, thanks.
>

Needed for 3.3, no?

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


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

* Re: [PATCH] KVM: do not #GP on perf MSR writes when vPMU is disabled
  2012-01-24 14:28   ` Avi Kivity
@ 2012-01-24 16:02     ` Gleb Natapov
  0 siblings, 0 replies; 4+ messages in thread
From: Gleb Natapov @ 2012-01-24 16:02 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm

On Tue, Jan 24, 2012 at 04:28:43PM +0200, Avi Kivity wrote:
> On 01/17/2012 01:24 PM, Marcelo Tosatti wrote:
> > On Sun, Jan 15, 2012 at 02:17:22PM +0200, Gleb Natapov wrote:
> > > Return to behaviour perf MSR had before introducing vPMU in case vPMU
> > > is disabled. Some guests access those registers unconditionally and do
> > > not expect it to fail.
> > > 
> > > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> >
> > Applied, thanks.
> >
> 
> Needed for 3.3, no?
> 
Yes. Should I do something special for that?

--
			Gleb.

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

end of thread, other threads:[~2012-01-24 16:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-15 12:17 [PATCH] KVM: do not #GP on perf MSR writes when vPMU is disabled Gleb Natapov
2012-01-17 11:24 ` Marcelo Tosatti
2012-01-24 14:28   ` Avi Kivity
2012-01-24 16:02     ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox