summaryrefslogtreecommitdiff
path: root/include/sbi_utils
diff options
context:
space:
mode:
authorAlexandre Ghiti <alex@ghiti.fr>2020-06-13 09:59:13 +0300
committerAnup Patel <anup@brainfault.org>2020-06-15 06:55:44 +0300
commit6966ad0abe7077b1b5c9342f588621426d997c38 (patch)
tree2e3cc405f9c5bebff0b54621578fa04d18d52da7 /include/sbi_utils
parente2c3f01af4329aa7e9009edee13b7cfdf379071f (diff)
downloadopensbi-6966ad0abe7077b1b5c9342f588621426d997c38.tar.xz
platform/lib: Allow the OS to map the regions that are protected by PMP
This is achieved by removing the 'no-map' property from the 'reserved-memory' node when PMP is present, otherwise we keep it as it offers a small protection if the OS does not map this region at all. A new callback in platform_override is introduced and allows to fixup the device-tree. It is used here to override this new default behaviour on SiFive Fu540 platforms that has an erratum that prevents S-mode software to access a PMP protected region using 1GB page table mapping. If PMP is present, telling the OS not to map the reserved regions does not add much protection since it only avoids access to regions that are already protected by PMP. But by not allowing the OS to map those regions, it creates holes in the OS system memory map and prevents the use of hugepages which would generate, among other benefits, less TLB miss. Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'include/sbi_utils')
-rw-r--r--include/sbi_utils/fdt/fdt_fixup.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/sbi_utils/fdt/fdt_fixup.h b/include/sbi_utils/fdt/fdt_fixup.h
index 54568c2..0697a18 100644
--- a/include/sbi_utils/fdt/fdt_fixup.h
+++ b/include/sbi_utils/fdt/fdt_fixup.h
@@ -48,6 +48,20 @@ void fdt_plic_fixup(void *fdt, const char *compat);
int fdt_reserved_memory_fixup(void *fdt);
/**
+ * Fix up the reserved memory subnodes in the device tree
+ *
+ * This routine adds the no-map property to the reserved memory subnodes so
+ * that the OS does not map those PMP protected memory regions.
+ *
+ * Platform codes must call this helper in their final_init() after fdt_fixups()
+ * if the OS should not map the PMP protected reserved regions.
+ *
+ * @param fdt: device tree blob
+ * @return zero on success and -ve on failure
+ */
+int fdt_reserved_memory_nomap_fixup(void *fdt);
+
+/**
* General device tree fix-up
*
* This routine do all required device tree fix-ups for a typical platform.