Re: [PATCH] KVM: VMX: Always treat MSR_IA32_PERF_CAPABILITIES as a valid PMU MSR
From: Paolo Bonzini
Date: Thu Jun 04 2020 - 12:49:51 EST
On 04/06/20 18:44, Jim Mattson wrote:
>>> 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?
Both, I guess (a valid assumption for userspace, an invariant to be
respected for the kernel code).
The part where we don't fare to well, is that a bunch of MSRs that need
save/restore are _not_ included in KVM_GET_MSR_INDEX_LIST (and the PMU
is the biggest if not the only offender there).
Paolo