Add support for the Boot Loader Specification (BLS) type 1 boot entries,
as generated by default by systemd's kernel-install when loader=bls.

Given that the format of BLS entries is pretty much the same as PXElinux,
reuse the existing library for the parsing logic.

BLS type 2 entries are out of scope, as they are effectively just EFI
applications and should be booted as such.

This implementation is also only allowing a single top-sorting entry to
boot, as the standard boot infrastruture currently doesn't support
multiple entries per partition-bootmeth tuple. I have a proposed extension
to enable that and will post it separately as RFC - that enables the use
of `bootflow menu` to select the kernel to boot without jumping through
several menus with different behavior as is currently required with
extlinux.conf.

CI passes all green [1]

[1] 
https://git.u-boot-project.org/u-boot/contributors/alchark/u-boot/-/pipelines/1089

Signed-off-by: Alexey Charkov <[email protected]>
---
Changes in v2:
- Dropped "default y" to avoid increasing image size for platforms which
  don't use Freedesktop-style userspace and won't benefit from BLS (thanks Tom)
- Fixed typo referring to BLS type 2 when type 1 was meant (thanks Simon)
- Added a kerneldoc for parse_label_keys() upon factoring it out, not just
  when it gets exported to a shared header (thanks Simon)
- Shared the pxelinux getfile helper rather than making a third copy of it
  in the new bootmeth (thanks Simon). It moves to a translation unit of its
  own, so that PXE_UTILS users without bootstd don't gain a dependency on
  the bootmeth uclass, and boards without PXE_UTILS don't pay for it
- Allocated the entry buffer with ARCH_DMA_MINALIGN rather than 1 (thanks
  Simon)
- Stopped retaining the parsed label in bflow->bootmeth_priv, which the core
  frees flat and would therefore leak (thanks Simon). It turned out to be
  worse than a leak: a bootflow is shallow-copied into the bootflow list, so
  the pointer was shared between the iterator's temporary and the stored copy
  and could be freed twice. bls_boot() now re-parses bflow->buf, as extlinux
  does
- Added a test for entries found under the '/boot/' prefix rather than at the
  root of the filesystem (thanks Simon for asking what happens there). No code
  change was needed
- Dropped the number prefix from the driver name (thanks Simon)
- Added sandbox tests and updated the bootmeth/bootflow expectations that
  binding a third bootmeth changes, plus a doc/develop/bootstd page (thanks
  Simon)
- Added a patch hardening the "append" parser. A bare "append" dereferenced 
NULL, and
  an "initrd=" at end-of-line computed a negative length before malloc()
- Link to v1: 
https://patch.msgid.link/[email protected]

To: [email protected]
Cc: Tom Rini <[email protected]>
Cc: Alexey Charkov <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Daniel Golle <[email protected]>
Cc: Johan Jonker <[email protected]>
Cc: "Lucien.Jheng" <[email protected]>
Cc: Casey Connolly <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Vincent Jardin <[email protected]>
Cc: Denis Mukhin <[email protected]>
Cc: Aristo Chen <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>

---
Alexey Charkov (13):
      pxe_utils: fix W=1 kernel-doc warnings
      pxe_utils: accept "options" as synonym for "append"
      pxe_utils: harden the "append" parser against malformed input
      pxe_utils: extract per-entry key parsing into parse_label_keys()
      pxe_utils: export per-entry label helpers
      pxe_utils: optionally ignore unknown keys in parse_label_keys()
      pxe_utils: accept "title" inside a label as a synonym for "menu label"
      bootmeth: share the pxelinux getfile helper
      boot: add a minimal bootmeth for the Boot Loader Specification
      test: bootstd: add a BLS entry to the Fedora fixture image
      sandbox: enable BLS boot method
      test: bootstd: cover BLS entries below a prefix
      doc: bootstd: describe the BLS bootmeth

 arch/sandbox/dts/test.dts        |  12 +
 boot/Kconfig                     |  24 ++
 boot/Makefile                    |   2 +
 boot/bootmeth_bls.c              | 370 +++++++++++++++++++++++++++++++
 boot/bootmeth_extlinux.c         |  20 --
 boot/bootmeth_pxe.c              |  22 +-
 boot/bootmeth_pxe_common.c       |  34 +++
 boot/pxe_utils.c                 | 146 +++++++-----
 configs/sandbox_defconfig        |   1 +
 doc/develop/bootstd/bls.rst      |  56 +++++
 doc/develop/bootstd/index.rst    |   1 +
 doc/develop/bootstd/overview.rst |   1 +
 include/extlinux.h               |  23 ++
 include/pxe_utils.h              |  62 ++++++
 test/boot/bootdev.c              |  14 ++
 test/boot/bootflow.c             | 467 +++++++++++++++++++++++++++++++--------
 test/boot/bootmeth.c             |  38 +++-
 test/py/tests/test_ut.py         | 122 ++++++++--
 18 files changed, 1200 insertions(+), 215 deletions(-)
---
base-commit: 2d379a529c257606946831a6dac1c37de6a3f8c0
change-id: 20260604-bls-db6a30b913ae

Best regards,
--  
Alexey Charkov <[email protected]>

Reply via email to