mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 1/6] arch: introduce new CONFIG_ARCH_HAS_MALLOC_SIZE
Date: Fri, 22 May 2026 12:53:07 +0200	[thread overview]
Message-ID: <20260522105852.2681680-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260522105852.2681680-1-a.fatoum@pengutronix.de>

The new option is selected for all platforms, except for x86 and kvx as
these two platforms are the only ones that do not use MALLOC_SIZE:

- x86 (EFI payload): always allocates 16M as all bigger allocations
  are serviced via calling into the UEFI firmware.

- kvx always initializes memory area from barebox_text_end to end of
  memory described in DT

Note that CONFIG_MALLOC_SIZE is not hidden when ARCH_HAS_MALLOC_SIZE
is not selected. The reason for that is that CONFIG_MALLOC_SIZE is most
often 0 (malloc area is dynamically determined), but the Kconfig default
is 4M. This would lead to a breakage when bisecting for most boards:

- Board has CONFIG_MALLOC_SIZE=0
- Bisect jumps over commit removing ARCH_HAS_MALLOC_SIZE for an arch
- CONFIG_MALLOC_SIZE is set to default SZ_4M

This can easily happen, so we keep CONFIG_MALLOC_SIZE around even when
the symbol is unset at a value of 0 to cover the most common case.

For boards that actually set a non-zero value, special consideration
may need to be taken on bisect if the dynamic determination is not
sufficient.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/Kconfig          | 6 ++++++
 arch/arm/Kconfig      | 1 +
 arch/mips/Kconfig     | 1 +
 arch/openrisc/Kconfig | 1 +
 arch/powerpc/Kconfig  | 1 +
 arch/riscv/Kconfig    | 1 +
 arch/sandbox/Kconfig  | 1 +
 common/Kconfig        | 5 +++--
 8 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 9f5673b5da31..23e65d58d52b 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -92,6 +92,12 @@ config ARCH_HAS_DATA_ABORT_MASK_PBL
 config ARCH_HAS_ZERO_PAGE
 	bool
 
+config ARCH_HAS_MALLOC_SIZE
+	bool
+	help
+	  This is selected by architectures, where CONFIG_MALLOC_SIZE
+	  can be used to specify an exact size of the malloc area.
+
 config HAVE_EFFICIENT_UNALIGNED_ACCESS
 	bool
 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c735a0dbfd5b..53bddd55e179 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -20,6 +20,7 @@ config ARM
 	select ARCH_HAS_DMA_WRITE_COMBINE
 	select HAVE_EFI_LOADER if MMU # for payload unaligned accesses
 	select PBL_IMAGE_ELF
+	select ARCH_HAS_MALLOC_SIZE
 	default y
 
 config ARCH_LINUX_NAME
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index d34377a33d47..264815f34d06 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -14,6 +14,7 @@ config MIPS
 	select ARCH_HAS_SJLJ
 	select ELF
 	select HAVE_ARCH_BOOTM_OFTREE
+	select ARCH_HAS_MALLOC_SIZE
 	default y
 
 config ARCH_LINUX_NAME
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index f82d160a3a15..c81be0aa8019 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -8,6 +8,7 @@ config OPENRISC
 	select GENERIC_FIND_NEXT_BIT
 	select ARCH_HAS_SJLJ
 	select HAS_DEBUG_LL
+	select ARCH_HAS_MALLOC_SIZE
 	default y
 
 config ARCH_MKIMAGE_NAME
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 49050a26d524..d9c9f3583463 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -9,6 +9,7 @@ config PPC
 	select OFTREE
 	select HAVE_ARCH_BOOTM_OFTREE
 	select ARCH_HAS_SJLJ
+	select ARCH_HAS_MALLOC_SIZE
 	default y
 
 config ARCH_LINUX_NAME
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index f1d98d1b33a5..3e5de8e0ec63 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -21,6 +21,7 @@ config RISCV
 	select PBL_IMAGE_ELF
 	select HAVE_ARCH_BOARD_GENERIC_DT
 	select HAVE_ARCH_BOOTM_OFTREE
+	select ARCH_HAS_MALLOC_SIZE
 
 config ARCH_LINUX_NAME
 	string
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 504171809193..07821738f27a 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -27,6 +27,7 @@ config SANDBOX
 	select HAVE_PBL_MULTI_IMAGES
 	select PBL_IMAGE_NO_PIGGY
 	select PBL_CLOCKSOURCE if COMPILE_TEST
+	select ARCH_HAS_MALLOC_SIZE
 	default y
 
 config ARCH_LINUX_NAME
diff --git a/common/Kconfig b/common/Kconfig
index a91fc86929f2..5ba4530d3f9b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -291,8 +291,9 @@ config STACK_SIZE
 
 config MALLOC_SIZE
 	hex
-	default 0x400000
-	prompt "malloc area size"
+	default 0x400000 if ARCH_HAS_MALLOC_SIZE
+	default 0
+	prompt "malloc area size" if ARCH_HAS_MALLOC_SIZE
 
 config SCRATCH_SIZE
 	hex
-- 
2.47.3




  reply	other threads:[~2026-05-22 11:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 10:53 [PATCH master 0/6] ARM: unify pbl and proper malloc area start Ahmad Fatoum
2026-05-22 10:53 ` Ahmad Fatoum [this message]
2026-05-22 10:53 ` [PATCH master 2/6] ARM: explicitly state CONFIG_MALLOC_SIZE in defconfigs Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 3/6] arch: introduce CONFIG_MALLOC_OFFSET Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 4/6] ARM: switch to CONFIG_MALLOC_OFFSET Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 5/6] ARM: configs: drop CONFIG_MALLOC_SIZE=0x0 as it's now the default Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 6/6] ARM: place PBL malloc area at start of barebox proper malloc area Ahmad Fatoum

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=20260522105852.2681680-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@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