]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-boot: Require gnu-efi 3.0.5
authorJan Janssen <medhefgo@web.de>
Thu, 30 Sep 2021 10:51:32 +0000 (12:51 +0200)
committerJan Janssen <medhefgo@web.de>
Sun, 17 Oct 2021 09:56:05 +0000 (11:56 +0200)
This version is from 2017 and should be stale enough to not cause
an outrage. All the relevant distros have it or a newer version.

We also already depend on some symbols defined in 3.0.5 anyway,
so let's take the opportunity to reduce our missing_efi.h
baggage.

README
src/boot/efi/boot.c
src/boot/efi/console.c
src/boot/efi/meson.build
src/boot/efi/missing_efi.h
src/boot/efi/pe.c
src/boot/efi/shim.c
src/boot/efi/splash.c
src/boot/efi/util.c

diff --git a/README b/README
index 3811abfe06056ba28c9f5812cc89e981bea8ff69..3e75e4435347e792c52cc6ed07b76ef8eaf596af 100644 (file)
--- a/README
+++ b/README
@@ -202,6 +202,7 @@ REQUIREMENTS:
         gcc, awk, sed, grep, and similar tools
         clang >= 10.0, llvm >= 10.0 (optional, required to build BPF programs
                 from source code in C)
+        gnu-efi >= 3.0.5 (optional, required for systemd-boot)
 
         During runtime, you need the following additional
         dependencies:
index fcbf50fc0e0a893ec667582c664c1d6ed971ea7a..6c4ddb193988b7fea39010240e0f0d93b6af2455 100644 (file)
         #error systemd-boot requires compilation with GNU_EFI_USE_MS_ABI defined.
 #endif
 
-#ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI
-#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
-#endif
-
 #define TEXT_ATTR_SWAP(c) EFI_TEXT_ATTR(((c) & 0b11110000) >> 4, (c) & 0b1111)
 
 /* magic string to find in the binary image */
@@ -1266,7 +1262,6 @@ static void config_entry_bump_counters(
 
         _cleanup_freepool_ CHAR16* old_path = NULL, *new_path = NULL;
         _cleanup_(FileHandleClosep) EFI_FILE_HANDLE handle = NULL;
-        static const EFI_GUID EfiFileInfoGuid = EFI_FILE_INFO_ID;
         _cleanup_freepool_ EFI_FILE_INFO *file_info = NULL;
         UINTN file_info_size;
         EFI_STATUS err;
@@ -1292,7 +1287,7 @@ static void config_entry_bump_counters(
 
         /* And rename the file */
         StrCpy(file_info->FileName, entry->next_name);
-        err = handle->SetInfo(handle, (EFI_GUID*) &EfiFileInfoGuid, file_info_size, file_info);
+        err = handle->SetInfo(handle, &GenericFileInfo, file_info_size, file_info);
         if (EFI_ERROR(err)) {
                 log_error_stall(L"Failed to rename '%s' to '%s', ignoring: %r", old_path, entry->next_name, err);
                 return;
index 88309484c71ac44c742dc17f8e5f9e80b812e2f5..6b71e1e02c1b675b3f57573abf3b1b2520a9ec78 100644 (file)
@@ -12,9 +12,6 @@
 #define VERTICAL_MAX_OK 1080
 #define VIEWPORT_RATIO 10
 
-#define EFI_SIMPLE_TEXT_INPUT_EX_GUID                           \
-        &(const EFI_GUID) EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID
-
 static inline void EventClosep(EFI_EVENT *event) {
         if (!*event)
                 return;
@@ -50,7 +47,7 @@ EFI_STATUS console_key_read(UINT64 *key, UINT64 timeout_usec) {
         assert(key);
 
         if (!checked) {
-                err = LibLocateProtocol((EFI_GUID*) EFI_SIMPLE_TEXT_INPUT_EX_GUID, (void **)&TextInputEx);
+                err = LibLocateProtocol(&SimpleTextInputExProtocol, (void **)&TextInputEx);
                 if (EFI_ERROR(err) || BS->CheckEvent(TextInputEx->WaitForKeyEx) == EFI_INVALID_PARAMETER)
                         /* If WaitForKeyEx fails here, the firmware pretends it talks this
                          * protocol, but it really doesn't. */
index 201a9a70f3760d808df78ea67dca65f1b7fa6714..e6bb7d7c6af77d1672f8b197b57daab3f70d0df4 100644 (file)
@@ -93,6 +93,14 @@ if conf.get('ENABLE_EFI') == 1 and get_option('gnu-efi') != 'false'
         endif
 
         have_gnu_efi = gnu_efi_path_arch != '' and efi_libdir != ''
+
+        if have_gnu_efi and not cc.has_header_symbol('efi.h', 'EFI_IMAGE_MACHINE_X64',
+           include_directories: include_directories(efi_incdir, efi_incdir / gnu_efi_path_arch))
+                have_gnu_efi = false
+                if get_option('gnu-efi') == 'true'
+                        error('gnu-efi support requested, but found headers are too old (3.0.5+ required)')
+                endif
+        endif
 else
         have_gnu_efi = false
 endif
index e3e0b978ef80ba36ef4e83afcad7ff7ba95a21ea..b0bd00365f45240d930e6b9b1318207a2ddc5055 100644 (file)
@@ -5,61 +5,12 @@
 
 #include "macro-fundamental.h"
 
-#ifndef EFI_RNG_PROTOCOL_GUID
-
-#define EFI_RNG_PROTOCOL_GUID                                           \
-          { 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44} }
-
-typedef EFI_GUID EFI_RNG_ALGORITHM;
-
-#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID       \
-     {0xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96} }
-
-#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID       \
-     {0xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7} }
-
-#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID        \
-     {0x44f0de6e, 0x4d8c, 0x4045, {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e} }
-
-#define EFI_RNG_ALGORITHM_X9_31_3DES_GUID              \
-     {0x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46} }
-
-#define EFI_RNG_ALGORITHM_X9_31_AES_GUID               \
-     {0xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9} }
-
-#define EFI_RNG_ALGORITHM_RAW                          \
-     {0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61} }
-
-INTERFACE_DECL(_EFI_RNG_PROTOCOL);
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_RNG_GET_INFO) (
-  IN      struct _EFI_RNG_PROTOCOL   *This,
-  IN OUT  UINTN                      *RNGAlgorithmListSize,
-  OUT     EFI_RNG_ALGORITHM          *RNGAlgorithmList
-);
-
-typedef
-EFI_STATUS
-(EFIAPI *EFI_RNG_GET_RNG) (
-  IN      struct _EFI_RNG_PROTOCOL   *This,
-  IN      EFI_RNG_ALGORITHM          *RNGAlgorithm,           OPTIONAL
-  IN      UINTN                      RNGValueLength,
-  OUT     UINT8                      *RNGValue
-);
-
-typedef struct _EFI_RNG_PROTOCOL {
-          EFI_RNG_GET_INFO           GetInfo;
-          EFI_RNG_GET_RNG            GetRNG;
-} EFI_RNG_PROTOCOL;
-
-#endif
-
+/* gnu-efi 3.0.13 */
 #ifndef EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID
 
 #define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
     { 0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa} }
+#define SimpleTextInputExProtocol ((EFI_GUID)EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID)
 
 #define EFI_SHIFT_STATE_VALID           0x80000000
 #define EFI_RIGHT_CONTROL_PRESSED       0x00000004
@@ -123,10 +74,12 @@ typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL {
 
 #endif
 
+/* gnu-efi 3.0.14 */
 #ifndef EFI_IMAGE_MACHINE_RISCV64
         #define EFI_IMAGE_MACHINE_RISCV64 0x5064
 #endif
 
+/* gnu-efi 3.0.14 */
 #ifndef EFI_DTB_TABLE_GUID
 #define EFI_DTB_TABLE_GUID \
         { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} }
@@ -163,6 +116,7 @@ struct _EFI_DT_FIXUP_PROTOCOL {
 
 #endif
 
+/* TCG EFI Protocol Specification */
 #ifndef EFI_TCG_GUID
 
 #define EFI_TCG_GUID \
@@ -262,6 +216,7 @@ typedef struct _EFI_TCG {
 
 #endif
 
+/* TCG EFI Protocol Specification */
 #ifndef EFI_TCG2_GUID
 
 #define EFI_TCG2_GUID \
index 518f5e66d07ae3e8a590251c3009e1204cea371e..6aecfe4526b051c43aaab224c1b1e86301db8304 100644 (file)
@@ -3,6 +3,7 @@
 #include <efi.h>
 #include <efilib.h>
 
+#include "missing_efi.h"
 #include "pe.h"
 #include "util.h"
 
index 0ccb90773a5925ffbaea67d8ff413ca14684e597..3ce6af42f94e0fb16bdccce4fbfad50a0386b0a0 100644 (file)
@@ -31,7 +31,6 @@ struct ShimLock {
         EFI_STATUS __sysv_abi__ (*read_header) (void *data, UINT32 datasize, void *context);
 };
 
-#define SIMPLE_FS_GUID &(const EFI_GUID) SIMPLE_FILE_SYSTEM_PROTOCOL
 #define SHIM_LOCK_GUID \
         &(const EFI_GUID) { 0x605dab50, 0xe046, 0x4300, { 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23 } }
 
@@ -119,7 +118,7 @@ static EFIAPI EFI_STATUS security_policy_authentication (const EFI_SECURITY_PROT
         if (!dev_path)
                 return EFI_OUT_OF_RESOURCES;
 
-        status = BS->LocateDevicePath((EFI_GUID*) SIMPLE_FS_GUID, &dev_path, &h);
+        status = BS->LocateDevicePath(&FileSystemProtocol, &dev_path, &h);
         if (EFI_ERROR(status))
                 return status;
 
index c27203eb8ca15b6e180d0a7416e761a6d766ca4a..fa923e77f20d6559d87884e707f633af9fdf09f9 100644 (file)
@@ -256,7 +256,6 @@ static EFI_STATUS bmp_to_blt(
 
 EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_OUTPUT_BLT_PIXEL *background) {
         EFI_GRAPHICS_OUTPUT_BLT_PIXEL pixel = {};
-        static const EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
         EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL;
         struct bmp_dib *dib;
         struct bmp_map *map;
@@ -281,7 +280,7 @@ EFI_STATUS graphics_splash(const UINT8 *content, UINTN len, const EFI_GRAPHICS_O
                 background = &pixel;
         }
 
-        err = LibLocateProtocol((EFI_GUID*) &GraphicsOutputProtocolGuid, (void **)&GraphicsOutput);
+        err = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&GraphicsOutput);
         if (EFI_ERROR(err))
                 return err;
 
index bbde2d8702f237b0eaea994f3368cce28dae245e..9128c507c803f31dbf1c3d80cfc2d7fe245074ff 100644 (file)
@@ -570,7 +570,6 @@ EFI_STATUS get_file_info_harder(
                 EFI_FILE_INFO **ret,
                 UINTN *ret_size) {
 
-        static const EFI_GUID EfiFileInfoGuid = EFI_FILE_INFO_ID;
         UINTN size = OFFSETOF(EFI_FILE_INFO, FileName) + 256;
         _cleanup_freepool_ EFI_FILE_INFO *fi = NULL;
         EFI_STATUS err;
@@ -584,14 +583,14 @@ EFI_STATUS get_file_info_harder(
         if (!fi)
                 return EFI_OUT_OF_RESOURCES;
 
-        err = handle->GetInfo(handle, (EFI_GUID*) &EfiFileInfoGuid, &size, fi);
+        err = handle->GetInfo(handle, &GenericFileInfo, &size, fi);
         if (err == EFI_BUFFER_TOO_SMALL) {
                 FreePool(fi);
                 fi = AllocatePool(size);  /* GetInfo tells us the required size, let's use that now */
                 if (!fi)
                         return EFI_OUT_OF_RESOURCES;
 
-                err = handle->GetInfo(handle, (EFI_GUID*) &EfiFileInfoGuid, &size, fi);
+                err = handle->GetInfo(handle, &GenericFileInfo, &size, fi);
         }
 
         if (EFI_ERROR(err))