Re: [PATCH v7 7/9] KVM: x86/pmu: Restrict RDPMC passthrough to known CPUs

From: Mi, Dapeng

Date: Thu Jul 30 2026 - 21:06:27 EST



On 7/30/2026 11:11 PM, Jim Mattson wrote:
> On Wed, Jul 29, 2026 at 7:51 PM Mi, Dapeng <dapeng1.mi@xxxxxxxxxxxxxxx> wrote:
>>
>> On 7/28/2026 3:21 AM, Zide Chen wrote:
>>> RDPMC type encodings are vendor-defined and could theoretically be
>>> extended on future CPUs. An unknown RDPMC type could leak host
>>> PMU information to the guest through RDPMC passthrough.
>>>
>>> Rather than assuming future CPUs are safe, explicitly permit only
>>> reviewed CPU models and require RDPMC interception everywhere else.
>>> This ensures RDPMC passthrough is enabled only on CPUs whose RDPMC
>>> encodings are audited and supported by KVM.
>>>
>>> Suggested-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
>>> Suggested-by: Jim Mattson <jmattson@xxxxxxxxxx>
>>> Signed-off-by: Zide Chen <zide.chen@xxxxxxxxx>
>>> ---
>>> v7: new patch.
>>> ---
>>> arch/x86/kvm/pmu.c | 32 ++++++++++++++++++++++++++++++++
>>> 1 file changed, 32 insertions(+)
>>>
>>> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
>>> index 51c6d00a485f..092809bd757d 100644
>>> --- a/arch/x86/kvm/pmu.c
>>> +++ b/arch/x86/kvm/pmu.c
>>> @@ -77,6 +77,21 @@ static const struct x86_cpu_id vmx_pebs_pdist_cpu[] = {
>>> {}
>>> };
>>>
>>> +/*
>>> + * CPUs whose RDPMC encodings have been audited for KVM RDPMC
>>> + * passthrough support.
>>> + */
>>> +static const struct x86_cpu_id kvm_rdpmc_known_cpus[] = {
>>> + X86_MATCH_VFM(INTEL_ATOM_DARKMONT_X, NULL),
>>> + X86_MATCH_VFM(INTEL_LUNARLAKE_M, NULL),
>>> + X86_MATCH_VFM(INTEL_NOVALAKE, NULL),
>>> + X86_MATCH_VFM(INTEL_NOVALAKE_L, NULL),
>>> + X86_MATCH_VFM(INTEL_PANTHERLAKE_L, NULL),
>>> + X86_MATCH_VFM(INTEL_PANTHERLAKE_R, NULL),
>>> + X86_MATCH_VFM(INTEL_WILDCATLAKE_L, NULL),
>>> + {}
>>> +};
>>> +
>>> /* NOTE:
>>> * - Each perf counter is defined as "struct kvm_pmc";
>>> * - There are two types of perf counters: general purpose (gp) and fixed.
>>> @@ -807,6 +822,20 @@ bool kvm_need_perf_global_ctrl_intercept(struct kvm_vcpu *vcpu)
>>> }
>>> EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_need_perf_global_ctrl_intercept);
>>>
>>> +static bool kvm_rdpmc_encoding_supported(void)
>>> +{
>>> + /* KVM understands all RDPMC encodings prior to PMU v6. */
>>> + if (kvm_host_pmu.version < 6)
>> I'm not sure if this works for AMD platforms. Jim said current AMD
>> platforms already have security holes and I believe the PMU version of AMD
>> platforms are less than 6.
> Let's not be pejorative! I said that AMD's RDPMC allows access to
> counters that KVM does not (yet) virtualize, such as the data fabric
> and L3 counters. The APM, volume 3, indicates that up to 28 counters
> are supported today. KVM only virtualizes 6.

I see. Thanks for clarifying this. My words were too arbitrary :(

Anyway, need @Sandipan and @Manali to double confirm this. If current
checks are not available for AMD platforms, we could need to introduce new
PMU vendor callbacks but not sure if it's worthy.

Thanks.


>
>> Need AMD guys to confirm. @Sandipan, @Manali.