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

From: Chen, Zide

Date: Fri Jul 31 2026 - 16:32:55 EST




On 7/30/2026 8:12 PM, Mi, Dapeng 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),
>
> Zide, it seems this list is incomplete. The
> DMR/ARL(INTEL_ARROWLAKE/INTEL_ARROWLAKE_H) should be secure as well. Thanks.

Thanks for pointing that out. I didn't realize that some Arrow Lake
models are PMU v6.

However, all of the client CPUs listed above are hybrid CPUs, and KVM
does not currently support vPMU on hybrid platforms.Therefore, only
Clearwater Forest and Diamond Rapids need to be included in this list
for now. I'll add a comment documenting the exclusion of hybrid CPUs.

>> + {}
>> +};
>> +
>> /* 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)
>> + return true;
>> +
>> + /*
>> + * Future PMU v6 implementations and future PMU versions require RDPMC
>> + * interception until their RDPMC encodings are audited and supported
>> + * by KVM.
>> + */
>> + return x86_match_cpu(kvm_rdpmc_known_cpus);
>> +}
>> +
>> bool kvm_need_rdpmc_intercept(struct kvm_vcpu *vcpu)
>> {
>> struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
>> @@ -818,6 +847,9 @@ bool kvm_need_rdpmc_intercept(struct kvm_vcpu *vcpu)
>> if (enable_vmware_backdoor)
>> return true;
>>
>> + if (!kvm_rdpmc_encoding_supported())
>> + return true;
>> +
>> return kvm_need_any_pmc_intercept(vcpu) ||
>> pmu->counter_bitmask[KVM_PMC_GP] != (BIT_ULL(kvm_host_pmu.bit_width_gp) - 1) ||
>> pmu->counter_bitmask[KVM_PMC_FIXED] != (BIT_ULL(kvm_host_pmu.bit_width_fixed) - 1);