Skip to content

Commit e083021

Browse files
palmer-dabbeltgregkh
authored andcommitted
RISC-V: Re-enable counter access from userspace
commit 5a5294f upstream. These counters were part of the ISA when we froze the uABI, removing them breaks userspace. Link: https://lore.kernel.org/all/YxEhC%[email protected]/ Fixes: e999143 ("RISC-V: Add perf platform driver based on SBI PMU extension") Tested-by: Conor Dooley <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Palmer Dabbelt <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1379df4 commit e083021

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/perf/riscv_pmu_sbi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,11 @@ static int pmu_sbi_starting_cpu(unsigned int cpu, struct hlist_node *node)
639639
struct riscv_pmu *pmu = hlist_entry_safe(node, struct riscv_pmu, node);
640640
struct cpu_hw_events *cpu_hw_evt = this_cpu_ptr(pmu->hw_events);
641641

642-
/* Enable the access for TIME csr only from the user mode now */
643-
csr_write(CSR_SCOUNTEREN, 0x2);
642+
/*
643+
* Enable the access for CYCLE, TIME, and INSTRET CSRs from userspace,
644+
* as is necessary to maintain uABI compatibility.
645+
*/
646+
csr_write(CSR_SCOUNTEREN, 0x7);
644647

645648
/* Stop all the counters so that they can be enabled from perf */
646649
pmu_sbi_stop_all(pmu);

0 commit comments

Comments
 (0)