Re: [PATCH v9 14/16] KVM: arm64: PMU: Implement fixed-counters-only emulation
Fuad Tabba <[email protected]> Wed, 29 Jul 2026 19:18:00 +0100
| 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 | <CA+EHjTx0zNQ_yPCz38vGYpBssshE4b3KWaoUxjzuerGgzB=JSQ@mail.gmail.com> |
Hi Akihiko, On Mon, 20 Jul 2026 at 06:39, Akihiko Odaki <[email protected]> wrote: ... > +/** > + * kvm_pmu_create_perf_event - create a perf event for a counter > + * @pmc: Counter context > + */ > +static void kvm_pmu_create_perf_event(struct kvm_pmc *pmc) > +{ > + struct kvm_vcpu *vcpu = kvm_pmc_to_vcpu(pmc); > + struct arm_pmu *arm_pmu = vcpu->kvm->arch.arm_pmu; > + > + if (kvm_pmu_fixed_counters_only(vcpu->kvm)) { > + do { > + arm_pmu = kvm_pmu_probe_armpmu(READ_ONCE(vcpu->cpu)); > + > + if (!arm_pmu) { > + pr_warn_once("kvm: Unsupported PMU variation detected.\n"); > + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); > + return; > + } Sashiko flagged that this can leave the perf event out of sync with the sysreg, which looks plausible: on a pCPU with no registered pPMU this returns without recreating the event, so a guest event-type change there updates the sysreg but not the event, and after migrating back to a pCPU the original pPMU covers, kvm_pmc_enable_perf_event() re-enables the stale event instead of recreating it. I know you treat the no-pPMU case as out of spec, but the dropped update lands once the vCPU is back on a normal pCPU. Is this intended? Cheers, /fuad