From patchwork Mon Nov 28 12:45:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 628983 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2912683pvb; Mon, 28 Nov 2022 04:45:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf77aD99BcCr3OmNz0RL1sqg5jV4BO/hh/SMkSvRC7jis49RbCESCaLfGpqIXKfWAb2Dx1i3 X-Received: by 2002:a02:7409:0:b0:375:4727:8625 with SMTP id o9-20020a027409000000b0037547278625mr15051148jac.300.1669639530702; Mon, 28 Nov 2022 04:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669639530; cv=none; d=google.com; s=arc-20160816; b=Dnd425gmL6Uf1LNiGY2IKO8ngarUJHgwomhFYxEcIXo3szhHhprcwm6gr43K9OsBNH RBr0UA6NoZUti+vEy+4NtyNk3/0ps/jZYR3Ds+wZL7qCAp+sb9R+jhvwrMn8gdKxM1eI qGnc1G3RTcTnyGn/TIp9dG4Zpw8r/B7Je/vMstBSLZ8zIKtcZa+4oYZsKrQgqzWdu9MW Yn8n4itYlCPEeaCH53erxqt/aklmx8gAKkEwdihJPbW/vQLaSoBOdjJ6UeAz6TotzbUp vvFfJtl3Ln4oo8n1XUDCPfH7o5Tc0u4bund3wr8e1qcWfiN1FwvyqXJP7oGBtghtG1tW S1Eg== 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=AYLv2DdFWoM7dDTfVFGLmo64B4+CdFRlEGO2AbinN3c=; b=xH9W6Mado1rkq6dp1KX0ryJaHN0mnLpg7xNl56G+J5uwpLY/pNK8Tfu1XBx7nw0eHL UbPiP+FNF4H5IK2Rd5VaQB3cbwc4617EDsW6uLTm7RpQIqLGwxwoEiEsatontLorFxfk ks1HPv1m4n0u1u0NqFR8L02RJ/9xUI8d+Xf48CQD3JgbEXgIt6vbQGBYXAnQUZwYMp7h lRoXcNkvEyj1FrIlC5mLhJUh9XVOY6vCJzfEEHf/oKNUhwq7GRYpNkUQYT+owPoFP+nH 9XRjQcG5qiivgbq8Yfzvl6AM+oQ1AoUwqovQaIqV07ieOwMk0iLQibu7igfZxVHTiWaP wWFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JJmw/70O"; 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 t6-20020a02c906000000b00374fe355993si8398792jao.157.2022.11.28.04.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:30 -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="JJmw/70O"; 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 B04AD85243; Mon, 28 Nov 2022 13:45:15 +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="JJmw/70O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA10A8525A; Mon, 28 Nov 2022 13:45:09 +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-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) (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 B35B58524F for ; Mon, 28 Nov 2022 13:45:05 +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-x62e.google.com with SMTP id g10so10011904plo.11 for ; Mon, 28 Nov 2022 04:45:05 -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=AYLv2DdFWoM7dDTfVFGLmo64B4+CdFRlEGO2AbinN3c=; b=JJmw/70OVra27M+6SNOE9BZRA1/fNVhSVyakxQcH/ESJcZ6N4583knVd12OXI1AzMj BNSfZlUDEO4yoAzIIKE40c6M6pZV70twiAVbnkqrH9OnDgClwliaQq0Ztsjtrgn+ETtM vA822qOZpK0sk0WMZjV0qXwGO69wLCcmsaumyYMj+9ZKaGe4Lx1uo1tb9APNe/EQVPUJ 2vZvM4GfY10bkSqHPU9Ub1OTkWuUA9HVVwDykok/ytwar0lBF0CUerC/PNC955I960lD lWMpDYPvnbKhVIctKQZB647btvQofPLiWeojSjJaG8D/yW620Iv/yHlNDDEc0mL9UQqh 1w+g== 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=AYLv2DdFWoM7dDTfVFGLmo64B4+CdFRlEGO2AbinN3c=; b=c5p54ahy2e9dnZwocG+lslC9CUOUqvmzXECRydNeSydjRvvzAHDvnUpQUAlxhoC4OZ RhtsNP7jKp5puCYY2jzqTzCOpCdpTQiYIOpXUXKE6C/hyBm4+0KQqUg2//HP8xOjcu15 ZrkSkkoZhm/46JTztSe/X9IOxEhveWBMW62f4tY/vU5d2/ySSjQKjZVo2Pzo4ivZ93CQ FqO3dNUstrFKRKlfys2kdkbm6CFOGeWK6e4+VztRSlW7XzjAh7OA/JlCHlimaNVL9UzC +fvFJIoDyMjasKaxZlUrV/wMpp25BqldpOKZZ5JMVXg1PwlFmg2a8944+cbMxanLh29L 54pg== X-Gm-Message-State: ANoB5pnnKxeDwbH7wiQ0jxvpZCPmxf/NwuoZhHxk9DNPiBBqNGYK24Ps AJH18X4OCOtcMjM9CnlaHVEMuVwrBXAJUA== X-Received: by 2002:a17:90b:394c:b0:213:1935:9744 with SMTP id oe12-20020a17090b394c00b0021319359744mr54431424pjb.207.1669639503695; Mon, 28 Nov 2022 04:45:03 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id w27-20020a63475b000000b0047681fa88d1sm3925303pgk.53.2022.11.28.04.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:02 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v2 1/5] eficonfig: fix going one directory up issue Date: Mon, 28 Nov 2022 21:45:05 +0900 Message-Id: <20221128124509.6939-2-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221128124509.6939-1-masahisa.kojima@linaro.org> References: <20221128124509.6939-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 Mon Nov 28 12:45:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 628984 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2912827pvb; Mon, 28 Nov 2022 04:45:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ODWkfKUERQxI9XvXILcNVJk7b3b5bz0RE1BWUlpcsXor7tJJInEranRgOWu2qaXXClzKk X-Received: by 2002:a05:6e02:544:b0:300:87d8:e317 with SMTP id i4-20020a056e02054400b0030087d8e317mr16032296ils.82.1669639542560; Mon, 28 Nov 2022 04:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669639542; cv=none; d=google.com; s=arc-20160816; b=OZKN2ZSnzgixeGPMBK7q9yAGZvdRUWjPIoLwcAUYTKeUoPX0NhAj+2uvTRUhm8UkQD hdYW/p3pGut+liB5+qjzGJ9bzhlKhkF8DWQzpHizWJGNkyiz631K/cPQZoeMRcCc1LRz yguyrCM0dgBqWVsMEw3tV4o0FjE5LJw125CnoO7rpzXDn+7lhpopOcGYp2ixtMVP9bv9 wZNegVWKXa501md8GXwezMBdwQhHFTwc8LPTLs7x+XXbIkrDi5yR1lIs49GehsksKZ5D k2IA/Kql8vAop/8hEtB7o5nNRsUXqwSe/LbpL1naKxCXpeP9ItzxcLLiVqD4GekfBO0c psIw== 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=AHjccI3gQMW6OnxtDlKme/V2gbo3JBwbxCWLCHWyYow=; b=MgvllgjCKkVlAyypuQam+k62L1ZmsBQl7lDQbOCA3/dgMsbrJNnvj0K7Wywg/RCIHg E1ZoAQ4aYx4iQe7EBGKRL9xHXpiDiABhDMDdsgPSng8zyAKYWl+Ng2npSpMXZW5iMtM3 3z1+KlClCAbU3lZkjUXdXY5665W1nycmbvdyNSZwRjT3eYsgJANIsiP9T6u/D6uPUn1P BBcsoBjIMhziVZ8m8O051oVWgLJfaHFNuSWUNxaBnaeUVcvLMTAdIRyCvZOdhudKgEXm 81Hz4WmJfGIyUqIjO/lc/lEwsifdiuhvw7gjzzEn4fpqheFtFlh8iQyEPPH0ApB3R/tW XWxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=msF9XJUC; 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 5-20020a056e0216c500b00302ab3d546asi9534746ilx.152.2022.11.28.04.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:42 -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=msF9XJUC; 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 45FE38527A; Mon, 28 Nov 2022 13:45:26 +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="msF9XJUC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1942F85231; Mon, 28 Nov 2022 13:45:11 +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-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) (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 372F685231 for ; Mon, 28 Nov 2022 13:45:08 +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-x102a.google.com with SMTP id v3-20020a17090ac90300b00218441ac0f6so12421593pjt.0 for ; Mon, 28 Nov 2022 04:45:08 -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=AHjccI3gQMW6OnxtDlKme/V2gbo3JBwbxCWLCHWyYow=; b=msF9XJUCoiFsGuWI5fGJ01meJ0yku94N6rsK7ePbis77CsJht63tN6IRD0Jw/n1P2S rD4BAa1UrjSqVuThNDogRFDYmxMpwytLGW3FK6JbtzcXBkX4AoBatOdIGfjVRYmdU4Ry Blp+NibpJv73rQXGAphMT2mUWTy6LCX8gAfMFKxYwL5U5+lmf8T1m5q+1V/r2LswW3fB FO6uzlQX5FKV5J8+0rIB+3KDvrzlMByutYvledUYQ0NXCZz4lU+ApfTmD+6O5Cfldir+ en1+yp4UYDTAuhWAYyPeVU3djrLLo8ftAFVptM8VXZ3/u4z25UloQS0xu2V2ZZdBncae kf4A== 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=AHjccI3gQMW6OnxtDlKme/V2gbo3JBwbxCWLCHWyYow=; b=yPTPQWpvTDwFeb9YhFJcrvkZNj6VNDq+nflk0xj6xwb69oK9iYm+mavs2awgmQPIQI 2rhyXIGrqV0jwhE0elQl7qJzbxTT+0BaaQHj/+htB0WYKwSwND2WLw+IsdILv7UoXGHf oRMm2bFgpvm6OEiZ+AYo1t/mvcN1Y0/a2u3CtjDXBTA/HTZx+lnaVk7csUVXhSTqn4jF z2U6lcj4I7MOaSYXC7giraFVnFma6Iv5/C5fPELde8CgU6Z1O4UlIFqZ7YwvdkaLIomJ m7hzhtG2Gq7fsP4OSfOW4FOqmq0/xYgwqfH1Kt5QocDQQYlm/AOTLY+MFvD/48elJ0Mk wCDw== X-Gm-Message-State: ANoB5pmylUCXUZwr5eYGLrI220ZcACEVErwHuRYl0vB0XM28szkYCWp2 1CnjylgSB9Rheo6Vhybu1zeAjTZZAL+b9g== X-Received: by 2002:a17:90b:1650:b0:218:6ad0:52c5 with SMTP id il16-20020a17090b165000b002186ad052c5mr27115575pjb.44.1669639506203; Mon, 28 Nov 2022 04:45:06 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id w27-20020a63475b000000b0047681fa88d1sm3925303pgk.53.2022.11.28.04.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:05 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v2 2/5] eficonfig: use u16_strsize() to get u16 string buffer size Date: Mon, 28 Nov 2022 21:45:06 +0900 Message-Id: <20221128124509.6939-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221128124509.6939-1-masahisa.kojima@linaro.org> References: <20221128124509.6939-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 Mon Nov 28 12:45:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 628985 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2912974pvb; Mon, 28 Nov 2022 04:45:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5betU+MiK02vRX2qpE6M+ztyjUjWNN9/04egZ1D6crkZOxPmLuvCCOViUmC89F7lv69Ws8 X-Received: by 2002:a02:9149:0:b0:375:9c59:7856 with SMTP id b9-20020a029149000000b003759c597856mr23444033jag.240.1669639553778; Mon, 28 Nov 2022 04:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669639553; cv=none; d=google.com; s=arc-20160816; b=kPcQsPy02Kd5Dsphp/FzaF2wfm/tSko1CdZfYzgui9+0upshMsOzxGcR0kfZ6e4VIe 890xYCyPHVNTJ1h2SjnH0f5unQyOOvlH2Atn1ox0uz12Kc1KB5ROCvycWovCFmQKXiqZ 133oEPqd0Xcy5G77B9BthmIrpiQEuAqIUJKFahA7MnxRxnD5aEOKnWlapK/w7sWBackg YIuTz2mTDQTBSYb6zPb4lkmKOwls1W7TL+br+ycqsBrCko1ayy1i2tCsKjWgOfzA8CD5 E+OTT3fHtjj2MpdX54FV0oqc6sMDbZTrB8AJBos+JIQAg07LUfvlxEfwWXouTbpCt1Wg 6dvA== 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=46oMHSDkat/aWjP/ELVjgbt8f6SIWI33I0ShpHcJ3lU=; b=BZUa1ShNO9PKrjzce4vZ/bpnqjzts7CiFypP3o6wwdb4AuKNJs6AFjh5HEhxuTBIP4 dBDcpp8hjKH27f8WNCJzQMfWq9E8B9Z11PlqPndSIX0G2pK3ZSjl3LJOAdxUkQq8tDjT XySGN3K4/xYyzzEJMahASSD1rumpco0/y9t9ozva5p5uNDoOQzFsnw7NdMIYhDnDoPd6 /q0+7Za+3B62HUFa2RaW0uCImWzfHyBzvmjQrubaLoX5fPhzKLiFhFeIcxarcpAw72DV /SzDTOQISBBSVI+rsae2vNkRRJ3KsLCpfuJECPvR866ac2FX9BtMZM1GkdUpZGkjV+oR AFKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a+qKT5B8; 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 l12-20020a0566022dcc00b006b3ad8240a7si10467155iow.69.2022.11.28.04.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:53 -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=a+qKT5B8; 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 312E885277; Mon, 28 Nov 2022 13:45:36 +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="a+qKT5B8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE65F85240; Mon, 28 Nov 2022 13:45:14 +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-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (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 E77CA8524F for ; Mon, 28 Nov 2022 13:45:10 +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-x531.google.com with SMTP id 6so9797462pgm.6 for ; Mon, 28 Nov 2022 04:45:10 -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=46oMHSDkat/aWjP/ELVjgbt8f6SIWI33I0ShpHcJ3lU=; b=a+qKT5B88UnO5qTkct3QnmEqcBBHbV3/a+yIOzhQQeYpDADjfaarCRHDx5TrTHUPt6 SXrtMvfAFLvWo2sgLQAFsYnH7tY34lawPbqa/SJDcz4Pa7C1yX0mZADiL49Sl5ZjHvde 8Kr3LBfr+aqCEz7p2j8Zf2h1313+ey+pt7Z7nCoCTlXrGC0wRKGmYcnPjQ7wIOm/Lais 2Phz4qKuqMqVlcdlzLwNUxOBXSm8Bv7vkVsvKZsfX9PRfcoV7+IwB8G/hQsMfsEdAgK3 eFD8ZSSyZ3t6qYstkg9PbGHcbJ0iHOaGWGn7nVQCYfdGcfjzW3TI0vfkUIYUVJAJEcI3 bjVQ== 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=46oMHSDkat/aWjP/ELVjgbt8f6SIWI33I0ShpHcJ3lU=; b=XAsVLvzquPwlBgpgokDgn9RInM4DUyefpo0EtLmQaWZ453nEZwOd/praK532XXiw0E ibKVONhYzADHS2i6OkNEyhsFbfzNsGgEnMTU1ogZr3woNlLuQeDWHjqVuLRlWv46nN97 B+nn10MpIbJ81ZcAtbLvssB32g9Olwbyu/afD3dkIpDPrGIDELDgGsBr43iIrjTTGMO3 sQ7c39mLckLg9LtTn6x4FI+ZaelmRNBUGy+vhyT/6zo65Z2lNdbS/rO2TBBnLRnHIbOO jjVsypUjd88OmBi1wh/pF6FTVdA1G/CyUBWAxrGHtmJR7xqPDundoNstXmq+XLeFDwWv fiQg== X-Gm-Message-State: ANoB5pl2hq5Fq4iYo9ciqNfGt4aqwlW6XvmLZyvxAI0XCXRPRpjd6qsk qFKsp4yhtF7/G1xaWjHgmchWarOAXlzVFQ== X-Received: by 2002:a62:3306:0:b0:56b:8181:fe3e with SMTP id z6-20020a623306000000b0056b8181fe3emr53537583pfz.57.1669639508698; Mon, 28 Nov 2022 04:45:08 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id w27-20020a63475b000000b0047681fa88d1sm3925303pgk.53.2022.11.28.04.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:07 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v2 3/5] efi_loader: utility function to check the variable name is "Boot####" Date: Mon, 28 Nov 2022 21:45:07 +0900 Message-Id: <20221128124509.6939-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221128124509.6939-1-masahisa.kojima@linaro.org> References: <20221128124509.6939-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 u16_tohex() and efi_varname_is_load_option() function to check whether the UEFI variable name is "Boot####". Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- Newly created in v2 cmd/efidebug.c | 23 +---------------------- include/efi_loader.h | 2 ++ lib/efi_loader/efi_helper.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 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..b1ded811e7 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -707,6 +707,8 @@ 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); +int u16_tohex(u16 c); +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..8a7afcc381 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; } + +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 Mon Nov 28 12:45:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 628986 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2913165pvb; Mon, 28 Nov 2022 04:46:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf75ROo38JPbZs6uofinA42sOPiutvAxU5xEe6blA9fAg3m1t2ilAv4CXB2sEbEdNqltENy6 X-Received: by 2002:a02:6068:0:b0:363:e6b8:2bac with SMTP id d40-20020a026068000000b00363e6b82bacmr23760497jaf.229.1669639569540; Mon, 28 Nov 2022 04:46:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669639569; cv=none; d=google.com; s=arc-20160816; b=kXK484ZZPKg3lni0HemqNYuY+AWzZ9CTy+DtN4+EWlfb6II8vpKaUbogDvtPe1SpZH 102RG0HUChRhq0lpFeVOKRUWBy6Iojlj/UCxEa8sAkJEpVHwHvTb1YKBgI7ev4DurVAh jOZlvMbGfu6oGXvt2DgbimYdDJ7EykbGrWrbWwHtJu+JDah/NamZQ4sD7XkWnKPZfdB7 YtjBhjx4GwxMqL9zzXlTIpqjWsMaQBnvrl4kZ2pNwPifCnhueyncXnTT+XxrfOlJIofR p7jaTGnOfooigO4JpB5VY+rLs8Jszf/mXDBJbJ3MoX1MwMIGtZjg0NhDxsPlQKcY2v6S fTfA== 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=j+Ju6qAlew/ykKCSWvbJzQzo3rtHmupHBYaDaxx6ic8=; b=KJw1rkqmafgEQ2hQeABW1nlW5N3BuI75wACVjN71+hHU9J2xr92V3Hhqtvj5md903a XmofB+riIuVijZyp1VToveW3fn9qF/l39W/WXrRqTKiUc+Onr+mg1PyuFb6EYUSdRXwn ogP7BcFw26OIPYeitAVCtFBVUKG0OD78PpyDYqri/fClM1GCCa20ET+YeOz7Yw8p2GmY icwfNtKrwfcUY8SkU99kkx4lo667Tn+aqEWYiTpB1gys5UFe283Pxc3xIqxTyh9t1UC4 nq3KYB6DDeTMpcMmtcLiCuyGxNg/4yzKbOdsYo0Of2X11Enr/9zDuJkwRxol1Jv1YJ4g 7ETw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YKpJlqlt; 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 x14-20020a02ac8e000000b00366cbda5541si9211208jan.51.2022.11.28.04.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:46:09 -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=YKpJlqlt; 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 C87A78529D; Mon, 28 Nov 2022 13:45:37 +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="YKpJlqlt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D926C85235; Mon, 28 Nov 2022 13:45:20 +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-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) (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 A0E3985231 for ; Mon, 28 Nov 2022 13:45:13 +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-x52e.google.com with SMTP id h33so4839038pgm.9 for ; Mon, 28 Nov 2022 04:45:13 -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=j+Ju6qAlew/ykKCSWvbJzQzo3rtHmupHBYaDaxx6ic8=; b=YKpJlqlt80epTY0G2cyJnvUPNS2MEUsxcXgsBDkWkJWiyaLV1WStthLqNdSdo4b3m1 dAiHU1bnGJxK60Zp6CexUpGVOkci6lQiHsmiTSxZU+QK02jVo+Llgo+Q7IIoG2yOsrXF aj2c2dFmsdQkIT39lZze98WA0euP6RMaw+6HZsPur2edH11aCEbOQQfFU3p43QoaDyeX ee7/uu76eOx3eSnDOAIH7X6U/AP2bzM/XPuLw4XmVZPLudNuMjoHYxW3o4nNECKKeBhx yRUs4OF7AMZFYsQrlf1OnpxCR486e+gzc3r7ZM5qF/C4JL8TbgVI9CTWL5WSC833keTz s6QA== 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=j+Ju6qAlew/ykKCSWvbJzQzo3rtHmupHBYaDaxx6ic8=; b=XMfFa5JAKlIG79CfKGOOB4ZQL0CPk5KbQVz/UZJZZbgrD7zb0CR7WvWgQB34SjPZTH 2pDDUT6n0SpDSS/oMDmjrbwQmpigh8n15efkRGxKE1a3Xb32qaBS+B0zsmJdMj6oJ+Cy /LLwi6UmZS7sH9XJ4Cc5YcARry0Aepluw74+4xlHO07LndBHnKTqCDhGEyAcb/nzThau Ue1B9bS/X1Q0VcaVRAqASrNYkntdeIcZFhAVSOKS8KQL/HwS5VVN1Pvtaz53B2+5tYFW RVF5axQAWtwJuP1mKMSdLzvEzKXRxW2K5bJTVO4RpcoZCYR0msvEesn/lAWyHk9auWvk ZMDg== X-Gm-Message-State: ANoB5pn7Uea8HVsdP6FMMiaXeMobFz8+idQ4rEQX8jaweMO8iPC5uZsU rd0lWgvOOFBR04X4CuCBUhh4QaOCIqKbFw== X-Received: by 2002:a63:4046:0:b0:46f:932:453f with SMTP id n67-20020a634046000000b0046f0932453fmr28737383pga.405.1669639511193; Mon, 28 Nov 2022 04:45:11 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id w27-20020a63475b000000b0047681fa88d1sm3925303pgk.53.2022.11.28.04.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:10 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v2 4/5] eficonfig: use efi_get_next_variable_name_int() Date: Mon, 28 Nov 2022 21:45:08 +0900 Message-Id: <20221128124509.6939-5-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221128124509.6939-1-masahisa.kojima@linaro.org> References: <20221128124509.6939-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 --- 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 Mon Nov 28 12:45: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: 628987 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2913299pvb; Mon, 28 Nov 2022 04:46:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/1tu17iBLzik9boJy8fx5iP2VMMzKJ/ApojQLynoXOdvhLOyN8L/PahRAJBf5Hc/LL2aH X-Received: by 2002:a05:6e02:50e:b0:303:d01:eb31 with SMTP id d14-20020a056e02050e00b003030d01eb31mr2708591ils.188.1669639581100; Mon, 28 Nov 2022 04:46:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669639581; cv=none; d=google.com; s=arc-20160816; b=GJG7/jPwr6+BOXRJUWloas2xZjz089dNAubIYa5vX91+05Mpgv01OaAZlV3dTPoEeA Opv7/8MUVa08nUDpl2VugmWGBke3sNmxxfEghKiiW7vnyUaZ3+pc0qBjFkT1xJkb39Un m3gFssMrQhZTeRe1kJUWVuFfD7EQ0Fhonzxb3uVdY9XK7oYjm1GcHwLP4+M1O2MUqZMO lUy6XjhmP1YaJApxtlRJziEY1OmWqqkhlssutiWozf0AC1rw0SQF544vZ7KqxA91fxSI vUwDFUvekQHaVn66l/PrscvqUBdLJdRTYo0zkeMm3A2Zt23ZtmZLOJ+7yrPQbpFvWaOM xn1w== 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=eG65erNUMV3tR1yBaVwihzSzeab2+GnhuxTVCJA3EMM=; b=MeMC53R+nznmtTupPbKZbvI2bBJi7i8KK1cap91AOUJtK30JRkWgYvEwl2P/4dJv4u tmQX2wBpXmdowJgspfkPckDmr8ZxeSPBZP+5rgNImys68Tn4iBD0LgF+ZDarQRHt0AGm qVM1CAyLnSBQXGFvfS6WpBRSAv4rtZzaAw7pReZKYQ56EYT2dhu7TknCAHl5+Oz7FOt4 n6iSyTa4YNqYq2NJG2+72/n0QmBeO0is13ElhtEtsW9h4LeZW1kF+SsQ0YKaE0t/y+6G kB6n5BGK51hs2yR8u0C7/wgt0ATWA6ZeXBa1GnLijkxIVXQroQiIlj09jk2nx9x79pbv c7aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dsRz1ay9; 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 h10-20020a92c26a000000b002f6ab84e5d9si9640723ild.65.2022.11.28.04.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:46:21 -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=dsRz1ay9; 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 1F41C8524F; Mon, 28 Nov 2022 13:45:40 +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="dsRz1ay9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD8888527D; Mon, 28 Nov 2022 13:45:27 +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-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (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 B1F5E8525A for ; Mon, 28 Nov 2022 13:45:17 +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-x42e.google.com with SMTP id c15so1034832pfb.13 for ; Mon, 28 Nov 2022 04:45:16 -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=eG65erNUMV3tR1yBaVwihzSzeab2+GnhuxTVCJA3EMM=; b=dsRz1ay9aMSN0LqE4XrY3qNBLP1yCAaDzD+REOtw3bG2zkMGmQyKVnxFL+a+vqeRHV W3dVvNKCHgDfT1bho8bao0Sx3AFWCnq/zEtkOgqfVKwTrB2TGoy9uvJPt3xQxtE9MhtE KdtwyxbalSIsIaXJN6ffFZ6OGOEqjkdqQwbCYACdYglQEn4B1CkHpWrSCAPHp1RSLs7+ pucfOiZUjsbUr7uuIHg7WALoqIaWD2vTD7yr+86TOkQStMtWCBKAdbeGf/vK6c/eMzbF orypV3EGI27bzWawsLdxtuEdLoWucpij8PbNQG92SAJEu+T6dfZLTsv5bPMtbmzuLthY wQLA== 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=eG65erNUMV3tR1yBaVwihzSzeab2+GnhuxTVCJA3EMM=; b=Kub+bLtTI0X6jojjrLg9ullixFP2uZHlFk/i1Dci+O6UuBOk1BOxGJMbB8ts0kGQ/P 6jMjF4rQbelUzCSLvnIQLY4KTQ1LZGNSQj1ycWHF1+a4whP05WYoNx5NRQ+O8sAAuBGe +pnKZuiILz6bRYqwZU7fBRuPo9W5fQ4a81xjiZzZTyljT8sinekXjWkFsDJfvtt6227h cA0z5Ye6RdbU76UbiNjluCcjMQbU0DoeYqTT85k9H2R2U90xbqx7In+WxDNqx2i1/pak EI2XJJkLmDLQLRwQpY4gGeD62Uh1+xFZh/vxtMX78J+sCKld5mKxUYSqkmv7HQ00dRUW bQ2A== X-Gm-Message-State: ANoB5pmjY8V3kOiWHiEnwDSS0BY0ddMhfSfi+RY78+TKnb0tjka5eIAG cvFf7Ua/sWaxzwXSs69doHF0TalByhquag== X-Received: by 2002:aa7:91d6:0:b0:574:c543:f804 with SMTP id z22-20020aa791d6000000b00574c543f804mr15077819pfa.51.1669639514169; Mon, 28 Nov 2022 04:45:14 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id w27-20020a63475b000000b0047681fa88d1sm3925303pgk.53.2022.11.28.04.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 04:45:13 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Jerome Forissier , Masahisa Kojima Subject: [PATCH v2 5/5] doc:eficonfig: add description for UEFI Secure Boot Configuration Date: Mon, 28 Nov 2022 21:45:09 +0900 Message-Id: <20221128124509.6939-6-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221128124509.6939-1-masahisa.kojima@linaro.org> References: <20221128124509.6939-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 --- 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