aboutsummaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_hart.c
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2023-12-12 15:19:11 +0530
committerAnup Patel <anup@brainfault.org>2023-12-19 15:56:37 +0530
commit2b80b92f028aa3726c6488eaaefddbdec43c5b54 (patch)
treea25d4ede29df67f05a8a95e9d2ef7592f67ad156 /lib/sbi/sbi_hart.c
parent5a57e8cd41f3c8754a5f0e511a63072724c1f0b7 (diff)
downloadopensbi-2b80b92f028aa3726c6488eaaefddbdec43c5b54.zip
opensbi-2b80b92f028aa3726c6488eaaefddbdec43c5b54.tar.gz
opensbi-2b80b92f028aa3726c6488eaaefddbdec43c5b54.tar.bz2
lib: sbi: Do not enter OpenSBI with mseccfg.MML == 1
On platforms with Smepmp, the previous booting stage must enter OpenSBI with mseccfg.MML == 0. This allows OpenSBI to configure it's own M-mode only regions without depending on the previous booting stage. Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Diffstat (limited to 'lib/sbi/sbi_hart.c')
-rw-r--r--lib/sbi/sbi_hart.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 46cd55d..e2b93e6 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -914,6 +914,16 @@ __pmp_skip:
/* Mark hart feature detection done */
hfeatures->detected = true;
+ /*
+ * On platforms with Smepmp, the previous booting stage must
+ * enter OpenSBI with mseccfg.MML == 0. This allows OpenSBI
+ * to configure it's own M-mode only regions without depending
+ * on the previous booting stage.
+ */
+ if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMEPMP) &&
+ (csr_read(CSR_MSECCFG) & MSECCFG_MML))
+ return SBI_EILL;
+
return 0;
}