diff options
author | Himanshu Chauhan <hchauhan@ventanamicro.com> | 2023-01-09 08:20:38 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2023-01-09 15:34:17 +0300 |
commit | 1ac14f10f6f27f1078d684b7931718db0e6822c4 (patch) | |
tree | d34b8924fc463ff8ed477ceb7a87448506c28580 | |
parent | 22dbdb3d60c64975d7e5704a6bd64f7b73bee157 (diff) | |
download | opensbi-1ac14f10f6f27f1078d684b7931718db0e6822c4.tar.xz |
lib: sbi: Use finer permission sematics to decide on PMP bits
Use the fine grained permission bits to decide if the region
permissions are to be enforced on all modes. Also use the new
permission bits for deciding on R/W/X bits in pmpcfg register.
Signed-off-by: Himanshu Chauhan <hchauhan@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Anup Patel <anup@brainfault.org>
-rw-r--r-- | lib/sbi/sbi_hart.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 5447c52..02ce991 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -303,14 +303,20 @@ int sbi_hart_pmp_configure(struct sbi_scratch *scratch) break; pmp_flags = 0; - if (reg->flags & SBI_DOMAIN_MEMREGION_READABLE) + + /* + * If permissions are to be enforced for all modes on this + * region, the lock bit should be set. + */ + if (reg->flags & SBI_DOMAIN_MEMREGION_ENF_PERMISSIONS) + pmp_flags |= PMP_L; + + if (reg->flags & SBI_DOMAIN_MEMREGION_SU_READABLE) pmp_flags |= PMP_R; - if (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE) + if (reg->flags & SBI_DOMAIN_MEMREGION_SU_WRITABLE) pmp_flags |= PMP_W; - if (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE) + if (reg->flags & SBI_DOMAIN_MEMREGION_SU_EXECUTABLE) pmp_flags |= PMP_X; - if (reg->flags & SBI_DOMAIN_MEMREGION_MMODE) - pmp_flags |= PMP_L; pmp_addr = reg->base >> PMP_SHIFT; if (pmp_gran_log2 <= reg->order && pmp_addr < pmp_addr_max) |