From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98DA9C77B73 for ; Mon, 22 May 2023 21:34:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD8BB8206E; Mon, 22 May 2023 23:33:58 +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="IDoN7lzJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6896982153; Mon, 22 May 2023 23:33:56 +0200 (CEST) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450: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 E7E4B81D65 for ; Mon, 22 May 2023 23:33: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=ilias.apalodimas@linaro.org Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-30796c0cbcaso6608299f8f.1 for ; Mon, 22 May 2023 14:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684791233; x=1687383233; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=059OcyQWAKlWbJDJSKaU4uDbp4Ag6/y5WL1nXA3oZHc=; b=IDoN7lzJ4ACjUigN7Mw97otrXUYTNsC2PzxrtAemTQOasOpAcJbwCiArob7VFSoNl+ vKh3UiDyhkWa4+sRQg9ArwyWVOq+Ca6rn59VEKzSetYme5ZJKbtyaqe9Gdzqhf6pf++7 bc9/zQt4WF7/luoVTO7oMG8l2eB7+obWkQKQk0VurLWrsNoO9jsXXkhzBVXhww7hEuhv 3Ubp1TIn/k518MSH8gd1uNfSBBUcE4hMhddVo5zF+2lP2HHLaEq8C2U1JVJoTnlzjvnV nmYwdJvDjUNm9BDHdS4GLf9CoTF6rYp9d+9aeRwBT2f8ucfxRbYAgTEEEwTph/rXKf7R nnKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684791233; x=1687383233; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=059OcyQWAKlWbJDJSKaU4uDbp4Ag6/y5WL1nXA3oZHc=; b=NH5BDVpW7/sPqdEuNeVrRPO3PVM6eoPNrDIcH4CkBWiFI5qOAa1zbvszYJ5KkNVECI V1D7NobyD5L5L1U5hJI9RvO5LnG3OHGKHMr0CNmix7wxWCikFqBqGO2HIAeqCe1681wl hGx665s+nfZ/Hv80sxrRViji/iXcCD/DaMG4CxmREaYYytRTL6CnjLcWTp+HKA7vtwWb XYD0jAAN5OOuFCrt5OilXHrt1pt3qJM3moK4eyx7VtKZaErKkmN6ojRou0N+f/ut0NO+ Oxj2yPUv9ZdBIJfTAuUAvmYeQ12uS707di1dB5c/6Ftt093JS33WsIahEBTG55hldEpr vN1g== X-Gm-Message-State: AC+VfDzbX1T1f6Zf8irvoy0FWJ/Hu5NafpYvEd4/qmbj1FYAxOk5+is2 vaiorVN4TIyLc3sBrfjZM0oCZQ== X-Google-Smtp-Source: ACHHUZ5eLE9quUlodlbzqC+Ae8A6KMxv3AmYQf62bR5tCWQ7SUeMTroPCoIry/teKtSgJg9LoVsoxA== X-Received: by 2002:adf:dd89:0:b0:307:7e68:3a47 with SMTP id x9-20020adfdd89000000b003077e683a47mr8430623wrl.37.1684791233315; Mon, 22 May 2023 14:33:53 -0700 (PDT) Received: from hera (ppp176092130041.access.hol.gr. [176.92.130.41]) by smtp.gmail.com with ESMTPSA id c5-20020adfe705000000b002c71b4d476asm8985147wrm.106.2023.05.22.14.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 14:33:52 -0700 (PDT) Date: Tue, 23 May 2023 00:33:50 +0300 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Simon Glass , Takahiro Akashi Subject: Re: [PATCH v6 4/8] efi_loader: get lowest supported version from device tree Message-ID: References: <20230519103214.1239656-1-masahisa.kojima@linaro.org> <20230519103214.1239656-5-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230519103214.1239656-5-masahisa.kojima@linaro.org> 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 On Fri, May 19, 2023 at 07:32:10PM +0900, Masahisa Kojima wrote: > This commit gets the lowest supported version from device tree, > then fills the lowest supported version in FMP->GetImageInfo(). > > Signed-off-by: Masahisa Kojima > --- > 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; > } > -- > 2.17.1 > Reviewed-by: Ilias Apalodimas