[RFC PATCH v5 4/4] lib: sbi: Initialize SMMPT during coldboot
Rahul Pathak
rahul.pathak at oss.qualcomm.com
Thu Sep 17 20:09:53 PDT 2026
Call sbi_mpt_init() function from coldboot path of
sbi_hart_init() to initialize the SMMPT core. It will
create and the MPT tables for each SBI domain and maps
its memregions with appropriate permissions in MPT tables.
Also each MPT table requires to memory to install tables
so reserve more space in heap for MPT tables
Signed-off-by: Rahul Pathak <rahul.pathak at oss.qualcomm.com>
---
lib/sbi/sbi_hart.c | 6 ++++++
platform/generic/platform.c | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 4261fea8..f95ee5d1 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -16,6 +16,7 @@
#include <sbi/sbi_csr_detect.h>
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
+#include <sbi/sbi_hart_mpt.h>
#include <sbi/sbi_hart_pmp.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_pmu.h>
@@ -731,6 +732,11 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)
rc = sbi_hart_pmp_init(scratch);
if (rc)
return rc;
+
+ /* Smmpt is optional. Continue if the Smmpt is not present. */
+ rc = sbi_mpt_init();
+ if (rc && rc != SBI_ENODEV)
+ return rc;
}
return sbi_hart_reinit(scratch);
diff --git a/platform/generic/platform.c b/platform/generic/platform.c
index 1df0280d..b9f5bb2a 100644
--- a/platform/generic/platform.c
+++ b/platform/generic/platform.c
@@ -30,6 +30,8 @@
#include <sbi_utils/serial/semihosting.h>
#include <sbi_utils/timer/fdt_timer.h>
+#define SBI_PLATFORM_MPT_HEAP 1048576 /* 1 MiB */
+
/* List of platform override modules generated at compile time */
extern const struct fdt_driver *const platform_override_modules[];
@@ -42,6 +44,15 @@ static u32 fw_platform_calculate_heap_size(u32 hart_count)
/* For TLB fifo */
heap_size += SBI_TLB_INFO_SIZE * (hart_count) * (hart_count);
+ /*
+ * MPT table budget
+ * 1 MiB memory for MPT allocated currently.
+ *
+ * TODO: Need better way to get the memory budget based on active
+ * SMMPT mode.
+ */
+ heap_size += SBI_PLATFORM_MPT_HEAP;
+
return BIT_ALIGN(heap_size, HEAP_BASE_ALIGN);
}
--
2.53.0
More information about the opensbi
mailing list