Re: [PATCH] KVM: VMX: Always treat MSR_IA32_PERF_CAPABILITIES as a valid PMU MSR
From: Paolo Bonzini
Date: Thu Jun 04 2020 - 12:20:38 EST
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.
Paolo