mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 15:51:41 +01:00
lib: sbi: fix number of PMP entries detection
CSR_PMPADDRn lower bits may read all-0 or all-1, depending on the configuration. For TOR it is all-0, for NAPOT - all-1. Thus if PMP entry was pre-configured as NAPOT, original code would stop scanning because value read back not equal to the written one. Mask lower bits before comparison to fix this Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
62447cd7aa
commit
1a2e507d23
@@ -825,7 +825,7 @@ static int hart_detect_features(struct sbi_scratch *scratch)
|
|||||||
} else { \
|
} else { \
|
||||||
csr_write_allowed(__csr, &trap, __wrval); \
|
csr_write_allowed(__csr, &trap, __wrval); \
|
||||||
if (!trap.cause) { \
|
if (!trap.cause) { \
|
||||||
if (csr_swap(__csr, oldval) == __wrval) \
|
if ((csr_swap(__csr, oldval) & __wrval) == __wrval) \
|
||||||
(hfeatures->__field)++; \
|
(hfeatures->__field)++; \
|
||||||
else \
|
else \
|
||||||
goto __skip; \
|
goto __skip; \
|
||||||
|
Reference in New Issue
Block a user