Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1phqIj-0000uD-9O for mharc-grub-devel@gnu.org; Thu, 30 Mar 2023 07:18:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phqIh-0000tc-KX for grub-devel@gnu.org; Thu, 30 Mar 2023 07:18:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phqIf-00054L-Hw for grub-devel@gnu.org; Thu, 30 Mar 2023 07:18:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680175116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Sg+l4fiHF33/lBlZisgm/qvnrqWYr0rXGSQvZ9dB9F8=; b=U2BiOtymARmuqkrbUfV1o4P/3CNGb4lCSv8qHXKD7EuexDvMfzbU3mycMlMC87uGrmOJpj zw7Mb2RH6pyjIGSohUcHmyhGzKj+go/Tp+CzOcRgd+guSGNu2cbECr6e9uVAhTTiJdryQe y5BGzlyscBgjkFW7R/hoZVpGBa5WU28= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-3RF1hqO5OV6hjmmvIK9baA-1; Thu, 30 Mar 2023 07:18:33 -0400 X-MC-Unique: 3RF1hqO5OV6hjmmvIK9baA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B46AF80C8C2; Thu, 30 Mar 2023 11:18:32 +0000 (UTC) Received: from osteffen-laptop.redhat.com (unknown [10.39.195.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 008322166B33; Thu, 30 Mar 2023 11:18:30 +0000 (UTC) From: Oliver Steffen To: grub-devel@gnu.org Cc: Daniel Kiper , Gerd Hoffmann , Javier Martinez Canillas , Glenn Washburn , Oliver Steffen Subject: [PATCH v5 0/8] Add basic Boot Loader Interface support Date: Thu, 30 Mar 2023 13:18:05 +0200 Message-Id: <20230330111813.480628-1-osteffen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Received-SPF: pass client-ip=170.10.133.124; envelope-from=osteffen@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Mar 2023 11:18:39 -0000 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 + . 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. [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/ v5: - Replace more grub_*_guid with the new grub_guid struct v4: - https://mail.gnu.org/archive/html/grub-devel/2023-03/msg00058.html - Place grub_utf8_to_utf16_alloc() in kern/misc.c and use it in kern/efi.c - bli: rework partition GUID code, improve error reporting - Add documentation for the bli module - Address other comments v3: - https://mail.gnu.org/archive/html/grub-devel/2023-03/msg00008.html - 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 (8): efi: Add grub_efi_set_variable_with_attributes Unify GUID types kern/misc: Add a format specifier GUIDs. grub-core: Make use of guid printf format specifier types.h: Add GRUB_SSIZE_MAX kern/misc, kern/efi: Extract UTF-8 to UTF-16 code Add a module for the Boot Loader Interface util/grub.d: Activate bli module on EFI Makefile.util.def | 6 + docs/grub.texi | 22 ++++ grub-core/Makefile.core.def | 6 + grub-core/commands/acpi.c | 4 +- grub-core/commands/bli.c | 166 +++++++++++++++++++++++++++ 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 | 11 +- grub-core/disk/efi/efidisk.c | 4 +- grub-core/disk/ldm.c | 2 +- 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 | 86 +++++--------- 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 | 118 +++++++++++++++---- grub-core/loader/efi/fdt.c | 2 +- grub-core/loader/efi/linux.c | 4 +- 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/partmap/gpt.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/gpt_partition.h | 13 +-- include/grub/misc.h | 3 + include/grub/types.h | 11 ++ util/grub-install.c | 2 +- util/grub-probe.c | 2 +- util/grub.d/25_bli.in | 25 ++++ 44 files changed, 491 insertions(+), 245 deletions(-) create mode 100644 grub-core/commands/bli.c create mode 100644 util/grub.d/25_bli.in -- 2.39.2