mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 0/6] ARM: unify pbl and proper malloc area start
@ 2026-05-22 10:53 Ahmad Fatoum
  2026-05-22 10:53 ` [PATCH master 1/6] arch: introduce new CONFIG_ARCH_HAS_MALLOC_SIZE Ahmad Fatoum
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-05-22 10:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With the most recent changes to the PBL rockchip code, barebox gained an
additional very early malloc pool:

- very early on, it reserves some space at the end of RAM for extracting
  compressed TF-A/OP-TEE blobs.

- a bit later, but still in PBL, it reserve some space directly under
  the start of the barebox area at end of RAM as before.

- In barebox proper, it reserves a large malloc area that ends also
  at the start of the barebox area at end of RAM.

Nothing allocated in these different pools needs to survive after the
next pool is instantiated, so reusing the memory is fine.

The new pool at the start causes a regression for Rockchip boards with
OP-TEE as the OP-TEE region overlapped that very early malloc area.

The clean resolution of this is if we could just use the same malloc
area used later in barebox proper in PBL, whether very early or just
before barebox proper decompression.

There's a problem though:

 - The end of the malloc region is relative to barebox area, which means
   we must know how big barebox is, which we can't very early on as it
   contains handoff data not yet allocated and may not even be possible
   at all if we have separate first and second stages

- The start of the malloc region is relative to the end of the malloc
  region


This mess has been a fertile ground for bugs, so in interest of avoiding
more bugs in future, this series changes the calculation of the malloc
area on ARM:


 - The end continues to be relative to the barebox area
 - The start of the malloc area is relative to the end of the initial
   memory without regard to the barebox area

For the common case of the malloc area being dynamic anyway, the malloc
area will change in size by few megabytes, which doesn't matter much.

For the uncommon case, CONFIG_MALLOC_OFFSET would need to be set
appropriately. The migration notes are extended to describe how to
determine the value.

An extra benefit is that CONFIG_MALLOC_OFFSET=0 becomes the default now
instead of CONFIG_MALLOC_SIZE=4M, which most boards were overriding
anyway.

A future change that can be built on top of this is saving handoff
_before_ the barebox executable on memory, not before it.

This could further simplify the code. This is not implemented here as
this is meant for master to fix the regression for Rockchip.

This passes the DistroKit pre-release tests and the Github Actions CI.
@Alexander, could you test on your OP-TEE enabled RK35xx?

Ahmad Fatoum (6):
  arch: introduce new CONFIG_ARCH_HAS_MALLOC_SIZE
  ARM: explicitly state CONFIG_MALLOC_SIZE in defconfigs
  arch: introduce CONFIG_MALLOC_OFFSET
  ARM: switch to CONFIG_MALLOC_OFFSET
  ARM: configs: drop CONFIG_MALLOC_SIZE=0x0 as it's now the default
  ARM: place PBL malloc area at start of barebox proper malloc area

 arch/Kconfig                                  | 20 +++++++++
 arch/arm/Kconfig                              |  1 +
 arch/arm/configs/am335x_mlo_defconfig         |  1 -
 .../arm/configs/am35xx_pfc200_xload_defconfig |  1 -
 arch/arm/configs/animeo_ip_defconfig          |  1 +
 arch/arm/configs/at91_multi_defconfig         |  1 -
 arch/arm/configs/at91rm9200ek_defconfig       |  1 +
 arch/arm/configs/at91sam9260ek_defconfig      |  1 +
 .../configs/at91sam9261ek_bootstrap_defconfig |  1 +
 arch/arm/configs/at91sam9261ek_defconfig      |  1 +
 arch/arm/configs/at91sam9g10ek_defconfig      |  1 +
 arch/arm/configs/at91sam9g20ek_defconfig      |  1 +
 arch/arm/configs/at91sam9m10g45ek_defconfig   |  2 +-
 arch/arm/configs/at91sam9m10ihd_defconfig     |  2 +-
 arch/arm/configs/at91sam9n12ek_defconfig      |  2 +-
 arch/arm/configs/clps711x_defconfig           |  1 +
 arch/arm/configs/dss11_defconfig              |  1 +
 arch/arm/configs/efi_v8_defconfig             |  1 -
 arch/arm/configs/haba_knx_lite_defconfig      |  1 +
 arch/arm/configs/imx23_defconfig              |  1 -
 arch/arm/configs/imx28_defconfig              |  1 -
 arch/arm/configs/imx_v7_defconfig             |  1 -
 arch/arm/configs/imx_v8_defconfig             |  1 -
 arch/arm/configs/k3-r5_defconfig              |  1 -
 arch/arm/configs/kindle-gen-6-7_defconfig     |  1 -
 arch/arm/configs/kindle-mx50_defconfig        |  1 -
 arch/arm/configs/layerscape_defconfig         |  1 -
 arch/arm/configs/layerscape_v7_defconfig      |  1 -
 arch/arm/configs/modules32_defconfig          |  1 -
 arch/arm/configs/multi_v5_v6_defconfig        |  1 -
 arch/arm/configs/multi_v7_defconfig           |  1 -
 arch/arm/configs/multi_v8_defconfig           |  1 -
 arch/arm/configs/mvebu_defconfig              |  1 -
 arch/arm/configs/omap_defconfig               |  1 -
 arch/arm/configs/pm9261_defconfig             |  1 +
 arch/arm/configs/pm9263_defconfig             |  1 +
 arch/arm/configs/pm9g45_defconfig             |  1 +
 arch/arm/configs/qil_a9260_defconfig          |  1 +
 arch/arm/configs/qil_a9g20_defconfig          |  1 +
 arch/arm/configs/rockchip_v7a_defconfig       |  1 -
 arch/arm/configs/rockchip_v8_defconfig        |  1 -
 arch/arm/configs/rpi_defconfig                |  1 -
 arch/arm/configs/rpi_v8a_defconfig            |  3 +-
 arch/arm/configs/socfpga-agilex5_defconfig    |  1 -
 arch/arm/configs/socfpga-arria10_defconfig    |  1 -
 arch/arm/configs/socfpga-xload_defconfig      |  1 -
 arch/arm/configs/socfpga_defconfig            |  1 -
 arch/arm/configs/stm32mp_defconfig            |  1 -
 arch/arm/configs/tegra_v7_defconfig           |  1 -
 arch/arm/configs/telit_evk_pro3_defconfig     |  1 +
 arch/arm/configs/tny_a9260_defconfig          |  1 +
 .../arm/configs/tny_a9263_bootstrap_defconfig |  1 +
 arch/arm/configs/tny_a9263_defconfig          |  1 +
 arch/arm/configs/tny_a9g20_defconfig          |  1 +
 arch/arm/configs/usb_a9260_defconfig          |  1 +
 .../arm/configs/usb_a9263_bootstrap_defconfig |  1 +
 arch/arm/configs/usb_a9263_defconfig          |  1 +
 arch/arm/configs/usb_a9g20_defconfig          |  2 +-
 arch/arm/configs/virt32_secure_defconfig      |  1 -
 arch/arm/configs/zii_vf610_dev_defconfig      |  1 -
 arch/arm/configs/zynq_defconfig               |  2 +-
 arch/arm/configs/zynqmp_defconfig             |  1 -
 arch/arm/cpu/common.c                         |  4 +-
 arch/arm/cpu/start.c                          | 14 +------
 arch/arm/cpu/uncompress.c                     |  2 +-
 arch/arm/include/asm/barebox-arm.h            |  6 ++-
 arch/arm/mach-rockchip/atf.c                  |  2 +-
 arch/mips/Kconfig                             |  1 +
 arch/openrisc/Kconfig                         |  1 +
 arch/powerpc/Kconfig                          |  1 +
 arch/riscv/Kconfig                            |  1 +
 arch/sandbox/Kconfig                          |  1 +
 common/Kconfig                                | 41 ++++++++++++++++++-
 include/asm-generic/memory_layout.h           | 20 +++++++++
 74 files changed, 123 insertions(+), 59 deletions(-)

-- 
2.47.3




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-22 11:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-22 10:53 [PATCH master 0/6] ARM: unify pbl and proper malloc area start Ahmad Fatoum
2026-05-22 10:53 ` [PATCH master 1/6] arch: introduce new CONFIG_ARCH_HAS_MALLOC_SIZE Ahmad Fatoum
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox