summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiang W <wxjstz@126.com>2021-11-08 12:43:03 +0300
committerAnup Patel <anup@brainfault.org>2021-11-12 09:49:00 +0300
commitd335a178d8cfdf2ed13af70fe385f7e38162e171 (patch)
tree4b4e98c302251875500b14e4ee314dd0e87d0274
parentf3744967c6b595c0caba164468b4b32b9c027dfd (diff)
downloadopensbi-d335a178d8cfdf2ed13af70fe385f7e38162e171.tar.xz
lib: sbi: clear pmpcfg.A before setting in pmp_set()
We should clear A bits in prot variable before enabling A_NA4 or A_NAPOT. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
-rw-r--r--lib/sbi/riscv_asm.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c
index 25b40cf..1642ac6 100644
--- a/lib/sbi/riscv_asm.c
+++ b/lib/sbi/riscv_asm.c
@@ -268,6 +268,7 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
return SBI_ENOTSUPP;
/* encode PMP config */
+ prot &= ~PMP_A;
prot |= (log2len == PMP_SHIFT) ? PMP_A_NA4 : PMP_A_NAPOT;
cfgmask = ~(0xffUL << pmpcfg_shift);
pmpcfg = (csr_read_num(pmpcfg_csr) & cfgmask);