From patchwork Tue Jun 6 09:40:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 689687 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp2537787wru; Tue, 6 Jun 2023 02:42:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78UQBlNtqy4GLVY+Rcx5laLpyvxXAjo55xLOVUFh+ovT9KpZ22u+fjO9Qmq5owqpcyehkK X-Received: by 2002:a05:6a00:1a0e:b0:651:cd9d:7dd7 with SMTP id g14-20020a056a001a0e00b00651cd9d7dd7mr1772652pfv.15.1686044550482; Tue, 06 Jun 2023 02:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686044550; cv=none; d=google.com; s=arc-20160816; b=sE0rrDAfvfhebgs8fHYzwUZQ/icRNYU3Ku/fS2fdPVY1KDx456cwxCwdXehkFAYdWP 7gAMGQvyV5y3nKX6anWieZuhHmwIwDWDLble2ihAsZPL8d2Vs60tbIMR8BVgyg0uBK9t AI7ZPv4ssh2/L1PvgnuErCrXnPXbKrMt9DAz7blmu5Tj35vQYeG80F1H8OpWYuaxO1Hh 3AlF3ORChl7DxWXO6G/D+Mxi+dB8OdGVlrXyCKnJELfF6PeVriVlXwZs39yUSXErtd3B Jw7TToDP/H5+DgddXK9IUQJAd1cvRmAu2Pg2T1ecyAZbk9CCQ706IrBQeJJVp6zfyrXD BgEA== 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=LTcQD4DwhN97QN3czdvdhy2I6dSvLRHA1wiNqAhhhUZbTevpwbvTc4Tq3IYNhitE+W T8S966rboVQDGAqXOv7vm/9P3Xj4snGiMOqc4MAbUHVFOCZ4Zp/LpzmRqjgSvgWSzr8J PKpJIu+xH2Bhb4ngV+Y49Hs1dalpGudia2MXfhBx4m0PIPQYUBjIlqvGfsYyEaqjF8lt 4CTCxh/eUJe7gWm4Us1muh3rQO5yNfm5PgjgGqvoK0wILQtSQbvpxjCdcEWbjqW151Ow 7psknX8T02JKKMlg/wiQZo9AT2R0s1eloHqqDHhnMdsp91cymnoL4Ktlnjf8/MeaCby9 mQKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QA8e2bV2; 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-20020aa797b2000000b00653a59e83b3si6336235pfq.70.2023.06.06.02.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:42:30 -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=QA8e2bV2; 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 2079E85F29; Tue, 6 Jun 2023 11:41:53 +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="QA8e2bV2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FF9485F4F; Tue, 6 Jun 2023 11:41:49 +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-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 8097585EE7 for ; Tue, 6 Jun 2023 11:41:42 +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-x430.google.com with SMTP id d2e1a72fcca58-6549df4321aso3318144b3a.2 for ; Tue, 06 Jun 2023 02:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686044500; x=1688636500; 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=QA8e2bV2WrD4E1IKvmCFIB9zczLuxbpusafa8B+CRCwjGP9K70Gt4LtPG8ML3oVVWG SNeKeuT956c034dGVLWJVY1mpN+ZbqjuZTcGYoggCvjM/7LdS741w99R+86izxrJKQIX QIJMj8PlvkVSwrFUm7+BmyFQV6LDP2ZQSUFuJkop7XYptgPaQqFK65E7DGYvP6Wq0yyX lnIVLlD9GMNhJ1VelN+BRF+HDJ5i5ipGwHyW6a5e+4w4QRzZVHsWJfjuT9s36ONK7RQB gwuNwwWjZsO21G+8NtVDfPONitb2wZaZjxxr6YPkDgHSIVna5+XaOmpRpJAfFOwSavLW 63Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686044500; x=1688636500; 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=lbnmnQw14ctkUTqQ6c+D8Kd4B9nBcRZzlb2Kwb49lDdUSGuXk8y7/t6VdwjA2SkMeZ mxMDgDBzxqJOPepQ6ehhEHrh+31hjzaoZTw9agXOS1iRc0fhJp5CmIQp/9WsRPG9P17J iIOUBN5tH98cvefXv01XZHCN5c4ycGlS+m0EE/nDwfTt8BRs6Y3nOTBAgp/Rd/foj10s JoRg4KnmuBOsqERvnL1WpMkCVbIydmbdN5qS6w7arFZ8nFjh3qNkwijkR0kNt7GuhR80 s1YBR3JL7XV6aahdSUxKioi8Hxhhyta7rxhP4hByDFa0oQ/ovSWevaV+h+eXpoFZUTve lw4A== X-Gm-Message-State: AC+VfDzsdBaDDBQWM872hQXO5IlS2GiH+yRsvzXib12ueRwmXqYv6Phk Tt51rXH7d6mmNjI1btdwHmFZ6h83gWdRBP69Qg8= X-Received: by 2002:a05:6a00:842:b0:658:f86f:b18e with SMTP id q2-20020a056a00084200b00658f86fb18emr1938622pfk.22.1686044500462; Tue, 06 Jun 2023 02:41:40 -0700 (PDT) Received: from ubuntu-SVE15129CJS.. ([240d:1a:cf7:5800:d3c2:bf07:d08b:b72d]) by smtp.gmail.com with ESMTPSA id u25-20020aa78399000000b00627ed4e23e0sm6542809pfm.101.2023.06.06.02.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:41:39 -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 v8 03/10] efi_loader: versioning support in GetImageInfo Date: Tue, 6 Jun 2023 18:40:27 +0900 Message-Id: <20230606094035.28990-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230606094035.28990-1-masahisa.kojima@linaro.org> References: <20230606094035.28990-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; }