Skip to content

Commit b2473a3

Browse files
uarif1robherring
authored andcommitted
of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify
__pa() is only intended to be used for linear map addresses and using it for initial_boot_params which is in fixmap for arm64 will give an incorrect value. Hence save the physical address when it is known at boot time when calling early_init_dt_scan for arm64 and use it at kexec time instead of converting the virtual address using __pa(). Note that arm64 doesn't need the FDT region reserved in the DT as the kernel explicitly reserves the passed in FDT. Therefore, only a debug warning is fixed with this change. Reported-by: Breno Leitao <[email protected]> Suggested-by: Mark Rutland <[email protected]> Signed-off-by: Usama Arif <[email protected]> Fixes: ac10be5 ("arm64: Use common of_kexec_alloc_and_setup_fdt()") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Herring (Arm) <[email protected]>
1 parent f9759e2 commit b2473a3

File tree

21 files changed

+36
-29
lines changed

21 files changed

+36
-29
lines changed

arch/arc/kernel/devtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt)
6262
const struct machine_desc *mdesc;
6363
unsigned long dt_root;
6464

65-
if (!early_init_dt_scan(dt))
65+
if (!early_init_dt_scan(dt, __pa(dt)))
6666
return NULL;
6767

6868
mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);

arch/arm/kernel/devtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt_virt)
200200

201201
mdesc_best = &__mach_desc_GENERIC_DT;
202202

203-
if (!dt_virt || !early_init_dt_verify(dt_virt))
203+
if (!dt_virt || !early_init_dt_verify(dt_virt, __pa(dt_virt)))
204204
return NULL;
205205

206206
mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);

arch/arm64/kernel/setup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
175175
if (dt_virt)
176176
memblock_reserve(dt_phys, size);
177177

178-
if (!dt_virt || !early_init_dt_scan(dt_virt)) {
178+
/*
179+
* dt_virt is a fixmap address, hence __pa(dt_virt) can't be used.
180+
* Pass dt_phys directly.
181+
*/
182+
if (!early_init_dt_scan(dt_virt, dt_phys)) {
179183
pr_crit("\n"
180184
"Error: invalid device tree blob at physical address %pa (virtual address 0x%px)\n"
181185
"The dtb must be 8-byte aligned and must not exceed 2 MB in size\n"

arch/csky/kernel/setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ asmlinkage __visible void __init csky_start(unsigned int unused,
112112
pre_trap_init();
113113

114114
if (dtb_start == NULL)
115-
early_init_dt_scan(__dtb_start);
115+
early_init_dt_scan(__dtb_start, __pa(dtb_start));
116116
else
117-
early_init_dt_scan(dtb_start);
117+
early_init_dt_scan(dtb_start, __pa(dtb_start));
118118

119119
start_kernel();
120120

arch/loongarch/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void __init fdt_setup(void)
290290
if (!fdt_pointer || fdt_check_header(fdt_pointer))
291291
return;
292292

293-
early_init_dt_scan(fdt_pointer);
293+
early_init_dt_scan(fdt_pointer, __pa(fdt_pointer));
294294
early_init_fdt_reserve_self();
295295

296296
max_low_pfn = PFN_PHYS(memblock_end_of_DRAM());

arch/microblaze/kernel/prom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void __init early_init_devtree(void *params)
1818
{
1919
pr_debug(" -> early_init_devtree(%p)\n", params);
2020

21-
early_init_dt_scan(params);
21+
early_init_dt_scan(params, __pa(params));
2222
if (!strlen(boot_command_line))
2323
strscpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
2424

arch/mips/kernel/prom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ char *mips_get_machine_name(void)
4141

4242
void __init __dt_setup_arch(void *bph)
4343
{
44-
if (!early_init_dt_scan(bph))
44+
if (!early_init_dt_scan(bph, __pa(bph)))
4545
return;
4646

4747
mips_set_machine_name(of_flat_dt_get_machine_name());

arch/mips/kernel/relocate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void *__init relocate_kernel(void)
337337
#if defined(CONFIG_USE_OF)
338338
/* Deal with the device tree */
339339
fdt = plat_get_fdt();
340-
early_init_dt_scan(fdt);
340+
early_init_dt_scan(fdt, __pa(fdt));
341341
if (boot_command_line[0]) {
342342
/* Boot command line was passed in device tree */
343343
strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);

arch/nios2/kernel/prom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void __init early_init_devtree(void *params)
2727
if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) ==
2828
OF_DT_HEADER) {
2929
params = (void *)CONFIG_NIOS2_DTB_PHYS_ADDR;
30-
early_init_dt_scan(params);
30+
early_init_dt_scan(params, __pa(params));
3131
return;
3232
}
3333
#endif
@@ -37,5 +37,5 @@ void __init early_init_devtree(void *params)
3737
params = (void *)__dtb_start;
3838
#endif
3939

40-
early_init_dt_scan(params);
40+
early_init_dt_scan(params, __pa(params));
4141
}

arch/openrisc/kernel/prom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222

2323
void __init early_init_devtree(void *params)
2424
{
25-
early_init_dt_scan(params);
25+
early_init_dt_scan(params, __pa(params));
2626
memblock_allow_resize();
2727
}

0 commit comments

Comments
 (0)