Re: [PATCH v8 09/11] KVM: arm64: PMU: Implement fixed-counters-only emulation

Akihiko Odaki <[email protected]>
Newsgroups org.kernel.vger.linux-hardening,dev.linux.lists.kvmarm,org.infradead.lists.linux-arm-kernel,org.kernel.vger.kvm,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest
Message-ID <[email protected]>
On 2026/07/13 16:41, Oliver Upton wrote:
> On Fri, Jul 10, 2026 at 08:15:03PM +0900, Akihiko Odaki wrote:
>> @@ -813,6 +842,15 @@ void kvm_host_pmu_init(struct arm_pmu *pmu)
>>   	if (!pmuv3_implemented(kvm_arm_pmu_get_pmuver_limit()))
>>   		return;
>>   
>> +	/*
>> +	 * IMPDEF PMUv3 traps are non-architectural, and KVM cannot assume a
>> +	 * uniform PMUv3-compatible arm_pmu is available on all CPUs.
>> +	 */
>> +	if (cpus_have_final_cap(ARM64_WORKAROUND_PMUV3_IMPDEF_TRAPS)) {
>> +		kvm_info("Non-architectural PMU, tainting kernel\n");
>> +		add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
>> +	}
>> +
> 
> This is an unrelated change, and really the taint should be added with the
> .cpu_enable() for this capability. That's the point where we flip the
> magic bit.

I'm abandoning this change because it does not effectively cover all 
corner cases we don't want to support:
https://lore.kernel.org/all/[email protected]/

> 
>> +void kvm_vcpu_load_pmu(struct kvm_vcpu *vcpu, int last_cpu)
>> +{
>> +	if (!kvm_pmu_fixed_counters_only(vcpu->kvm) || vcpu->cpu == last_cpu || last_cpu == -1)
> 										^~~~~~~~~~~~~~
> 
> Does this do anything other than avoid a spurious reload on the first KVM_RUN?

Yes. Without this check, the value will be passed to cpu_max_bits_warn() 
in the following call chain, resulting in a warning ifdef 
CONFIG_DEBUG_PER_CPU_MAPS:

1. kvm_vcpu_load_pmu()
2. kvm_pmu_probe_armpmu()
3. cpumask_test_cpu()
4. cpumask_check()
5. cpu_max_bits_warn()

Regards,
Akihiko Odaki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.