Hi Congkai,

Thanks for respinning.

On Thu, Jul 02, 2026 at 07:04:18PM +0000, Congkai Tan wrote:
> Today when the perf tool runs in a guest on cores with PMUv3p4, it fails
> to parse the default metrics with "Failure to read '#slots'", since perf
> can only read 0 from sysfs caps/slots, which is backed by PMMIR_EL1.SLOTS
> that KVM traps as RAZ/WI.
> 
> Taking into account backward compatibility and heterogeneous systems, the
> exposure of PMMIR_EL1.SLOTS is gated behind a new vCPU feature flag:
> 
> - Patch 1 adds the new flag KVM_ARM_VCPU_PMU_V3_STRICT. When set, KVM does
>   not create a default PMU during vCPU init, and the VMM must select one
>   explicitly via KVM_ARM_VCPU_PMU_V3_SET_PMU before the first KVM_RUN.
> - Patch 2 exposes PMMIR_EL1.SLOTS of the selected PMU under the flag, and
>   adds userspace get/set for PMMIR_EL1 so that SLOTS can be reset to 0
>   for backward compatibility.
> - Patch 3 stops masking STALL_SLOT* in PMCEID1 under the flag.

I think the series is starting to shape up. Few more things to address:

 - Didn't mention it in v1, but writes to PMCR_EL0.N should be ignored
   when V3_STRICT is set. We now have a vCPU attribute for configuring
   event counters and the register-based thing is just broken :)

 - The vCPU feature flag needs a corresponding KVM_CAP so userspace can
   detect it

 - In terms of patch ordering, the vCPU flag / KVM_CAP exposure should
   come last after all the behavior changes are implemented (and
   flag-guarded)

 - Move enforcement of a non-NULL arm_pmu to kvm_arm_pmu_v3_init() since
   userspace must call KVM_ARM_VCPU_PMU_V3_INIT before KVM_RUN

 - Prevent the PMU event filter from being configured until a hardware
   PMU has been selected

I've addressed all of this locally and pushed to my tree [*]. Untested,
as always :) Would you be able to give it a spin?

Also, do you have VMM patches for using the new feature flag?

[*]: 
https://git.kernel.org/pub/scm/linux/kernel/git/oupton/linux.git/log/?h=kvm-arm64/pmu-7.3

Thanks,
Oliver

Reply via email to