From patchwork Wed Mar 1 09:15:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 657797 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp3386665wrb; Wed, 1 Mar 2023 01:16:55 -0800 (PST) X-Google-Smtp-Source: AK7set+H8L1WfTddr8m2c1awOh9D9lXlVPm8tI5BjdPSnCV+XPmhj7c+pE0k4gCkVwrwrjZk9Q1g X-Received: by 2002:a05:6808:54:b0:384:ea9:23ab with SMTP id v20-20020a056808005400b003840ea923abmr2669611oic.18.1677662215364; Wed, 01 Mar 2023 01:16:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677662215; cv=none; d=google.com; s=arc-20160816; b=dMczUMdazOiEPncpcEcMTxpKuPRBi10rbI6TaPg5K6bNeo1+Ti5bvXJlGUCyZJ/lMZ 1/Gm/9Yc+UO2ypd6LCGoADzsF/FCJ9FUnNu2WOHf+6W8EC9IMjtCDRhefn1p1BrxwzJk jh5+b9cXyFSTjvnaoJZTww1BxVpAWi729f02BgtjBmGEo0C++iyaXCo64IrLv7vaYL3h qpokEMngTBM/Po38b0mNoaMuWJmbSjZsDwnOSSvrUQH8K1FYG9mXcrWeO8lTmLg7XZlj SWCAdTXbBKBPFgTEoG8sA3DhzeXDeZCHHGuZqEJvGZQa2O4FOH3oJidbk66qr4tRObVv wFKQ== 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=KNtK2Kv9VKitVI2gSAeD17XqjZxXNzZl+xSvIQS063k=; b=DUf8RwgXhRECnjGboCfcPmxP85fQjDq2v7KJYZ2H41BeK7rgbQ0KbAe13Xl8WoTNeK F2grtVS2zqDCY6cpgqdnyrq780GceFEzRVkzt/pmBLupNtQ9P//QhRIYNwhI4QS/ZEEp U9BMtreQLvjhNMH4gIxZuWybmNMHgioHtCxyqcDrrPfs0tNkTU/LTgEecmhrlm3tXlPV hP33CIqZ+4UM8zB0xPkeGA148WCP1G2FVl5y+5oQup29WfawvGElvFjt9CCFZUBbL6vF fqTLagEM2UOCA8Sz2gvj0yVdqU9cXqxBCrAsHNtrHDK5kkA5h4JWab+WqN91iliOEseN 9N+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vbKV4RTv; 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 h23-20020a056808015700b0038423b74892si10347346oie.192.2023.03.01.01.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 01:16:55 -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=vbKV4RTv; 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 44C1F85C12; Wed, 1 Mar 2023 10:16:28 +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="vbKV4RTv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 373D185C04; Wed, 1 Mar 2023 10:16:23 +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-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (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 26AEB85C12 for ; Wed, 1 Mar 2023 10:16: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-x52f.google.com with SMTP id q23so7307383pgt.7 for ; Wed, 01 Mar 2023 01:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677662158; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=KNtK2Kv9VKitVI2gSAeD17XqjZxXNzZl+xSvIQS063k=; b=vbKV4RTvL694IQjdFTQEM5/OJuWgmQV7rQ26p5VeRK+ZRLETi/bommy/4lbKptCTge 2YSB0d5VNIHiGE4CzXnbgYfGLfwCTTaLYWoPya2vE8fwr/opwaTxhlVemVdlsTO1Ywl3 C3Gcq6rBpNcyLcdFSsq8Ed4Dd+OTs2fXBTIqY14c4pVJGx64TQ7Da/MOiApWFbKJGZz2 dRaXG5XE7HR5kaJrT2pBXsAEiZG1dKbb+J5IPxpqcBnYVdRkbiFAJ7ohPA2B3ovIIN8c kz6uKZKh+TgbOaRwQ3HNNSVoPD+NmPWUgicO5Joggugdtc6ZQMLHHn0Cd3fmlqeVqPjE jW5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677662158; 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=KNtK2Kv9VKitVI2gSAeD17XqjZxXNzZl+xSvIQS063k=; b=YnH4wnJKvJ4x2U3JbJWgFj/tqCKvglhtD4R1yz95EzzCrc43s6hGIUFn6DhqIaQ4IC nXvOENcB/J5Xo7a1btrAd2wSfzJlSLu55xMGT6Svz5kMY+IE0s4lvve/q+G/F5CVN3ys X9VhfT+VncYBm2dmdoWNQzBmG4+YGD15eLOec/lCLeB74/4hE3PSD8Wg37DsxRQk0wf8 D0PHiBrEohBohaBBW0MkGZmGAOOGZ8dDLFC3p3d7HK1IQvzvz6OGXdLVctECoiJmlRQD vksXEg7HpA9v48sVcH4j2ohMVWH9qdDp+caNXbMhmd8HYu7rFouxpD75gYqGcTc8m4Ta WJqw== X-Gm-Message-State: AO0yUKUaWBAvTywnd+xCWKLoOSpdae2ZnN2M+djxQ/kH3Q/yqf4O6UkQ xzLZWZMcejPFmO4uTBp1DfDTdYYfRboyaNsp X-Received: by 2002:aa7:940b:0:b0:5dc:107f:2e19 with SMTP id x11-20020aa7940b000000b005dc107f2e19mr6155034pfo.9.1677662157712; Wed, 01 Mar 2023 01:15:57 -0800 (PST) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id 13-20020aa7910d000000b005a8173829d5sm7466637pfh.66.2023.03.01.01.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 01:15:57 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Masahisa Kojima Subject: [PATCH v2 2/4] efi_loader: versioning support in GetImageInfo Date: Wed, 1 Mar 2023 18:15:20 +0900 Message-Id: <20230301091523.18384-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230301091523.18384-1-masahisa.kojima@linaro.org> References: <20230301091523.18384-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 Current FMP->GetImageInfo() always return 0 for the firmware version, user can not identify which firmware version is currently running through the EFI interface. This commit reads the "FmpStateXXXX" EFI variable, then fills the firmware version, lowest supported version, last attempt version and last attempt status in FMP->GetImageInfo(). Now FMP->GetImageInfo() and ESRT have the meaningful version number. Signed-off-by: Masahisa Kojima --- No update since v1 lib/efi_loader/efi_firmware.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index d1afafb052..ead20fa914 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -173,13 +173,38 @@ static efi_status_t efi_fill_image_desc_array( *package_version_name = NULL; /* not supported */ for (i = 0; i < num_image_type_guids; i++) { + u16 varname[13]; /* u"FmpStateXXXX" */ + efi_status_t ret; + efi_uintn_t size; + struct fmp_state var_state = { 0 }; + image_info[i].image_index = fw_array[i].image_index; image_info[i].image_type_id = fw_array[i].image_type_id; image_info[i].image_id = fw_array[i].image_index; image_info[i].image_id_name = fw_array[i].fw_name; - image_info[i].version = 0; /* not supported */ + efi_create_indexed_name(varname, sizeof(varname), "FmpState", + fw_array[i].image_index); + size = sizeof(var_state); + ret = efi_get_variable_int(varname, &efi_guid_fmp_state, NULL, + &size, &var_state, NULL); + if (ret == EFI_SUCCESS) { + image_info[i].version = var_state.fw_version; + image_info[i].lowest_supported_image_version = + var_state.lowest_supported_version; + image_info[i].last_attempt_version = + var_state.last_attempt_version; + image_info[i].last_attempt_status = + var_state.last_attempt_status; + } else { + image_info[i].version = 0; + image_info[i].lowest_supported_image_version = 0; + image_info[i].last_attempt_version = 0; + image_info[i].last_attempt_status = + LAST_ATTEMPT_STATUS_SUCCESS; + } + image_info[i].version_name = NULL; /* not supported */ image_info[i].size = 0; image_info[i].attributes_supported = @@ -193,9 +218,6 @@ static efi_status_t efi_fill_image_desc_array( image_info[0].attributes_setting |= IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED; - image_info[i].lowest_supported_image_version = 0; - image_info[i].last_attempt_version = 0; - image_info[i].last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS; image_info[i].hardware_instance = 1; image_info[i].dependencies = NULL; }