lib: sbi: Do not enter OpenSBI with mseccfg.MML == 1
authorAnup Patel <apatel@ventanamicro.com>
Tue, 12 Dec 2023 09:49:11 +0000 (15:19 +0530)
committerAnup Patel <anup@brainfault.org>
Tue, 19 Dec 2023 10:26:37 +0000 (15:56 +0530)
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>
lib/sbi/sbi_hart.c

index 46cd55d063cf8d4ee9c7882904ece4e54f8f935b..e2b93e6b134921c4a0db8c8d447adb644f73a5b8 100644 (file)
@@ -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;
 }