build/patch/kernel/archive/meson64-6.2/general-of-fdt-Scan-memreserve-last.patch

49 lines
1.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lucas Tanure <tanure@linux.com>
Date: Wed, 12 Apr 2023 18:46:20 -0400
Subject: FROMLIST(v4): of: fdt: Scan /memreserve/ last
Change the scanning /memreserve/ and /reserved-memory node order to fix
Kernel panic on Khadas Vim3 Board.
If /memreserve/ goes first, the memory is reserved, but nomap can't be
applied to the region. So the memory won't be used by Linux, but it is
still present in the linear map as normal memory, which allows
speculation. Legitimate access to adjacent pages will cause the CPU
to end up prefetching into them leading to Kernel panic.
So /reserved-memory node should go first, as it has a more updated
description of the memory regions and can apply flags, like nomap.
Signed-off-by: Lucas Tanure <tanure@linux.com>
---
drivers/of/fdt.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 81508e8b34d2..0252a7189d99 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -626,6 +626,9 @@ void __init early_init_fdt_scan_reserved_mem(void)
if (!initial_boot_params)
return;
+ fdt_scan_reserved_mem();
+ fdt_reserve_elfcorehdr();
+
/* Process header /memreserve/ fields */
for (n = 0; ; n++) {
fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
@@ -634,8 +637,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
memblock_reserve(base, size);
}
- fdt_scan_reserved_mem();
- fdt_reserve_elfcorehdr();
fdt_init_reserved_mem();
}
--
Armbian