[PATCH 1/2] ARM: fix wrong calculation of barebox base

Sascha Hauer s.hauer at pengutronix.de
Wed May 13 06:57:58 PDT 2026


We assumed that barebox_image_size matches the size of the uncompressed
barebox proper binary. This was true until dbbca16895, but since then
the uncompressed length of the barebox proper binary includes the ELF
header whereas barebox_image_size does not. With this it can happen
that barebox_base is calculated too high resulting in the malloc area
overlapping the barebox image. For now fix that by using the real
barebox base address from the __image_start linker variable.

Fixes: dbbca16895 ("ARM: link ELF image into PBL")
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/include/asm/barebox-arm.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 99f8231194..611b2bb2d6 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -194,11 +194,15 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 						  unsigned long uncompressed_len,
 						  const struct handoff_data *handoff_data)
 {
+#ifdef __PBL__
 	unsigned long size = uncompressed_len + MAX_BSS_SIZE + __handoff_data_size(handoff_data);
 
 	endmem = arm_mem_ramoops(endmem);
 
 	return ALIGN_DOWN(endmem - size, SZ_1M);
+#else
+	return (unsigned long)__image_start;
+#endif
 }
 
 /*

-- 
2.47.3




More information about the barebox mailing list