Skip to content

Commit b413281

Browse files
lucastanurerobherring
authored andcommitted
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. Link: https://lore.kernel.org/all/CAJX_Q+1Tjc+-TjZ6JW9X0NxEdFe=82a9626yL63j7uVD4LpxEA@mail.gmail.com/ Signed-off-by: Lucas Tanure <tanure@linux.com> Link: https://lore.kernel.org/r/20230424113846.46382-1-tanure@linux.com Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 6e0c2bf commit b413281

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/of/fdt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ void __init early_init_fdt_scan_reserved_mem(void)
635635
if (!initial_boot_params)
636636
return;
637637

638+
fdt_scan_reserved_mem();
639+
fdt_reserve_elfcorehdr();
640+
638641
/* Process header /memreserve/ fields */
639642
for (n = 0; ; n++) {
640643
fdt_get_mem_rsv(initial_boot_params, n, &base, &size);
@@ -643,8 +646,6 @@ void __init early_init_fdt_scan_reserved_mem(void)
643646
memblock_reserve(base, size);
644647
}
645648

646-
fdt_scan_reserved_mem();
647-
fdt_reserve_elfcorehdr();
648649
fdt_init_reserved_mem();
649650
}
650651

0 commit comments

Comments
 (0)