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 B79EEC433F5 for ; Thu, 31 Mar 2022 15:08:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5EC4A841DF; Thu, 31 Mar 2022 17:08:19 +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="Fx9H8HOW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD07884220; Thu, 31 Mar 2022 17:08:16 +0200 (CEST) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 BDF55841D6 for ; Thu, 31 Mar 2022 17:08:07 +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-x431.google.com with SMTP id r13so173125wrr.9 for ; Thu, 31 Mar 2022 08:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1DSpjPNxkTsgxXvg2Vry/9qeDx5UGWARS9wpmgBtZlA=; b=Fx9H8HOWsX4z9NGAcFRafXS/vAewRC2K7kYn8SlGHiWMaZw/4y3fu0YZordoRliH/m 1o9s7eTcYvvmX4yp8Eda/+QyzYoHUUnbWKtvLrEasH5GW8lkK4KmHuRw1GMMBuBCVdeM U9cVcW58dw7P03celPOdXHBBRjmapFYo+AC8sOoWlVrhN2Agt/doWqZiuEPISxOn6ZI6 pZs+BhBLG6iQznDyjFmyyLylbOY6ckWmVSNEU5ZsFYBQwSN4J44nVa4Ns0pUEQn5D/je Q0kH/BwIZUfkA9THNcCv9nI8XMlXCL2p9vLPhnTz/0DZCvUJhMpf5yjfqWPC/DtQ6tqw D4TA== 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:references :mime-version:content-disposition:in-reply-to; bh=1DSpjPNxkTsgxXvg2Vry/9qeDx5UGWARS9wpmgBtZlA=; b=k5OzEQIj9zyaaoWoeVHIsm+gGe5+toCNCiwFdUtwwK36Pp6OV9XrpcS3GfvjBzp2RY LhdHYxsMZ77ugCZax0cDHplwu+4bVNLbjykS9j1nUzV86oK3mVul/BB7XdLxQ21TDaCM Oyz8SjsZqS4xEKsdfwLotsWdZ4gVryWQB86lO8NvlthJD4tJdJA0PPHxIQT8dEo0dfbg JOmhdj50eYuTEGr54bAt0I+pH/38jHs+u/D3eWwohu2Wp9A7ETa2cJv3ozf/gLFTiCcV NiXC8vwKr3ugUxzrk7Gr2Zw1r2gmULIEzkzYxVaoo2sVDlwUxjxUeuaa1xSaSM9/OsGy JToQ== X-Gm-Message-State: AOAM531/s/qSFU7RkzRxmJLu9UKU2oU0aiY8t3QRpctAJE3M/9Xs3vXT WJEIytKNNJ3Na+T9RhPpxNOpmg== X-Google-Smtp-Source: ABdhPJz6vFE2FxFa7b5e9fdF5wmYGAOKs13/M6QLuxYAqWGR5NJKXq8IesObA7bZMrsrsIgNohKwpg== X-Received: by 2002:adf:e605:0:b0:203:d5f6:86f1 with SMTP id p5-20020adfe605000000b00203d5f686f1mr4365479wrm.689.1648739287210; Thu, 31 Mar 2022 08:08:07 -0700 (PDT) Received: from hades (athedsl-4461682.home.otenet.gr. [94.71.4.98]) by smtp.gmail.com with ESMTPSA id t4-20020a05600001c400b00203fb5dcf29sm19655584wrx.40.2022.03.31.08.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 08:08:06 -0700 (PDT) Date: Thu, 31 Mar 2022 18:08:03 +0300 From: Ilias Apalodimas To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , AKASHI Takahiro , Ying-Chun Liu , Tuomas Tynkkynen , Heiko Thiery , Frieder Schrempf , Michael Walle , Masami Hiramatsu , Jassi Brar , Michal Simek , Michal Simek Subject: Re: [PATCH v4 2/8] capsule: FMP: Populate the image descriptor array from platform data Message-ID: References: <20220331132750.1532722-1-sughosh.ganu@linaro.org> <20220331132750.1532722-3-sughosh.ganu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220331132750.1532722-3-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 Thu, Mar 31, 2022 at 06:57:44PM +0530, Sughosh Ganu wrote: > Currently, the image descriptor array that has been passed to the > GetImageInfo function of the Firmware Management Protocol(FMP) gets > populated through the data stored with the dfu framework. The > dfu data is not restricted to contain information only of the images > updatable through the capsule update mechanism, but it also contains > information on other images. > > The image descriptor array is also parsed by the ESRT generation code, > and thus the ESRT table contains entries for other images that are not > being handled by the FMP for the capsule updates. > > The other issue fixed is assignment of a separate GUID for all images > in the image descriptor array. The UEFI specification mandates that > all entries in the ESRT table should have a unique GUID value as part > of the FwClass member of the EFI_SYSTEM_RESOURCE_ENTRY. Currently, all > images are assigned a single GUID value, either an FIT GUID or a raw > image GUID. This is fixed by obtaining the GUID values from the > efi_fw_images array defined per platform. > > Signed-off-by: Sughosh Ganu > Reviewed-by: Masami Hiramatsu > --- > > Changes since V3: None > > include/efi_loader.h | 3 ++ > lib/efi_loader/efi_firmware.c | 91 +++++++++++------------------------ > 2 files changed, 30 insertions(+), 64 deletions(-) > > diff --git a/include/efi_loader.h b/include/efi_loader.h > index 284d64547b..9704397bd7 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -997,6 +997,9 @@ struct efi_fw_images { > u8 image_index; > }; > > +extern struct efi_fw_images fw_images[]; > +extern u8 num_image_type_guids; > + > /** > * Install the ESRT system table. > * > diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c > index a5ff32f121..169f3a29bb 100644 > --- a/lib/efi_loader/efi_firmware.c > +++ b/lib/efi_loader/efi_firmware.c > @@ -97,91 +97,60 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( > } > > /** > - * efi_get_dfu_info - return information about the current firmware image > + * efi_fill_image_desc_array - populate image descriptor array > * @this: Protocol instance > * @image_info_size: Size of @image_info > * @image_info: Image information > * @descriptor_version: Pointer to version number > - * @descriptor_count: Pointer to number of descriptors > + * @descriptor_count: Image count > * @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 > * > * Return information bout the current firmware image in @image_info. > * @image_info will consist of a number of descriptors. > - * Each descriptor will be created based on "dfu_alt_info" variable. > + * Each descriptor will be created based on "efi_fw_images" variable. > * > * Return status code > */ > -static efi_status_t efi_get_dfu_info( > +static efi_status_t efi_fill_image_desc_array( > efi_uintn_t *image_info_size, > struct efi_firmware_image_descriptor *image_info, > u32 *descriptor_version, > u8 *descriptor_count, > efi_uintn_t *descriptor_size, > u32 *package_version, > - u16 **package_version_name, > - const efi_guid_t *image_type) > + u16 **package_version_name) > { > - struct dfu_entity *dfu; > size_t names_len, total_size; > - int dfu_num, i; > - u16 *name, *next; > - int ret; > - > - ret = dfu_init_env_entities(NULL, NULL); > - if (ret) > - return EFI_SUCCESS; > + struct efi_fw_images *fw_array; > + u8 image_count; > + int i; > > + fw_array = &fw_images[0]; nit, but fw_array = fw_images looks better > + *descriptor_count = image_count = num_image_type_guids; We could get rid of image_count here > names_len = 0; > - dfu_num = 0; > - list_for_each_entry(dfu, &dfu_list, list) { > - names_len += (utf8_utf16_strlen(dfu->name) + 1) * 2; > - dfu_num++; > - } > - if (!dfu_num) { > - log_warning("No entities in dfu_alt_info\n"); > - *image_info_size = 0; > - dfu_free_entities(); > > - return EFI_SUCCESS; > - } > + total_size = sizeof(*image_info) * image_count; > > - total_size = sizeof(*image_info) * dfu_num + names_len; > - /* > - * we will assume that sizeof(*image_info) * dfu_name > - * is, at least, a multiple of 2. So the start address for > - * image_id_name would be aligned with 2 bytes. > - */ > if (*image_info_size < total_size) { > *image_info_size = total_size; > - dfu_free_entities(); > > return EFI_BUFFER_TOO_SMALL; > } > *image_info_size = total_size; > > *descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; > - *descriptor_count = dfu_num; > *descriptor_size = sizeof(*image_info); > *package_version = 0xffffffff; /* not supported */ > *package_version_name = NULL; /* not supported */ > > - /* DFU alt number should correspond to image_index */ > - i = 0; > - /* Name area starts just after descriptors */ > - name = (u16 *)((u8 *)image_info + sizeof(*image_info) * dfu_num); > - 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_id = dfu->alt; > - > - /* copy the DFU entity name */ > - utf8_utf16_strcpy(&next, dfu->name); > - image_info[i].image_id_name = name; > - name = ++next; > + for (i = 0; i < image_count; i++) { > + image_info[i].image_index = fw_array[i].image_index; > + image_info[i].image_type_id = fw_array[i].image_type_id; > + image_info[i].image_id = fw_array[i].image_index; > + > + image_info[i].image_id_name = (u16 *)fw_array[i].fw_name; We shouldn't be casting const qualifications away. In theory no one will even modify that in this case and nothing bad will happen. Since the efi spec defines the image_id_name as u16 * are we better of removing the const from efi_fw_images? Thanks /Ilias > > image_info[i].version = 0; /* not supported */ > image_info[i].version_name = NULL; /* not supported */ > @@ -202,12 +171,8 @@ static efi_status_t efi_get_dfu_info( > image_info[i].last_attempt_status = LAST_ATTEMPT_STATUS_SUCCESS; > image_info[i].hardware_instance = 1; > image_info[i].dependencies = NULL; > - > - i++; > } > > - dfu_free_entities(); > - > return EFI_SUCCESS; > } > > @@ -267,11 +232,10 @@ efi_status_t EFIAPI efi_firmware_fit_get_image_info( > !descriptor_size || !package_version || !package_version_name)) > return EFI_EXIT(EFI_INVALID_PARAMETER); > > - 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); > + ret = efi_fill_image_desc_array(image_info_size, image_info, > + descriptor_version, descriptor_count, > + descriptor_size, package_version, > + package_version_name); > > return EFI_EXIT(ret); > } > @@ -376,11 +340,10 @@ efi_status_t EFIAPI efi_firmware_raw_get_image_info( > !descriptor_size || !package_version || !package_version_name)) > return EFI_EXIT(EFI_INVALID_PARAMETER); > > - 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); > + ret = efi_fill_image_desc_array(image_info_size, image_info, > + descriptor_version, descriptor_count, > + descriptor_size, package_version, > + package_version_name); > > return EFI_EXIT(ret); > } > -- > 2.25.1 >