From: "Ard Biesheuvel" <ardb@kernel.org>
To: "Vincent Mailhol" <mailhol@kernel.org>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>
Cc: linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org
Subject: Re: [PATCH v3] efi/libstub: add initial Boot Loader Interface support
Date: Tue, 08 Sep 2026 09:37:59 +0200 [thread overview]
Message-ID: <33a38234-c46b-41bf-838f-db0beec8b1cf@app.fastmail.com> (raw)
In-Reply-To: <20260906-efi_stub_bli-v3-1-e7dc0d6b8fcd@kernel.org>
Hi Vincent,
On Sun, 6 Sep 2026, at 23:52, Vincent Mailhol wrote:
> The Boot Loader Interface (BLI) [1] defines EFI variables that expose
> boot loader state to the running OS. LoaderInfo identifies the boot
> loader, while LoaderDevicePartUUID records the GPT partition UUID of
> the partition containing it.
>
> LoaderDevicePartUUID is used, for example, by systemd-gpt-auto-generator
> [2] to identify the disk the boot loader was launched from and
> automatically detect and mount partitions on it.
>
> GRUB [3] and systemd-boot [4] populate these variables, but when the
> kernel is started directly by EFI firmware, there is no conventional
> external boot loader to provide them. In that case, because the EFI stub
> performs the boot loader role, it should provide the variables itself.
>
> Use LoaderInfo as a sentinel: if it is already set by an earlier boot
> stage or cannot be set, bail out. Otherwise, populate the other BLI
> variables.
>
> Parse the loaded image device path, extract the GUID signature from its
> GPT HD() node and publish it under the Linux loader entry vendor GUID as
> the volatile LoaderDevicePartUUID EFI variable.
>
> Install the efi_bli_set_variables() hook in both the generic efi-stub.c
> path and the x86-specific x86-stub.c path.
>
> [1] The Boot Loader Interface
> Link: https://systemd.io/BOOT_LOADER_INTERFACE/
>
> [2] systemd-gpt-auto-generator
> Link:
> https://www.freedesktop.org/software/systemd/man/latest/systemd-gpt-auto-generator.html
>
> [3] GRUB -- §16.2 bli
> Link:
> https://www.gnu.org/software/grub/manual/grub/html_node/bli_005fmodule.html
>
> [4] systemd -- systemd-boot UEFI Boot Manager
> Link: https://github.com/systemd/systemd/blob/main/docs/BOOT.md?plain=1#L102
>
> Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
> ---
> Changes in v3:
>
> - Populate LoaderInfo in addition to LoaderDevicePartUUID.
>
> - Use LoaderInfo as the provider-level sentinel before setting BLI variables.
>
> - Drop CONFIG_EFI_STUB_BLI and enable the feature unconditionally.
>
> - Use the libstub %pUl formatter instead of local GUID string conversion.
>
> - Mode type definitions to efi.h and add enums for the EFI HD()
> partition format and signature type fields.
>
> - Reintroduce the NULL check on image to resolve the sashiko finding:
>
> https://sashiko.dev/#/patchset/20260903-efi_stub_bli-v2-1-dbf7ba915117%40kernel.org
>
> - Link to v2:
> https://patch.msgid.link/20260903-efi_stub_bli-v2-1-dbf7ba915117@kernel.org
>
> Changes in v2:
>
> - Add CONFIG_EFI_STUB_BLI to make the BLI feature optional.
>
> - Use static storage for GUID initializers. This reduces the size by
> about 10% compared to v1.
>
> - Remove the redundant NULL check on image.
>
> - Move the nibble-to-ASCII-hex conversion out of efi_bli_guid_to_str()
> into the new efi_bli_nibble_to_hex().
>
> - Rename variables to be closer to the EFI specification.
>
> Link to v1:
> https://lore.kernel.org/r/20260725-efi_stub_bli-v1-1-966e4748077f@kernel.org
> ---
> This patch depends on series "efi/libstub: Avoid UTF-16 conversion
> busywork" from Ard.
>
> Link:
> https://lore.kernel.org/all/20260906130817.1151961-9-ardb@kernel.org/
> Link:
> https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=efi-libstub-native-utf16
>
> Bloat-o-meter results on drivers/firmware/efi/libstub/lib.a before and
> after this patch on x86_64 with gcc 15.3.0:
>
> add/remove: 4/0 grow/shrink: 1/0 up/down: 770/0 (770)
> Function old new delta
> efi_bli_set_variables - 636 +636
> loader_info - 90 +90
> loader_entry_guid - 16 +16
> device_path_guid - 16 +16
> efi_stub_entry 4180 4192 +12
> Total: Before=29436, After=30206, chg +2.62%
> ---
> drivers/firmware/efi/libstub/Makefile | 2 +-
> drivers/firmware/efi/libstub/bli.c | 87 +++++++++++++++++++++++++++++++++
> drivers/firmware/efi/libstub/efi-stub.c | 1 +
> drivers/firmware/efi/libstub/efistub.h | 2 +
> drivers/firmware/efi/libstub/x86-stub.c | 1 +
> include/linux/efi.h | 22 +++++++++
> 6 files changed, 114 insertions(+), 1 deletion(-)
>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
I'll pick this up once the prerequisites are in place.
next prev parent reply other threads:[~2026-09-08 7:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 21:52 [PATCH v3] efi/libstub: add initial Boot Loader Interface support Vincent Mailhol
2026-09-08 7:37 ` Ard Biesheuvel [this message]
2026-09-08 18:48 ` Vincent Mailhol
2026-09-09 7:32 ` Ard Biesheuvel
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=33a38234-c46b-41bf-838f-db0beec8b1cf@app.fastmail.com \
--to=ardb@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.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