From patchwork Fri Dec 2 04:59:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 630191 Delivered-To: patch@linaro.org Received: by 2002:a17:906:9c8c:b0:7c0:a5ce:226a with SMTP id fj12csp903265ejc; Thu, 1 Dec 2022 21:00:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4dc307xIgb2Sn1trXmgRCqy0351exOL3uqa9qdrbTD01U89VCGRmduHexRiAY/sh5q2D3L X-Received: by 2002:a05:6638:34a1:b0:38a:2138:5d25 with SMTP id t33-20020a05663834a100b0038a21385d25mr416587jal.273.1669957220631; Thu, 01 Dec 2022 21:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669957220; cv=none; d=google.com; s=arc-20160816; b=x9kE0jS8CKppt0IAAwbpc++/w3OHBL/g5ZA1bFj8HcaLHWpMU6suahBsxD+9kfB7Mz jf6Pt/1W2iJgT+XdWnkvUW26aIFfsC4tAI1APbQmA4epLzjtkK/bKpH/ERbvj053CXvR Ttat8BYZ5RmwPzvt5LQ/QfAzvmYwdc4HODQMwvnL+/8Jx9AOrP6W4kbhTpwOj7nUToOf sO3M3JMoRoXmXBT9sFCyNTQdR7g3acgPifvKcK9/qGCF6r8nhzupunvlKN//Es3aDZcA ZrlUL60R8MLIUm0UlzW2Jl9zRsqcoR5B6su27dtuUTms1o2ul/PP8ypRjyS7Gh0pd6aZ LRsQ== 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=LpKwKuv6nmxPh7XEkrWYyb0202mdchBNzTeGK9wi7VA=; b=fAU2OTTMlPLibekXiKlxzUrP7mES7teqSqhNi52z3PczR6oK5CZfvFS8NzOAQmCOsl Rruap0LRx963foQrfRETInD45THue0a5mqNlWh4c8lSsyHkCy7uC5WaLgd04+Lm/xEKR E9XH/IkCocktzrPhdxs21sJKlapWNwUYgjYESK1y2YHsBWEhTW8t+sZPcc3KUg6LBCMB /SG+bB8d9rspZJg52ZHV0i195wrBx5MZt6VXPPsQsEmd5SrVDRuAqXqkzzHGoOA6klAy A0+TeWxihmD5khXJeXylAMW2+Ys/h52pmrvLJpB5Iah74iAnWHXCNrXrcPGah5aReMpW ifLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hc8H56E8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id n38-20020a056602342600b006dc21cabdf9si4852256ioz.1.2022.12.01.21.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:00:20 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hc8H56E8; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 A4A088544D; Fri, 2 Dec 2022 05:59:58 +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="hc8H56E8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D4B6B85439; Fri, 2 Dec 2022 05:59:53 +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-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) (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 4EB1785440 for ; Fri, 2 Dec 2022 05:59:51 +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-pg1-x52b.google.com with SMTP id q1so3469885pgl.11 for ; Thu, 01 Dec 2022 20:59:51 -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=LpKwKuv6nmxPh7XEkrWYyb0202mdchBNzTeGK9wi7VA=; b=hc8H56E8fidGN+QITYqO9v39/R9Um0Sf5jBRj3XnjOQaNjXeZf3F3jojcA2hT7nKPD bGV1AcGBrBmRVX2pk7TPDDQSZlYS1m8l/vGcq4GuWn+J2oqdrNsFQ1jaK7rt9wH3Tq5j 3E2qVIiqouowkR4ui//CVpFktOTjnmCnfSzNiycWkjjpmqE5qdD6SRfWa4nXAQ1et57A MBUuG1M+l3VNXUN6DsWVXbDWMfqMt5oOGg/uqkZSlDQEBJlJhwtuu0ezu0+2i2PNwIcC KEVyl6Vw89egFVbbtUReqXzQaAZx9cZ8FtB8RWJDBy2eQFdUiSpx8QkvI9I5UCiGpQQg piYQ== 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=LpKwKuv6nmxPh7XEkrWYyb0202mdchBNzTeGK9wi7VA=; b=qI5IVbA2sw+HzFLmI359W5QPnUskFXX/E/tTr0UCHFx/MmU+MgByHPaK6X5746uEd+ BwwLoH0E4eRYnA3BobD822poMA4BN7eF17r1jFxGj293furnh11081vQ7SP031j74BNy cBqHGoQnQCHQAy7VQ49ppMovXNujdBEa8JdcEHC0balsRKfjt9gpHsAXlaRtEi94daaN g9lOqViUNISC+iENoJFTAGUVc1Trx1YP2AEtg+ox9Oxwqzs5n8SFzzqVRkNH6O0GZKF0 q8D1c0Ul8eYP5YDXVOdslPQTDgfq/GnYqC8TKheQZQG+r0VO+tn4VZCexEcXm4YMt4z7 7bIg== X-Gm-Message-State: ANoB5pnh7XtcmO6r6XfZ/725xa9ukdJtYaWN85b8fEdX26eRy4NEeuQ7 gQC4Z6bvbOlznlzk4xelFVoY7gr+TrFBJ7/l X-Received: by 2002:a63:f503:0:b0:470:4acb:1eb with SMTP id w3-20020a63f503000000b004704acb01ebmr43013890pgh.440.1669957190520; Thu, 01 Dec 2022 20:59:50 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id z27-20020aa7949b000000b00575fbe1cf31sm3234456pfk.67.2022.12.01.20.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 20:59:49 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v3 1/5] eficonfig: fix going one directory up issue Date: Fri, 2 Dec 2022 13:59:33 +0900 Message-Id: <20221202045937.7846-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202045937.7846-1-masahisa.kojima@linaro.org> References: <20221202045937.7846-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 The directory name in eficonfig menu entry contains the '\' separator. strcmp() argument ".." is wrong and one directory up handling does not work correctly. strcmp() argument must include '\' separator. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- No change since v1 cmd/eficonfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 97d35597a2..5529edc85e 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -488,7 +488,7 @@ static efi_status_t eficonfig_file_selected(void *data) if (!info) return EFI_INVALID_PARAMETER; - if (!strcmp(info->file_name, "..")) { + if (!strcmp(info->file_name, "..\\")) { struct eficonfig_filepath_info *iter; struct list_head *pos, *n; int is_last; From patchwork Fri Dec 2 04:59:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 630192 Delivered-To: patch@linaro.org Received: by 2002:a17:906:9c8c:b0:7c0:a5ce:226a with SMTP id fj12csp903363ejc; Thu, 1 Dec 2022 21:00:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YlgkT+6mp9POugidMOnL3EWMq1h3Zn3fF2lg1GmV9cJgu4sE7tMP8W5lcF4yyWr5LNIy3 X-Received: by 2002:a05:6638:ca4:b0:389:dbc8:c058 with SMTP id x4-20020a0566380ca400b00389dbc8c058mr12207612jad.10.1669957235233; Thu, 01 Dec 2022 21:00:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669957235; cv=none; d=google.com; s=arc-20160816; b=tGfn7DaronFgTSLfUioIlri1oT6g6lJ6ZLAc5yQmCCRagx9UdEr/wGtAj/OkM7A4c0 18AbZKCc9FqE8xhwtuy+r0ebx3r6by/65RdOsXhJI2V+GAb6tFBvQcUMWqZFKe6Pxkou 8nkrCwX7OP1rGZmE9uryYdZnnwEgDNw7MYzM7zgueOFLNlch5mHXRdvwLquUcCHeOUJ4 nvhJAhyda/Gg8/Zp/RxBrjSs8P6tj3r+VyyizrrY4sRP+Iehefk1+6b9nDr4pQgSsHFP M2L7q0ceVWYgpMY/bJMOHRfBEgSk5KM+edUFb9ZJyoGWWFfptUmMAqug4ziZIF+nLGu8 oYaA== 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=S5v+DipCYjKetPPz6/+HLl16R221oH+bNOTlG6ddslo=; b=HD3IS2DeCYqPt59Dm53KCZ/IMro0O2tbqN3aSvKU2w9TOTkXyuqMjaB5h1aP7D/7Rp SFolpH9Hm6ITmiFRcVbEV0MckkbmGl2F7v1Oe1sm/IosJeqvgFzyK+5oy5DqmqJw9nFh 5TgY5dXt1SqG1DDXoIG4Mo1bt8vYGbnlOeU6LgHHqBWOCyOtnECOXbfuBVSg17UwuexV 5NylLqbssdf3oofbCdnUhSwsHrWQYinu5I8E3ZE0G8TtOihR+XCu29RZ+QRe18Kl0Wbv hfwA0JA/1Ljuhu3DjnHB6BYxBudARm/tGV23VuKNwGY1jcIhUyNsi69B/eMxDPHIl3lC KNuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UzdSQiik; 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 m21-20020a026d15000000b00375dad8d905si4742434jac.21.2022.12.01.21.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:00:35 -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=UzdSQiik; 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 E427F8545A; Fri, 2 Dec 2022 06:00: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=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="UzdSQiik"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9D1478544E; Fri, 2 Dec 2022 05:59:59 +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-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) (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 2B1FB85445 for ; Fri, 2 Dec 2022 05:59:55 +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-pj1-x1035.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so7250023pjc.3 for ; Thu, 01 Dec 2022 20:59:55 -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=S5v+DipCYjKetPPz6/+HLl16R221oH+bNOTlG6ddslo=; b=UzdSQiikB7cmX0ZahKkhYONOZ7LlSCyTXkxuCRL0w7cj+z+lbijUKfL+ZD/pvalbCA vqHTOV1pR/5FWR+X+iq8zTsgnicuI8fD7++55UXlDQUC4mhxMXhENgHIDO8vP7d+Who4 mY8IhdB0StTilowPnmhMeBXMnbQuNGHPfpCX5e/VjesOPWrgxkzSiex5AxddfyVA+uR+ HfcG/T2GUpiTqCIG6sE6mfItNcD692IRztU1W/hKtExMnhryviYpXCWPaC9b8B+slwjJ Diz6Q2eCQ4RGHFV1H3EMpho+gmfFA+RTn6WUIF/RHe+NzBPIIJUpAKEV/w+jUwGTZBDc 2eJg== 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=S5v+DipCYjKetPPz6/+HLl16R221oH+bNOTlG6ddslo=; b=YqtPR6tUdLARV8G7qBIqGPrLNS6r4vzHJ8lBJbZXAcx383lTAl71kaPiOOZ/tSk7mJ GuYdmOnoMI5iJywNEZCSJTia64PONSZfRiR7sz5ZGTd+F2us5U061MIiZu2NNIGgUOXk KfXp3nBMBCaZgh0yuyOsSLTnq6SjBvMujVItd9H+ZKbAKBWEWMntFqG5Aitq74oxcOa4 jVHnTAH3hCnNRa69m5H1TFpN0Ifik1NJTP0wzkc7KAPZl76VY06pBzBu7le53tl0SBJv rxYF01jV3s6b371PT1dKnQ5Jke/vGHluchjgWEwBx5uTNotcIRhfqN56jYFqQpVTTCmB eNDw== X-Gm-Message-State: ANoB5pkfUs16iuWA8QGSzMPr4Bo0CJZh6MqieezjXxRpPDo0e2dYxiAm CrfJ3pEgxKQzVfJyBcC6TJxPIUh9WAK/SEV0 X-Received: by 2002:a17:90a:4fc1:b0:213:16b5:f45e with SMTP id q59-20020a17090a4fc100b0021316b5f45emr78327338pjh.170.1669957192972; Thu, 01 Dec 2022 20:59:52 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id z27-20020aa7949b000000b00575fbe1cf31sm3234456pfk.67.2022.12.01.20.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 20:59:52 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v3 2/5] eficonfig: use u16_strsize() to get u16 string buffer size Date: Fri, 2 Dec 2022 13:59:34 +0900 Message-Id: <20221202045937.7846-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202045937.7846-1-masahisa.kojima@linaro.org> References: <20221202045937.7846-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 Use u16_strsize() to simplify the u16 string buffer size calculation. Signed-off-by: Masahisa Kojima Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- No update since v1. cmd/eficonfig.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 5529edc85e..88d507d04c 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -452,8 +452,7 @@ struct efi_device_path *eficonfig_create_device_path(struct efi_device_path *dp_ struct efi_device_path *dp; struct efi_device_path_file_path *fp; - fp_size = sizeof(struct efi_device_path) + - ((u16_strlen(current_path) + 1) * sizeof(u16)); + fp_size = sizeof(struct efi_device_path) + u16_strsize(current_path); buf = calloc(1, fp_size + sizeof(END)); if (!buf) return NULL; From patchwork Fri Dec 2 04:59:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 630193 Delivered-To: patch@linaro.org Received: by 2002:a17:906:9c8c:b0:7c0:a5ce:226a with SMTP id fj12csp903488ejc; Thu, 1 Dec 2022 21:00:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6U5lBZ3itS3VjFDuht8TSh6gmf+eJrZDD4sYLMafGzQ8x6AEPa/WtAHS/VmyugEkGB2atg X-Received: by 2002:a02:c897:0:b0:374:100a:b0c7 with SMTP id m23-20020a02c897000000b00374100ab0c7mr24196784jao.185.1669957248670; Thu, 01 Dec 2022 21:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669957248; cv=none; d=google.com; s=arc-20160816; b=VXQ99ReeGyptTAmxytqJJLwb7DKbYY1ykkX28BJ3MEt2x9tG0hWnI99xOpKvZBlHcw Fbpls8EExmHk+x2tFDIMgYKPDp+Ib1YZtpRoT+CuxAiAhP0Otvn8t65hitLOVaBbbnIC JOR4whqF2XBU+iMDwWK+hT7O/JmZ8iCVqn/yxhmSgqJAhmRnCmrMxqPEL0Cr68a4yNDq y4Yfs/3LlQJ4ln9f9TQfRHSf5JDuC9zKOFC2yMa4U4STV7qvF1Dk7bH+NiH0XbacDa29 cnGQesr7jCVKoRGrSkriJrrLoOwoON2tke7h3YDdRFLzZIekhdWufBCFiIW7az/lacAh cJVw== 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=DWpIc09y3cY4o59Y13swgpi3Gjilon5p2T/Sn6ZbRw0=; b=FiAl7tY/Hb3lgDCqREOxAqVRIh2LswrWoEU1Hn9TyH5fEPj8tbFgmLJjYYasvsV5Wl OhNaTQM5vT6csnXfUkG+RoOyp+WYx4kNaYtqkkzDiuNtlyTLQo0ReXI6IiPsOM8VMShS /4SlB3BJbY3Wa68j66u4ozU79S44HJmtPF0LitiDgcDfYM9bc8DSQsQMuh3twaQPchVV s0LGAHLimv81/JOonH6jQZVNTTnEeacZkXW+cFXXM4kIPhEA2R6vtDhmkTnNU7I5itNP x1ECAnkLMBugQrpjw7e2uwStwYbws/qI4x7mLyNcOI0ln9e6D3QtLn7Ie6jZ+nl/hHo9 g/Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wO8HHRw5; 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 b9-20020a92ce09000000b002f8140b4ff3si3730571ilo.103.2022.12.01.21.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:00:48 -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=wO8HHRw5; 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 42BCE85445; Fri, 2 Dec 2022 06:00:31 +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="wO8HHRw5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C00F8544C; Fri, 2 Dec 2022 06:00:10 +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-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (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 8A2F78544A for ; Fri, 2 Dec 2022 05:59:57 +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-pf1-x434.google.com with SMTP id r7so3864574pfl.11 for ; Thu, 01 Dec 2022 20:59:57 -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=DWpIc09y3cY4o59Y13swgpi3Gjilon5p2T/Sn6ZbRw0=; b=wO8HHRw5IdVNn2YiCvBFFb6Utpm0FY3OyXpTt96e3nYnW1mXPvvsUskBuOtSTFsmeG I0hd5mUsXDS23SXNXwNSqdygMpmHcjyCYNF9OObq6ZScYqQhvBDYWFDWK0oSO/ISbQQK BmyG8U+Mm7xV18D6NCHDAB6HOuIq+5hGiisBquaMFmkQxUwSvnu8wddkDkP7CDyTvpFo irfn3/VxWtYhkLo+GhYKEgMXKd+Fejpmj+Om2wzpxIBntU1HMjwyl74E7nIF1eAWGmnj 8BErpBlMCFNGc7nCRJxDJBuRAZEf/0Kvq3H21lh6KdAghU1oeMrAfthIU1WsIt4cQBGx SFzg== 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=DWpIc09y3cY4o59Y13swgpi3Gjilon5p2T/Sn6ZbRw0=; b=gWjeQsN4sr46PdcZcA/gzJbC+997QZdNCc1jvFqzkX+vkJB1qy2BuzRneFMCEPYf0d 6WLEJMm0FRsWQD/zXQrwGGEzgV2PBjUXxyaYJxUyt5fcLSL/LXGHp5TW3flw1dqhpcPA PpzFH6pfnAGV2v+9zXjxP8+QLkKXItBhS0xNkb6JJg1wH4HKzyoxXDZakV/wIJimcoQ4 B8uZMyGdUTffi6RBEAIF+9KDq3hqZBDmmNsAMr+kG/1d2wD08y6mwY33JKbxypMl0eR6 p98o1OOkpsyNq+/CNoa1cXKxQNAf2dcxMMBlefFrIty6DyXEAP2cCOdE+hO0HTb+r+OQ FAVQ== X-Gm-Message-State: ANoB5pnglfOyibNu8mDz09zLPsnG6oXUBmX4AAqLkKsd/cu/wrPoxfFf nkhz9k3fdqu7DsnT2AXuXBmUFTYED6tBDe00 X-Received: by 2002:a62:1c95:0:b0:571:baf8:8945 with SMTP id c143-20020a621c95000000b00571baf88945mr50434964pfc.83.1669957195254; Thu, 01 Dec 2022 20:59:55 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id z27-20020aa7949b000000b00575fbe1cf31sm3234456pfk.67.2022.12.01.20.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 20:59:54 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v3 3/5] efi_loader: utility function to check the variable name is "Boot####" Date: Fri, 2 Dec 2022 13:59:35 +0900 Message-Id: <20221202045937.7846-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202045937.7846-1-masahisa.kojima@linaro.org> References: <20221202045937.7846-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 Some commands need to enumerate the existing UEFI load option variable("Boot####"). This commit transfers some code from cmd/efidebug.c to lib/efi_loder/, then exposes efi_varname_is_load_option() function to check whether the UEFI variable name is "Boot####". Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- v2->v3: - add static qualifier to u16_tohex() Newly created in v2 cmd/efidebug.c | 23 +---------------------- include/efi_loader.h | 1 + lib/efi_loader/efi_helper.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index ef239bb34b..ceb3aa5cee 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1010,17 +1010,6 @@ static void show_efi_boot_opt(u16 *varname16) } } -static int u16_tohex(u16 c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - - /* not hexadecimal */ - return -1; -} - /** * show_efi_boot_dump() - dump all UEFI load options * @@ -1041,7 +1030,6 @@ static int do_efi_boot_dump(struct cmd_tbl *cmdtp, int flag, u16 *var_name16, *p; efi_uintn_t buf_size, size; efi_guid_t guid; - int id, i, digit; efi_status_t ret; if (argc > 1) @@ -1074,16 +1062,7 @@ static int do_efi_boot_dump(struct cmd_tbl *cmdtp, int flag, return CMD_RET_FAILURE; } - if (memcmp(var_name16, u"Boot", 8)) - continue; - - for (id = 0, i = 0; i < 4; i++) { - digit = u16_tohex(var_name16[4 + i]); - if (digit < 0) - break; - id = (id << 4) + digit; - } - if (i == 4 && !var_name16[8]) + if (efi_varname_is_load_option(var_name16, NULL)) show_efi_boot_opt(var_name16); } diff --git a/include/efi_loader.h b/include/efi_loader.h index 0c6c95ba46..0899e293e5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -707,6 +707,7 @@ int algo_to_len(const char *algo); int efi_link_dev(efi_handle_t handle, struct udevice *dev); int efi_unlink_dev(efi_handle_t handle); +bool efi_varname_is_load_option(u16 *var_name16, int *index); /** * efi_size_in_pages() - convert size in bytes to size in pages diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index c71e87d118..788cb9faec 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -190,3 +190,36 @@ int efi_unlink_dev(efi_handle_t handle) return 0; } + +static int u16_tohex(u16 c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + + /* not hexadecimal */ + return -1; +} + +bool efi_varname_is_load_option(u16 *var_name16, int *index) +{ + int id, i, digit; + + if (memcmp(var_name16, u"Boot", 8)) + return false; + + for (id = 0, i = 0; i < 4; i++) { + digit = u16_tohex(var_name16[4 + i]); + if (digit < 0) + break; + id = (id << 4) + digit; + } + if (i == 4 && !var_name16[8]) { + if (index) + *index = id; + return true; + } + + return false; +} From patchwork Fri Dec 2 04:59:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 630194 Delivered-To: patch@linaro.org Received: by 2002:a17:906:9c8c:b0:7c0:a5ce:226a with SMTP id fj12csp903590ejc; Thu, 1 Dec 2022 21:01:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf68Cc57+PGDyURzDuPeoOHiqTNCZE1QujUnkHAAPL9ohkQyiyh5XtfcsoB1bMhyoAXsVMpy X-Received: by 2002:a5e:9515:0:b0:6df:e6e8:39fd with SMTP id r21-20020a5e9515000000b006dfe6e839fdmr1152235ioj.24.1669957261108; Thu, 01 Dec 2022 21:01:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669957261; cv=none; d=google.com; s=arc-20160816; b=YKBW/RyO4MkxtGp35Bs9t9yAE4HfsD9jvqmKJfCc7DFrE92AXTZDg6qUoe/B7g8Jks s/oIWQx4d11nO58KckaWLBtazQ9rtLmDG3hFhdo5gdTM1Abie0WwUfXB7ZfvdQs1yTI1 l0v+XsseIORqQnucEyEN56RNLQAaoCgR6Cdurh5ccx0TkmZ0T/I0WaqqPFkC7ZOc/1aE vO1TbLzf3Xng7TJJQty6Tvi9CdVDsAt0bHaA5GeLko7+FHJW0qbo4ZLTLxeiDM/z5iiK 43sDTizRoDFtTYMr2gE4epNZLmjVvu+o1w+w6trY5jJg2AYgweRo4D0YYX2DIhh57UQn FODw== 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=JwVaoFqkTKjsdH9BGs/xnhh8pUYAScZ75/3kFTxkHEM=; b=LN9fAMVjcyK3LEWcl+g/oydR85vhfHLh38onlnm+zjlPt4fQZO5oPOlOJ4s4dfX+qj MojjK81SOAqxeO0ti37LsO8/+bYqIMI/9Zgjl4fINSAmzJ0a84Q7a0q2YAULkad3kfpi cKLLXFcoN5t1c0kmkb4BTMLnvT7V72BXmzMPZ/nGtbgfFcFWsvdxc6KJdO10hXBjNdSz 4i+e8zuBkXDCqIfE+JYN0PbJjcCG2Nj0keE8YUlSHHigzLz/UQDd/+gOFBzbahy+zKMm +5Z5xz9yCaRYx/4IIrwwoZ8qlojGx+iqb6Onj5LIXk2Bw9/4iTbpm3K8vAoSNX1/QgL6 rCig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DwKrpzZX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id j14-20020a056e02220e00b003031ed0a479si4881979ilf.175.2022.12.01.21.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:01:01 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DwKrpzZX; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 091258544A; Fri, 2 Dec 2022 06:00:38 +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="DwKrpzZX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B90D85460; Fri, 2 Dec 2022 06:00:31 +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-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 1F41985445 for ; Fri, 2 Dec 2022 06:00:00 +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-pg1-x530.google.com with SMTP id s196so3500302pgs.3 for ; Thu, 01 Dec 2022 21:00:00 -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=JwVaoFqkTKjsdH9BGs/xnhh8pUYAScZ75/3kFTxkHEM=; b=DwKrpzZXwvBU1KxdnUr1Q34CDnN9jlJe1cuz6/SMFhE5w/yhsCQ4jVNAY507f/ZB4J Ov5sK0d3rbpngrdjFmQer/WNb/ttxwilFCNWGlmFpCo/u3ugZoIN481lKgRKl0vydA1o 7tvfy6H6gcvaFeF6KK7JewXPn5qFTGQovBF7GW+jAoVs29Lx5BRoKLdBHJjJGLQDy6c8 TFDP8/L0pBBCy+G6MeXbUQp97mp9339nPwKH1sI3WybjSYZ0grHcWgK2+EZqsEu2WQFY DpMoKhXOyN2VRSfCWKl6Qk53106/yq8V8jlJJzmoYkgRxJm69Pb1KFU24V7/IXwQy65v DwDA== 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=JwVaoFqkTKjsdH9BGs/xnhh8pUYAScZ75/3kFTxkHEM=; b=HN8HVSwRHdMmFOMZDAOUFyOCpiRogiJJR/9iwnhl+SseCFTIQ0RnRXgL1MtUstb2WS 4fbTTUtULPuRGbeP/5xFHp3Y/J/WJ9KjLqcDDaOzxDzXmlcL2gZ3PnUPjf4Qs1J7ZS2B lxZJPsQWeO8oi55Urj7tCFTqcQey7DztzXXfWjh1iBoi6alyCWWY7zTOVQRAlfsmH9lM Edhta1o18Rme7kWT9mY3ivRpnpeo2V8a1XoPXMop6Cgfa80KAKaCOS9nJXNa3K8GOUh5 HuKJt5gocWq1gHDXAKAXbMVdwiomGzNHWLY+/ZBRq0TTVHdx00q5jNsHnd3ywjWOsjFT +A2w== X-Gm-Message-State: ANoB5pn+su+UDRb03FYTrbFeiOdXLAveQCsEi1ubZzRLtk9f1zbz0Yhv 6PO9JDeYiipoAeQKDYrzFXnAKDhjS18OluCy X-Received: by 2002:a05:6a00:1941:b0:56b:a80f:38d4 with SMTP id s1-20020a056a00194100b0056ba80f38d4mr51263025pfk.12.1669957197608; Thu, 01 Dec 2022 20:59:57 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id z27-20020aa7949b000000b00575fbe1cf31sm3234456pfk.67.2022.12.01.20.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 20:59:56 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v3 4/5] eficonfig: use efi_get_next_variable_name_int() Date: Fri, 2 Dec 2022 13:59:36 +0900 Message-Id: <20221202045937.7846-5-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202045937.7846-1-masahisa.kojima@linaro.org> References: <20221202045937.7846-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 all possible UEFI load options from 0x0000 to 0xFFFF to construct the menu. This takes too much time in some environment. This commit uses efi_get_next_variable_name_int() to read all existing UEFI load options to significantlly reduce the count of efi_get_var() call. Signed-off-by: Masahisa Kojima --- No update since v2 v1->v2: - totaly change the implemention, remove new Kconfig introduced in v1. - use efi_get_next_variable_name_int() to read the all existing UEFI variables, then enumerate the "Boot####" variables - this commit does not provide the common function to enumerate all "Boot####" variables. I think common function does not simplify the implementation, because caller of efi_get_next_variable_name_int() needs to remember original buffer size, new buffer size and buffer address and it is a bit complicated when we consider to create common function. cmd/eficonfig.c | 141 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 117 insertions(+), 24 deletions(-) diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 88d507d04c..394ae67cce 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -1683,7 +1683,8 @@ static efi_status_t eficonfig_show_boot_selection(unsigned int *selected) u32 i; u16 *bootorder; efi_status_t ret; - efi_uintn_t num, size; + u16 *var_name16 = NULL, *p; + efi_uintn_t num, size, buf_size; struct efimenu *efi_menu; struct list_head *pos, *n; struct eficonfig_entry *entry; @@ -1707,14 +1708,43 @@ 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++) { - /* If the index is included in the BootOrder, skip it */ - if (search_bootorder(bootorder, num, i, NULL)) - continue; + buf_size = 128; + var_name16 = malloc(buf_size); + if (!var_name16) + return EFI_OUT_OF_RESOURCES; - ret = eficonfig_add_boot_selection_entry(efi_menu, i, selected); - if (ret != EFI_SUCCESS) - goto out; + var_name16[0] = 0; + for (;;) { + int index; + efi_guid_t guid; + + size = buf_size; + ret = efi_get_next_variable_name_int(&size, var_name16, &guid); + if (ret == EFI_NOT_FOUND) + break; + if (ret == EFI_BUFFER_TOO_SMALL) { + buf_size = size; + p = realloc(var_name16, buf_size); + if (!p) { + free(var_name16); + return EFI_OUT_OF_RESOURCES; + } + var_name16 = p; + ret = efi_get_next_variable_name_int(&size, var_name16, &guid); + } + if (ret != EFI_SUCCESS) { + free(var_name16); + return ret; + } + if (efi_varname_is_load_option(var_name16, &index)) { + /* If the index is included in the BootOrder, skip it */ + if (search_bootorder(bootorder, num, index, NULL)) + continue; + + ret = eficonfig_add_boot_selection_entry(efi_menu, index, selected); + if (ret != EFI_SUCCESS) + goto out; + } if (efi_menu->count >= EFICONFIG_ENTRY_NUM_MAX - 1) break; @@ -1732,6 +1762,8 @@ out: } eficonfig_destroy(efi_menu); + free(var_name16); + return ret; } @@ -1994,6 +2026,8 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi u32 i; char *title; efi_status_t ret; + u16 *var_name16 = NULL, *p; + efi_uintn_t size, buf_size; /* list the load option in the order of BootOrder variable */ for (i = 0; i < num; i++) { @@ -2006,17 +2040,45 @@ 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++) { + buf_size = 128; + var_name16 = malloc(buf_size); + if (!var_name16) + return EFI_OUT_OF_RESOURCES; + + var_name16[0] = 0; + for (;;) { + int index; + efi_guid_t guid; + if (efi_menu->count >= EFICONFIG_ENTRY_NUM_MAX - 2) break; - /* If the index is included in the BootOrder, skip it */ - if (search_bootorder(bootorder, num, i, NULL)) - continue; - - ret = eficonfig_add_change_boot_order_entry(efi_menu, i, false); + size = buf_size; + ret = efi_get_next_variable_name_int(&size, var_name16, &guid); + if (ret == EFI_NOT_FOUND) + break; + if (ret == EFI_BUFFER_TOO_SMALL) { + buf_size = size; + p = realloc(var_name16, buf_size); + if (!p) { + ret = EFI_OUT_OF_RESOURCES; + goto out; + } + var_name16 = p; + ret = efi_get_next_variable_name_int(&size, var_name16, &guid); + } if (ret != EFI_SUCCESS) goto out; + + if (efi_varname_is_load_option(var_name16, &index)) { + /* If the index is included in the BootOrder, skip it */ + if (search_bootorder(bootorder, num, index, NULL)) + continue; + + ret = eficonfig_add_change_boot_order_entry(efi_menu, index, false); + if (ret != EFI_SUCCESS) + goto out; + } } /* add "Save" and "Quit" entries */ @@ -2035,9 +2097,9 @@ static efi_status_t eficonfig_create_change_boot_order_entry(struct efimenu *efi goto out; efi_menu->active = 0; - - return EFI_SUCCESS; out: + free(var_name16); + return ret; } @@ -2270,17 +2332,48 @@ out: efi_status_t eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_option *opt, efi_status_t count) { - u32 i, j; + u32 i; efi_uintn_t size; void *load_option; struct efi_load_option lo; + u16 *var_name16 = NULL, *p; u16 varname[] = u"Boot####"; efi_status_t ret = EFI_SUCCESS; + efi_uintn_t varname_size, buf_size; - for (i = 0; i <= 0xFFFF; i++) { + buf_size = 128; + var_name16 = malloc(buf_size); + if (!var_name16) + return EFI_OUT_OF_RESOURCES; + + var_name16[0] = 0; + for (;;) { + int index; + efi_guid_t guid; efi_uintn_t tmp; - efi_create_indexed_name(varname, sizeof(varname), "Boot", i); + varname_size = buf_size; + ret = efi_get_next_variable_name_int(&varname_size, var_name16, &guid); + if (ret == EFI_NOT_FOUND) + break; + if (ret == EFI_BUFFER_TOO_SMALL) { + buf_size = varname_size; + p = realloc(var_name16, buf_size); + if (!p) { + free(var_name16); + return EFI_OUT_OF_RESOURCES; + } + var_name16 = p; + ret = efi_get_next_variable_name_int(&varname_size, var_name16, &guid); + } + if (ret != EFI_SUCCESS) { + free(var_name16); + return ret; + } + if (!efi_varname_is_load_option(var_name16, &index)) + continue; + + efi_create_indexed_name(varname, sizeof(varname), "Boot", index); load_option = efi_get_var(varname, &efi_global_variable_guid, &size); if (!load_option) continue; @@ -2292,15 +2385,15 @@ efi_status_t eficonfig_delete_invalid_boot_option(struct eficonfig_media_boot_op if (size >= sizeof(efi_guid_bootmenu_auto_generated)) { if (guidcmp(lo.optional_data, &efi_guid_bootmenu_auto_generated) == 0) { - for (j = 0; j < count; j++) { - if (opt[j].size == tmp && - memcmp(opt[j].lo, load_option, tmp) == 0) { - opt[j].exist = true; + for (i = 0; i < count; i++) { + if (opt[i].size == tmp && + memcmp(opt[i].lo, load_option, tmp) == 0) { + opt[i].exist = true; break; } } - if (j == count) { + if (i == count) { ret = delete_boot_option(i); if (ret != EFI_SUCCESS) { free(load_option); From patchwork Fri Dec 2 04:59:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 630195 Delivered-To: patch@linaro.org Received: by 2002:a17:906:9c8c:b0:7c0:a5ce:226a with SMTP id fj12csp903710ejc; Thu, 1 Dec 2022 21:01:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7GJV0BOBQgBSv/bni07j2zbnrdsqn05LD1MUUcjzOGEnaUfm3sWI9hUnd7CRQxudSDV5wA X-Received: by 2002:a05:6e02:d94:b0:302:a008:83e5 with SMTP id i20-20020a056e020d9400b00302a00883e5mr22049794ilj.293.1669957274261; Thu, 01 Dec 2022 21:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669957274; cv=none; d=google.com; s=arc-20160816; b=W8UziSXe1KTtSfMty+iOG3chdBfjJg60q0VrNIJ02CTLASODa589qcbdb2daXHjzj5 tsl6wzXcd2e/Uf8IXkgQJ1W9wn1o1y4VhyzfsBv7PQwwLiJpoR8kNnMuCWZ1o1qpkrzC zwyjP8oehjVOXZr6f2g0hMXPrE/B90VqH4TsKIaRPqQmyGuNs7Skv2PykA/fs3aKn7zM uhtBSjT3QkWX4TXCqD+wr3tehKTRe412a0lhoT8hx64juMP9y2/j78gy8It1frWKn0bt aSxKT33HBHI5bM0O5FAJoMkePyGb4sDdl8Q/UFCUSFTDGRCPvl2FFF7E8EmbtpMoTmXG sS9g== 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=O8mWAAwKdfybUlXpGFE+LMAc3b8fp6XdKJhw/TdjzEU=; b=en/lfKw6NlZv0CZK9gFP64CNB9LIT0y/7OIm6X1egjweI4fMQyUlf0CLfA4S9v5Kb9 bDuPtCS8fBT924L4QR3aV29ceUWtS4zsYcnE32f/8tSXy/U5mfY5yzRWQa+jbiEwkBrZ XU3uDlCtF9aNLdpl8T5TO0bl1CpYbr0iIczE6BDIx49K/oNoJUPSybHqNU+rrJZwIjxN 7u3giyPf5rUTJkbS2ggbGR1JDCIo0FpN9Mx4MJt0TX5a6xGAZVqyMUG4fsBhrCgiO21u lJrQWvM0oMT7SNVBn+hdnITZF6dTwhOpX5qKtWuBZpLpp1N8C1BZ78WdeP6OZLddxRCI MqJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rwukqj0w; 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 d14-20020a056e02214e00b00300033748b6si5137744ilv.44.2022.12.01.21.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:01:14 -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=rwukqj0w; 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 B80F88545F; Fri, 2 Dec 2022 06:00:41 +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="rwukqj0w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1607B85466; Fri, 2 Dec 2022 06:00:33 +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-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 DE47085452 for ; Fri, 2 Dec 2022 06:00:12 +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-pg1-x535.google.com with SMTP id 82so3534613pgc.0 for ; Thu, 01 Dec 2022 21:00:12 -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=O8mWAAwKdfybUlXpGFE+LMAc3b8fp6XdKJhw/TdjzEU=; b=rwukqj0wt7ulKBx2QPTOvw59CDcL+wH3+H7lpaf1gui0JW35oZFi0rJqwd19UPUC6j PDyG0OyFP4mggqOaWlIbWQrEPZsHw11nszSAH+Y8/5PrYRcFlD/caJ1v6u9NH+s0AbPs 2gB1rndorPWbOM60nx57dqEBUFVx3SAY9DHXeHqiddX2zdhlccAb42JryQAGU9KoSMT0 5ukSUG92jzQW2wXGzp0MjjjDLU34GIsepl41QzYR+FntszDtVflNtlaljw8wE+ArkNz9 oNsf9TGnLCsM+fH8+W0zS1cmSyBpnwsMT7QgTugEapMB1zNkxa4fxsRhRY2LE9xDd2LU Y+4w== 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=O8mWAAwKdfybUlXpGFE+LMAc3b8fp6XdKJhw/TdjzEU=; b=kuqesq2Tagu6SGrBwY5/xwGynK+9foM4Yud8fQ6/K3R27t9r4ShMfUtYXs06/9oNxW hQ5xqNcNVBGGdG53n3EjVf6HuFTGw75ErujeXPtYNIkOCu7irqR2ShOvqEnyectLh6QW 3Si4wU2YfFpuNjs/Lt9hDYgP6AGvsm7hU932dKOsoMhlqtgm2miUm/LCvIG6G+hWH1sN Be2qN58fItYiEwuaXWOEXlNeem37CyHkx9XELsIAeQrdzSCNbe+lsXHmIgsirynDHFC4 rdcrTS4T/p4D44lu/EoWGwR5/PB14XbeQ1youzHU3YFFDXfhMPgcXwD4UY14g3KJNcf3 425Q== X-Gm-Message-State: ANoB5pmUXWGdp+L697hGqNRfGcLmRaFtvENj+QcPUO3m4e7ZQYARQC+l FMEjNgT6EhPni7kzCGe49OG6fhKFHAe7lCTy X-Received: by 2002:a62:ab18:0:b0:56b:9ae8:ca05 with SMTP id p24-20020a62ab18000000b0056b9ae8ca05mr50872380pff.59.1669957200544; Thu, 01 Dec 2022 21:00:00 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id z27-20020aa7949b000000b00575fbe1cf31sm3234456pfk.67.2022.12.01.20.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 20:59:59 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v3 5/5] doc:eficonfig: add description for UEFI Secure Boot Configuration Date: Fri, 2 Dec 2022 13:59:37 +0900 Message-Id: <20221202045937.7846-6-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221202045937.7846-1-masahisa.kojima@linaro.org> References: <20221202045937.7846-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 This commits add the description for the UEFI Secure Boot Configuration through the eficonfig menu. Signed-off-by: Masahisa Kojima --- No update since v2 Newly created in v2 doc/usage/cmd/eficonfig.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/usage/cmd/eficonfig.rst b/doc/usage/cmd/eficonfig.rst index 340ebc80db..67c859964f 100644 --- a/doc/usage/cmd/eficonfig.rst +++ b/doc/usage/cmd/eficonfig.rst @@ -31,6 +31,9 @@ Change Boot Order Delete Boot Option Delete the UEFI Boot Option +Secure Boot Configuration + Edit UEFI Secure Boot Configuration + Configuration ------------- @@ -44,6 +47,16 @@ U-Boot console. In this case, bootmenu can be used to invoke "eficonfig":: CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="setenv bootmenu_0 UEFI Maintenance Menu=eficonfig" +UEFI specification requires that UEFI Secure Boot Configuration (especially +for PK and KEK) is stored in non-volatile storage which is tamper resident. +CONFIG_EFI_MM_COMM_TEE is mandatory to provide the secure storage in U-Boot. +UEFI Secure Boot Configuration menu entry is enabled when the following +options are enabled:: + + CONFIG_EFI_SECURE_BOOT=y + CONFIG_EFI_MM_COMM_TEE=y + + How to boot the system with newly added UEFI Boot Option '''''''''''''''''''''''''''''''''''''''''''''''''''''''' @@ -66,6 +79,15 @@ add "bootefi bootmgr" entry as a default or first bootmenu entry:: CONFIG_PREBOOT="setenv bootmenu_0 UEFI Boot Manager=bootefi bootmgr; setenv bootmenu_1 UEFI Maintenance Menu=eficonfig" +UEFI Secure Boot Configuration +'''''''''''''''''''''''''''''' + +User can enroll PK, KEK, db and dbx by selecting file. +"eficonfig" command only accepts the signed EFI Signature List(s) +with an authenticated header, typically ".auth" file. +To clear the PK, KEK, db and dbx, user needs to enroll the null key +signed by PK or KEK. + See also -------- * :doc:`bootmenu` provides a simple mechanism for creating menus with different boot items