Check cntr_mask before using pmccntr to ensure it's available. With a
partitioned PMU, there may be instances where pmccntr is being used by
the guest and will ba absent from cntr_mask.

Signed-off-by: Colton Lewis <[email protected]>
---
 drivers/perf/arm_pmuv3.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c
index 1cceb1f614515..7ff3139dda893 100644
--- a/drivers/perf/arm_pmuv3.c
+++ b/drivers/perf/arm_pmuv3.c
@@ -993,6 +993,9 @@ static bool armv8pmu_can_use_pmccntr(struct pmu_hw_events 
*cpuc,
        if (evtype != ARMV8_PMUV3_PERFCTR_CPU_CYCLES)
                return false;
 
+       if (!test_bit(ARMV8_PMU_CYCLE_IDX, cpu_pmu->cntr_mask))
+               return false;
+
        /*
         * A CPU_CYCLES event with threshold counting cannot use PMCCNTR_EL0
         * since it lacks threshold support.
-- 
2.54.0.545.g6539524ca2-goog


Reply via email to