Re: [PATCH v2 10/10] efi/libstub: add initial Boot Loader Interface support
From: Vincent Mailhol
Date: Tue Sep 15 2026 - 13:16:29 EST
On 9/9/26 13:55, Ard Biesheuvel wrote:
> From: Vincent Mailhol <mailhol@xxxxxxxxxx>
>
> 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>
> [ardb: - constify 'image' pointer parameter
> - pass efi_guid_t* to efi_snprintf()]
> Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> ---
(...)
> diff --git a/drivers/firmware/efi/libstub/bli.c b/drivers/firmware/efi/libstub/bli.c
> new file mode 100644
> index 000000000000..b2407f63b743
> --- /dev/null
> +++ b/drivers/firmware/efi/libstub/bli.c
> @@ -0,0 +1,87 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <generated/utsrelease.h>
> +
> +#include <linux/efi.h>
> +#include <linux/errno.h>
<linux/errno.h> is not needed anymore following the changes in v3.
(Sorry, this is my mistake)
> +#include <linux/unaligned.h>
> +
> +#include "efistub.h"
(...)
Yours sincerely,
Vincent Mailhol