[PATCH 2/3] cmd: add maximum boot option index Kconfig option
Heinrich Schuchardt
xypron.glpk at gmx.de
Wed Nov 23 08:26:21 CET 2022
On 11/23/22 08:17, Masahisa Kojima wrote:
> eficonfig command reads the all possible UEFI boot options
> from 0x0000 to 0xFFFF to construct the menu. This takes too much
> time in some environment, especially for the platform using
> OP-TEE and RPMB based secure storage.
> For example, on Socionext Developerbox, it takes more than 30 seconds
> to draw the boot option menu.
>
> To reduce the time to draw the menu, this patch introduces the
> maximum UEFI boot option index that eficonfig can manage.
We should avoid deviations from the UEFI specification.
There cannot be more boot options than UEFI variables. Instead of
iterating over Boot0000 to BootFFFF just iterate over all UEFI variables
to collect Boot#### entries using GetNextVariableName(). Afterwards
decide which ones are mentioned in BootOrder.
Best regards
Heinrich
>
> Signed-off-by: Masahisa Kojima <masahisa.kojima at linaro.org>
> ---
> cmd/Kconfig | 12 ++++++++++++
> cmd/eficonfig.c | 10 +++++-----
> 2 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 1092fb9c91..3978a5ef30 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1981,6 +1981,18 @@ config CMD_EFICONFIG
> Enable the 'eficonfig' command which provides the menu-driven UEFI
> variable maintenance interface.
>
> +config EFICONFIG_BOOT_OPTION_MAX_INDEX
> + int "Maximum index of UEFI Boot Option"
> + depends on CMD_EFICONFIG
> + default 99
> + help
> + Define the number of boot option entry that 'eficonfig' command
> + can manage.
> + In UEFI specification, the boot option is indexed from 0x0000
> + to 0xFFFF. 'eficonfig' command read the boot option from uefi
> + variable storage, reading all possible boot option may
> + significantly affect the performance of boot option enumeration.
> +
> config CMD_EXCEPTION
> bool "exception - raise exception"
> depends on ARM || RISCV || SANDBOX || X86
> diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> index 5529edc85e..20b9a29d3a 100644
> --- a/cmd/eficonfig.c
> +++ b/cmd/eficonfig.c
> @@ -1079,7 +1079,7 @@ efi_status_t eficonfig_get_unused_bootoption(u16 *buf, efi_uintn_t buf_size,
> if (buf_size < u16_strsize(u"Boot####"))
> return EFI_BUFFER_TOO_SMALL;
>
> - for (i = 0; i <= 0xFFFF; i++) {
> + for (i = 0; i <= CONFIG_EFICONFIG_BOOT_OPTION_MAX_INDEX; i++) {
> size = 0;
> efi_create_indexed_name(buf, buf_size, "Boot", i);
> ret = efi_get_variable_int(buf, &efi_global_variable_guid,
> @@ -1090,7 +1090,7 @@ efi_status_t eficonfig_get_unused_bootoption(u16 *buf, efi_uintn_t buf_size,
> break;
> }
>
> - if (i > 0xFFFF)
> + if (i > CONFIG_EFICONFIG_BOOT_OPTION_MAX_INDEX)
> return EFI_OUT_OF_RESOURCES;
>
> *index = i;
> @@ -1708,7 +1708,7 @@ static efi_status_t eficonfig_show_boot_selection(unsigned int *selected)
> }
>
> /* list the remaining load option not included in the BootOrder */
> - for (i = 0; i <= 0xFFFF; i++) {
> + for (i = 0; i <= CONFIG_EFICONFIG_BOOT_OPTION_MAX_INDEX; i++) {
> /* If the index is included in the BootOrder, skip it */
> if (search_bootorder(bootorder, num, i, NULL))
> continue;
> @@ -2007,7 +2007,7 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi
> }
>
> /* list the remaining load option not included in the BootOrder */
> - for (i = 0; i < 0xFFFF; i++) {
> + for (i = 0; i < CONFIG_EFICONFIG_BOOT_OPTION_MAX_INDEX; i++) {
> if (efi_menu->count >= EFICONFIG_ENTRY_NUM_MAX - 2)
> break;
>
> @@ -2278,7 +2278,7 @@ efi_status_t eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op
> u16 varname[] = u"Boot####";
> efi_status_t ret = EFI_SUCCESS;
>
> - for (i = 0; i <= 0xFFFF; i++) {
> + for (i = 0; i <= CONFIG_EFICONFIG_BOOT_OPTION_MAX_INDEX; i++) {
> efi_uintn_t tmp;
>
> efi_create_indexed_name(varname, sizeof(varname), "Boot", i);
More information about the U-Boot
mailing list