Skip to content

Commit 921d701

Browse files
tklauserLey Foon Tan
authored andcommitted
nios2: reserve boot memory for device tree
Make sure to reserve the boot memory for the flattened device tree. Otherwise it might get overwritten, e.g. when initial_boot_params is copied, leading to a corrupted FDT and a boot hang/crash: bootconsole [early0] enabled Early console on uart16650 initialized at 0xf8001600 OF: fdt: Error -11 processing FDT Kernel panic - not syncing: setup_cpuinfo: No CPU found in devicetree! ---[ end Kernel panic - not syncing: setup_cpuinfo: No CPU found in devicetree! Guenter Roeck says: > I think I found the problem. In unflatten_and_copy_device_tree(), with added > debug information: > > OF: fdt: initial_boot_params=c861e400, dt=c861f000 size=28874 (0x70ca) > > ... and then initial_boot_params is copied to dt, which results in corrupted > fdt since the memory overlaps. Looks like the initial_boot_params memory > is not reserved and (re-)allocated by early_init_dt_alloc_memory_arch(). Cc: [email protected] Reported-by: Guenter Roeck <[email protected]> Reference: http://lkml.kernel.org/r/[email protected] Tested-by: Guenter Roeck <[email protected]> Signed-off-by: Tobias Klauser <[email protected]> Acked-by: Ley Foon Tan <[email protected]>
1 parent a71c9a1 commit 921d701

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arch/nios2/kernel/prom.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
4848
return alloc_bootmem_align(size, align);
4949
}
5050

51+
int __init early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size,
52+
bool nomap)
53+
{
54+
reserve_bootmem(base, size, BOOTMEM_DEFAULT);
55+
return 0;
56+
}
57+
5158
void __init early_init_devtree(void *params)
5259
{
5360
__be32 *dtb = (u32 *)__dtb_start;

arch/nios2/kernel/setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ void __init setup_arch(char **cmdline_p)
201201
}
202202
#endif /* CONFIG_BLK_DEV_INITRD */
203203

204+
early_init_fdt_reserve_self();
205+
early_init_fdt_scan_reserved_mem();
206+
204207
unflatten_and_copy_device_tree();
205208

206209
setup_cpuinfo();

0 commit comments

Comments
 (0)