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 973B7C433F5 for ; Thu, 10 Feb 2022 02:48:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36B7483801; Thu, 10 Feb 2022 03:48:41 +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="gjhPqrRh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7A0E983804; Thu, 10 Feb 2022 03:48:39 +0100 (CET) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 B4C49837F5 for ; Thu, 10 Feb 2022 03:48:35 +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-pf1-x433.google.com with SMTP id i21so6259920pfd.13 for ; Wed, 09 Feb 2022 18:48:35 -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=Nw9jKTyGau3WDGRRMXi+kjcjW9P3E0zxK8Fqd51aW3s=; b=gjhPqrRhSVzRSwaGyh9XM/PYigLE5iNzZrQhQ2OvMkvjO4bv4WtQ9euWUtbWLCZRLA YPbYS+kNVJ1BC/cHh1PdEKzLgTiixab3YJl5pGeeFVL1h80t+HAQL/5jjz1nniR2gQ0U Z7O7+vQ1Dv8sh8+Bfo4HXXkRiX9lQFsvkKbxnitqOhGBxZI3t3ozinlr2oRttWFz/B7+ S+7HVDm8arRt/6AWAzhfTZsNnCtD6U/zICpMbSV9O1TVlfu3NZlI4giygRhlfReM/rUE nT/xV3SjqwJTxWi341krYa2VpwBkJuBFSdr8Dk6yXpE20Ul1xGyD89OtqOXls6LLBPxX Zx7Q== 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=Nw9jKTyGau3WDGRRMXi+kjcjW9P3E0zxK8Fqd51aW3s=; b=X1FxAHuAVq59HlWX/E2SRcRSx9wew0DCKCntgfjp4UhcI0FTEwjDZWwsLa/3DjWWFj bo6d1gXYOm77FbtIwNmLQoBDDB2ZJpHpkk6F06XzUf8vICx+bzCUE1sx31w00y/RIjnE 6hwSoagm0hurNstm3FSIxc1apfdJPp0vamsApjDyapipXwdg1UKypf1pr4AB/0knt47G qRC0S27ljO29sOMZ0DwVaXp+/vP1LEZExM3krPSkTBTmb6pLSzwgeravJEEgveqZD+NU iO92x7QkRboaHhakZvl6s8+n+k6knxd5UdUECOizJxxSScxpSesxu5eLmeZMeKopJM9e fAQw== X-Gm-Message-State: AOAM530FLRyLRrenK4Wsu4IJznhx4yA46/Zxi83yvA8G5GLPuzat617l 6pNC3fSGUijzxDP4OaNu3tZ/NA== X-Google-Smtp-Source: ABdhPJwzCrH8yj43wRj9SXF6H45DBIX6NdA//8FGSvFFjZuaBLqUY+CdEoquxdbqnQhv/HDPR0Vz+w== X-Received: by 2002:a63:1d56:: with SMTP id d22mr4408680pgm.149.1644461313901; Wed, 09 Feb 2022 18:48:33 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:412e:384:fab9:f24]) by smtp.gmail.com with ESMTPSA id k14sm21569772pff.25.2022.02.09.18.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 18:48:33 -0800 (PST) Date: Thu, 10 Feb 2022 11:48:28 +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: <20220210024828.GB12412@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220207182001.31270-6-sughosh.ganu@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.5 at phobos.denx.de X-Virus-Status: Clean 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. 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. -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 >