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 41960C433F5 for ; Thu, 10 Feb 2022 07:58:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E6BB810F3; Thu, 10 Feb 2022 08:58:22 +0100 (CET) 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="EX+7Xha3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 22FCB81109; Thu, 10 Feb 2022 08:58:20 +0100 (CET) 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 14AB981109 for ; Thu, 10 Feb 2022 08:58:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x102c.google.com with SMTP id t14-20020a17090a3e4e00b001b8f6032d96so4793160pjm.2 for ; Wed, 09 Feb 2022 23:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=7XpEEIzJQhp4gENgcxshTt/tgJI0VFBTeE6/6QuSvQQ=; b=EX+7Xha3eoMqGg0T+t1VQo4gWWsDheSLCsbaGPLnGNeG0y0t2s7TuLzcSIMtqagUJh AsJ5WBajuGCVWLzHqxvpzR321h389BRp/E9Jz5lmOdS7QBAsNcrPZfP6BQHCpphNMvjt wbP2QtbU69HDdN1YJFaWl7D8lqXY8U8O92oBCYVyUqUdG/Gkp0/BgUGZp1IVsmperxWV BcsJJixu3e1O6K3CK+gaTrRPzOIc+HYCtx6ZLP1CZtwZjcOJznHVAFhtO1t/ISRr0ymW iCnFCrerLVe9hzbUOberuPoFRJZ6h9v2/fRgsSteWd0EaNaTG3sXF9rsnDfmQUfas2Ad d3XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=7XpEEIzJQhp4gENgcxshTt/tgJI0VFBTeE6/6QuSvQQ=; b=FGCRh7i09fVx9MqJLGDcWwd7EALF68rRETqH0yCfde6HHLGBV6UHYQxOKldUwr+mv6 KKGBc/vnMosuUN+4Y0Y8IGtimlCjtU6fIpsBAEiaFELnKT0Hliy2FeJS3aNrjdju0A10 L077lvdhhMpuGAK+BalICEmHkFcLsW0wRSt0n3ETWqF6YSXJGBk8lu62Aopb08cdTmhf WHrhPy2RxuOZgORIEAFD0KD/9IgbKg9dSD1V7GdKvKyhK3jEsbgxzBhT76PfNTE60m84 f8ijmgae7zFjmG+5+HOwmyIk+ZNAd6h3bCNGpYgFas8H2/Jmdvw6Rq2fEKboFc5DJoYD Cr+g== X-Gm-Message-State: AOAM533RTeuDpoYGchFsNVuX82fuxFoChiY7UgW5QyCuilKsptQCGuKY /QjcTdqikYB4X3vlaKqkEvtnFfyHbY4Waw== X-Google-Smtp-Source: ABdhPJwPIXsKuL4ZZNVHS9xiQXeAZarL326oiRrd0DsinGuTBeXxAQaZlyHExcNHrHeQEdPk7AB/1w== X-Received: by 2002:a17:90b:1c0f:: with SMTP id oc15mr1548691pjb.70.1644479894473; Wed, 09 Feb 2022 23:58:14 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id pi9sm1556230pjb.46.2022.02.09.23.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 23:58:14 -0800 (PST) Date: Thu, 10 Feb 2022 16:58:08 +0900 From: AKASHI Takahiro To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Alexander Graf , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere Subject: Re: [PATCH v4 05/11] EFI: FMP: Add provision to update image's ImageTypeId in image descriptor Message-ID: <20220210075808.GI12412@laputa> Mail-Followup-To: AKASHI Takahiro , Sughosh Ganu , u-boot@lists.denx.de, Heinrich Schuchardt , Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Alexander Graf , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere References: <20220207182001.31270-1-sughosh.ganu@linaro.org> <20220207182001.31270-6-sughosh.ganu@linaro.org> <20220210024828.GB12412@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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.5 at phobos.denx.de X-Virus-Status: Clean On Thu, Feb 10, 2022 at 12:48:13PM +0530, Sughosh Ganu wrote: > hi Takahiro, > > On Thu, 10 Feb 2022 at 08:18, AKASHI Takahiro > wrote: > > > > Hi Sughosh, > > > > On Mon, Feb 07, 2022 at 11:49:55PM +0530, Sughosh Ganu wrote: > > > The FWU Multi Banks Update feature allows updating different types of > > > updatable firmware images on the platform. These image types are > > > identified using the ImageTypeId GUID value. Add support in the > > > GetImageInfo function of the FMP protocol to get the GUID values for > > > the individual images and populate these in the image descriptor for > > > the corresponding images. > > > > After re-thinking of your approach here, I would have to say NAK. > > > > You use ImageTypeId to identify a particular firmware object. > > (By "object," I mean one of firmware instances represented by "dfu_alto_info". > > Please don't confuse it with the binary blob embedded in a capsule file.) > > But ImageTypeId is not for that purpose, at least, as my intention > > in initially implementing capsule framework and FMP drivers. > > > > 1) ImageTypeId is used to uniquely identify a corresponding FMP driver, > > either FIT FMP driver or Raw FMP driver. > > I believe the identification of an FMP protocol should be done by the > FMP GUID, What does FMP GUID stand for? > which is what is done in efi_fmp_find. The ImageTypeId is > nowhere involved in this identification. Please take a look at efi_capsule_update_firmware() carefully. efi_find_fmp() is called with the image's update_image_type_id which is to be set to EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID by mkeficapsule (see create_fwbin()). > > 2) Each firmware object handled by a given FMP driver can further be > > identified by ImageIndex. > > > > My implementation of efi_fmp_find() does (1) and Raw FMP driver does > > (2) in efi_firmware_raw_set_image() which takes "image_index" as > > a parameter. > > > > Using ImageTypeId as an identifier is simply wrong in my opinion and > > doesn't meet the UEFI specification. > > So, as per what you are stating, all payloads under a given > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER should have the same > ImageTypeId, either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID or > EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID. Same applies for all images in > the EFI_FIRMWARE_IMAGE_DESCRIPTOR. Because, without one of the two > values, > the check in efi_fmp_find to compare the UpdateImageTypeId > with the ImageTypeId retrieved from the image descriptor would simply > fail. I don't follow your point. Please elaborate a bit more. > I think this interpretation of the UEFI spec is incorrect, since the > spec states that the ImageTypeId and the UpdateImageTypeId are fields > used to identify the firmware component targeted for the update. If > all values in the image descriptor array and the UpdateImageTypeId are > the same, why have this field in the first place for individual > images. As I said, ImageIndex is for that purpose. -Takahiro Akashi > > -sughosh > > > > > -Takahiro Akashi > > > > > > > Signed-off-by: Sughosh Ganu > > > --- > > > > > > Changes since V3: > > > * Define a weak function fill_image_type_guid_array for populating the > > > image descriptor array with u-boot's raw and fit image GUIDs > > > > > > include/efi_loader.h | 2 + > > > lib/efi_loader/efi_firmware.c | 71 +++++++++++++++++++++++++++++++---- > > > 2 files changed, 66 insertions(+), 7 deletions(-) > > > > > > diff --git a/include/efi_loader.h b/include/efi_loader.h > > > index f4860e87fc..ae60de0be5 100644 > > > --- a/include/efi_loader.h > > > +++ b/include/efi_loader.h > > > @@ -992,4 +992,6 @@ efi_status_t efi_esrt_populate(void); > > > efi_status_t efi_load_capsule_drivers(void); > > > > > > efi_status_t platform_get_eventlog(struct udevice *dev, u64 *addr, u32 *sz); > > > +efi_status_t fill_image_type_guid_array(const efi_guid_t *default_guid, > > > + efi_guid_t **part_guid_arr); > > > #endif /* _EFI_LOADER_H */ > > > diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c > > > index a1b88dbfc2..5642be9f9a 100644 > > > --- a/lib/efi_loader/efi_firmware.c > > > +++ b/lib/efi_loader/efi_firmware.c > > > @@ -96,6 +96,46 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( > > > return EFI_EXIT(EFI_UNSUPPORTED); > > > } > > > > > > +efi_status_t __weak fill_image_type_guid_array(const efi_guid_t *guid, > > > + efi_guid_t **part_guid_arr) > > > +{ > > > + int i; > > > + int dfu_num = 0; > > > + efi_guid_t *guid_arr; > > > + struct dfu_entity *dfu; > > > + efi_status_t ret = EFI_SUCCESS; > > > + > > > + dfu_init_env_entities(NULL, NULL); > > > + > > > + dfu_num = 0; > > > + list_for_each_entry(dfu, &dfu_list, list) { > > > + dfu_num++; > > > + } > > > + > > > + if (!dfu_num) { > > > + log_warning("Probably dfu_alt_info not defined\n"); > > > + ret = EFI_NOT_READY; > > > + goto out; > > > + } > > > + > > > + *part_guid_arr = malloc(sizeof(efi_guid_t) * dfu_num); > > > + if (!*part_guid_arr) { > > > + ret = EFI_OUT_OF_RESOURCES; > > > + goto out; > > > + } > > > + > > > + guid_arr = *part_guid_arr; > > > + for (i = 0; i < dfu_num; i++) { > > > + guidcpy(guid_arr, guid); > > > + ++guid_arr; > > > + } > > > + > > > +out: > > > + dfu_free_entities(); > > > + > > > + return ret; > > > +} > > > + > > > /** > > > * efi_get_dfu_info - return information about the current firmware image > > > * @this: Protocol instance > > > @@ -104,9 +144,9 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( > > > * @descriptor_version: Pointer to version number > > > * @descriptor_count: Pointer to number of descriptors > > > * @descriptor_size: Pointer to descriptor size > > > - * package_version: Package version > > > - * package_version_name: Package version's name > > > - * image_type: Image type GUID > > > + * @package_version: Package version > > > + * @package_version_name: Package version's name > > > + * @guid_array: Image type GUID array > > > * > > > * Return information bout the current firmware image in @image_info. > > > * @image_info will consist of a number of descriptors. > > > @@ -122,7 +162,7 @@ static efi_status_t efi_get_dfu_info( > > > efi_uintn_t *descriptor_size, > > > u32 *package_version, > > > u16 **package_version_name, > > > - const efi_guid_t *image_type) > > > + const efi_guid_t *guid_array) > > > { > > > struct dfu_entity *dfu; > > > size_t names_len, total_size; > > > @@ -172,7 +212,7 @@ static efi_status_t efi_get_dfu_info( > > > next = name; > > > list_for_each_entry(dfu, &dfu_list, list) { > > > image_info[i].image_index = dfu->alt + 1; > > > - image_info[i].image_type_id = *image_type; > > > + image_info[i].image_type_id = guid_array[i]; > > > image_info[i].image_id = dfu->alt; > > > > > > /* copy the DFU entity name */ > > > @@ -250,6 +290,7 @@ efi_status_t EFIAPI efi_firmware_fit_get_image_info( > > > u16 **package_version_name) > > > { > > > efi_status_t ret; > > > + efi_guid_t *part_guid_arr = NULL; > > > > > > EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this, > > > image_info_size, image_info, > > > @@ -264,12 +305,19 @@ efi_status_t EFIAPI efi_firmware_fit_get_image_info( > > > !descriptor_size || !package_version || !package_version_name)) > > > return EFI_EXIT(EFI_INVALID_PARAMETER); > > > > > > + ret = fill_image_type_guid_array(&efi_firmware_image_type_uboot_fit, > > > + &part_guid_arr); > > > + if (ret != EFI_SUCCESS) > > > + goto out; > > > + > > > ret = efi_get_dfu_info(image_info_size, image_info, > > > descriptor_version, descriptor_count, > > > descriptor_size, > > > package_version, package_version_name, > > > - &efi_firmware_image_type_uboot_fit); > > > + part_guid_arr); > > > > > > +out: > > > + free(part_guid_arr); > > > return EFI_EXIT(ret); > > > } > > > > > > @@ -359,6 +407,7 @@ efi_status_t EFIAPI efi_firmware_raw_get_image_info( > > > u16 **package_version_name) > > > { > > > efi_status_t ret = EFI_SUCCESS; > > > + efi_guid_t *part_guid_arr = NULL; > > > > > > EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this, > > > image_info_size, image_info, > > > @@ -373,12 +422,20 @@ efi_status_t EFIAPI efi_firmware_raw_get_image_info( > > > !descriptor_size || !package_version || !package_version_name)) > > > return EFI_EXIT(EFI_INVALID_PARAMETER); > > > > > > + ret = fill_image_type_guid_array( > > > + &efi_firmware_image_type_uboot_raw, > > > + &part_guid_arr); > > > + if (ret != EFI_SUCCESS) > > > + goto out; > > > + > > > ret = efi_get_dfu_info(image_info_size, image_info, > > > descriptor_version, descriptor_count, > > > descriptor_size, > > > package_version, package_version_name, > > > - &efi_firmware_image_type_uboot_raw); > > > + part_guid_arr); > > > > > > +out: > > > + free(part_guid_arr); > > > return EFI_EXIT(ret); > > > } > > > > > > -- > > > 2.17.1 > > >