This is a step towards supporting unified kernel images (UKI) in Grub. Add a new module named boot_loader_interface, which provides a command with the same name. It implements a small but quite useful part of the Boot Loader Interface [0]. This interface uses EFI variables for communication between the boot loader and the operating system.
This module sets two EFI variables under the vendor GUID 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f: - LoaderInfo: contains GRUB + <version number>. This allows the running operating system to identify the boot loader used during boot. - LoaderDevicePartUUID: contains the partition UUID of the EFI System Partition (ESP). This is used by systemd-gpt-auto-generator [1] to find the root partitions (and others too), via partition type IDs [2]. This is especially useful for UKIs, where the kernel command line is fixed and usually does not contain any information about the root partition. This module is only available on EFI platforms. This series also unifies the GUID implementations and introduces a printf format specifier for them: %pG. Some comments from v2 where not fully addressed, see "commands/bli: Extract uft8 to utf16 conversion" patch. [0] https://systemd.io/BOOT_LOADER_INTERFACE/ [1] https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html [2] https://uapi-group.org/specifications/specs/discoverable_partitions_specification/ v3: - Unify GUID implementations for GPT and EFI - Add printf format specifier for GUIDs, drop guid print function from v2. - WIP/Please comment: Started extracting utf8->utf16 code. Where should this go? - Address other comments v2: - https://mail.gnu.org/archive/html/grub-devel/2023-02/msg00099.html - Addressed comments from Daniel - Added a print function for gpt guids` - Added integer overflow check in UTF16 conversion - Added config drop-in file that loads the module on EFI v1: - https://mail.gnu.org/archive/html/grub-devel/2023-01/msg00104.html Oliver Steffen (10): efi: Add grub_efi_set_variable_with_attributes efi: Check for integer overflow in string conversion Unify GUID types kern/misc: Add a format specifier GUIDs. grub-core: Make use of guid printf format specifier Add a module for the Boot Loader Interface grub-core/kern/efi: Remove redundant null-termination types.h: Add GRUB_SSIZE_MAX commands/bli: Extract uft8 to utf16 conversion util/grub.d: Activate bli module on EFI grub-core/Makefile.core.def | 6 + grub-core/commands/acpi.c | 4 +- grub-core/commands/bli.c | 222 ++++++++++++++++++++++++ grub-core/commands/efi/efifwsetup.c | 4 +- grub-core/commands/efi/loadbios.c | 14 +- grub-core/commands/efi/lsefi.c | 17 +- grub-core/commands/efi/lsefisystab.c | 10 +- grub-core/commands/efi/lssal.c | 4 +- grub-core/commands/efi/smbios.c | 12 +- grub-core/commands/efi/tpm.c | 6 +- grub-core/commands/probe.c | 9 +- grub-core/disk/efi/efidisk.c | 4 +- grub-core/efiemu/i386/pc/cfgtables.c | 6 +- grub-core/efiemu/main.c | 4 +- grub-core/efiemu/runtime/efiemu.c | 14 +- grub-core/kern/efi/acpi.c | 12 +- grub-core/kern/efi/efi.c | 73 ++++---- grub-core/kern/efi/fdt.c | 2 +- grub-core/kern/efi/init.c | 2 +- grub-core/kern/efi/sb.c | 4 +- grub-core/kern/misc.c | 86 ++++++--- grub-core/loader/arm64/linux.c | 4 +- grub-core/loader/efi/fdt.c | 2 +- grub-core/loader/i386/xnu.c | 13 +- grub-core/loader/ia64/efi/linux.c | 2 +- grub-core/net/drivers/efi/efinet.c | 4 +- grub-core/term/efi/console.c | 2 +- grub-core/term/efi/serial.c | 2 +- grub-core/video/efi_gop.c | 8 +- grub-core/video/efi_uga.c | 2 +- include/grub/efi/api.h | 69 +++----- include/grub/efi/efi.h | 20 ++- include/grub/efiemu/efiemu.h | 10 +- include/grub/efiemu/runtime.h | 2 +- include/grub/types.h | 11 ++ util/grub.d/25_boot_loader_interface.in | 34 ++++ 36 files changed, 485 insertions(+), 215 deletions(-) create mode 100644 grub-core/commands/bli.c create mode 100644 util/grub.d/25_boot_loader_interface.in -- 2.39.2 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel