lib: sbi: use unsigned masks for HPM counter 31

The HPM feature detector and CSR emulator build mhpm_mask bits with a
plain signed 1. Both macro families expand through counter 31, so the
last expansion evaluates 1 << 31 and shifts a signed int into its sign
bit.

Use BIT() at both sites. The mask is unsigned and bit 31 is part of the
represented HPM counter set.

Fixes: c744ed77b1 ("lib: sbi_pmu: Enable noncontigous hpm event and counters")
Fixes: ee1f83ca84 ("lib: sbi_pmu: remove mhpm_count field in hart feature")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260828142354.13035-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Pengpeng Hou authored and Anup Patel committed 2026-10-23 12:59:53 +05:30
1 parent 10b5ac7222
commit 9dcd9f9365
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -512,7 +512,7 @@ static int hart_detect_features(struct sbi_scratch *scratch, bool cold_boot)
if (!trap.cause) { \
csr_write_allowed(__csr, &trap, 1UL); \
if (!trap.cause && csr_swap(__csr, oldval) == 1UL) { \
(hfeatures->__mask) |= 1 << (__csr - CSR_MCYCLE); \
(hfeatures->__mask) |= BIT(__csr - CSR_MCYCLE); \
} \
}