mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 1/2] ARM: fix wrong calculation of barebox base
Date: Wed, 13 May 2026 15:57:58 +0200	[thread overview]
Message-ID: <20260513-pbl-elf-fixes-v1-1-440cc04c634f@pengutronix.de> (raw)
In-Reply-To: <20260513-pbl-elf-fixes-v1-0-440cc04c634f@pengutronix.de>

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@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




  reply	other threads:[~2026-05-13 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 13:57 [PATCH 0/2] Fix ELF image linking into PBL Sascha Hauer
2026-05-13 13:57 ` Sascha Hauer [this message]
2026-05-13 13:57 ` [PATCH 2/2] riscv: fix wrong calculation of barebox base Sascha Hauer
2026-05-15  9:28 ` [PATCH 0/2] Fix ELF image linking into PBL Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260513-pbl-elf-fixes-v1-1-440cc04c634f@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox