From patchwork Wed Jun 7 05:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 690169 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp139795wru; Tue, 6 Jun 2023 22:43:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73jlD1G/BLWjdz8p8E05XHRJa15IrXq/MPIml+G7SfJoZR+XmunR1buRjkT/GwaqR7ZzNe X-Received: by 2002:a17:903:32cf:b0:1b2:1ee9:682 with SMTP id i15-20020a17090332cf00b001b21ee90682mr2893754plr.23.1686116617141; Tue, 06 Jun 2023 22:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686116617; cv=none; d=google.com; s=arc-20160816; b=VXZSYE2P+xWBcm6gC0FO7OYaRihLBD2fBSdXVRfOq3oj7JLYjNG6XvQZDhEqaykukk zJ6dTdiOeJXzj9/0YSKKn57t6aMkyvewMTzDeXHvaqco5tk3q4Yi+O+XrygwwX0bI6lJ oEjRy/TOpwBRsIqiWmbarX5uxg25oChzdwLYvCe8XQl7mq38yGDSqr2SbwaIRvpxIDtV Rz39XRDmmbuq3E0c1zL5t+HEFdoTe1F9RQgfSYwWKIxZ0AW4jePAr22Y0EUK2bHTBa75 T8rK3B/u3bbjMtSs9pZImSDzDRw6jv/ebUrcfwCto4FCVBCuxGLYt7psmQEJqCHkrVMU mOkA== 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=zHNH1e3DvXkdHTV1G1nA6dtwhOQUMXNT/LMvyWH6ix0=; b=lKkQypNlAxeEHofYxM/Aqw9vzZdg+TWPB0N/sEOuxWB6+ZaeXoYnE5OfeWBq59yJHc pouOH6JP/25eplEwpl4XRGKXmWuzQETq8yy/KuYozU/LDT9V9wghx5U+XBinzYOuHLt2 3NIy3N9JiOmYYvPoiti0I+WR0ZQmYkGxUSbRPzTxNszIR4Xb8Y771vCO/o7LXvBzyqjy R3XhkShhgLj82nvHfKNQKC2/zW5mTX/rkKLKyzTxGUyape3pq41IG5fHHp1jdSTxTpcR IfCuZmVfQyHg/HZYmKg5PWMgo9ccTT9dc2DsXWL0l4ch6VLEugaPFbtf+KJWSndYwYfU hyAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cmgfClUC; 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 e14-20020a17090301ce00b001afada38c64si8443466plh.302.2023.06.06.22.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 22:43:37 -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=cmgfClUC; 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 A254385FDD; Wed, 7 Jun 2023 07:42:56 +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="cmgfClUC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0052185FEB; Wed, 7 Jun 2023 07:42: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-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) (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 D7C0A80181 for ; Wed, 7 Jun 2023 07:42:49 +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-xc32.google.com with SMTP id 006d021491bc7-55564892accso4747061eaf.2 for ; Tue, 06 Jun 2023 22:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686116568; x=1688708568; 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=zHNH1e3DvXkdHTV1G1nA6dtwhOQUMXNT/LMvyWH6ix0=; b=cmgfClUCHbOnTD0QC4CYcSEVvfF9E2LM91FUA4mV7EIJKVsUMgsASuqm9BAizppoyD 4gXkaeMisLUzEeteb9FTQKrI2QIxp194gkDBk3GeuCUyi+eXGGXKLN8Ud4SNLlvxiKDt 5fPp+7OYxJvFYExkhZ83Hw6kNT8qwCG41iUU6T4/EffqcNrelr99NKemi+Ju1gvnxwdI uB15JDQuRH94xPRGw+88JYi7MiBvn8bCGlj6JooyN6bOc2J8h3KNQibcAWgUs6dbNWql JM9Vx7Fii2x9L6uAuUNPBcMu97NwS4UB5QTcGd7OPSopa4TViQCjJ8Fc8GwbZaaV/AlV dzuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686116568; x=1688708568; 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=zHNH1e3DvXkdHTV1G1nA6dtwhOQUMXNT/LMvyWH6ix0=; b=Ew3FpTptPmzx2h4RFPmreNBDfZfEtGDEZEh3+Qwmej8+zGdaNaiRGXgX3BqS7lMaVX MJ2Gaf/qqpmC+y93cJFcz2ZgCB9nGj/YKCa9/qpkApG/YVHB18G014BES8NCRV9gp7v0 V3n0qLJly3TxWpOwkgCqiVKPiMEoyZZ2OtCk0AGKs7roZ13Tn3X1JoULJdj2ymdbC1KN 2GE3AI+tSc1as1KY9HfHi9C3wuMwGXzrBYnuxwJ1fKCdG06cf5LlqCok7jKmplTJ5vvk Cjndp5H83qI0xjjKvIW4Mtw2JKTV70MH6qB4bu5Mx3mie9GvFTvqZudOVY7QgBQ8kSh+ lJMA== X-Gm-Message-State: AC+VfDzzak+3nte3RcpMquhEbKGG94JjxIE9avmkqp9oMX0uFqM/v+Q5 5K+3KJWISQEl50jK0Kg+z+pH5bDTasTv0TBC0Bw= X-Received: by 2002:a05:6358:1a9c:b0:128:5278:cbcf with SMTP id gm28-20020a0563581a9c00b001285278cbcfmr2279270rwb.31.1686116567958; Tue, 06 Jun 2023 22:42:47 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 22:42:47 -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 04/10] efi_loader: get lowest supported version from device tree Date: Wed, 7 Jun 2023 14:41:54 +0900 Message-Id: <20230607054201.42702-5-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 This commit gets the lowest supported version from device tree, then fills the lowest supported version in FMP->GetImageInfo(). Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- No update since v6 Changed in v6: - fw_version is removed from device tree .../firmware/firmware-version.txt | 22 ++++++++ lib/efi_loader/efi_firmware.c | 50 ++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 doc/device-tree-bindings/firmware/firmware-version.txt diff --git a/doc/device-tree-bindings/firmware/firmware-version.txt b/doc/device-tree-bindings/firmware/firmware-version.txt new file mode 100644 index 0000000000..ee90ce3117 --- /dev/null +++ b/doc/device-tree-bindings/firmware/firmware-version.txt @@ -0,0 +1,22 @@ +firmware-version bindings +------------------------------- + +Required properties: +- image-type-id : guid for image blob type +- image-index : image index +- lowest-supported-version : lowest supported version + +Example: + + firmware-version { + image1 { + image-type-id = "09D7CF52-0720-4710-91D1-08469B7FE9C8"; + image-index = <1>; + lowest-supported-version = <3>; + }; + image2 { + image-type-id = "5A7021F5-FEF2-48B4-AABA-832E777418C0"; + image-index = <2>; + lowest-supported-version = <7>; + }; + }; diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 5b71a2fcc9..ae631f49f7 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -144,6 +144,51 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( return EFI_EXIT(EFI_UNSUPPORTED); } +/** + * efi_firmware_get_lsv_from_dtb - get lowest supported version from dtb + * @image_index: Image index + * @image_type_id: Image type id + * @lsv: Pointer to store the lowest supported version + * + * Read the firmware version information from dtb. + */ +static void efi_firmware_get_lsv_from_dtb(u8 image_index, + efi_guid_t *image_type_id, u32 *lsv) +{ + const void *fdt = gd->fdt_blob; + const fdt32_t *val; + const char *guid_str; + int len, offset, index; + int parent; + + *lsv = 0; + + parent = fdt_subnode_offset(fdt, 0, "firmware-version"); + if (parent < 0) + return; + + fdt_for_each_subnode(offset, fdt, parent) { + efi_guid_t guid; + + guid_str = fdt_getprop(fdt, offset, "image-type-id", &len); + if (!guid_str) + continue; + uuid_str_to_bin(guid_str, guid.b, UUID_STR_FORMAT_GUID); + + val = fdt_getprop(fdt, offset, "image-index", &len); + if (!val) + continue; + index = fdt32_to_cpu(*val); + + if (!guidcmp(&guid, image_type_id) && index == image_index) { + val = fdt_getprop(fdt, offset, + "lowest-supported-version", &len); + if (val) + *lsv = fdt32_to_cpu(*val); + } + } +} + /** * efi_firmware_fill_version_info - fill the version information * @image_info: Image information @@ -171,8 +216,11 @@ void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_ else image_info->version = 0; + efi_firmware_get_lsv_from_dtb(fw_array->image_index, + &fw_array->image_type_id, + &image_info->lowest_supported_image_version); + 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; }