Fix Random Kernel panic from when fail to reserve memory
Subsystems (3)
v3 cover Fix Random Kernel panic from when fail to reserve memory
I am trying to fix an issue where the kernel panics randomly on my Vim3 board. The problem happens when the ARM Trusted Firmware memory is not removed from the available ram.
This happens because my u-boot provides /memreserve/, but it doesn't flag it as nomap. And the kernel scan of /reserved-memory node can't map as nomap as the region is already reserved.
The idea now is to scan /memreserve/ after /reserved-memory node, and /memreserve/ will skip regions already reserved by /reserved-memory node.
Previous Threads:
#regzbot link: https://lore.kernel.org/linux-arm-kernel/[email protected]/#regzbot
#regzbot link: https://lore.kernel.org/all/CAJX_Q+1Tjc+-TjZ6JW9X0NxEdFe=82a9626yL63j7uVD4LpxEA@mail.gmail.com/
V1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
Change from V2:
- Remove region overlap and reserved checks
Change from V1:
- Instead of allowing to mark nomap a region already reserved, give
precedence to /reserved-memory node scan.
Lucas Tanure (1):
of: fdt: Scan /memreserve/ last
drivers/of/fdt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.40.0
PATCH v3 1/1 of: fdt: Scan /memreserve/ last
Change the order of scanning /memreserve/ and /reserved-memory node. /reserved-memory node should go first, as it has a more updated description of the memory regions and it can apply flags, like nomap. Also, /memreserve/ should avoid reserving regions described in /reserved-memory node.
--- drivers/of/fdt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/of/fdt.c +3 -2
@@ -635,6 +635,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);
@@ -643,8 +646,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 (); }
Signature · 1 line
2.40.0
Re: [PATCH v3 1/1] of: fdt: Scan /memreserve/ last
Quoted 6 lines · Lucas Tanure
Change the order of scanning /memreserve/ and /reserved-memory node. /reserved-memory node should go first, as it has a more updated description of the memory regions and it can apply flags, like nomap. Also, /memreserve/ should avoid reserving regions described in /reserved-memory node.
Please give some background details why we need to make this change. As-is, sounds like some theoretical issue. IOW, incorporate some of the details in the cover letter here. For single patches, you don't need a cover letter anyways.
Powerpc folks, please comment and/or test. I worry there could be some subtle differences with this change.
Quoted 32 lines
Signed-off-by Lucas Tanure <[email protected]>--- drivers/of/fdt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/of/fdt.c +3
-3@@ -635,6 +635,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);@@ -643,8 +646,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 (); } --2.40.0