mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-11-22 19:01:33 +00:00
lib: sbi_domain: allow specifying inaccessible region
According to the RISC‑V Privileged Specification, SmePMP regions that grant no access in any privilege mode are valid. Allow such regions to be specified. Signed-off-by: Yu-Chien Peter Lin <peter.lin@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20251008084444.3525615-3-peter.lin@sifive.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
committed by
Anup Patel
parent
32c1d38dcf
commit
667eed2266
@@ -126,7 +126,17 @@ unsigned int sbi_domain_get_smepmp_flags(struct sbi_domain_memregion *reg)
|
||||
{
|
||||
unsigned int pmp_flags = 0;
|
||||
|
||||
if (SBI_DOMAIN_MEMREGION_IS_SHARED(reg->flags)) {
|
||||
if ((reg->flags & SBI_DOMAIN_MEMREGION_ACCESS_MASK) == 0) {
|
||||
/*
|
||||
* Region is inaccessible in all privilege modes.
|
||||
*
|
||||
* SmePMP allows two encodings for an inaccessible region:
|
||||
* - pmpcfg.LRWX = 0000 (Inaccessible region)
|
||||
* - pmpcfg.LRWX = 1000 (Locked inaccessible region)
|
||||
* We use the first encoding here.
|
||||
*/
|
||||
return 0;
|
||||
} else if (SBI_DOMAIN_MEMREGION_IS_SHARED(reg->flags)) {
|
||||
/* Read only for both M and SU modes */
|
||||
if (SBI_DOMAIN_MEMREGION_IS_SUR_MR(reg->flags))
|
||||
pmp_flags = (PMP_L | PMP_R | PMP_W | PMP_X);
|
||||
|
||||
Reference in New Issue
Block a user