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 03C73C433F5 for ; Tue, 21 Dec 2021 05:34:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C32D983772; Tue, 21 Dec 2021 06:34:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (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=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="VuFn6fNj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C0C7837A6; Tue, 21 Dec 2021 06:34:27 +0100 (CET) Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) (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 BE0F48369E for ; Tue, 21 Dec 2021 06:34: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=sughosh.ganu@linaro.org Received: by mail-io1-xd36.google.com with SMTP id q72so16201090iod.12 for ; Mon, 20 Dec 2021 21:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=CqdUIUQZ0PDK9usUIkXdCjQRlspKtzjacXVwLMcVCVw=; b=VuFn6fNjnQzOp0KVzBsa4nyuZ+IsDDBCmyeYZO0QxToK0haRS8u0Sioyvy6EE8Z4Wt 1czCuL7pxWJN8CPQxYp0EjC2/W51zB6Z+rUkH0jbXGO6AdGn9C/Jji2Hyx6jYiWpON3l zF7KyNlzsX9cCZ33oBc4gzvWZe9Nc/zu5529L5pvJzA3AG3BSreLocmzwqIuwkwtFTzz Qglz2JNaRLBnQSHP2VC4uC0ATjfAeHfP20fpCbatncdjxHbwRfLwrIWaXH8Hp0Nveqlu BeMxG3r5LpTsdHLk37fkrWPDAHJkX+rFpIrfT+J59/SNxpOMnY3zkXhaccS4ggkhP1on DbrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=CqdUIUQZ0PDK9usUIkXdCjQRlspKtzjacXVwLMcVCVw=; b=JsidmvBSxJ6tKQWKdV93dG82cx8fd+Q7OFJs/eXZBCB0MOFuHnaAOZ+SUsH1uddF4u 2ipb+o5CFHeMTW4G+SLDCs5suTJpOc312zDjgD1d+3gG1yf7ZZCKUQB9WoGjpJbR5bjm bHyXR4QnUohbCt6jy+jxyy3z469EdLTKii90jaYTIrC2S13ytU0dsrzCbXc5IU4C22nK UPTzkbnRchq1NvafzSuOdtx4/4kJrYrzPv/zf9VRwldKl5WHW0VP5rn5ginn688Pm482 o1DlnKfxTG04O5p3KtMDSdGS5GehsaJn4k/yGD23Ghto8i6ZHzljyuRJj2kROUUw/Csa KjeQ== X-Gm-Message-State: AOAM531NjqnKbad2vV6Mihu0IyFnWrKYZugcWDdM2w3rsxqgy6W194WZ uiOCtOV50mB7nRAPONDUf4oYZ4Q6J38PNRdEBf5x1w== X-Google-Smtp-Source: ABdhPJzyphZYFVMlwT5jSmPYZrrKtse0njMqMGp74ocn210DcKw930b23joR1sH0HTar/2eq9vnLB/Wd8m8dxhdmMDo= X-Received: by 2002:a05:6638:3182:: with SMTP id z2mr958954jak.134.1640064861295; Mon, 20 Dec 2021 21:34:21 -0800 (PST) MIME-Version: 1.0 References: <20211219070605.14894-1-sughosh.ganu@linaro.org> <20211219070605.14894-6-sughosh.ganu@linaro.org> <20211221045318.GD40272@laputa> In-Reply-To: <20211221045318.GD40272@laputa> From: Sughosh Ganu Date: Tue, 21 Dec 2021 11:04:10 +0530 Message-ID: Subject: Re: [RFC PATCH v2 5/8] EFI: FMP: Add provision to update image's ImageTypeId in image descriptor To: AKASHI Takahiro , Sughosh Ganu , u-boot@lists.denx.de, Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Jason Liu , Tom Rini , Etienne Carriere Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.38 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean hi Takahiro, On Tue, 21 Dec 2021 at 10:23, AKASHI Takahiro wrote: > Sughosh, > > On Sun, Dec 19, 2021 at 12:36:02PM +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. > > > > Signed-off-by: Sughosh Ganu > > --- > > Changes since V1: > > * Define a new function fwu_plat_get_alt_num for filling up > > all the dfu partitions with a preset ImageTypeId guid > > * Remove the distinction made in the earlier version for > > setting image_type_id as suggested by Heinrich > > > > lib/efi_loader/efi_firmware.c | 90 ++++++++++++++++++++++++++++++++--- > > 1 file changed, 83 insertions(+), 7 deletions(-) > > > > diff --git a/lib/efi_loader/efi_firmware.c > b/lib/efi_loader/efi_firmware.c > > index a1b88dbfc2..648342ae72 100644 > > --- a/lib/efi_loader/efi_firmware.c > > +++ b/lib/efi_loader/efi_firmware.c > > @@ -10,6 +10,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -96,6 +97,46 @@ efi_status_t EFIAPI > efi_firmware_set_package_info_unsupported( > > return EFI_EXIT(EFI_UNSUPPORTED); > > } > > > > +static efi_status_t fill_part_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 +145,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 > > If I understand your code correctly, a guid in descriptor for any image > (I mean any part defined by dfu_alto_info) will have the same value > even with this change. > If so, why do we have to take an array of GUIDs as a parameter? > One of Heinrich's comments in my previous version was not to distinguish between the FWU case and the normal case when setting the image_type_id. The existing code sets the same GUID value(image_type) for all images. I have kept this consistent. With the FWU feature enabled, fwu_plat_fill_partition_guids is called and this function fills in the array with the relevant values of partition GUIDs. fwu_plat_fill_partition_guids has been defined for the ST board in patch 3/8. > On your previous version, Heinrich made a comment like: > > ! The sequence of GUIDs in a capsule should not influence the update. The > ! design lacks a configuration defining which GUID maps to which DFU part. > ! > ! Please, get rid of all DFU environment variables and describe the update > ! in a configuration file that you add to the capsule. > > Have you addressed this issue in this series? > (To do that, we may have to introduce a new format of capsule file.) > No, Ilias and I had replied back that detaching capsule update from DFU is a separate effort, not related to the addition of the FWU functionality and should be taken up as a separate activity. -sughosh > > -Takahiro Akashi > > > > > * > > * Return information bout the current firmware image in @image_info. > > * @image_info will consist of a number of descriptors. > > @@ -122,7 +163,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 +213,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 +291,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 +306,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_part_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); > > } > > > > @@ -358,7 +407,10 @@ efi_status_t EFIAPI efi_firmware_raw_get_image_info( > > u32 *package_version, > > u16 **package_version_name) > > { > > + int status; > > efi_status_t ret = EFI_SUCCESS; > > + const efi_guid_t null_guid = NULL_GUID; > > + 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 +425,36 @@ efi_status_t EFIAPI > efi_firmware_raw_get_image_info( > > !descriptor_size || !package_version || > !package_version_name)) > > return EFI_EXIT(EFI_INVALID_PARAMETER); > > > > + if (IS_ENABLED(CONFIG_FWU_MULTI_BANK_UPDATE)) { > > + ret = fill_part_guid_array(&null_guid, &part_guid_arr); > > + if (ret != EFI_SUCCESS) > > + goto out; > > + > > + /* > > + * Call the platform function to fill the GUID array > > + * with the corresponding partition GUID values > > + */ > > + status = fwu_plat_fill_partition_guids(&part_guid_arr); > > + if (status < 0) { > > + log_err("Unable to get partiion guid's\n"); > > + ret = EFI_DEVICE_ERROR; > > + goto out; > > + } > > + } else { > > + ret = > fill_part_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 > > >