Commit b2473a35 authored by Usama Arif's avatar Usama Arif Committed by Rob Herring (Arm)
Browse files

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: default avatarBreno Leitao <leitao@debian.org>
Suggested-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarUsama Arif <usamaarif642@gmail.com>
Fixes: ac10be5c ("arm64: Use common of_kexec_alloc_and_setup_fdt()")
Link: https://lore.kernel.org/r/20241023171426.452688-1-usamaarif642@gmail.com


Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
parent f9759e2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt)
	const struct machine_desc *mdesc;
	unsigned long dt_root;

	if (!early_init_dt_scan(dt))
	if (!early_init_dt_scan(dt, __pa(dt)))
		return NULL;

	mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt_virt)

	mdesc_best = &__mach_desc_GENERIC_DT;

	if (!dt_virt || !early_init_dt_verify(dt_virt))
	if (!dt_virt || !early_init_dt_verify(dt_virt, __pa(dt_virt)))
		return NULL;

	mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach);
+5 −1
Original line number Diff line number Diff line
@@ -175,7 +175,11 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
	if (dt_virt)
		memblock_reserve(dt_phys, size);

	if (!dt_virt || !early_init_dt_scan(dt_virt)) {
	/*
	 * dt_virt is a fixmap address, hence __pa(dt_virt) can't be used.
	 * Pass dt_phys directly.
	 */
	if (!early_init_dt_scan(dt_virt, dt_phys)) {
		pr_crit("\n"
			"Error: invalid device tree blob at physical address %pa (virtual address 0x%px)\n"
			"The dtb must be 8-byte aligned and must not exceed 2 MB in size\n"
+2 −2
Original line number Diff line number Diff line
@@ -112,9 +112,9 @@ asmlinkage __visible void __init csky_start(unsigned int unused,
	pre_trap_init();

	if (dtb_start == NULL)
		early_init_dt_scan(__dtb_start);
		early_init_dt_scan(__dtb_start, __pa(dtb_start));
	else
		early_init_dt_scan(dtb_start);
		early_init_dt_scan(dtb_start, __pa(dtb_start));

	start_kernel();

+1 −1
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ static void __init fdt_setup(void)
	if (!fdt_pointer || fdt_check_header(fdt_pointer))
		return;

	early_init_dt_scan(fdt_pointer);
	early_init_dt_scan(fdt_pointer, __pa(fdt_pointer));
	early_init_fdt_reserve_self();

	max_low_pfn = PFN_PHYS(memblock_end_of_DRAM());
Loading