Skip to content

Commit 1b92e65

Browse files
committed
KVM: arm64: Provide 1 event counter on IMPDEF hardware
PMUv3 requires that all programmable event counters are capable of counting any event. The Apple M* PMU is quite a bit different, and events have affinities for particular PMCs. Expose 1 event counter on IMPDEF hardware, allowing the guest to do something useful with its PMU while also upholding the requirements of the architecture. Tested-by: Janne Grunau <j@jannau.net> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250305203021.428366-1-oliver.upton@linux.dev Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 2d00cab commit 1b92e65

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/arm64/kvm/pmu-emul.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,13 @@ u8 kvm_arm_pmu_get_max_counters(struct kvm *kvm)
10381038
{
10391039
struct arm_pmu *arm_pmu = kvm->arch.arm_pmu;
10401040

1041+
/*
1042+
* PMUv3 requires that all event counters are capable of counting any
1043+
* event, though the same may not be true of non-PMUv3 hardware.
1044+
*/
1045+
if (cpus_have_final_cap(ARM64_WORKAROUND_PMUV3_IMPDEF_TRAPS))
1046+
return 1;
1047+
10411048
/*
10421049
* The arm_pmu->cntr_mask considers the fixed counter(s) as well.
10431050
* Ignore those and return only the general-purpose counters.

0 commit comments

Comments
 (0)