Skip to content

Commit a0a52b2

Browse files
ouptonjannau
authored andcommitted
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. Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent c6de7fa commit a0a52b2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

arch/arm64/kvm/pmu-emul.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,12 @@ u8 kvm_arm_pmu_get_max_counters(struct kvm *kvm)
942942
{
943943
struct arm_pmu *arm_pmu = kvm->arch.arm_pmu;
944944

945+
/*
946+
* PMUv3 requires that all event counters are capable of counting any
947+
* event, though the same may not be true of non-PMUv3 hardware.
948+
*/
945949
if (cpus_have_final_cap(ARM64_WORKAROUND_PMUV3_IMPDEF_TRAPS))
946-
return 0;
950+
return 1;
947951

948952
/*
949953
* The arm_pmu->cntr_mask considers the fixed counter(s) as well.

0 commit comments

Comments
 (0)