From patchwork Tue Jun 6 09:40:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 689688 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp2537883wru; Tue, 6 Jun 2023 02:42:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7bXW8tnMyW2xY60rN8MfOQrcQnRUuzhurkiK4GwEKVr3Qy4akX8VEaPe9lQ9OmsLqCjCGC X-Received: by 2002:a17:902:760d:b0:1b1:862b:cdbb with SMTP id k13-20020a170902760d00b001b1862bcdbbmr500516pll.20.1686044573311; Tue, 06 Jun 2023 02:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686044573; cv=none; d=google.com; s=arc-20160816; b=bVLDJuvSJBIIsyIvuaHFBuq4Ad4NE7kUlBSvHAYsdq6vy3O4Z4xS8ZVL0KS+2g6h8c TI+tOCZ1VmTPL8itqkrwi4Gu1spdEj7CVGK5YC317VQwqi8TqiWcuWcEB05j55aGwtIQ gkljDGr0bBkC+TOA0q9kpSPe1nElN1nHmxAg0zUdQ0171n7XcGQQS8NfjSCp2JOnGGbo krsvx0KAN1Bdt0tNUyagBFt0M6oe97SbKZUgIQpuIhnlcXHLHaZvkE/KtIogzQo9CFNT JVImcbM6Is259j13m8tpurCBpKLqV8ncT1AkSphmUPMrOZmdD3TTpR3zaXdVXSoEMOym ncVw== 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=CflX0yJqASLhW0SjYkG5uBYc4kYeyWkxSPAqJhJOX1ek6/lg0drj2/STFZ+mSVaP/Q Vs01+KPA1284Xs7HMXV1LYPZCicQlibhA9tUnPjxJsP7p5t5BLm4bhztsvtMquvzfUG7 VlO5/FkWHUlsH99DjQ+QA0WnjidTtNCFpQiLM1QyHO68Sf5GHyU/ungo9F0SZOI98RRf 3MYeIi2y4P/dQ/9hCt3NDDisSykNF5OJZ/Vfu1skQwp1s5MO1Gx/UjE2hspa45VNpySA mRMvrziVJBO6FAbD3/t5nxM9Af3t2vkq4rVOKLa5jq1kr3B0nj7PxtdQoFTLU+u8d0OD xX8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B0aHKzdX; 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 n1-20020a170902dc8100b001add3e4ee84si6941106pld.132.2023.06.06.02.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:42:53 -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=B0aHKzdX; 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 8F27785E7D; Tue, 6 Jun 2023 11:41:57 +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="B0aHKzdX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C439185F3D; Tue, 6 Jun 2023 11:41:50 +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-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (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 BBE5C85DE2 for ; Tue, 6 Jun 2023 11:41:45 +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-oi1-x22d.google.com with SMTP id 5614622812f47-39c503bc770so224204b6e.0 for ; Tue, 06 Jun 2023 02:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686044504; x=1688636504; 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=B0aHKzdXj1a+all4kqFROghElIAzSK7O5ezR4pcGZhoY1tgzGpJo/UDwvM041J//pZ qIRj+VaDBi2sYSHYSz3GYDaUVCi7oYM/Rkd/gMo4xntCsh6DPPPoIhALgzIDzrqCiByD 3S5B6E5dTbJZHL9HX0qeRUyf9Pm8TbJI30gkOYNUKpc6ZHiIvQ4FiMOb4Wb8kTvZL1v+ utWqUM5meDf+UJj3l00Wnu0mcUMzYcvT4J5K3Hp4/QTbvu+CW0YavfNIqNUpFH/sir4Q 8O5JJ2pvehDnykC6LQs6Ir9frr8sUwKD/5p0hmGvEadSgTEMQvEdHK0lz+QpXwqn1Erh 1C/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686044504; x=1688636504; 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=bhk925K3vTb7ojY52BU5eByQqr+Q6Bb+pI5h5OOf57l/huJ5NdU8miy+Y1lzMSBIin RxGwB9Ky89fusxvs21l4T2nOTq0BVdmzL/gkJlSYlt2aH2BjAdcW1XbXeF1FZAGZLNsL kacYR+wY3aOQpkteqntQehvXC/JHJ+K0PkQUNVxpG+EtKqvLkyDfgaDXed02poz1V9l/ 6yi2MicNm9PB+7wKA0uTzys4bdlxLCGUMRKi9oL68pXbR2kSKzb2xcuI/FzzyzMr1ZAW yfH9luJBiIFLSJys5OfvLTs0+nEmbEU8HV33gVbMEc6Lx674LzEG5HuCr9tmoJTPuO3h BN3Q== X-Gm-Message-State: AC+VfDx9K1g83uiZ56mSAf09FbkO+lLS08fpiT/MnZ8NZeH9RDCjfowv 6yi+zkgBZKLWiDE6SYaLQrclNkGSrYu8djTStFw= X-Received: by 2002:aca:1011:0:b0:38c:c177:a6bb with SMTP id 17-20020aca1011000000b0038cc177a6bbmr1788633oiq.23.1686044503960; Tue, 06 Jun 2023 02:41:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:41: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 v8 04/10] efi_loader: get lowest supported version from device tree Date: Tue, 6 Jun 2023 18:40:28 +0900 Message-Id: <20230606094035.28990-5-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 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; }