From patchwork Fri May 19 10:32:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 683900 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp853239wrt; Fri, 19 May 2023 03:33:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6RlYpjZ+qOJOj3SeovDzPE9nN7X7CXavtWjsuclJVjg3ymLzroMh0cmcixqlh2eW40UKv/ X-Received: by 2002:a17:90a:af96:b0:253:5375:bf57 with SMTP id w22-20020a17090aaf9600b002535375bf57mr1711440pjq.26.1684492425635; Fri, 19 May 2023 03:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684492425; cv=none; d=google.com; s=arc-20160816; b=hrSjsdyCEIfbLwcyA9zfI1HDHPsg8x4+20xVg0LCbHNktDyHLSvirQ6kKX9CvhpXc9 tGmYbrAzI7EIyIe8VJ/NOakS3rC1ama6Y9/OUn7V8a2jxi6kbFj72tdKnpXETpXLIFPx /BTN1FiPqdtEluVNlcJMm119Hd3oBL1Y1v6qlSzIAI7Nb2nu7XziWxFJl6x53Sioab/3 5i8e16kqX21jp4nXQsoRtCBfnEbHiMmg92BdlnJQ1vJjKOTIIBF5Offai7RMGfHYi2YG HHV8r1s1qHNJ01h6/32nZ7gCKqPMO6BO9x4xnNjHzci0c5WSPMkG6mGx0OGrJyuvKn6s XYtQ== 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=tbjlSo/Rx7V8KMXVY5KC1bmVaKeb6AIJaZOay3qxEmk=; b=DO6uxVKY5RkOumfms0GA727TvEeHxmpN6p2Ol+ZRq1BKABFCkjP0H6yXP84sX61nFy h3a6nqUZbAgeXTVfcFtHaNys7mF5HhcrbvMW4e7pFZQpbcacUq9C7Ri+lBPOhITORzhA opqTX7gnNCx1AWC+wSO1x9wVpkwHU9AkLzVjGwo6soXUmDtZ65wYbZLpavkJgMNcim9B QmmKCZrcV7u583LUQ/ZD9gROcftneqRYr1w0fDhCmiOilK0N1sRLLo5U45u4MYh3B/lD wBRCwm3yyCx+829dZPYj0jDxSbIaSFCnjZqc49qxbKSgWDx2T9XJ41tuuYAcgF7WMlqN RA4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K7ORRnD2; 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 c5-20020a17090abf0500b0025350783742si1619355pjs.5.2023.05.19.03.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 03:33:45 -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=K7ORRnD2; 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 9622C86292; Fri, 19 May 2023 12:33:03 +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="K7ORRnD2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 35FF3862C5; Fri, 19 May 2023 12:32:59 +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-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) (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 6927086274 for ; Fri, 19 May 2023 12:32:54 +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-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-25372604818so842019a91.2 for ; Fri, 19 May 2023 03:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684492372; x=1687084372; 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=tbjlSo/Rx7V8KMXVY5KC1bmVaKeb6AIJaZOay3qxEmk=; b=K7ORRnD21EVbhTVhap9PGCJl2IaQECy0ScXejWV4hCQbgmuamFpNO9vsuomb3DiCH8 ICeKJgMowtlYX9Q2+V1l10eOu+Ky9WDNlYU5GxFP6mlNa7ltqrDK69WCgvm632SPfEM3 LtA/PPGh/Q/w0qi57ny3bcd2LqBqmVEekXdexsGIgyzrUyHQ21VeLek1PehTPVVY1xjg W0togjlS8H7KeZ6wGT1JFIGNo6uDrep8S+9flFDpxRnD1Rkqh2DEbX3rs0OlbIYoJkF6 yCNLEfFgBtevSm8fkOn3JK+NQu0yNtr6IWZV0zAVPDx9Hcvs6qMOTxQtRuc3dIQytn1B wd1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684492372; x=1687084372; 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=tbjlSo/Rx7V8KMXVY5KC1bmVaKeb6AIJaZOay3qxEmk=; b=RG8hIq8phDWfvNQhQWZiUlDgVgLuBWToUW94MpcY+wQmhXYCBB+OU7gBGZhmqHM04y /XpFjnvC+t+5rUr6EW+GTI690uNAHYbGC+FClPd3OQjkR4dkdfcucBW1xNNFcfmQoU3S znWRWWKKdZUaT/+RHCyjU86UhWc2hRE3kzMI69E05HuAC0sgDCP/wFLldlgErow4jfti CG0a+W77iCVLpmkqGvH14V8VD9UAAclJnBfOnocLxchBe45V2Tqqm3vXiHp5hVzyitTy yEpk0qunZ+f/MvMWN39mp7bB7Zcq2WVW0Lq2nFScA5cfbXcHKOdDX85Hqg5dbpEn8HtL 8Hcw== X-Gm-Message-State: AC+VfDzuvP036Z67gTydM8dAGoFgWUwGTQZgaLnIH/YZkUGRja4mVQsS krmlM53qnx+rIRlj3Doy/k5zUDyZyrth79J98Uk= X-Received: by 2002:a17:90b:892:b0:24e:1a7:9976 with SMTP id bj18-20020a17090b089200b0024e01a79976mr1751198pjb.10.1684492372612; Fri, 19 May 2023 03:32:52 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 03:32:52 -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 4/8] efi_loader: get lowest supported version from device tree Date: Fri, 19 May 2023 19:32:10 +0900 Message-Id: <20230519103214.1239656-5-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 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 --- 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 64ceefa212..00cf9a088a 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; }