linux-stable/drivers/perf
Anshuman Khandual 313dd0d9a7 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:40:41 +02:00
..
hisilicon perf: replace bitmap_weight with bitmap_empty where appropriate 2022-02-15 14:38:57 +00:00
Kconfig perf: MARVELL_CN10K_DDR_PMU should depend on ARCH_THUNDER 2022-04-04 10:51:20 +01:00
Makefile RISC-V Patches for the 5.18 Merge Window, Part 1 2022-03-25 10:11:38 -07:00
apple_m1_cpu_pmu.c drivers/perf: Add Apple icestorm/firestorm CPU PMU driver 2022-03-08 13:32:48 +00:00
arm-cci.c perf: replace bitmap_weight with bitmap_empty where appropriate 2022-02-15 14:38:57 +00:00
arm-ccn.c perf/arm-ccn: Use platform_get_irq() to get the interrupt 2022-02-08 14:25:35 +00:00
arm-cmn.c perf/arm-cmn: Update watchpoint format 2022-03-08 11:02:26 +00: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-13 11:48:45 +01:00
arm_pmu_acpi.c drivers/perf: arm_pmu_acpi: Fix incorrect checking of gicc pointer 2020-03-02 12:07:35 +00:00
arm_pmu_platform.c perf/arm_pmu_platform: Clean up with dev_printk 2021-03-30 11:41:50 +01:00
arm_smmuv3_pmu.c perf/smmuv3: Don't cast parameter in bit operations 2022-02-15 16:51:26 +00:00
arm_spe_pmu.c drivers/perf: arm_spe: Fix consistency of SYS_PMSCR_EL1.CX 2022-08-17 14:40:41 +02:00
fsl_imx8_ddr_perf.c perf/imx_ddr: Fix undefined behavior due to shift overflowing the constant 2022-04-08 14:17:57 +01:00
marvell_cn10k_ddr_pmu.c perf/marvell: Fix !CONFIG_OF build for CN10K DDR PMU driver 2022-03-09 12:31:00 +00:00
marvell_cn10k_tad_pmu.c perf/marvell_cn10k: Fix unused variable warning when W=1 and CONFIG_OF=n 2022-02-08 15:12:28 +00:00
qcom_l2_pmu.c perf: qcom_l2_pmu: fix an incorrect NULL check on list iterator 2022-04-04 10:50:02 +01:00
qcom_l3_pmu.c drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c 2021-06-11 11:18:40 +01:00
riscv_pmu.c RISC-V: Update user page mapping only once during start 2022-08-17 14:40:11 +02:00
riscv_pmu_legacy.c RISC-V: Add a simple platform driver for RISC-V legacy perf 2022-03-21 14:58:25 -07:00
riscv_pmu_sbi.c perf: RISC-V: Add of_node_put() when breaking out of for_each_of_cpu_node() 2022-08-17 14:40:41 +02:00
thunderx2_pmu.c perf: Replace acpi_bus_get_device() 2022-02-08 15:14:53 +00:00
xgene_pmu.c perf: replace bitmap_weight with bitmap_empty where appropriate 2022-02-15 14:38:57 +00:00