This series introduces support in the ARM PMUv3 driver for partitioning PMU counters into two separate ranges by taking advantage of the MDCR_EL2.HPMN register field.
The advantage of a partitioned PMU would be to allow KVM guests direct access to a subset of PMU functionality, greatly reducing the overhead of performance monitoring in guests.
While this series could be accepted on its own merits, practically there is a lot more to be done before it will be fully useful, so I'm sending as an RFC for now.
This patch is based on v6.13-rc7. It needs a small additional change after Oliver's Debug cleanups series going into 6.14, specifically this patch [1], because it changes kvm_arm_setup_mdcr_el2() to initialize HPMN from a cached value read early in the boot process instead of reading from the register. The only sensible way I can see to deal with this is returning to reading the register.
[1] https://lore.kernel.org/kvmarm/20241219224116.3941496-3-oliver.upton@linux.d...
Colton Lewis (4): perf: arm_pmuv3: Introduce module param to partition the PMU KVM: arm64: Make guests see only counters they can access perf: arm_pmuv3: Generalize counter bitmasks perf: arm_pmuv3: Keep out of guest counter partition
arch/arm/include/asm/arm_pmuv3.h | 10 ++ arch/arm64/include/asm/arm_pmuv3.h | 10 ++ arch/arm64/kvm/pmu-emul.c | 8 +- drivers/perf/arm_pmuv3.c | 113 ++++++++++++++++-- include/linux/perf/arm_pmu.h | 2 + include/linux/perf/arm_pmuv3.h | 34 +++++- .../kvm/aarch64/vpmu_counter_access.c | 2 +- 7 files changed, 160 insertions(+), 19 deletions(-)
base-commit: 5bc55a333a2f7316b58edc7573e8e893f7acb532 -- 2.48.1.262.g85cc9f2d1e-goog