Skip to content

Commit 498d812

Browse files
uarif1smb49
authored andcommitted
of/fdt: add dt_phys arg to early_init_dt_scan and early_init_dt_verify
BugLink: https://bugs.launchpad.net/bugs/2101915 [ Upstream commit b2473a3 ] __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 <leitao@debian.org> Suggested-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Usama Arif <usamaarif642@gmail.com> Fixes: ac10be5 ("arm64: Use common of_kexec_alloc_and_setup_fdt()") Link: https://lore.kernel.org/r/20241023171426.452688-1-usamaarif642@gmail.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8338a6b commit 498d812

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
@@ -190,7 +190,11 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
190190
if (dt_virt)
191191
memblock_reserve(dt_phys, size);
192192

193-
if (!dt_virt || !early_init_dt_scan(dt_virt)) {
193+
/*
194+
* dt_virt is a fixmap address, hence __pa(dt_virt) can't be used.
195+
* Pass dt_phys directly.
196+
*/
197+
if (!early_init_dt_scan(dt_virt, dt_phys)) {
194198
pr_crit("\n"
195199
"Error: invalid device tree blob at physical address %pa (virtual address 0x%px)\n"
196200
"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
@@ -26,12 +26,12 @@ void __init early_init_devtree(void *params)
2626
if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) ==
2727
OF_DT_HEADER) {
2828
params = (void *)CONFIG_NIOS2_DTB_PHYS_ADDR;
29-
early_init_dt_scan(params);
29+
early_init_dt_scan(params, __pa(params));
3030
return;
3131
}
3232
#endif
3333
if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
3434
params = (void *)__dtb_start;
3535

36-
early_init_dt_scan(params);
36+
early_init_dt_scan(params, __pa(params));
3737
}

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)