From patchwork Wed Jun 7 05:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 690168 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp139755wru; Tue, 6 Jun 2023 22:43:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68S803XJ1095s7bVQu0LDzpo7p2YIKR1HpR2aQdZ3o5RMZMNXTkuDPtD1n/PH2Jswc4jt2 X-Received: by 2002:a05:6a21:9101:b0:10a:9f45:e3f with SMTP id tn1-20020a056a21910100b0010a9f450e3fmr789182pzb.12.1686116603941; Tue, 06 Jun 2023 22:43:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686116603; cv=none; d=google.com; s=arc-20160816; b=tPx749DqaKflLvMuWEOEOtA8HB1A45fHil8YAum7Od5IW4VpU29Z1FitoeA29ZN6SG dMLyKBBwpQSHlxcWwYZNEdqDvssmWChWkWQ114kBsYGbduvP0IWJ7rzgj1KyV2kCJ7O6 IXh3BXKx/9iZjiEQCL5GPKaLGOUfmRkEfaiaiy5U+tEJpkioIfQFjV6WLcPz6Ldtb4Eb HhygvzuWYwV55gQ6oy5x6eQhpYZwz0zQ/jOkanvX3KC5GXuV6Rhl1isjvXv/uLSdg3G6 +JoncZE8mAKjbEjcvT2wn3gvURyJid+Lmw44cDh+4n2Voiga4pM1ppf2xd9wmMtJOpGK j0jw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n0Z04dWPgPckxWdjfSL17/6m3hBT++D2uJu2TYzne6g=; b=TSXpWfqn/ACx4ECBsygMD02hRCfE5lPUY4dd2WRsJn/SQ3sBhliZ6KAcKPfjW9HM2l O/HyDU8yQkI7jEuJSuX/jPBr7ljWRaQG0d+5qK1T72UPndL8mXNPdMqgYmHqCv+IQkWJ Db/H5FOP5QhOB+rhEZ3MxwQ9ezHux0fSldEaKUXbBD9wNdDmKPzhJTCAtacMixMHBnhp v2xLdu4Qja6Eb5fhQ+3vKbk3KJeUkAqYd7/0tg9v7Gr1i8V7mfCvkKuZ9RGFvpzYa3nc xXOvVLCNkgTh5iWGaE3Co8KaL2vUJX/+76oaXe/76T9O4L1m3vAs8PdCYxgSdf6WSFis Xi3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o7pJhXnl; 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 d18-20020a170902aa9200b001aadd1e0384si8297406plr.192.2023.06.06.22.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 22:43:23 -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=o7pJhXnl; 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 90F7E86020; Wed, 7 Jun 2023 07:42:51 +0200 (CEST) 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="o7pJhXnl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ECDC385FD2; Wed, 7 Jun 2023 07:42:48 +0200 (CEST) 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) (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 1E66E85F8E for ; Wed, 7 Jun 2023 07:42:46 +0200 (CEST) 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-oo1-xc31.google.com with SMTP id 006d021491bc7-558b04141e2so2579822eaf.0 for ; Tue, 06 Jun 2023 22:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686116564; x=1688708564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n0Z04dWPgPckxWdjfSL17/6m3hBT++D2uJu2TYzne6g=; b=o7pJhXnlRsQIlwQhlCy2RFuoTc9nlB7TWD+s4R/ftK9tyotKTgHItQex8w7fONOhRK lz0qX9mqbvws9TY4gTjfOtM79yuon3sTsWHEOudB02BDNSn1tw6Vti8MKUkURrW+JPGu YBFOVwh1z3XsxYqC3tiXhTiAdQdCw99y6bl/UHhu1XuKMQ6CU38OKSCcBa3r4UtynYUh hWkh+1p5kfezmHcL9DRnxhxnsdkJ4MMl/ZfzZ1p44Vm5VnugAxoDQATsr/Ags0rEmWy7 McKL4VoDwFDTza35+x66ABG0IRjbzIlpzBIHAPh+V5TBLGKra8EvreoWiBDAxhI6iPcZ ijDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686116564; x=1688708564; h=content-transfer-encoding:mime-version: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=n0Z04dWPgPckxWdjfSL17/6m3hBT++D2uJu2TYzne6g=; b=TqSsGTIeeEA96UIqK5N34nsr0+aqYD+Lt66FVUpZx0MH+CIND6E1tAyp5y8mgGUZq4 asbPp/ED7dcJmPiivR1DmXn26tFBIqqHE9Z0gu/CTf/y6inilSWYRANZQEoEq+zcuLQ6 AmmvAqwofatG7QWm94biMzHms4d3AEaeUk8fisEFR9MrrU299KqdyM7Hp/sHmZleGAsC WDERrLZhHymxTi8YSrhOJ2gIQQa2a1Lq9MzCrx6avkWwNrE+c8HmCBZt5DxZCSntH5sO JC1mYzH1/2W2OkC1ZhdWDk0t+8f6F591Q/Jy/7KvBZWRKcAXNGvmg7skYEnLFFKpZ0l4 MAnA== X-Gm-Message-State: AC+VfDwIe43Fgc+jy1DXp6vEgRBb9E8vOXx3Ji/ucni/AIRxNoAguGaD HWe4gMjeV1HXEfIzhZz3PK7aUtLkj1+NzkieYQA= X-Received: by 2002:a05:6358:1a9c:b0:128:5278:cbcf with SMTP id gm28-20020a0563581a9c00b001285278cbcfmr2279112rwb.31.1686116564415; Tue, 06 Jun 2023 22:42:44 -0700 (PDT) Received: from ubuntu-SVE15129CJS.. ([240d:1a:cf7:5800:d3c2:bf07:d08b:b72d]) by smtp.gmail.com with ESMTPSA id fh2-20020a17090b034200b0024df2b712a7sm469033pjb.52.2023.06.06.22.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 22:42:43 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , malte.schmidt-oss@weidmueller.com, Masahisa Kojima Subject: [PATCH v9 03/10] efi_loader: versioning support in GetImageInfo Date: Wed, 7 Jun 2023 14:41:53 +0900 Message-Id: <20230607054201.42702-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607054201.42702-1-masahisa.kojima@linaro.org> References: <20230607054201.42702-1-masahisa.kojima@linaro.org> MIME-Version: 1.0 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 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 v6 Changes in v6: - create function to fill the version information lib/efi_loader/efi_firmware.c | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index a798d380a3..5b71a2fcc9 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -144,6 +144,39 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( return EFI_EXIT(EFI_UNSUPPORTED); } +/** + * efi_firmware_fill_version_info - fill the version information + * @image_info: Image information + * @fw_array: Pointer to size of new image + * + * Fill the version information into image_info strucrure. + * + */ +static +void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_info, + struct efi_fw_image *fw_array) +{ + u16 varname[13]; /* u"FmpStateXXXX" */ + efi_status_t ret; + efi_uintn_t size; + struct fmp_state var_state = { 0 }; + + efi_create_indexed_name(varname, sizeof(varname), "FmpState", + fw_array->image_index); + size = sizeof(var_state); + ret = efi_get_variable_int(varname, &fw_array->image_type_id, + NULL, &size, &var_state, NULL); + if (ret == EFI_SUCCESS) + image_info->version = var_state.fw_version; + else + image_info->version = 0; + + image_info->version_name = NULL; /* not supported */ + image_info->lowest_supported_image_version = 0; + image_info->last_attempt_version = 0; + image_info->last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS; +} + /** * efi_fill_image_desc_array - populate image descriptor array * @image_info_size: Size of @image_info @@ -193,11 +226,10 @@ static efi_status_t efi_fill_image_desc_array( 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 */ - image_info[i].version_name = NULL; /* not supported */ + efi_firmware_fill_version_info(&image_info[i], &fw_array[i]); + image_info[i].size = 0; image_info[i].attributes_supported = IMAGE_ATTRIBUTE_IMAGE_UPDATABLE | @@ -210,9 +242,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; }