diff --git a/man/systemd-stub.xml b/man/systemd-stub.xml index 9528d9fdb6..730d27cf6c 100644 --- a/man/systemd-stub.xml +++ b/man/systemd-stub.xml @@ -81,27 +81,27 @@ An optional .dtb section with a compiled binary DeviceTree. - Zero or more .dtbauto sections. systemd-stub + Zero or more .dtbauto sections. systemd-stub will always use the first matching one. The match is performed by taking the first DeviceTree's - compatible string supplied by the firmware in configuration tables and comparing it - with the first compatible string from each of the .dtbauto + compatible string supplied by the firmware in configuration tables and comparing it + with the first compatible string from each of the .dtbauto sections. If the firmware does not provide a DeviceTree, the match is done using the - .hwids section instead. After selecting a .hwids section (see the - description below), the compatible string from that section will be used to perform + .hwids section instead. After selecting a .hwids section (see the + description below), the compatible string from that section will be used to perform the same matching procedure. If a match is found, that .dtbauto section will be - loaded and will override .dtb if present. + loaded and will override .dtb if present. Zero or more .efifw sections for the firmware image. It works - in many ways similar to .dtbauto sections. systemd-stub + in many ways similar to .dtbauto sections. systemd-stub will always use the first matching one. The match is performed by first selecting the most appropriate - entry in the .hwids section based on the hardware IDs supplied by SMBIOS (see below). - If a suitable entry is found, the fwid string from that entry will be used to - perform the matching procedure for firmware blobs in .efifw section. The first + entry in the .hwids section based on the hardware IDs supplied by SMBIOS (see below). + If a suitable entry is found, the fwid string from that entry will be used to + perform the matching procedure for firmware blobs in .efifw section. The first matching firmware will be loaded. Zero or more .hwids sections with hardware IDs of the machines to - match DeviceTrees. systemd-stub will use the SMBIOS data to calculate hardware IDs + match DeviceTrees. systemd-stub will use the SMBIOS data to calculate hardware IDs of the machine (as per specification), and then it will try to find any of them in each of the .hwids sections. The first @@ -189,7 +189,7 @@ archive is generated from all files found that way, placing them in the /.extra/credentials/ directory of the initrd file hierarchy. The main initrd may then access them in this directory. This is supposed to be used to store auxiliary, encrypted, - authenticated credentials for use with LoadCredentialEncrypted= in the UEFI System + authenticated credentials for use with LoadCredentialEncrypted in the UEFI System Partition. See systemd.exec5 and diff --git a/src/boot/efifirmware.c b/src/boot/efi-firmware.c similarity index 73% rename from src/boot/efifirmware.c rename to src/boot/efi-firmware.c index 8cf8e622ca..01bb2c2c71 100644 --- a/src/boot/efifirmware.c +++ b/src/boot/efi-firmware.c @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "efifirmware.h" +#include "efi-firmware.h" #include "util.h" -#include static bool efifw_validate_header( const void *blob, @@ -43,7 +42,7 @@ static bool efifw_validate_header( if (blob_len < total_computed_size) return false; - const char *fwid = (const char*)blob + header_len; + const char *fwid = (const char*) blob + header_len; const char *payload = fwid + fwid_len; /* check that fwid points to a NUL terminated string */ @@ -58,27 +57,17 @@ static bool efifw_validate_header( return true; } -static const char* efifw_get_fwid( - const void *efifwblob, - size_t efifwblob_len) { - - const char* fwid; - if (!efifw_validate_header(efifwblob, efifwblob_len, &fwid, NULL)) - return NULL; - - return fwid; -} - -EFI_STATUS efifirmware_match_by_fwid( - const void *uki_efifw, - size_t uki_efifw_len, +EFI_STATUS efi_firmware_match_by_fwid( + const void *blob, + size_t blob_len, const char *fwid) { + assert(blob); assert(fwid); - const char *fwblob_fwid = efifw_get_fwid(uki_efifw, uki_efifw_len); - if (!fwblob_fwid) + const char *blob_fwid; + if (!efifw_validate_header(blob, blob_len, &blob_fwid, NULL)) return EFI_INVALID_PARAMETER; - return streq8(fwblob_fwid, fwid) ? EFI_SUCCESS : EFI_NOT_FOUND; + return streq8(blob_fwid, fwid) ? EFI_SUCCESS : EFI_NOT_FOUND; } diff --git a/src/boot/efifirmware.h b/src/boot/efi-firmware.h similarity index 92% rename from src/boot/efifirmware.h rename to src/boot/efi-firmware.h index 888de35a98..9901d7d5c0 100644 --- a/src/boot/efifirmware.h +++ b/src/boot/efi-firmware.h @@ -28,4 +28,4 @@ typedef struct EfiFwHeader { uint8_t payload[] _alignas_(uint64_t); } EfiFwHeader; -EFI_STATUS efifirmware_match_by_fwid(const void *uki_efifw, size_t uki_efifw_length, const char *fwid); +EFI_STATUS efi_firmware_match_by_fwid(const void *blob, size_t blob_len, const char *fwid); diff --git a/src/boot/meson.build b/src/boot/meson.build index 31f36ea46d..3a17ab5ed0 100644 --- a/src/boot/meson.build +++ b/src/boot/meson.build @@ -284,8 +284,8 @@ libefi_sources = files( 'console.c', 'device-path-util.c', 'devicetree.c', - 'efifirmware.c', 'drivers.c', + 'efi-firmware.c', 'efi-string.c', 'efivars.c', 'export-vars.c', diff --git a/src/boot/pe.c b/src/boot/pe.c index 348296f001..04139c7ff6 100644 --- a/src/boot/pe.c +++ b/src/boot/pe.c @@ -2,7 +2,7 @@ #include "chid.h" #include "devicetree.h" -#include "efifirmware.h" +#include "efi-firmware.h" #include "pe.h" #include "util.h" @@ -215,7 +215,7 @@ static bool pe_use_this_firmware( if (!fwid) return false; - err = efifirmware_match_by_fwid(efifw, efifw_size, fwid); + err = efi_firmware_match_by_fwid(efifw, efifw_size, fwid); if (err == EFI_SUCCESS) return true; if (err == EFI_INVALID_PARAMETER)