[MIPS P8700 v6 6/7] Convey MMIO flag as specified by SBI_DOMAIN_MEMREGION_MMIO
Chao-ying Fu
icebergfu at gmail.com
Thu May 22 14:21:39 PDT 2025
From: Vladimir Kondratiev <vladimir.kondratiev at mobileye.com>
Introduce non-architecture bit PMP_MMIO for this new flag, have it
out of valid bit mask for the PMPCFG register to avoid side effects
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev at mobileye.com>
---
include/sbi/riscv_asm.h | 2 ++
lib/sbi/sbi_hart.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/sbi/riscv_asm.h b/include/sbi/riscv_asm.h
index ef48dc8..1bb2be7 100644
--- a/include/sbi/riscv_asm.h
+++ b/include/sbi/riscv_asm.h
@@ -215,6 +215,8 @@ int pmp_disable(unsigned int n);
/* Check if the matching field is set */
int is_pmp_entry_mapped(unsigned long entry);
+#define PMP_MMIO _UL(0x100)
+
int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
unsigned long log2len);
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 74ccdd8..49aaa49 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -361,6 +361,13 @@ static unsigned int sbi_hart_get_smepmp_flags(struct sbi_scratch *scratch,
pmp_flags |= PMP_X;
}
+ /*
+ * indicate whether it is MMIO, to be evaluated by code,
+ * out of pmpcfg mask
+ */
+ if (reg->flags & SBI_DOMAIN_MEMREGION_MMIO)
+ pmp_flags |= PMP_MMIO;
+
return pmp_flags;
}
@@ -489,6 +496,12 @@ static int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch,
pmp_flags |= PMP_W;
if (reg->flags & SBI_DOMAIN_MEMREGION_SU_EXECUTABLE)
pmp_flags |= PMP_X;
+ /*
+ * indicate whether it is MMIO, to be evaluated by code,
+ * out of pmpcfg mask
+ */
+ if (reg->flags & SBI_DOMAIN_MEMREGION_MMIO)
+ pmp_flags |= PMP_MMIO;
pmp_addr = reg->base >> PMP_SHIFT;
if (pmp_log2gran <= reg->order && pmp_addr < pmp_addr_max) {
--
2.47.1
More information about the opensbi
mailing list