From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 2/2] riscv: fix wrong calculation of barebox base
Date: Wed, 13 May 2026 15:57:59 +0200 [thread overview]
Message-ID: <20260513-pbl-elf-fixes-v1-2-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 ec8b2ce7c2, 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: ec8b2ce7c2 ("riscv: link ELF image into PBL")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/riscv/include/asm/barebox-riscv.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/riscv/include/asm/barebox-riscv.h b/arch/riscv/include/asm/barebox-riscv.h
index db6ff0ea71..083889817b 100644
--- a/arch/riscv/include/asm/barebox-riscv.h
+++ b/arch/riscv/include/asm/barebox-riscv.h
@@ -79,9 +79,13 @@ static inline unsigned long riscv_mem_barebox_image(unsigned long membase,
unsigned long endmem,
unsigned long size)
{
+#ifdef __PBL__
endmem = riscv_mem_ramoops(membase, endmem);
return ALIGN_DOWN(endmem - size, SZ_1M);
+#else
+ return (unsigned long)__image_start;
+#endif
}
#define ENTRY_FUNCTION(name, arg0, arg1, arg2) \
--
2.47.3
next prev parent 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 ` [PATCH 1/2] ARM: fix wrong calculation of barebox base Sascha Hauer
2026-05-13 13:57 ` Sascha Hauer [this message]
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-2-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