[PATCH v8 12/22] RISC-V: perf: Modify the counter discovery mechanism
Charlie Jenkins
thecharlesjenkins at gmail.com
Mon Jul 20 00:21:59 PDT 2026
On Wed, 01 Jul 2026 01:47:00 -0700, Atish Patra <atish.patra at linux.dev> wrote:
> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c
> index 74d934238821..c20f1e33c65d 100644
> --- a/drivers/perf/riscv_pmu_sbi.c
> +++ b/drivers/perf/riscv_pmu_sbi.c
> @@ -1599,13 +1658,23 @@ static int __init rvpmu_devinit(void)
> [ ... skip 15 lines ... ]
> + * in S-mode via Supervisor Counter delegation.
> + */
> + if (riscv_isa_extension_available(NULL, SSCCFG) &&
> + riscv_isa_extension_available(NULL, SMCDELEG) &&
> + riscv_isa_extension_available(NULL, SSCSRIND))
> + static_branch_enable(&riscv_pmu_cdeleg_available);
This needs to not only check that smcdeleg is supported in linux, but
also that it is supported in the SBI implementation correct? Trying to
boot this on OpenSBI before 6bb6b61c27eb ("lib: sbi: Add support for smcsrind and
smcdeleg") will fail on an illegal instruction in
rvpmu_deleg_find_ctrs() while trying to access the scountinhibit csr in
the patch "RISC-V: perf: Implement supervisor counter delegation
support". The proper mstateen bits need to be set for this to work
without crashing.
--
- Charlie
More information about the linux-riscv
mailing list