From eeb55254dd0808f008f9ce99195f61520daae28d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 19 Jan 2023 16:22:10 +0100 Subject: [PATCH 01/23] buildman: invalid reference to README The readme file for buildman is called buildman.rst. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- tools/buildman/toolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index 38b0dea8c7..ea1ad1bcb8 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -265,7 +265,7 @@ class Toolchains: print(("Warning: No tool chains. Please run 'buildman " "--fetch-arch all' to download all available toolchains, or " "add a [toolchain] section to your buildman config file " - "%s. See README for details" % + "%s. See buildman.rst for details" % bsettings.config_fname)) paths = [] From fe34e163e0a6b77894c5d533fbfe6909a8bccfb3 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 28 Jan 2023 01:11:56 +0100 Subject: [PATCH 02/23] cmd: improve coninfo output formatting Device name are typically longer than 8 characters. This leads to ragged output. Only the I and O bit of the device flags are of interest for the user. Writing a hexadecimal number is just confusing. Before the patch the output looked like this: => coninfo List of available devices: pl011@9000000 00000007 IO stdin stdout stderr serial 00000003 IO usbkbd 00000001 I. With the patch the output looks like this: => coninfo List of available devices |-- pl011@9000000 (IO) | |-- stdin | |-- stdout | |-- stderr |-- serial (IO) |-- usbkbd (I) Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- cmd/console.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/console.c b/cmd/console.c index 9a1db83c7c..620a961cde 100644 --- a/cmd/console.c +++ b/cmd/console.c @@ -22,23 +22,21 @@ static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc, /* Scan for valid output and input devices */ - puts ("List of available devices:\n"); + puts("List of available devices\n"); list_for_each(pos, list) { dev = list_entry(pos, struct stdio_dev, list); - printf ("%-8s %08x %c%c ", - dev->name, - dev->flags, - (dev->flags & DEV_FLAGS_INPUT) ? 'I' : '.', - (dev->flags & DEV_FLAGS_OUTPUT) ? 'O' : '.'); + printf("|-- %s (%s%s)\n", + dev->name, + (dev->flags & DEV_FLAGS_INPUT) ? "I" : "", + (dev->flags & DEV_FLAGS_OUTPUT) ? "O" : ""); for (l = 0; l < MAX_FILES; l++) { if (stdio_devices[l] == dev) { - printf ("%s ", stdio_names[l]); + printf("| |-- %s\n", stdio_names[l]); } } - putc ('\n'); } return 0; } From 67835c20901c4286dae0553704fe43039d441dfe Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 27 Jan 2023 22:00:30 +0100 Subject: [PATCH 03/23] doc: complete setexpr configuration information Add missing information to the configuration section of the setexpr man-page. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- doc/usage/cmd/setexpr.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/usage/cmd/setexpr.rst b/doc/usage/cmd/setexpr.rst index 2e511b1290..4d19fa340d 100644 --- a/doc/usage/cmd/setexpr.rst +++ b/doc/usage/cmd/setexpr.rst @@ -138,7 +138,10 @@ Example Configuration ------------- -The setexpr gsub and sub operations are only available if CONFIG_REGEX=y. +* The *setexpr* command is only available if CMD_SETEXPR=y. +* The *setexpr fmt* sub-command is only available if CMD_SETEXPR_FMT=y. +* The *setexpr gsub* and *setexpr sub* sub-commands are only available if + CONFIG_REGEX=y. Return value ------------ From 8ad7cfec37b72c6bd629b4f1a18bf3ceebf9bd57 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Feb 2023 15:30:52 -0700 Subject: [PATCH 04/23] doc: Link to some useful talks Talks are a great way to learn about U-Boot and have been lost now that the Denx Wiki has gone away. These are stored at elinux.org so link to that . Signed-off-by: Simon Glass Reviewed-by: Sean Anderson --- doc/index.rst | 1 + doc/learn/index.rst | 9 +++++++++ doc/learn/talks.rst | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 doc/learn/index.rst create mode 100644 doc/learn/talks.rst diff --git a/doc/index.rst b/doc/index.rst index 02de1d4684..57b42c68e4 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -25,6 +25,7 @@ trying to get it to work optimally on a given system. :maxdepth: 2 build/index + learn/index usage/index Developer-oriented documentation diff --git a/doc/learn/index.rst b/doc/learn/index.rst new file mode 100644 index 0000000000..8075c01d1d --- /dev/null +++ b/doc/learn/index.rst @@ -0,0 +1,9 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Learn about U-Boot +================== + +.. toctree:: + :maxdepth: 1 + + talks diff --git a/doc/learn/talks.rst b/doc/learn/talks.rst new file mode 100644 index 0000000000..33bac483e1 --- /dev/null +++ b/doc/learn/talks.rst @@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +U-Boot Talks +============ + +U-Boot is a topic at various conferences each year. These talkes might help you +learn a bit about U-Boot. + +See elinux_talks_ for a list. + +.. _elinux_talks: https://elinux.org/Boot_Loaders#U-Boot From 1dd705cf990364eaf7312ed327b93fc04b43fbe5 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Sat, 28 Jan 2023 13:56:14 +0900 Subject: [PATCH 05/23] efi: use 32-bit alignment for efi_guid_t Current U-Boot implements 64-bit boundary for efi_guid_t structure. It follows the UEFI specification, page 21 of the UEFI Specification v2.10 says about EFI_GUID: 128-bit buffer containing a unique identifier value. Unless otherwise specified, aligned on a 64-bit boundary. On the other hand, page 163 of the UEFI specification v2.10 and EDK2 reference implementation both define EFI_GUID as struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment is 32-bit not 64-bit like U-Boot efi_guid_t. Due to this alignment difference, EDK2 application "CapsuleApp.efi -P" does not work as expected. This calls EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo() and dump the EFI_FIRMWARE_IMAGE_DESCRIPTOR structure, offsetof(EFI_FIRMWARE_IMAGE_DESCRIPTOR, ImageTypeId) is different, 8 in U-Boot and 4 in EDK2(CapsuleApp.efi). Here is the wrong EFI_GUID dump. wrong dump : ImageTypeId - 00000000-7D83-058B-D550-474CA19560D8 expected : ImageTypeId - 058B7D83-50D5-4C47-A195-60D86AD341C4 EFI_FIRMWARE_IMAGE_DESCRIPTOR structure is defined in UEFI specification: typedef struct { UINT8 ImageIndex; EFI_GUID ImageTypeId; UINT64 ImageId } EFI_FIRMWARE_IMAGE_DESCRIPTOR; There was the relevant patch for linux kernel to use 32-bit alignment for efi_guid_t [1]. U-Boot should get aligned to EDK2 reference implementation and linux kernel. Due to this alignment change, efi_hii_ref structure in include/efi_api.h is affected, but it is not used in the current U-Boot code. [1] https://lore.kernel.org/all/20190202094119.13230-5-ard.biesheuvel@linaro.org/ Cc: Ilias Apalodimas Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 42f4e58a91..c3087d3da2 100644 --- a/include/efi.h +++ b/include/efi.h @@ -54,9 +54,18 @@ struct efi_device_path; +/* + * The EFI spec defines the EFI_GUID as + * "128-bit buffer containing a unique identifier value. Unless otherwise specified, + * aligned on a 64-bit boundary". + * Page 163 of the UEFI specification v2.10 and + * EDK2 reference implementation both define EFI_GUID as + * struct { u32 a; u16; b; u16 c; u8 d[8]; }; which is 4-byte + * aligned. + */ typedef struct { u8 b[16]; -} efi_guid_t __attribute__((aligned(8))); +} efi_guid_t __attribute__((aligned(4))); #define EFI_BITS_PER_LONG (sizeof(long) * 8) From 45f5319fa6e88cf3b59addee5caebf06fd26e305 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Thu, 2 Feb 2023 18:24:43 +0900 Subject: [PATCH 06/23] menu: remove CTRL+C to quit On the sandbox called without "--terminal raw" CTRL+C leaves U-Boot, "ESC/CTRL+C to quit" is misleading. Let's remove CTRL+C to quit key handling from bootmenu and eficonfig menu. Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt --- cmd/bootmenu.c | 2 +- cmd/eficonfig.c | 6 +++--- doc/usage/cmd/bootmenu.rst | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 3236ca5d79..8dc133c236 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -437,7 +437,7 @@ static void menu_display_statusline(struct menu *m) printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); puts(ANSI_CLEAR_LINE); printf(ANSI_CURSOR_POSITION, menu->count + 6, 3); - puts("Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"); + puts("Press UP/DOWN to move, ENTER to select, ESC to quit"); puts(ANSI_CLEAR_LINE_TO_END); printf(ANSI_CURSOR_POSITION, menu->count + 7, 1); puts(ANSI_CLEAR_LINE); diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 47c04cf536..f365a988d4 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -23,12 +23,12 @@ static struct efi_simple_text_input_protocol *cin; const char *eficonfig_menu_desc = - " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"; + " Press UP/DOWN to move, ENTER to select, ESC to quit"; static const char *eficonfig_change_boot_order_desc = " Press UP/DOWN to move, +/- to change orde\n" " Press SPACE to activate or deactivate the entry\n" - " Select [Save] to complete, ESC/CTRL+C to quit"; + " Select [Save] to complete, ESC to quit"; static struct efi_simple_text_output_protocol *cout; static int avail_row; @@ -927,7 +927,7 @@ static efi_status_t handle_user_input(u16 *buf, int buf_size, ANSI_CURSOR_POSITION "%s" ANSI_CURSOR_POSITION - " Press ENTER to complete, ESC/CTRL+C to quit", + " Press ENTER to complete, ESC to quit", 0, 1, msg, 8, 1); /* tmp is used to accept user cancel */ diff --git a/doc/usage/cmd/bootmenu.rst b/doc/usage/cmd/bootmenu.rst index cb3c8d2f93..684a18d8e1 100644 --- a/doc/usage/cmd/bootmenu.rst +++ b/doc/usage/cmd/bootmenu.rst @@ -122,7 +122,7 @@ Example bootmenu is as below:: Default behavior when user exits from the bootmenu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ User can exit from bootmenu by selecting the last entry -"U-Boot console"/"Quit" or ESC/CTRL+C key. +"U-Boot console"/"Quit" or ESC key. When the CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is disabled, user exits from the bootmenu and returns to the U-Boot console. From 88df36346c767f8756e54cc1941b6cda180b61db Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Thu, 2 Feb 2023 18:24:44 +0900 Subject: [PATCH 07/23] eficonfig: CTRL+S to save the boot order The change boot order menu in eficonfig can have at most INT_MAX lines and it is troublesome to scroll down to the "Save" entry. This commit assigns CTRL+S to save the boot order. Signed-off-by: Masahisa Kojima Acked-by: Heinrich Schuchardt --- cmd/eficonfig.c | 6 +++++- common/menu.c | 3 +++ include/menu.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index f365a988d4..0a17b8cf34 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -28,7 +28,7 @@ const char *eficonfig_menu_desc = static const char *eficonfig_change_boot_order_desc = " Press UP/DOWN to move, +/- to change orde\n" " Press SPACE to activate or deactivate the entry\n" - " Select [Save] to complete, ESC to quit"; + " CTRL+S to save, ESC to quit"; static struct efi_simple_text_output_protocol *cout; static int avail_row; @@ -1983,6 +1983,10 @@ char *eficonfig_choice_change_boot_order(void *data) eficonfig_menu_down(efi_menu); return NULL; + case BKEY_SAVE: + /* force to select "Save" entry */ + efi_menu->active = efi_menu->count - 2; + fallthrough; case BKEY_SELECT: /* "Save" */ if (efi_menu->active == efi_menu->count - 2) { diff --git a/common/menu.c b/common/menu.c index cdcdbb2a18..94514177e4 100644 --- a/common/menu.c +++ b/common/menu.c @@ -503,6 +503,9 @@ enum bootmenu_key bootmenu_conv_key(int ichar) case CTL_CH('n'): key = BKEY_DOWN; break; + case CTL_CH('s'): + key = BKEY_SAVE; + break; case '+': key = BKEY_PLUS; break; diff --git a/include/menu.h b/include/menu.h index 1e88141d6b..64ce89b7d2 100644 --- a/include/menu.h +++ b/include/menu.h @@ -53,6 +53,7 @@ enum bootmenu_key { BKEY_PLUS, BKEY_MINUS, BKEY_SPACE, + BKEY_SAVE, BKEY_COUNT, }; From 1f0583beeb32b0eab4d87ea9c0bef247432aa0c6 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Thu, 2 Feb 2023 18:24:45 +0900 Subject: [PATCH 08/23] eficonfig: set EFICONFIG_ENTRY_NUM_MAX to INT_MAX - 1 eficonfig_append_menu_entryi() accepts the number of entries less than or equal to EFICONFIG_ENTRY_NUM_MAX. EFICONFIG_ENTRY_NUM_MAX is currently set as INT_MAX, so the invalid menu count check(efi_menu->count > EFICONFIG_ENTRY_NUM_MAX) in eficonfig_process_common() is always false. This commit sets EFICONFIG_ENTRY_NUM_MAX to (INT_MAX - 1). Reported-by: Coverity (CID 435659) Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt --- include/efi_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/efi_config.h b/include/efi_config.h index e5edbb5e09..01ce9b2b06 100644 --- a/include/efi_config.h +++ b/include/efi_config.h @@ -11,7 +11,7 @@ #include #include -#define EFICONFIG_ENTRY_NUM_MAX INT_MAX +#define EFICONFIG_ENTRY_NUM_MAX (INT_MAX - 1) #define EFICONFIG_VOLUME_PATH_MAX 512 #define EFICONFIG_FILE_PATH_MAX 512 #define EFICONFIG_FILE_PATH_BUF_SIZE (EFICONFIG_FILE_PATH_MAX * sizeof(u16)) From 454a9442fbce761db7655381fdfaded8f09c8cf3 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Thu, 2 Feb 2023 22:53:35 +0900 Subject: [PATCH 09/23] efi_loader: update attribute check for QueryVariableInfo() Current U-Boot supports two EFI variable service, U-Boot own implementation and op-tee based StMM variable service. With ACS Security Interface Extension(SIE) v22.10_SIE_REL1.1.0, there are several failure items of QueryVariableInfo(). Current attribute check for QueryVariableInfo() was implemented based on the Self Certification Test (SCT) II Case Specification, June 2017, chapter 4.1.4 QueryVariableInfo(). This test case specification is outdated and don't align at all with the SCT test case code, and UEFI specification v2.10 does not clearly define the priority of the attribute check. For U-Boot standard case that EFI variables are stored in a file in the ESP, this commit modifies the attribute check to get align to the EDK2 implementation. For latter case(op-tee based StMM variable service), parameter check should be delegated to StMM. Now all ACS SIE QueryVariableInfo() test cases passed both EFI variable storage implementations. Signed-off-by: Masahisa Kojima Acked-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_var_common.c | 10 +--------- lib/efi_loader/efi_variable.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index eb83702781..ad50bffd2b 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -165,17 +165,9 @@ efi_status_t EFIAPI efi_query_variable_info( if (!maximum_variable_storage_size || !remaining_variable_storage_size || - !maximum_variable_size || - !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS)) + !maximum_variable_size) return EFI_EXIT(EFI_INVALID_PARAMETER); - if ((attributes & ~(u32)EFI_VARIABLE_MASK) || - (attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || - (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) || - (!IS_ENABLED(CONFIG_EFI_SECURE_BOOT) && - (attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS))) - return EFI_EXIT(EFI_UNSUPPORTED); - ret = efi_query_variable_info_int(attributes, maximum_variable_storage_size, remaining_variable_storage_size, diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 7c32adf6e5..4d4dfa6b15 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -349,6 +349,29 @@ efi_status_t efi_query_variable_info_int(u32 attributes, u64 *remaining_variable_storage_size, u64 *maximum_variable_size) { + if (attributes == 0) + return EFI_INVALID_PARAMETER; + + /* EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated */ + if ((attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) || + ((attributes & EFI_VARIABLE_MASK) == 0)) + return EFI_UNSUPPORTED; + + if ((attributes & EFI_VARIABLE_MASK) == EFI_VARIABLE_NON_VOLATILE) + return EFI_INVALID_PARAMETER; + + /* Make sure if runtime bit is set, boot service bit is set also. */ + if ((attributes & + (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == + EFI_VARIABLE_RUNTIME_ACCESS) + return EFI_INVALID_PARAMETER; + + if (attributes & EFI_VARIABLE_HARDWARE_ERROR_RECORD) + return EFI_UNSUPPORTED; + + if (attributes & ~(u32)EFI_VARIABLE_MASK) + return EFI_INVALID_PARAMETER; + *maximum_variable_storage_size = EFI_VAR_BUF_SIZE - sizeof(struct efi_var_file); *remaining_variable_storage_size = efi_var_mem_free(); From 75d494df01c6edd25abdde98e700cc117a066180 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 8 Feb 2023 13:56:33 +0100 Subject: [PATCH 10/23] cmd: CONFIG_CMD_EFICONFIG requires CONFIG_MENU The eficonfig command invokes functions implemented in common/menu.c like * menu_default_set() * menu_get_choice() * menu_destroy() * menu_item_add() Fixes: 87d791423ac6 ("eficonfig: menu-driven addition of UEFI boot option") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Ilias Apalodimas --- cmd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index c7344ee1f6..aef99d2eb8 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2001,6 +2001,7 @@ config CMD_EFIDEBUG config CMD_EFICONFIG bool "eficonfig - provide menu-driven uefi variables maintenance interface" depends on CMD_BOOTEFI_BOOTMGR + select MENU help Enable the 'eficonfig' command which provides the menu-driven UEFI variable maintenance interface. From 8925f0ee7ee4efd4d76ff1e5c119af154d5d104a Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 8 Feb 2023 09:57:00 +0100 Subject: [PATCH 11/23] efi_loader: enable eficonfig command by default The eficonfig command is required to set boot options. Signed-off-by: Heinrich Schuchardt --- cmd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index aef99d2eb8..2caa4af71c 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2000,6 +2000,7 @@ config CMD_EFIDEBUG config CMD_EFICONFIG bool "eficonfig - provide menu-driven uefi variables maintenance interface" + default y if !HAS_BOARD_SIZE_LIMIT depends on CMD_BOOTEFI_BOOTMGR select MENU help From 7d840627ca38d775107dc9480f4d14ce236f95ce Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:09:40 +0100 Subject: [PATCH 12/23] efi_loader: make get_load_options() static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In program initrddump.efi function get_load_options() can be static. This avoids a warning when building with 'make W=1': lib/efi_loader/initrddump.c:442:6: warning: no previous prototype for ‘get_load_options’ [-Wmissing-prototypes] 442 | u16 *get_load_options(void) | ^~~~~~~~~~~~~~~~ Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/initrddump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/initrddump.c b/lib/efi_loader/initrddump.c index 9872106981..971a3b6236 100644 --- a/lib/efi_loader/initrddump.c +++ b/lib/efi_loader/initrddump.c @@ -439,7 +439,7 @@ out: * * Return: load options or NULL */ -u16 *get_load_options(void) +static u16 *get_load_options(void) { efi_status_t ret; struct efi_loaded_image *loaded_image; From 4db17a4b12524d0ec2dc30913dbbf44f968ce8e0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:13:23 +0100 Subject: [PATCH 13/23] efi_loader: fix struct efi_input_key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UEFI specification defines filed UnicodeChar as CHAR16. We use u16 for CHAR16 throughout our code. The change fixes the following errors: lib/efi_loader/initrddump.c: In function ‘efi_input’: lib/efi_loader/initrddump.c:218:38: warning: comparison is always false due to limited range of data type [-Wtype-limits] 218 | if (key.unicode_char >= 0xD800 && key.unicode_char <= 0xDBFF) | ^~ lib/efi_loader/initrddump.c:218:68: warning: comparison is always true due to limited range of data type [-Wtype-limits] 218 | if (key.unicode_char >= 0xD800 && key.unicode_char <= 0xDBFF) | ^~ Fixes: 867a6ac86dd8 ("efi: Add start-up library code") Reported-by: Marek Vasut Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/efi_api.h b/include/efi_api.h index 9bd70b0f18..e1cdaf5247 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -817,7 +817,7 @@ struct efi_simple_text_output_protocol { struct efi_input_key { u16 scan_code; - s16 unicode_char; + u16 unicode_char; }; #define EFI_SHIFT_STATE_INVALID 0x00000000 From 60e3fedc64532c66f5bcd7c5c3d95e51ab2783e7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:23:24 +0100 Subject: [PATCH 14/23] efi_loader: add definition for efi_main() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit U-Boot provides multiple EFI applications. The entry point is called efi_main(). Provide a definition for this function. This avoids build warnings like lib/efi_loader/initrddump.c:468:21: warning: no previous prototype for ‘efi_main’ [-Wmissing-prototypes] 468 | efi_status_t EFIAPI efi_main(efi_handle_t image_handle, | ^~~~~~~~ Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index e1cdaf5247..2d18d25a71 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -513,6 +513,16 @@ struct efi_system_table { struct efi_configuration_table *tables; }; +/** + * efi_main() - entry point of EFI applications + * + * @image_handle: handle with the Loaded Image Protocol + * @systab: pointer to the system table + * Return: status code + */ +efi_status_t EFIAPI efi_main(efi_handle_t image_handle, + struct efi_system_table *systab); + #define EFI_LOADED_IMAGE_PROTOCOL_GUID \ EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \ 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) From 8d4c2c770c8935d4f1e06f8eb9d6416b8f63ea62 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 09:19:41 +0100 Subject: [PATCH 15/23] efi_loader: fix efi_ecpt_register() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit num_entries should be unsigned to avoid warnings. As the target field is u16 we should use this type. lib/efi_loader/efi_conformance.c: In function ‘efi_ecpt_register’: lib/efi_loader/efi_conformance.c:30:33: warning: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion] 30 | ecpt_size = num_entries * sizeof(efi_guid_t) | ^ lib/efi_loader/efi_conformance.c:46:36: warning: conversion from ‘int’ to ‘u16’ {aka ‘short unsigned int’} may change value [-Wconversion] 46 | ecpt->number_of_profiles = num_entries; | ^~~~~~~~~~~ Fixes: 6b92c1735205 ("efi: Create ECPT table") Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_conformance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_conformance.c b/lib/efi_loader/efi_conformance.c index 3036d46349..0ca26f57a7 100644 --- a/lib/efi_loader/efi_conformance.c +++ b/lib/efi_loader/efi_conformance.c @@ -22,7 +22,7 @@ static const efi_guid_t efi_ebbr_2_1_guid = */ efi_status_t efi_ecpt_register(void) { - int num_entries = 0; + u16 num_entries = 0; struct efi_conformance_profiles_table *ecpt; efi_status_t ret; size_t ecpt_size; From 575cfe7b47143673580cc0c0e4573c9e008f5207 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:45:38 +0100 Subject: [PATCH 16/23] efi_loader: static functions in helloworld.c Make functions that are not used externally static. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/helloworld.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c index d565f32745..49fa8cc2f0 100644 --- a/lib/efi_loader/helloworld.c +++ b/lib/efi_loader/helloworld.c @@ -125,7 +125,7 @@ static void print_config_tables(void) * @systable: system table * @con_out: simple text output protocol */ -void print_load_options(struct efi_loaded_image *loaded_image) +static void print_load_options(struct efi_loaded_image *loaded_image) { /* Output the load options */ con_out->output_string(con_out, u"Load options: "); @@ -143,6 +143,7 @@ void print_load_options(struct efi_loaded_image *loaded_image) * @device_path: device path to print * @dp2txt: device path to text protocol */ +static efi_status_t print_device_path(struct efi_device_path *device_path, struct efi_device_path_to_text_protocol *dp2txt) { From be6784789eb10391473bffbe72c643f2a8c565a4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:50:06 +0100 Subject: [PATCH 17/23] efi_loader: static functions in efi_boottime.c Make functions that are no used externally static. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index ba28989f36..caaab685ee 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -264,7 +264,7 @@ static void efi_queue_event(struct efi_event *event) * @tpl: TPL level to check * Return: status code */ -efi_status_t is_valid_tpl(efi_uintn_t tpl) +static efi_status_t is_valid_tpl(efi_uintn_t tpl) { switch (tpl) { case TPL_APPLICATION: @@ -592,7 +592,7 @@ efi_status_t efi_remove_protocol(const efi_handle_t handle, * * Return: status code */ -efi_status_t efi_remove_all_protocols(const efi_handle_t handle) +static efi_status_t efi_remove_all_protocols(const efi_handle_t handle) { struct efi_object *efiobj; struct efi_handler *protocol; @@ -728,6 +728,7 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, /* * efi_create_event_ex() - create an event in a group + * * @type: type of the event to create * @notify_tpl: task priority level of the event * @notify_function: notification function of the event @@ -742,6 +743,7 @@ efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl, * * Return: status code */ +static efi_status_t EFIAPI efi_create_event_ex(uint32_t type, efi_uintn_t notify_tpl, void (EFIAPI *notify_function) ( struct efi_event *event, From e7175f9320d9806e4c36ca3715d923b2a7dfcc7f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:51:41 +0100 Subject: [PATCH 18/23] efi_loader: static functions in efi_console.c Define function set_shift_mask() as static as it is not used externally. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 1ed8c7aa36..4317630907 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -669,7 +669,7 @@ static LIST_HEAD(cin_notify_functions); * @mod: Xterm shift mask * @key_state: receives the state of the shift, alt, control, and logo keys */ -void set_shift_mask(int mod, struct efi_key_state *key_state) +static void set_shift_mask(int mod, struct efi_key_state *key_state) { key_state->key_shift_state = EFI_SHIFT_STATE_VALID; if (mod) { From 6c2377f9a00d246cb77096564e5980e7c1d7b0e4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 08:56:06 +0100 Subject: [PATCH 19/23] efi_loader: static functions in efi_runtime.c Functions that are not used externally should be static. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_runtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index ad2ab825d1..cee96bfc7f 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -462,7 +462,7 @@ efi_status_t __weak __efi_runtime EFIAPI efi_set_time(struct efi_time *time) * @scatter_gather_list: pointer to array of physical pointers * Returns: status code */ -efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( +static efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, u64 scatter_gather_list) @@ -484,7 +484,7 @@ efi_status_t __efi_runtime EFIAPI efi_update_capsule_unsupported( * @reset_type: type of reset needed for capsule update * Returns: status code */ -efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported( +static efi_status_t __efi_runtime EFIAPI efi_query_capsule_caps_unsupported( struct efi_capsule_header **capsule_header_array, efi_uintn_t capsule_count, u64 *maximum_capsule_size, From a9f20ef37aae226e9d4366d764869bdcf32ddd82 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 09:01:13 +0100 Subject: [PATCH 20/23] efi_loader: provide definition for efi_add_known_memory() We should provide a definition in an include for efi_add_known_memory(). Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/efi_loader.h b/include/efi_loader.h index 4560b0d04c..c664d6cdf2 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -1137,4 +1137,11 @@ efi_status_t efi_console_get_u16_string efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int size); +/** + * efi_add_known_memory() - add memory banks to EFI memory map + * + * This weak function may be overridden for specific architectures. + */ +void efi_add_known_memory(void); + #endif /* _EFI_LOADER_H */ From b9276637ce6d84229d31ba9873a0a6211a9979fb Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 09:02:56 +0100 Subject: [PATCH 21/23] efi_loader: include definition of allow_unaligned() Add missing include. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_setup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index f0f01d3b1d..69aaefab63 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -11,6 +11,7 @@ #include #include #include +#include #define OBJ_LIST_NOT_INITIALIZED 1 From f28c4b22228e465c3d2535728dd40ce2ff5095fa Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 09:05:03 +0100 Subject: [PATCH 22/23] efi_loader: make gop_blt() static This function is not used externally. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_gop.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index d1dc2f22d0..778b693f98 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -400,11 +400,12 @@ out: * @delta: length in bytes of a line in the pixel buffer (optional) * Return: status code */ -efi_status_t EFIAPI gop_blt(struct efi_gop *this, struct efi_gop_pixel *buffer, - u32 operation, efi_uintn_t sx, - efi_uintn_t sy, efi_uintn_t dx, - efi_uintn_t dy, efi_uintn_t width, - efi_uintn_t height, efi_uintn_t delta) +static efi_status_t EFIAPI gop_blt(struct efi_gop *this, + struct efi_gop_pixel *buffer, + u32 operation, efi_uintn_t sx, + efi_uintn_t sy, efi_uintn_t dx, + efi_uintn_t dy, efi_uintn_t width, + efi_uintn_t height, efi_uintn_t delta) { efi_status_t ret = EFI_INVALID_PARAMETER; efi_uintn_t vid_bpp; From 124725732fdfd63ebb2f6514c690181ccbe13444 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 10 Feb 2023 09:06:17 +0100 Subject: [PATCH 23/23] efi_loader: static efi_query_variable_info_runtime() This function is not used externally and hence should be static. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 4d4dfa6b15..4c85cfa607 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -395,7 +395,7 @@ efi_status_t efi_query_variable_info_int(u32 attributes, * selected type * Returns: status code */ -efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime( +static efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime( u32 attributes, u64 *maximum_variable_storage_size, u64 *remaining_variable_storage_size,