linux-stable/drivers/perf
Anshuman Khandual 4125108ec8 drivers/perf: arm_spe: Fix consistency of SYS_PMSCR_EL1.CX
[ Upstream commit 92f2b8bafa ]

The arm_spe_pmu driver will enable SYS_PMSCR_EL1.CX in order to add CONTEXT
packets into the traces, if the owner of the perf event runs with required
capabilities i.e CAP_PERFMON or CAP_SYS_ADMIN via perfmon_capable() helper.

The value of this bit is computed in the arm_spe_event_to_pmscr() function
but the check for capabilities happens in the pmu event init callback i.e
arm_spe_pmu_event_init(). This suggests that the value of the CX bit should
remain consistent for the duration of the perf session.

However, the function arm_spe_event_to_pmscr() may be called later during
the event start callback i.e arm_spe_pmu_start() when the "current" process
is not the owner of the perf session, hence the CX bit setting is currently
not consistent.

One way to fix this, is by caching the required value of the CX bit during
the initialization of the PMU event, so that it remains consistent for the
duration of the session. It uses currently unused 'event->hw.flags' element
to cache perfmon_capable() value, which can be referred during event start
callback to compute SYS_PMSCR_EL1.CX. This ensures consistent availability
of context packets in the trace as per event owner capabilities.

Drop BIT(SYS_PMSCR_EL1_CX_SHIFT) check in arm_spe_pmu_event_init(), because
now CX bit cannot be set in arm_spe_event_to_pmscr() with perfmon_capable()
disabled.

Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Fixes: d5d9696b03 ("drivers/perf: Add support for ARMv8.2 Statistical Profiling Extension")
Reported-by: German Gomez <german.gomez@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20220714061302.2715102-1-anshuman.khandual@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-17 14:23:14 +02:00
..
hisilicon perf/hisi: Constify static attribute_group structs 2021-06-08 12:49:54 +01:00
arm-cci.c drivers/perf: arm-cci: Fix checkpatch spacing error 2021-05-25 18:59:23 +01:00
arm-ccn.c
arm-cmn.c perf/arm-cmn: Fix CPU hotplug unregistration 2022-01-27 11:03:36 +01:00
arm_dmc620_pmu.c perf/arm-dmc620: Use irq_set_affinity() 2021-05-24 11:01:59 +01:00
arm_dsu_pmu.c perf/arm-dsu: Use irq_set_affinity() 2021-05-24 11:02:00 +01:00
arm_pmu.c arm_pmu: Validate single/group leader events 2022-04-27 14:39:00 +02:00
arm_pmu_acpi.c
arm_pmu_platform.c
arm_smmuv3_pmu.c drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver 2021-06-11 11:18:40 +01:00
arm_spe_pmu.c drivers/perf: arm_spe: Fix consistency of SYS_PMSCR_EL1.CX 2022-08-17 14:23:14 +02:00
fsl_imx8_ddr_perf.c perf/imx_ddr: Fix undefined behavior due to shift overflowing the constant 2022-04-20 09:34:18 +02:00
Kconfig
Makefile
qcom_l2_pmu.c perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator 2022-04-13 20:59:24 +02:00
qcom_l3_pmu.c drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c 2021-06-11 11:18:40 +01:00
thunderx2_pmu.c drivers/perf: Remove redundant dev_err call in tx2_uncore_pmu_init_dev() 2021-05-25 18:57:19 +01:00
xgene_pmu.c drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c 2021-06-11 11:18:40 +01:00