From patchwork Wed Nov 23 07:17:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 627917 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2966521pvb; Tue, 22 Nov 2022 23:17:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4XW2tCeYlGpogrQs6eeUNbNphX9aYS/i+KVTtoNOq85CbmlV19qfN/MZBhTLYMFEx9tl/B X-Received: by 2002:a05:6e02:12c2:b0:302:e38e:761b with SMTP id i2-20020a056e0212c200b00302e38e761bmr287358ilm.61.1669187861316; Tue, 22 Nov 2022 23:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669187861; cv=none; d=google.com; s=arc-20160816; b=RztMCQ9Ccf5h3VxGnTwBADQBmQcQLxsEWhXO26keVs3pV+IAL25cgIr0M3gPge62II 5xoonfdHsJl2hnQvYhYnjK+nAKcysDLRPjzmQfAnhxCld2P4xAPIQe65iABDYZS2vu8/ 7IagSRXcyMhweYCbMo4AXPRn3l6O39dXnobHsEVWizOntM3sbULn+G/6P1uP8eA3AGgk l/2rOe9Pc43O91TkAuiOMBva+0rgqk9Ve5znsT7hHa1FYXi/YOV/NOarDlGlbfTNjqC+ NcPpcs4sNIKAyDNhXuOyahn3IEmj10t51Ijxfknat2RRcGDO9ktcfUnYXspyZ2yE6Jvq Ecnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=pXDpghEsNMFUqpw/YcptGLuFQtSZlh02WqwTvFNapMg=; b=bLTVsyIalAmNpdOOvTJGMRPJ8SfyWyZUj86qgjEDIkFi5ecGQ+RmADQd69U6IrXRWo T1Dps6g/OwmVHoiMRZmd4Mylf4n/3JNufuw9yA7XuL7+OU56sFrzkFNGPaRAzAKEQGKv odhLpeOvI8+TAZyB86bRtGu3a8d7bKNotnKT6xLtTFxdvY9q3PmtJjQoSjpNjrh+61LM QyjPPv+7Z0xnqjwcx1DiUmwYjlv4eA8+USGrciJL6C08KcXezO47UjYdHlUX17fk8snD 3kT9dbE1i8DmnHFm2gLSeh6/LYFT5pbaNdWC4WXTOuVMBNpYqeWXX06f3A6njSoKtgym AWVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snUkGT6i; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id c9-20020a92cf49000000b00300e56f28b9si8041618ilr.139.2022.11.22.23.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:17:41 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=snUkGT6i; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 062918554C; Wed, 23 Nov 2022 08:17:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="snUkGT6i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CC8085565; Wed, 23 Nov 2022 08:17:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 01DB685411 for ; Wed, 23 Nov 2022 08:17:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pl1-x62a.google.com with SMTP id d6so2362843pll.7 for ; Tue, 22 Nov 2022 23:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=pXDpghEsNMFUqpw/YcptGLuFQtSZlh02WqwTvFNapMg=; b=snUkGT6iTVNsHulxF54BbdfyeaD3u9S+t3Ge783Et0dYevEvzj9Arm+8yoejPevEgi rf4TvX1DpuV7r71LUCZYi+QOTxcDbD/A7eV41CJGrQ027ZhGEYSWsvbHaj1EKiVtMchR NW34ASpquVyhjOcPZSdSG9LhOpjtux9BH1pZnv+q0XxtOyHgWcOLl2oYB9u3Vcw2A9Ma yb4tHpt+b41AvKs1syVRmp+VGa+F4HENbSonfU6Fpz5utDFHkho+4u2i31wN/HmDKLyn bD6ZaaYSoAi46CIsxhq0DKE2U0uDiBl+3wfILEIlAiHGBukt89KxiZMTOZjUraYsGBJ5 8PpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pXDpghEsNMFUqpw/YcptGLuFQtSZlh02WqwTvFNapMg=; b=ewLhhxaAsVnRpX0IMqW+TS8/C/AggVEHU4UodGlugGqrPnLfHEhoma6KJjR+jsM83z nnGEpWDhpxEJTAIeiHM97yv0tVCDYcQR6M8cUcgmNo9cFi3JsCxb0odm0XseqOwPeYnG FRzqC1U0TTLzd2MrP6oPIpxWdrpAKkrUD2Ye04x2faRU0ZOfd+0+nQLVM0eZe38kDKbo eT5ak6Dhs0O5g4hiEFY3DRqitdcOqQylj2GrAmtxZrE3DJvgH8fkKXcV5RnwJGaL8TX7 onG2sePJ3UX2PEN5M1jRhC9Fkk5wRFjEXbJVNXZT6mykeDzmpasWOC+CVqkAVT3sKOE1 sjSQ== X-Gm-Message-State: ANoB5pkmGdxFEvG86kK3FxTc7sNvx2ss7tIRyYBsAewQilZ2kP7Fz35X BvcHasr4Mqj2vq899ZPSotGjCX9qmj+GOA== X-Received: by 2002:a17:90a:1a11:b0:213:f398:ed51 with SMTP id 17-20020a17090a1a1100b00213f398ed51mr28930236pjk.216.1669187837038; Tue, 22 Nov 2022 23:17:17 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id n20-20020a170902d0d400b0016d72804664sm5512863pln.205.2022.11.22.23.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 23:17:16 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , Ovidiu Panait , Ashok Reddy Soma Subject: [PATCH 2/3] cmd: add maximum boot option index Kconfig option Date: Wed, 23 Nov 2022 16:17:09 +0900 Message-Id: <20221123071710.28506-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123071710.28506-1-masahisa.kojima@linaro.org> References: <20221123071710.28506-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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. Signed-off-by: Masahisa Kojima --- 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);