perf: RISC-V: Limit the number of counters returned from SBI
authorViacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Fri, 5 May 2023 07:20:57 +0000 (07:20 +0000)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 20 Jun 2023 19:55:24 +0000 (12:55 -0700)
commitee95b88d71b9cf7ac1085ebc014f161971e1be9a
treed49f81b52150bff37bc7be32b9fcc2ce608fcbd6
parent4681dacadeefa5ca6017e00736adc1d7dc963c6a
perf: RISC-V: Limit the number of counters returned from SBI

Perf gets the number of supported counters from SBI. If it happens that
the number of returned counters more than RISCV_MAX_COUNTERS the code
trusts it. It does not lead to an immediate problem but can potentially
lead to it. Prevent getting more than RISCV_MAX_COUNTERS from SBI.

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20230505072058.1049732-1-v.v.mitrofanov@yadro.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
drivers/perf/riscv_pmu_sbi.c