Skip to content

pxe_utils: small fixups, implement BLS type 1 boot on top of them

Alexey Charkov u-boot 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20260604-bls-db6a30b913ae

Versions newest first

  1. v2 Latest13 patches 1 replyIn review
  2. v17 patches 26 repliesSuperseded

Changes in v2 from the cover letter

- 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]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13pxe_utils: fix W=1 kernel-doc warningsboot/pxe_utils.c+12 -00 replies
2/13pxe_utils: accept "options" as synonym for "append"boot/pxe_utils.c+1 -00 replies
3/13pxe_utils: harden the "append" parser against malformed inputboot/pxe_utils.c+6 -60 replies
4/13pxe_utils: extract per-entry key parsing into parse_label_keys()boot/pxe_utils.c+43 -210 replies
5/13pxe_utils: export per-entry label helpersboot/pxe_utils.c include/pxe_utils.h+60 -390 replies
6/13pxe_utils: optionally ignore unknown keys in parse_label_keys()boot/pxe_utils.c include/pxe_utils.h+34 -30 replies
7/13pxe_utils: accept "title" inside a label as a synonym for "menu label"boot/pxe_utils.c+13 -00 replies
8/13bootmeth: share the pxelinux getfile helperboot/Kconfig boot/Makefile boot/bootmeth_extlinux.c +3 more+67 -410 replies
9/13boot: add a minimal bootmeth for the Boot Loader Specificationboot/Kconfig boot/Makefile boot/bootmeth_bls.c+387 -00 replies
10/13test: bootstd: add a BLS entry to the Fedora fixture imagetest/py/tests/test_ut.py+40 -180 replies
11/13sandbox: enable BLS boot methodarch/sandbox/dts/test.dts configs/sandbox_defconfig test/boot/bootdev.c +2 more+332 -1020 replies
12/13test: bootstd: cover BLS entries below a prefixarch/sandbox/dts/test.dts test/boot/bootflow.c test/py/tests/test_ut.py+163 -10 replies
13/13doc: bootstd: describe the BLS bootmethdoc/develop/bootstd/bls.rst doc/develop/bootstd/index.rst doc/develop/bootstd/overview.rst+58 -00 replies

Reviews trailers per patch

2 of 13 patches have a Reviewed-by or Acked-by.

PatchTom RiniSimon Glass
1/13R-b R-b
2/13R-b
3/13
4/13
5/13
6/13
7/13
8/13
9/13
10/13
11/13
12/13
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/13] pxe_utils: small fixups, implement BLS type 1 boot on top of them

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

---
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,

Signature · 1 line
Alexey Charkov <[email protected]>