All of lore.kernel.org
 help / color / mirror / Atom feed
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: Wed, 09 Sep 2026 09:32:34 +0200	[thread overview]
Message-ID: <e66a0ac8-7bb8-4f1a-b05c-7cb28b61814e@app.fastmail.com> (raw)
In-Reply-To: <2c7c1cfe-3ed7-468d-9056-8d7e77d15a5a@kernel.org>



On Tue, 8 Sep 2026, at 20:48, Vincent Mailhol wrote:
> On 06/09/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>
>> ---
>
> (...)
>
>> +static void efi_bli_populate_loader_part_uuid(efi_loaded_image_t *image)
>> +{
>> +	static efi_guid_t device_path_guid = EFI_DEVICE_PATH_PROTOCOL_GUID;
>> +	efi_char16_t partuuid[UUID_STRING_LEN + 1];
>> +	const struct efi_hd_dev_path *hd_node;
>> +	const struct efi_dev_path *path;
>> +
>> +	if (efi_bs_call(handle_protocol, efi_table_attr(image, device_handle),
>> +			&device_path_guid, (void **)&path) != EFI_SUCCESS)
>> +		return;
>> +
>> +	hd_node = efi_bli_find_hd_node(path);
>> +	if (!hd_node)
>> +		return;
>> +
>> +	if (efi_snprintf(partuuid, ARRAY_SIZE(partuuid), "%pUl",
>> +			 hd_node->signature.b) != UUID_STRING_LEN)
>                          ^^^^^^^^^^^^^^^^^^^^
> I just realize that there is a small mistake here. Conceptually
> speaking, %pUl expects a pointer to a efi_guid_t. Of course, because of
> the function being variadic, no type enforcement is done and the
> compiler is happy with hd_node->signature.b which is an u8 array.
>
> But the clean approach is definitely:
>
> 	if (efi_snprintf(partuuid, ARRAY_SIZE(partuuid), "%pUl",
> 			 &hd_node->signature) != UUID_STRING_LEN)
>
> @Ard, do you want me to send a v4, or can you just fix while applying?
>

I'll fix that up.


>> +		return;
>> +
>> +	set_efi_var(L"LoaderDevicePartUUID", &loader_entry_guid,
>> +		    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
>> +		    sizeof(partuuid), partuuid);
>> +}
>
> (...)
>
>
> Yours sincerely,
> Vincent Mailhol

      reply	other threads:[~2026-09-09  7:33 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
2026-09-08 18:48 ` Vincent Mailhol
2026-09-09  7:32   ` Ard Biesheuvel [this message]

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=e66a0ac8-7bb8-4f1a-b05c-7cb28b61814e@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.