From patchwork Wed May 31 03:35:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 687223 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp1054700wru; Tue, 30 May 2023 20:36:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5okt2aURUb1zmO8FJjU5RDEL6h0zta43CsIb+Wpv5aM0uIfx0SCu69r/LhQjTQ+jweEK/k X-Received: by 2002:a05:6870:b145:b0:187:e50a:43b7 with SMTP id a5-20020a056870b14500b00187e50a43b7mr2265651oal.1.1685504213730; Tue, 30 May 2023 20:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685504213; cv=none; d=google.com; s=arc-20160816; b=EfZaSyMRGjxcS2f1x4p5CfBW6zAlGl+NiDhmI/FvC4xa4d4avt4jm45pmEyqfMNPcp 1c1DG9dkBWti8NeGYptsixprA052R66nXnbPn6vThjQWzLNzOoJUjMcP01lePmw7kAWZ OR4k7l7xZEkTbRbA066JZClKLpv97LoOPGFeS1hmJporDh66mHHDeB3F+Zp3fZsfgAp6 Z+8tyVQ8fjWzC2RbaVT8SOYVTDm404+g39IlOQmCBCc6Pa1WNuTV0TS3jILf1jVbjvDs GBpg44gAcTEVhYIIQDe/kTQj/CLFeTISjQTYcV+l8pvWfOS2FT/pkBjX6+4jyDdNDEse Abog== 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=RSzDd7kO55tcRRv/Qc7RO01pEYgiMD0iuXM/nEA78DnKs+2HqJKeEspRJ5aX18H26z 7eO5PJ+U+nbyQWlBXmq/CQ2YIvosgADvr4lJOmWQ39WF0NE4bYQ0Z4w0pX7YtL+g/LoZ vmjM31Qj6uqdX01ZYTg6fEG3auUh+N7p6XldrJlkvMFQyB0CBN+OTJkXQZZdKSTzE5ip qqsuKmniZhtP7314TkN3pucLcmPhKlZHIRFJbsgiaWQumaa+hzs8XfXfprc2kh3PYo10 ppweVEQ2tEok4hdG2mqUKDx4PWe2cxCyOi6vUWrQ+JSPjZ51Lja+XTiGjQ5xr1mXe7hr VE3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D2M0nfIZ; 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 j191-20020a6380c8000000b0053f23442f2bsi222807pgd.443.2023.05.30.20.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 20:36: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=D2M0nfIZ; 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 339B886195; Wed, 31 May 2023 05:36:11 +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="D2M0nfIZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 737F3861A4; Wed, 31 May 2023 05:36:04 +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-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 2443F86130 for ; Wed, 31 May 2023 05:36:00 +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-il1-x12c.google.com with SMTP id e9e14a558f8ab-33b257651baso5872355ab.0 for ; Tue, 30 May 2023 20:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685504158; x=1688096158; 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=D2M0nfIZeafRSPMWOQz34q5dEIoZ3FjUtM/UnQtC6Xs9VceiRyCPwdbzUtcufXCBev wYx+GNc7ycxCUCp/ADn7Y7jxn+FlMTOCRd2EVSt9NUG21sYDpFfL/vdBNtfKw5tQF8ZB KDmbVKHJNpHm+7FwKy3nfGwLHgFf0GnGZqUwGYwNlk0RbEQGsrD+5zo8Ya4xO/9rQqtc j8qvMM/ikh1UrgnDNSmC7KpH9MzJN1LXNusFhAvo7DXdQshGhHxsxzZilh5hkfvuayZ9 5t3ZBILssPaXkDQ0h6RBeod/68IHR6naQ3WB4nmJ9Yybshbd9JsIh6gRIEM1vKVzrill pl8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685504158; x=1688096158; 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=jZwmmseSgsFd6IFwjQUzafgYyVlyhkgK9qSNHN6eAZSMrDSSea57p6OCEaEqP/tF3K /K9tBTR0Cl+WEFCWM8LpI5eBUToyyHRWsB68nXEvFHQkkaZkZYqQEmrfKxaByF0Fxm0r 5gGKMsIzAj/G2RZeDetKGiboX3h+8mKZ+JBvDaLmEdqrdKHY4RhNj8GpAxyxW5GqGVzx c0dsRF4jPsW/tx3jkXqMNReGUm6eEPPZn0XLdzthaKcQwTxZ15PwVvxXrtbdKvwkWqvj aIlUrlo3UeDNnsCYZYRKIYhljArP/se6gDm53HjAUMV7Zt6p+JhsuHYiCLauNZGv41pz Woyw== X-Gm-Message-State: AC+VfDzd97hA44fv49CIAFdpcbgKIwGEZyvo/8KbOcvaukhog9oIs7A9 nWGLTUkEClqmNApE5LemODoEqmjGvr7Xb0v+n00= X-Received: by 2002:a92:d581:0:b0:33b:848:378b with SMTP id a1-20020a92d581000000b0033b0848378bmr1141014iln.8.1685504158520; Tue, 30 May 2023 20:35:58 -0700 (PDT) Received: from ubuntu-SVE15129CJS.. ([240d:1a:cf7:5800:b037:3ab0:51c1:7dff]) by smtp.gmail.com with ESMTPSA id b4-20020a170902d30400b001b0395c3ffasm85709plc.180.2023.05.30.20.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 20:35:58 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Masahisa Kojima Subject: [PATCH v7 04/10] efi_loader: get lowest supported version from device tree Date: Wed, 31 May 2023 12:35:17 +0900 Message-Id: <20230531033523.1581973-5-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531033523.1581973-1-masahisa.kojima@linaro.org> References: <20230531033523.1581973-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; }