linux-stable/drivers/perf
Fei Wu 9f599ba3b9 perf: RISCV: Fix panic on pmu overflow handler
[ Upstream commit 34b5678687 ]

(1 << idx) of int is not desired when setting bits in unsigned long
overflowed_ctrs, use BIT() instead. This panic happens when running
'perf record -e branches' on sophgo sg2042.

[  273.311852] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000098
[  273.320851] Oops [#1]
[  273.323179] Modules linked in:
[  273.326303] CPU: 0 PID: 1475 Comm: perf Not tainted 6.6.0-rc3+ #9
[  273.332521] Hardware name: Sophgo Mango (DT)
[  273.336878] epc : riscv_pmu_ctr_get_width_mask+0x8/0x62
[  273.342291]  ra : pmu_sbi_ovf_handler+0x2e0/0x34e
[  273.347091] epc : ffffffff80aecd98 ra : ffffffff80aee056 sp : fffffff6e36928b0
[  273.354454]  gp : ffffffff821f82d0 tp : ffffffd90c353200 t0 : 0000002ade4f9978
[  273.361815]  t1 : 0000000000504d55 t2 : ffffffff8016cd8c s0 : fffffff6e3692a70
[  273.369180]  s1 : 0000000000000020 a0 : 0000000000000000 a1 : 00001a8e81800000
[  273.376540]  a2 : 0000003c00070198 a3 : 0000003c00db75a4 a4 : 0000000000000015
[  273.383901]  a5 : ffffffd7ff8804b0 a6 : 0000000000000015 a7 : 000000000000002a
[  273.391327]  s2 : 000000000000ffff s3 : 0000000000000000 s4 : ffffffd7ff8803b0
[  273.398773]  s5 : 0000000000504d55 s6 : ffffffd905069800 s7 : ffffffff821fe210
[  273.406139]  s8 : 000000007fffffff s9 : ffffffd7ff8803b0 s10: ffffffd903f29098
[  273.413660]  s11: 0000000080000000 t3 : 0000000000000003 t4 : ffffffff8017a0ca
[  273.421022]  t5 : ffffffff8023cfc2 t6 : ffffffd9040780e8
[  273.426437] status: 0000000200000100 badaddr: 0000000000000098 cause: 000000000000000d
[  273.434512] [<ffffffff80aecd98>] riscv_pmu_ctr_get_width_mask+0x8/0x62
[  273.441169] [<ffffffff80076bd8>] handle_percpu_devid_irq+0x98/0x1ee
[  273.447562] [<ffffffff80071158>] generic_handle_domain_irq+0x28/0x36
[  273.454151] [<ffffffff8047a99a>] riscv_intc_irq+0x36/0x4e
[  273.459659] [<ffffffff80c944de>] handle_riscv_irq+0x4a/0x74
[  273.465442] [<ffffffff80c94c48>] do_irq+0x62/0x92
[  273.470360] Code: 0420 60a2 6402 5529 0141 8082 0013 0000 0013 0000 (6d5c) b783
[  273.477921] ---[ end trace 0000000000000000 ]---
[  273.482630] Kernel panic - not syncing: Fatal exception in interrupt

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Fei Wu <fei2.wu@intel.com>
Link: https://lore.kernel.org/r/20240228115425.2613856-1-fei2.wu@intel.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:17:55 -04:00
..
amlogic perf/amlogic: add missing MODULE_DEVICE_TABLE 2023-10-17 12:36:12 +01:00
arm_cspmu arm64 fixes: 2023-11-10 12:22:14 -08:00
hisilicon drivers/perf: hisi: Fix some event id for HiSilicon UC pmu 2024-01-25 15:44:38 -08:00
Kconfig perf/smmuv3: Remove build dependency on ACPI 2023-07-27 13:00:49 +01:00
Makefile cxl for v6.5 2023-07-01 08:58:41 -07:00
alibaba_uncore_drw_pmu.c driver/perf: Add identifier sysfs file for Yitian 710 DDR 2023-07-27 12:57:04 +01:00
apple_m1_cpu_pmu.c drivers/perf: apple_m1: Force 63bit counters for M2 CPUs 2023-06-05 15:39:59 +01:00
arm-cci.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
arm-ccn.c
arm-cmn.c perf/arm-cmn: Workaround AmpereOneX errata AC04_MESH_1 (incorrect child count) 2024-03-26 18:17:49 -04:00
arm_dmc620_pmu.c perf/arm-dmc620: Fix dmc620_pmu_irqs_lock/cpu_hotplug_lock circular lock dependency 2023-08-16 14:16:03 +01:00
arm_dsu_pmu.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
arm_pmu.c arm_pmu: Remove unused PERF_PMU_CAP_HETEROGENEOUS_CPUS capability 2023-07-26 12:28:47 +02:00
arm_pmu_acpi.c arm_pmu: acpi: Add a representative platform device for TRBE 2023-08-18 18:07:10 +01:00
arm_pmu_platform.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
arm_pmuv3.c drivers/perf: pmuv3: don't expose SW_INCR event in sysfs 2024-02-05 20:16:44 +00:00
arm_smmuv3_pmu.c perf/smmuv3: Add MODULE_ALIAS for module auto loading 2023-08-15 12:53:04 +01:00
arm_spe_pmu.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
cxl_pmu.c perf: CXL: fix CPMU filter value mask length 2024-03-26 18:17:52 -04:00
fsl_imx8_ddr_perf.c perf/imx_ddr: don't enable counter0 if none of 4 counters are used 2023-08-16 14:34:51 +01:00
fsl_imx9_ddr_perf.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
marvell_cn10k_ddr_pmu.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
marvell_cn10k_tad_pmu.c drivers/perf: Explicitly include correct DT includes 2023-07-27 13:02:23 +01:00
qcom_l2_pmu.c perf: qcom_l2_pmu: Make l2_cache_pmu_probe_cluster() more robust 2023-06-05 15:01:27 +01:00
qcom_l3_pmu.c perf: qcom: use acpi_device_uid() for fetching _UID 2023-10-20 19:21:14 +02:00
riscv_pmu.c drivers: perf: ctr_get_width function for legacy is not defined 2024-03-06 14:53:53 +00:00
riscv_pmu_legacy.c drivers: perf: ctr_get_width function for legacy is not defined 2024-03-06 14:53:53 +00:00
riscv_pmu_sbi.c perf: RISCV: Fix panic on pmu overflow handler 2024-03-26 18:17:55 -04:00
thunderx2_pmu.c
xgene_pmu.c drivers/perf: xgene: Use device_get_match_data() 2023-10-17 12:43:13 +01:00