Re: [PATCH v3] efi/libstub: add initial Boot Loader Interface support
From: Ard Biesheuvel
Date: Tue Sep 08 2026 - 03:45:57 EST
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@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxx
>
> 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@xxxxxxxxxx
> ---
> This patch depends on series "efi/libstub: Avoid UTF-16 conversion
> busywork" from Ard.
>
> Link:
> https://lore.kernel.org/all/20260906130817.1151961-9-ardb@xxxxxxxxxx/
> 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@xxxxxxxxxx>
I'll pick this up once the prerequisites are in place.