From patchwork Mon Mar 20 05:54:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 665177 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp958068wrv; Sun, 19 Mar 2023 22:55:36 -0700 (PDT) X-Google-Smtp-Source: AK7set+CXriP83FpLsP1+U9S/ZezYgRUXb16GOWtvQw7ffUiQ1colQ9kHrWtBOOndCYbhyQsW4+U X-Received: by 2002:a05:6214:5284:b0:5ab:af50:eb36 with SMTP id kj4-20020a056214528400b005abaf50eb36mr37934183qvb.45.1679291736099; Sun, 19 Mar 2023 22:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679291736; cv=none; d=google.com; s=arc-20160816; b=TqzMzmg8hD+0u90bGOtG9lS9ayi1M00KLdm6ySlE6ovgDmWJinO47OgxKVXRmaI6Xl wH5vc6lOTxm6r2lXF1BJaVFfCpCycy2LWojYNXZ9OMbzXDShMe3V21n5wGtorgxmf6WS WszBGY5HdkUkpx6mKF92ybNWq5bB3hIvQ8Sp3kLHZYLMViVLO7uEMuMDykSLWH2ij/b1 YmBHJP8I7tWCP/8RzdaE9eVjR0wJBW4d7WsNyRwPAmc3M5bhlAXKBrvNfOAhoP3HbuNs EkEH82N5BzadpslvNn3bvsA2Bjbk6zjkC3M9XWg04jurGIwA/2OozvoLZsZ+Ka5Yl1wV /MBg== 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=8cV95/lP8lmMyT89SuJ1JbF4cgBxYpvW/XdEdWca0pQ=; b=N3fB80MrKZOxgxiPCkX2TFH0oIEzoiipTnm/DDiAZQ/LIyhvXZAngBDBmS6g6qDkU9 vUqG081E5LNvSL1NJXD06sHalVuVOKMRJPVYyIOAdq2lMOgs5Q1R+SUoGvuEJen4Yw1E ijAFifFWiEQmyXfJTaKZqgrkOdDYGgPR/wAORJGDlR1X5nmagqqoldiNY0Iz3seG2zB9 B8X4iXIuL5ccfrUHwi4ovovCs+wmf/3peb30q47w/xxWOhdvp0YHTHLFfGO8tY5iuZ+K 6oRY+af6F/72/FvOD6AgH4DQ9hJjvWbkwLur6r3eiWXr+OknQACkcPJRTG2Sf+RKDcVA V/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aq8TgvjC; 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 y18-20020ad457d2000000b005b3a4d92f2fsi5170923qvx.587.2023.03.19.22.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 22:55:36 -0700 (PDT) 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=Aq8TgvjC; 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 0283785B23; Mon, 20 Mar 2023 06:55: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="Aq8TgvjC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B70885A48; Mon, 20 Mar 2023 06:55: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-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (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 5EC468584D for ; Mon, 20 Mar 2023 06:55:01 +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-x632.google.com with SMTP id o11so11340189ple.1 for ; Sun, 19 Mar 2023 22:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679291699; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=8cV95/lP8lmMyT89SuJ1JbF4cgBxYpvW/XdEdWca0pQ=; b=Aq8TgvjCKGjT5978B3ALDnQcy38xWNfd7VUc37yDKdMjggO2LBpMy5RJQF+FCwdrdW 0fvJkLE05XE7PvOUK/jxqpMvyqJYHpaBaGwIp49Qi1O1rJDzilKFo/Pr2t59zUP9PE9C Nsv/SAS3BvLoUC1AwCUlI4UBsX4taFKSl1YALuKYTSG/E+Ac5HMd+hqMEC8jClibSgIE EMfSvzsk1PhO9ZLDKLaBSbCzKNsedSER6ybp4kxyk1SUSG6YmbaDzdF5TwUtmber2xvW q/y3TjqVPuikBPrQOAJObNa3dUzujm72UV8gUt89cVsccMjabW5iIWn/dSt/jwMMmcT/ qGqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679291699; 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=8cV95/lP8lmMyT89SuJ1JbF4cgBxYpvW/XdEdWca0pQ=; b=y32j3P6Ru+k1HcxtYuGh7PIqRcyQr4sbH70/gOqjSjIo5vGZSlUaf84F7olVg02/ks AT3KnXpw43ZFxYwubPHggfQq9IxQa973/xAeFWGG4jTTJIwiIiSqDURzaADMxl/++IBi 7/FFogpj5RzRTpOWkLTbR9kUP1efGNgb3Z14y3L0gi6MyR5p37nVwyL/2VImiE0VfcLp sznFXk8yjOixcM/hfhRmAE33rVhT+z4tBgcj9qyWes7+hV7c0NpZX6BJ1mV26C9hDmwo TytLo9tL0V36gza3AeS1j7tH0Al+Zq6KxFWwUcGEXco/pvFJ5/QuLKuQB5DHErx0LX0+ MzeQ== X-Gm-Message-State: AO0yUKWIMSyWJKddFlZvdrPx/3kT0nDW533T+Ys0XFSN07df1lEwtJTa SfksskIvdiaE9kF+TbqyOzcpF/cGpuzhKVUc8sc= X-Received: by 2002:a17:903:138f:b0:1a1:b313:718f with SMTP id jx15-20020a170903138f00b001a1b313718fmr7217756plb.22.1679291699559; Sun, 19 Mar 2023 22:54:59 -0700 (PDT) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id h6-20020a170902eec600b0019cb131b89csm4826718plb.254.2023.03.19.22.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 22:54:59 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Masahisa Kojima Subject: [PATCH v3 2/4] efi_loader: versioning support in GetImageInfo Date: Mon, 20 Mar 2023 14:54:45 +0900 Message-Id: <20230320055448.12439-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230320055448.12439-1-masahisa.kojima@linaro.org> References: <20230320055448.12439-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.8 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 d6f3741024..289456ecbb 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -190,13 +190,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, &fw_array[i].image_type_id, + 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 = @@ -210,9 +235,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; }