[PATCH 00/19] spl: Support a relocating jump between phases (VBE part F)

Simon Glass sjg at chromium.org
Wed Sep 25 14:55:26 CEST 2024


This series includes a way to deal with multiple XPL phases being
built to run from the same region of SRAM. This is useful because it may
not be possible to fit all the different phases in different parts of
the SRAM. Also it is a pain to have to build them with different values
for CONFIG_TEXT_BASE such that they can be loaded at different
addresses.

The mechanism is to copy some relocation code to the top of memory, then
load the next phase below that. Finally, the first phase jumps to the
relocation code, which copies or decompresses the next phase,
overwriting the first phase in the process. Finally, the relocation code
jumps to the start of the next phase.

In this way the maximum amount of space can be used, particular if the
next phase is compressed.

For this to work, some code in U-Boot must be placed in a 'rcode'
(relocation code) section. This ensures it can be copied as a block,
thus reducing the amount of the first-stage code which needs to survive
the relocation process.

For now there is a qemu-arm64 test for this feature, which ensures that
the basic mechanism is sound. Further work will likely expand this test
to include VPL and LZ4-compression, which so far have only been used on
real hardware.

Overall, without SPL_RELOC_LOADER enabled, this series provides a very
small code-size benefit due to it dropping some unneeded symbols.


Simon Glass (19):
  spl: Reduce the size of the bl_len field
  spl: Provide a way of indicating the phase to load
  spl: Avoid including hash algorithms which are not wanted
  spl: Provide a way to mark code needed for relocation
  lib: Mark crc8 as relocation code
  lib: Mark lz4 as relocation code
  lib: Mark memcpy() and memmove() as relocation code
  spl: Add a type for the jumper function
  spl: Add support for a relocating jump to the next phase
  spl: Plumb in the relocating loader
  spl: Support jumping to VPL from TPL
  spl: Record the correct name of the next phase
  spl: Show how to fill in the size of the next image
  spl: Add debugging in spl_set_header_raw_uboot()
  arm: qemu: Allow SPL and TPL
  arm: Add a new qemu_arm64_tpl board
  arm: Provide an rcode section in ARMv8 link script
  arm: qemu_arm64_tpl: Enable the relocating loader
  CI: Add new test for reloc loader

 .azure-pipelines.yml                  |   3 +
 .gitlab-ci.yml                        |   6 +
 MAINTAINERS                           |   6 +
 arch/arm/Kconfig                      |   2 +
 arch/arm/cpu/armv8/u-boot-spl.lds     |   8 ++
 arch/arm/dts/qemu-arm64.dts           |  17 +++
 arch/arm/mach-qemu/Kconfig            |  20 +++
 board/emulation/qemu-arm/Kconfig      |   2 +-
 board/emulation/qemu-arm/MAINTAINERS  |   5 +
 board/emulation/qemu-arm/Makefile     |   1 +
 board/emulation/qemu-arm/qemu-arm.env |   4 +
 board/emulation/qemu-arm/xpl.c        |  50 +++++++
 common/spl/Kconfig                    |   9 ++
 common/spl/Kconfig.tpl                |   9 ++
 common/spl/Kconfig.vpl                |   8 ++
 common/spl/Makefile                   |   1 +
 common/spl/spl.c                      |  45 +++++--
 common/spl/spl_reloc.c                | 182 ++++++++++++++++++++++++++
 configs/qemu_arm64_tpl_defconfig      |  83 ++++++++++++
 doc/develop/spl.rst                   |  35 +++++
 include/asm-generic/sections.h        |  16 +++
 include/spl.h                         |  57 +++++++-
 lib/Makefile                          |   6 +-
 lib/crc8.c                            |   5 +-
 lib/lz4.c                             |  27 ++--
 lib/lz4_wrapper.c                     |   2 +-
 lib/string.c                          |   5 +-
 test/py/tests/test_reloc.py           |  21 +++
 28 files changed, 604 insertions(+), 31 deletions(-)
 create mode 100644 board/emulation/qemu-arm/xpl.c
 create mode 100644 common/spl/spl_reloc.c
 create mode 100644 configs/qemu_arm64_tpl_defconfig
 create mode 100644 test/py/tests/test_reloc.py

-- 
2.43.0



More information about the U-Boot mailing list