mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 02:21:38 +00:00
SKIP_MATCH selects the first counter in the caller-provided set, but the
current path checks only that the index exists and is active. A supervisor
can select an active hardware counter for a firmware event. CLEAR_VALUE or
AUTO_START then indexes firmware-counter state with
ctr_idx - num_hw_ctrs, which underflows. The inverse mismatch sends a
firmware-counter index to hardware-counter operations.
Reject the selected counter when its hardware/firmware class cannot monitor
the requested event. Return SBI_ENOTSUPP, matching the PMU specification's
case where the selected counter cannot monitor that event.
Fixes: 13d40f21d5 ("lib: sbi: Add PMU support")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Tested-by: Sebastian Alba Vives <sebasjosue84@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260827115718.50124-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>