aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorAlexandre Ghiti <alexghiti@rivosinc.com>2023-06-14 10:20:39 +0200
committerAnup Patel <anup@brainfault.org>2023-06-15 18:27:17 +0530
commit8153b2622b08802cc542f30a1fcba407a5667ab9 (patch)
tree8f9934cf456d14a691e2c242b3d968500c8f9059 /platform
parent932be2cde1b0f38c676bddaf801fa1030f9e9065 (diff)
downloadopensbi-8153b2622b08802cc542f30a1fcba407a5667ab9.zip
opensbi-8153b2622b08802cc542f30a1fcba407a5667ab9.tar.gz
opensbi-8153b2622b08802cc542f30a1fcba407a5667ab9.tar.bz2
platform/lib: Set no-map attribute on all PMP regions
This reverts commit 6966ad0abe70 ("platform/lib: Allow the OS to map the regions that are protected by PMP"). It was thought at the time of this commit that allowing the kernel to map PMP protected regions was safe but it is actually not: for example, the hibernation process will try to access any linear mapping page and then will fault on such mapped PMP regions [1]. Another issue is that the device tree specification [2] states that a !no-map region must be declared as EfiBootServicesData/Code in the EFI memory map which would make the PMP protected regions reclaimable by the kernel. And to circumvent this, RISC-V edk2 diverges from the DT specification to declare those regions as EfiReserved. The no-map attribute was removed to allow the kernel to use hugepages larger than 2MB to map the linear mapping to improve the performance but actually a recent talk from Mike Rapoport [3] stated that the performance benefit was marginal. For all those reasons, let's mark all the PMP protected regions as "no-map". [1] https://lore.kernel.org/linux-riscv/CAAYs2=gQvkhTeioMmqRDVGjdtNF_vhB+vm_1dHJxPNi75YDQ_Q@mail.gmail.com/ [2] "3.5.4 /reserved-memory and UEFI" https://github.com/devicetree-org/devicetree-specification/releases/download/v0.4-rc1/devicetree-specification-v0.4-rc1.pdf [3] https://lwn.net/Articles/931406/ Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/generic/sifive/fu540.c13
1 files changed, 0 insertions, 13 deletions
diff --git a/platform/generic/sifive/fu540.c b/platform/generic/sifive/fu540.c
index 08f7bfc..b980f44 100644
--- a/platform/generic/sifive/fu540.c
+++ b/platform/generic/sifive/fu540.c
@@ -20,18 +20,6 @@ static u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match)
return 0;
}
-static int sifive_fu540_fdt_fixup(void *fdt, const struct fdt_match *match)
-{
- /*
- * SiFive Freedom U540 has an erratum that prevents S-mode software
- * to access a PMP protected region using 1GB page table mapping, so
- * always add the no-map attribute on this platform.
- */
- fdt_reserved_memory_nomap_fixup(fdt);
-
- return 0;
-}
-
static const struct fdt_match sifive_fu540_match[] = {
{ .compatible = "sifive,fu540" },
{ .compatible = "sifive,fu540g" },
@@ -43,5 +31,4 @@ static const struct fdt_match sifive_fu540_match[] = {
const struct platform_override sifive_fu540 = {
.match_table = sifive_fu540_match,
.tlbr_flush_limit = sifive_fu540_tlbr_flush_limit,
- .fdt_fixup = sifive_fu540_fdt_fixup,
};