From patchwork Fri May 19 10:32:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 683899 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp853123wrt; Fri, 19 May 2023 03:33:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kh/0gCBCVO59ty54G6GiD3tQKt8GH+e+cjRkHyOZH18bq3xTD+WQyB29YKx9BX9tzc+Pl X-Received: by 2002:a05:6a00:a21:b0:644:ad29:fd37 with SMTP id p33-20020a056a000a2100b00644ad29fd37mr2492847pfh.28.1684492412374; Fri, 19 May 2023 03:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684492412; cv=none; d=google.com; s=arc-20160816; b=Ex10j4ob55vAkhe9D1GmNqzj+CLFFClqopKcAiJ+8dsh7hYRbcIi0gGRkL5xlzEbVd JM2TnsGsq8LJeibdUAO+o1o+icZcnHLWd5cEznT+MXNBNKKrwy56TMf7m2UQfQO7DFe/ FBcT6LVS+++BHgx4DK314IKpWrV1WJf+AU9UzMCKjG/6ZkIFWIbwHXHTDHVXqsBRRsLE KJuD5DaDQdVdHjUOJxykeCRsu6ljFJRkpP6CmcJ9gC/sqz8/wauyjoQ98rDU6hEISAVm QjnIN2VO9OEHt/hsetjzA5LqKnMz6nYza59FPaYdCs4Xgw7hBoJKZqTUIsvlEZof90Jp mhGA== 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=vFe4jYnKKjMjgznj7YCL9N3/YwICxUwPXFki6mDDffE=; b=ChkYE4biGS6uETyseYZPCqW8zZUsMiWHBMrWsWBdB/Vso18YBKm6Nlt9UofCtlxjO2 2MYMZFA/oEFlU4cLBSn7yQEx5oZUryttD1PB8r535ATo65E41tFl1lXFpEID0LFGcHL8 H5qmgX1EvkaoawJ8j0fPduv5JUrnVokaPyHkMWthFlTtfqfbc/ChMEJk95N6hAzhdp5y h4TBLK9ppHaXpifNVvPfgd58gP1GncOk7BhslSROf3S5N12mz/qRGq4CICJI8VZEkqIZ FWN7cjZRIb9DiISW6zsW9IKFNQ7dP65RWMyKtshIgmfPF95Jo/odNVsUV7lYrqrvm2Wp vlzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ma2YIP2w; 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 p18-20020aa79e92000000b0063f18073138si3760652pfq.99.2023.05.19.03.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 03:33:32 -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=ma2YIP2w; 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 E3121862D2; Fri, 19 May 2023 12:32:59 +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="ma2YIP2w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89DA281DCF; Fri, 19 May 2023 12:32:54 +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-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) (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 8289881DCF for ; Fri, 19 May 2023 12:32: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=masahisa.kojima@linaro.org Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6436dfa15b3so2242889b3a.1 for ; Fri, 19 May 2023 03:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684492369; x=1687084369; 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=vFe4jYnKKjMjgznj7YCL9N3/YwICxUwPXFki6mDDffE=; b=ma2YIP2whprCB9J+WwtFNBQdQPc67lM88b6wCMHgLAzMx/ucu33NQHGD8lCSWFj6zG 8FQ5BfoumDi8ABeM1UKrEEcJmGdgyjAVP8GGH96FgOFNQ4gamej9v+g+qbsm5kUa49rq tWlXKvDtuv4KjHA1OhI32m7sRtOzHVV1G+GwwQHZCEVJtV/VeMFDDCxyLxSloLMBmpnA nGw/9kZji8T9rI+091UQCvJuu/5Oj/TrJOgE04hoDYbBA3KWkGVoh7JfzbPYsRRfy6Dr aa90VXH9lewCQr1+0Cy8SNKdNmeRWZXchmw1jYr+1/y3sgzk58mzbp54+BQYGRTBvU0l H8CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684492369; x=1687084369; 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=vFe4jYnKKjMjgznj7YCL9N3/YwICxUwPXFki6mDDffE=; b=aynJrhled9msVZ8Kdh7PJxa1q0aGIFYYyJKug3ITvKIx0/4s1ncCfMxLRKys011rBH 2KfZGgNoTKdJGGrabMuosGFwcGAgMHMy0kPy11DNPvH7agTufIaUWIP+tveZaKSkih0p 5sBTPG1plZSvVvpoWmS1iEemuCqnzIxufQjAmat+xP2hDFok4nkpuwwM1qB4hku8zEp3 Yana//x9/pSRJj1wn6To0oGJKS/A88m68AEp98TpPUuiX8g+FJprzd9vuvRJX8dWdJAj 8EQRwfpLXBQc6NIbFVydWUujnH2vhJgu+5kcZspDr8k86iaxefmTiIN85/cIpW2PZfbE cbaQ== X-Gm-Message-State: AC+VfDxbJUfIBzlZ8Rq08YY/C7jNwgmSrgfyRi5Q643fLx+9/7ARvn4t a4wIDg4i6szRpGUiSdXqXp59qsYAEQFC3imUQmE= X-Received: by 2002:a05:6a21:3703:b0:102:dd98:509b with SMTP id yl3-20020a056a21370300b00102dd98509bmr1391827pzb.21.1684492369624; Fri, 19 May 2023 03:32:49 -0700 (PDT) Received: from ubuntu-SVE15129CJS.. ([240d:1a:cf7:5800:8e72:6c60:18e6:c4c4]) by smtp.gmail.com with ESMTPSA id r13-20020a17090a940d00b0025352448ba9sm1195870pjo.0.2023.05.19.03.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 03:32:48 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Masahisa Kojima Subject: [PATCH v6 3/8] efi_loader: versioning support in GetImageInfo Date: Fri, 19 May 2023 19:32:09 +0900 Message-Id: <20230519103214.1239656-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519103214.1239656-1-masahisa.kojima@linaro.org> References: <20230519103214.1239656-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 --- 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 fc085e3c08..64ceefa212 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; }