summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2024-02-21 01:45:15 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2024-02-21 01:45:15 +0000
commitbcc7411de0047b5f954382d00b08fef672213b67 (patch)
tree684ebbd862f570796d7cb0877c7cf28f34348cbd /sys
parent1f82e911222a55625af78a7f8816e767f33f106a (diff)
handle /reserved-memory nodes from device trees on arm64.
u-boot is supposed to take these entries and put them in the efi memory map, but i keep hitting machines where an otherwise functional u-boot does not do this, resulting in weird errors. i have an espressobin with a vendor u-boot that has a reserved-memory region for psci. without this diff the machine faults when the kernel tries to reboot using a psci handler. a macchiatobin with an otherwise working u-boot throws SErrors or panics on weird memory corruption problems without this. i thought it was bad RAM, but the problems persisted with completely different ram, and very underclocked and well cooled ram. riscv64 already has code to handle reserved-memory regions. the riscv64 change is to add handling for the "no-map" property. ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arm64/arm64/machdep.c18
-rw-r--r--sys/arch/riscv64/riscv64/machdep.c5
2 files changed, 21 insertions, 2 deletions
diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c
index 69dc76ae9d2..fc1df710f67 100644
--- a/sys/arch/arm64/arm64/machdep.c
+++ b/sys/arch/arm64/arm64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.85 2023/12/04 15:00:09 claudio Exp $ */
+/* $OpenBSD: machdep.c,v 1.86 2024/02/21 01:45:14 dlg Exp $ */
/*
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
@@ -1053,6 +1053,22 @@ initarm(struct arm64_bootparams *abp)
}
}
+ /* Remove reserved memory. */
+ node = fdt_find_node("/reserved-memory");
+ if (node) {
+ for (node = fdt_child_node(node); node;
+ node = fdt_next_node(node)) {
+ char *no_map;
+ if (fdt_node_property(node, "no-map", &no_map) < 0)
+ continue;
+ if (fdt_get_reg(node, 0, &reg))
+ continue;
+ if (reg.size == 0)
+ continue;
+ memreg_remove(&reg);
+ }
+ }
+
/* Remove the initial 64MB block. */
reg.addr = memstart;
reg.size = memend - memstart;
diff --git a/sys/arch/riscv64/riscv64/machdep.c b/sys/arch/riscv64/riscv64/machdep.c
index 7658ba0df54..1141cd27786 100644
--- a/sys/arch/riscv64/riscv64/machdep.c
+++ b/sys/arch/riscv64/riscv64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.34 2024/01/23 19:51:10 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.35 2024/02/21 01:45:14 dlg Exp $ */
/*
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
@@ -792,6 +792,9 @@ initriscv(struct riscv_bootparams *rbp)
if (node) {
for (node = fdt_child_node(node); node;
node = fdt_next_node(node)) {
+ char *no_map;
+ if (fdt_node_property(node, "no-map", &no_map) < 0)
+ continue;
if (fdt_get_reg(node, 0, &reg))
continue;
if (reg.size == 0)