Re: [PATCH] KVM: VMX: Always treat MSR_IA32_PERF_CAPABILITIES as a valid PMU MSR
From: Jim Mattson
Date: Thu Jun 04 2020 - 12:44:49 EST
On Thu, Jun 4, 2020 at 9:20 AM Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
>
> On 04/06/20 17:16, Sean Christopherson wrote:
> > On Thu, Jun 04, 2020 at 09:37:59AM +0800, Xu, Like wrote:
> >> On 2020/6/4 4:33, Sean Christopherson wrote:
> >>> Unconditionally return true when querying the validity of
> >>> MSR_IA32_PERF_CAPABILITIES so as to defer the validity check to
> >>> intel_pmu_{get,set}_msr(), which can properly give the MSR a pass when
> >>> the access is initiated from host userspace.
> >> Regardless ofÃâà the MSR is emulated or not, is it a really good assumption that
> >> the guest cpuids are not properly ready when we do initialization from host
> >> userspace
> >> ?
> >
> > I don't know if I would call it a "good assumption" so much as a "necessary
> > assumption". KVM_{GET,SET}_MSRS are allowed, and must function correctly,
> > if they're called prior to KVM_SET_CPUID{2}.
>
> Generally speaking this is not the case for the PMU; get_gp_pmc for
> example depends on pmu->nr_arch_gp_counters which is initialized based
> on CPUID leaf 0xA.
>
> The assumption that this patch fixes is that you can blindly take the
> output of KVM_GET_MSR_INDEX_LIST and pass it to KVM_{GET,SET}_MSRS.
Is that an assumption or an invariant?