[PATCH] arm64: Extend pr_crit message on invalid FDT

Bartosz Szczepanek posted 1 patch 7 months, 4 weeks ago
arch/arm64/kernel/setup.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
[PATCH] arm64: Extend pr_crit message on invalid FDT
Posted by Bartosz Szczepanek 7 months, 4 weeks ago
Log size in addition to physical and virtual addresses. It has potential
to be helpful when DTB exceeds the 2 MB limit.

Initialize size to 0 to print out sane value if fixmap_remap_fdt fails
without setting the size.

Signed-off-by: Bartosz Szczepanek <bsz@amazon.de>
---
 arch/arm64/kernel/setup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 85104587f849..77c7926a4df6 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -169,7 +169,7 @@ static void __init smp_build_mpidr_hash(void)
 
 static void __init setup_machine_fdt(phys_addr_t dt_phys)
 {
-	int size;
+	int size = 0;
 	void *dt_virt = fixmap_remap_fdt(dt_phys, &size, PAGE_KERNEL);
 	const char *name;
 
@@ -182,10 +182,10 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
 	 */
 	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"
-			"\nPlease check your bootloader.",
-			&dt_phys, dt_virt);
+			"Error: invalid device tree blob: PA=%pa, VA=%px, size=%d bytes\n"
+			"The dtb must be 8-byte aligned and must not exceed 2 MB in size.\n"
+			"\nPlease check your bootloader.\n",
+			&dt_phys, dt_virt, size);
 
 		/*
 		 * Note that in this _really_ early stage we cannot even BUG()
-- 
2.47.1
Re: [PATCH] arm64: Extend pr_crit message on invalid FDT
Posted by Will Deacon 7 months, 3 weeks ago
On Wed, 23 Apr 2025 08:48:51 +0000, Bartosz Szczepanek wrote:
> Log size in addition to physical and virtual addresses. It has potential
> to be helpful when DTB exceeds the 2 MB limit.
> 
> Initialize size to 0 to print out sane value if fixmap_remap_fdt fails
> without setting the size.
> 
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: Extend pr_crit message on invalid FDT
      https://git.kernel.org/arm64/c/83a39eccdf2f

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev