From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset. Date: Tue, 10 Apr 2012 15:25:01 +0300 Message-ID: <4F84269D.1010601@redhat.com> References: <20120409143835.GY11918@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, mtosatti@redhat.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9379 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753714Ab2DJMZE (ORCPT ); Tue, 10 Apr 2012 08:25:04 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3ACP3pp002942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 10 Apr 2012 08:25:04 -0400 In-Reply-To: <20120409143835.GY11918@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 04/09/2012 05:38 PM, Gleb Natapov wrote: > On reset all MPU counters should be enabled in GLOBAL_CTRL MSR. > > Signed-off-by: Gleb Natapov > diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c > index 173df38..2e88438 100644 > --- a/arch/x86/kvm/pmu.c > +++ b/arch/x86/kvm/pmu.c > @@ -459,17 +459,17 @@ void kvm_pmu_cpuid_update(struct kvm_vcpu *vcpu) > pmu->available_event_types = ~entry->ebx & ((1ull << bitmap_len) - 1); > > if (pmu->version == 1) { > - pmu->global_ctrl = (1 << pmu->nr_arch_gp_counters) - 1; > - return; > + pmu->nr_arch_fixed_counters = 0; > + } else { > + pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f), > + X86_PMC_MAX_FIXED); > + pmu->counter_bitmask[KVM_PMC_FIXED] = > + ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1; > } > > - pmu->nr_arch_fixed_counters = min((int)(entry->edx & 0x1f), > - X86_PMC_MAX_FIXED); > - pmu->counter_bitmask[KVM_PMC_FIXED] = > - ((u64)1 << ((entry->edx >> 5) & 0xff)) - 1; > - pmu->global_ctrl_mask = ~(((1 << pmu->nr_arch_gp_counters) - 1) > - | (((1ull << pmu->nr_arch_fixed_counters) - 1) > - << X86_PMC_IDX_FIXED)); > + pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) | > + (((1ull << pmu->nr_arch_fixed_counters) - 1) << X86_PMC_IDX_FIXED); > + pmu->global_ctrl_mask = ~pmu->global_ctrl; > } > > This is not called on INIT (not sure it should be). On the other hand update_cpuid() is not the best place to initialize stuff. Oh well, this can be fixed later (not sure its possible), I'll apply this to master. -- error compiling committee.c: too many arguments to function