From 19e0e60a577cd0e2d79b2871cbcc2a2946ad1d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Mon, 15 Jan 2018 17:59:33 +0100 Subject: [PATCH 1/4] EFI stub: add LoaderImageIdentifier if non-existant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when an image with the stub is booted directly from UEFI, bootctl status shows this: ``` Current Loader: Product: n/a ESP: /dev/disk/by-partuuid/b0a0807d-0592-40e9-adac-3bb724e9e305 File: └─n/a ``` After this change, the stub reports the image itself: ``` Current Loader: Product: n/a ESP: /dev/disk/by-partuuid/b0a0807d-0592-40e9-adac-3bb724e9e305 File: └─/EFI/Secure/secure-boot-4.14.8+.efi ``` --- src/boot/efi/stub.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index e917019c0c..8066c2b8b5 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -104,6 +104,13 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS) efivar_set(L"LoaderDevicePartUUID", uuid, FALSE); + /* if LoaderImageIdentifier is not set, assume the image with this stub was loaded directly from UEFI */ + if (efivar_get_raw(&global_guid, L"LoaderImageIdentifier", &b, &size) != EFI_SUCCESS) { + CHAR16 *loaded_image_path = DevicePathToStr(loaded_image->FilePath); + efivar_set(L"LoaderImageIdentifier", loaded_image_path, FALSE); + FreePool(loaded_image_path); + } + if (szs[3] > 0) graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL); From 1aa15defbf37ef83191c4b0dd224957f3d1114b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Mon, 15 Jan 2018 18:01:04 +0100 Subject: [PATCH 2/4] EFI stub: add LoaderFirmwareInfo, LoaderFirmwareType if non-existant bootctl previously: ``` System: Firmware: n/a (n/a) ``` after: ``` System: Firmware: UEFI 2.50 (Lenovo 0.4704) ``` --- src/boot/efi/stub.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 8066c2b8b5..cf52579086 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -111,6 +111,20 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { FreePool(loaded_image_path); } + /* if LoaderFirmwareInfo is not set, let's set it */ + if (efivar_get_raw(&global_guid, L"LoaderFirmwareInfo", &b, &size) != EFI_SUCCESS) { + CHAR16 *loader_firmware_info = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); + efivar_set(L"LoaderFirmwareInfo", loader_firmware_info, FALSE); + FreePool(loader_firmware_info); + } + /* ditto for LoaderFirmwareType */ + if (efivar_get_raw(&global_guid, L"LoaderFirmwareType", &b, &size) != EFI_SUCCESS) { + CHAR16 *loader_firmware_type = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff); + efivar_set(L"LoaderFirmwareType", loader_firmware_type, FALSE); + FreePool(loader_firmware_type); + } + + if (szs[3] > 0) graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL); From 34412f79e6ad439d3fa99de6d97d8322e08c1e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Mon, 15 Jan 2018 18:08:11 +0100 Subject: [PATCH 3/4] EFI stub: add StubInfo if non-existant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit currently if a stub image is directly booted, bootctl reports: ``` Current Loader: Product: n/a ESP: /dev/disk/by-partuuid/b0a0807d-0592-40e9-adac-3bb724e9e305 File: └─/EFI/Secure/secure-boot-4.14.8+.efi ``` Let's add a StubInfo which will be displayed by bootctl too (in a later patch). --- src/boot/efi/stub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index cf52579086..ff45cebd45 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -124,6 +124,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { FreePool(loader_firmware_type); } + /* add StubInfo */ + if (efivar_get_raw(&global_guid, L"StubInfo", &b, &size) != EFI_SUCCESS) + efivar_set(L"StubInfo", L"systemd-stub " PACKAGE_VERSION, FALSE); if (szs[3] > 0) graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL); From 81375b9bf780505c6971993aaf7a62303f16c93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Mon, 15 Jan 2018 18:21:14 +0100 Subject: [PATCH 4/4] bootctl: report StubInfo if present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current Loader: Product: n/a Stub: systemd-stub 236 ESP: /dev/disk/by-partuuid/b0a0807d-0592-40e9-adac-3bb724e9e305 File: └─/EFI/Secure/secure-boot-4.14.13+.efi --- src/boot/bootctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 0c2a39d34b..ae034f5cdb 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -950,12 +950,13 @@ static int verb_status(int argc, char *argv[], void *userdata) { * can show */ if (is_efi_boot()) { - _cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL; + _cleanup_free_ char *fw_type = NULL, *fw_info = NULL, *loader = NULL, *loader_path = NULL, *stub = NULL; sd_id128_t loader_part_uuid = SD_ID128_NULL; read_loader_efi_var("LoaderFirmwareType", &fw_type); read_loader_efi_var("LoaderFirmwareInfo", &fw_info); read_loader_efi_var("LoaderInfo", &loader); + read_loader_efi_var("StubInfo", &stub); read_loader_efi_var("LoaderImageIdentifier", &loader_path); if (loader_path) @@ -983,6 +984,8 @@ static int verb_status(int argc, char *argv[], void *userdata) { printf("Current Loader:\n"); printf(" Product: %s\n", strna(loader)); + if (stub) + printf(" Stub: %s\n", stub); if (!sd_id128_is_null(loader_part_uuid)) printf(" ESP: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", SD_ID128_FORMAT_VAL(loader_part_uuid));