summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimanshu Chauhan <[email protected]>2023-07-12 10:04:34 +0530
committerAnup Patel <[email protected]>2023-07-13 12:42:06 +0530
commitf3fdd041acf5bfb9c261c1e8a909e9b0d78c03e8 (patch)
tree6e13e00ecd479d88f760dd88db22c70b02ba38e9
parent4a42a2347c757457f455d9293812a32a7552e4d5 (diff)
lib: sbi: Change the order of PMP initialization
Configure PMP at last when all other initializations have been done. Because if SMEPMP is detected, M-mode access to the S/U space will be rescinded. Signed-off-by: Himanshu Chauhan <[email protected]> Reviewed-by: Anup Patel <[email protected]>
-rw-r--r--lib/sbi/sbi_init.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index 423e6d83..35e66333 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -356,13 +356,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
sbi_hart_hang();
}
- rc = sbi_hart_pmp_configure(scratch);
- if (rc) {
- sbi_printf("%s: PMP configure failed (error %d)\n",
- __func__, rc);
- sbi_hart_hang();
- }
-
/*
* Note: Platform final initialization should be after finalizing
* domains so that it sees correct domain assignment and PMP
@@ -392,6 +385,17 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
sbi_boot_print_hart(scratch, hartid);
+ /*
+ * Configure PMP at last because if SMEPMP is detected,
+ * M-mode access to the S/U space will be rescinded.
+ */
+ rc = sbi_hart_pmp_configure(scratch);
+ if (rc) {
+ sbi_printf("%s: PMP configure failed (error %d)\n",
+ __func__, rc);
+ sbi_hart_hang();
+ }
+
wake_coldboot_harts(scratch, hartid);
count = sbi_scratch_offset_ptr(scratch, init_count_offset);
@@ -445,11 +449,15 @@ static void __noreturn init_warm_startup(struct sbi_scratch *scratch,
if (rc)
sbi_hart_hang();
- rc = sbi_hart_pmp_configure(scratch);
+ rc = sbi_platform_final_init(plat, false);
if (rc)
sbi_hart_hang();
- rc = sbi_platform_final_init(plat, false);
+ /*
+ * Configure PMP at last because if SMEPMP is detected,
+ * M-mode access to the S/U space will be rescinded.
+ */
+ rc = sbi_hart_pmp_configure(scratch);
if (rc)
sbi_hart_hang();