From patchwork Thu Mar 23 11:09:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 666126 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp619909wrt; Thu, 23 Mar 2023 04:09:53 -0700 (PDT) X-Google-Smtp-Source: AK7set/psGHPiSrP8cQTbP/xEbME4cFkkEGUGmZr0nJNU21aCMx74LWCDHLxNIYdmKlJn75gNUuL X-Received: by 2002:a5d:8406:0:b0:74c:8801:af4b with SMTP id i6-20020a5d8406000000b0074c8801af4bmr3858733ion.1.1679569793290; Thu, 23 Mar 2023 04:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679569793; cv=none; d=google.com; s=arc-20160816; b=yqOMCRvBgC6X0DGx96rJXoCJE+7c8T5gRyNhHOzoMO4/XW5ZZ1my60B8zka2T+YK/D 14kDK/+g7H7rF6x1gd5ZiWtKwtm5G9bcYGMkrAZy22SEf0GCrVwBPf4qONvgLFKndxQD CO2Y79fgOtDqHjmjbiuPhTzMi0k8HXwzs6a/0jK7zC93RMbmNdmJ0AkmtCoRoBOtZnF7 qnJbzHVF2qK68xTKbzYoUKHMz2uDfILsCDISUTskkfT6QKF08ETSaqe6owuB5odxAEjn q/x6E1SSiI7vd8rAFMAsBAENBs7E5tN3LKh+AAFJUXt4MnodBWIhJZmio1KKzLHaPsar mMIQ== 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=i8QcTdAPo9tZA7Tbg7Cxn9lOw1noRZG//SDNZsydkUI=; b=uMYzBgsQsQS9qnAVuMkWLBw5zOsrzkvaPViiO94qFvvRW2xtOuZg0U7q5EBjiJJaZR OrOUdSRxGNZYXh19NZgo2KPyofibdY/3288LIfHXvoz2yU44gEa9BTQyvXnjCxmkcEnC BKlUl2sm1VrFmXYYkRXy2unww6IBrRmYY+v6FFXwiaUwyT8T3ZICh29m4GfTrCCS6y7r UABImf+HogHe3V1rxpE1c5N07+PVNG17mMoQBSmNCba9vua/lvhsZ4Wra7jJK5F2vbfY E2VgrOIQjyw2x8bFdag5Hn5sYYlOSTDxwUp5qmsKSPGIytef4wbIkZaRkMdOoPxeitkn N7Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oI6S1z8V; 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 h16-20020a056602009000b0074cbb86110bsi16474399iob.11.2023.03.23.04.09.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 04:09:53 -0700 (PDT) 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=oI6S1z8V; 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 D092785D8A; Thu, 23 Mar 2023 12:09: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="oI6S1z8V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABDA585D80; Thu, 23 Mar 2023 12:09:34 +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-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 CF6E485BC0 for ; Thu, 23 Mar 2023 12:09:30 +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-x42a.google.com with SMTP id s8so12812147pfk.5 for ; Thu, 23 Mar 2023 04:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679569769; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=i8QcTdAPo9tZA7Tbg7Cxn9lOw1noRZG//SDNZsydkUI=; b=oI6S1z8V+Q4oymfm0WWFZR+28XO/Fbv0i7WRiFnLyyc+nTvCYoin6BcrDd1zhdUTd3 AsePQwX8ynDYeDFIfqGf5UVCaMqqcBMnVIqjJIUs2RVI5BF4FXOfSh3Pb3zZnOkG+8gP 7G4FnBHD2JWyDLSyeBgUEZJaYVIG3vZNLaGv7Q31wui0KxYityMeEIeoqRgxhCcNIpHb QhGRGdVd32GEHKbRRSOJG/wSahy7X1MXdSVvam/D/gFRfTNEENdxw+gIJy64KAepqn7/ WwS56G5iCcwE1EIFO7O9rNwfLJwZG1U3sv6iWvc3VNw5YQgPqD8HiYJWWlPvH6fEO/YR V6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679569769; 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=i8QcTdAPo9tZA7Tbg7Cxn9lOw1noRZG//SDNZsydkUI=; b=WyGVX2DibwwHvwAoW9PO46/KrJhYzewswbWSaMAe0d2+JA4QFtlVpb1V96EEAsVuqx L/RJzuHS8Vut641GJvCl1pv2Ln8flyfB/0nxmby9b+SSla+UkmB6cZFQYcBLjhDlau6h zy9V0D56SNdkS9EHVDJirQGZjq7HkorODR8AJeC5mgYIIGCzf0qUp90lfjgznmi5Zcua tpG/ZNxoQuWwn/myiUPL5wh5BXwh3j96p8YvuUhIU56VqPvAAeQHJ39YtVGgTrrzV3YG m/WodrZhV2pQFEuDnan+6WHf/IrfH8cfZJhEI3Jh/rbhk+umfbtIb4o83E777p3ll5q5 yauw== X-Gm-Message-State: AO0yUKUxocP+4DYC6oamY025A9ZA81pOXUGEKjia2MVUfwx5Z1gt7406 mluCwaVpk7XJ+C3r1tmNWdX/TtbKn6BeNQSl5DM= X-Received: by 2002:a62:4e06:0:b0:628:9b4:a6a3 with SMTP id c6-20020a624e06000000b0062809b4a6a3mr5322716pfb.2.1679569768883; Thu, 23 Mar 2023 04:09:28 -0700 (PDT) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q17-20020a62ae11000000b005abc0d426c4sm11787011pff.54.2023.03.23.04.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 04:09:28 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Masahisa Kojima Subject: [PATCH v4 2/5] efi_loader: versioning support in GetImageInfo Date: Thu, 23 Mar 2023 20:09:02 +0900 Message-Id: <20230323110906.23783-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230323110906.23783-1-masahisa.kojima@linaro.org> References: <20230323110906.23783-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 Reviewed-by: Ilias Apalodimas --- 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 fb5f7906d3..7536fcfa55 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; }