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 766A9C433F5 for ; Thu, 14 Apr 2022 11:37:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFA898390C; Thu, 14 Apr 2022 13:37:43 +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="m3YPoOKj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 719A88390C; Thu, 14 Apr 2022 13:37:42 +0200 (CEST) Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) (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 6210F83934 for ; Thu, 14 Apr 2022 13:37:39 +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=masami.hiramatsu@linaro.org Received: by mail-il1-x131.google.com with SMTP id d3so2894777ilr.10 for ; Thu, 14 Apr 2022 04:37:39 -0700 (PDT) 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 :cc:content-transfer-encoding; bh=GfOaN+KQtFIDdfiSshHo4PcO9LMRZznOjomtOPP1LH4=; b=m3YPoOKjfP34LEJNrYLourOxtEF1OERXItrsG6eAVv1q0W3dQs6ZgapjWYleyK2QD3 LubJUBJJE/m7MQFbWboXgq+dELyWvKyZKZklR0lPn3dRDFUaIuBdV7/sUq2Hu+p7GxRd pPJ3jRpRd1bc0/Zr3rVfxM5g325wtf0D7D8nl39imBMAnfhjCT9uF+eeuIY1F9LC+rR1 p1vQ13J3AVhW4K8EiCzGJEs7tAtn3OayM+j+euMjIbdY7k8EKHSvsyP9JcJ4oPM4MLaH AjpARwfOHg5z2XEUueJHxe1TPjrAS3Q4Ni9L/cI7N86drC2a/hjnWVPLXQNmO4iAhbSy Hvgw== 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:cc:content-transfer-encoding; bh=GfOaN+KQtFIDdfiSshHo4PcO9LMRZznOjomtOPP1LH4=; b=FfltU1pU8em7MNUAIfArIx4So7Fak6uglEJSXaZjYIl+tJkESl8dn8piZcpU1isWHG szmPsQ5Q/vfwYHe6O4HDRPkNL3f2Mtk4ePDrT2VVbUNX8v3y79cL8SMDyVHUgUUV/UDj eb4sOwpdiNMJNu23scOTInWWA+3LV+wVniaibECLHxcEp9xN8f/jQ7XAXGGdRqnXvGK6 hyRBXdGsqxEe52vPvy6ouFeCM1X2t2FLkdMmsjYXq0kxoRyWscUEYHeCMsvgs1PVf8BH PPAYP39VNc8hXvNkInyF2LXbW8vW5zkFev200Pb52OduBhCGtdpNHshgvwUfpGDe3eP2 SMLg== X-Gm-Message-State: AOAM532X2hdioE/bb9LzAuH8QzOobHply2h2CLldtka+EwL9G/Ls/WMS TZKG3qXXHq+SYhGdEM9d1MkSfVYfNe4/8cec6UeQow== X-Google-Smtp-Source: ABdhPJzQNj1ITy+IPxScrMwuXyIcRZkUSLYbq43n3530At/K6r1RG+y6lOWgpQIeO4BP/KWBWQnAa6vEvup895T8nws= X-Received: by 2002:a05:6e02:1be6:b0:2ca:8609:eb81 with SMTP id y6-20020a056e021be600b002ca8609eb81mr854668ilv.183.1649936258028; Thu, 14 Apr 2022 04:37:38 -0700 (PDT) MIME-Version: 1.0 References: <20220414105448.559043-1-sughosh.ganu@linaro.org> <20220414105448.559043-3-sughosh.ganu@linaro.org> In-Reply-To: <20220414105448.559043-3-sughosh.ganu@linaro.org> From: Masami Hiramatsu Date: Thu, 14 Apr 2022 20:37:27 +0900 Message-ID: Subject: Re: [PATCH v7 2/8] capsule: FMP: Populate the image descriptor array from platform data To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Ilias Apalodimas , AKASHI Takahiro , Ying-Chun Liu , Tuomas Tynkkynen , Heiko Thiery , Frieder Schrempf , Michael Walle , Jassi Brar , Michal Simek , Michal Simek Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, 2022=E5=B9=B44=E6=9C=8814=E6=97=A5(=E6=9C=A8) 19:55 Sughosh Ganu : > > 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. Fix this by populating the image descriptor array from the > structure initialised in the board file. > > 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 > --- > > Changes since V6: > * Use renamed struct efi_fw_image instead of struct efi_fw_images > > > lib/efi_loader/efi_firmware.c | 95 +++++++++++------------------------ > 1 file changed, 28 insertions(+), 67 deletions(-) > > diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.= c > index a5ff32f121..46aa7a001a 100644 > --- a/lib/efi_loader/efi_firmware.c > +++ b/lib/efi_loader/efi_firmware.c > @@ -97,91 +97,58 @@ efi_status_t EFIAPI efi_firmware_set_package_info_uns= upported( > } > > /** > - * efi_get_dfu_info - return information about the current firmware imag= e > + * 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. nit: here is "efi_fw_images". Except for that, this looks good to me. Reviewed-by: Masami Hiramatsu Thank you, > * > * 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 =3D dfu_init_env_entities(NULL, NULL); > - if (ret) > - return EFI_SUCCESS; > - > - names_len =3D 0; > - dfu_num =3D 0; > - list_for_each_entry(dfu, &dfu_list, list) { > - names_len +=3D (utf8_utf16_strlen(dfu->name) + 1) * 2; > - dfu_num++; > - } > - if (!dfu_num) { > - log_warning("No entities in dfu_alt_info\n"); > - *image_info_size =3D 0; > - dfu_free_entities(); > + size_t total_size; > + struct efi_fw_image *fw_array; > + int i; > > - return EFI_SUCCESS; > - } > + fw_array =3D update_info.images; > + *descriptor_count =3D num_image_type_guids; > + > + total_size =3D sizeof(*image_info) * num_image_type_guids; > > - total_size =3D 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 =3D total_size; > - dfu_free_entities(); > > return EFI_BUFFER_TOO_SMALL; > } > *image_info_size =3D total_size; > > *descriptor_version =3D EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION; > - *descriptor_count =3D dfu_num; > *descriptor_size =3D sizeof(*image_info); > *package_version =3D 0xffffffff; /* not supported */ > *package_version_name =3D NULL; /* not supported */ > > - /* DFU alt number should correspond to image_index */ > - i =3D 0; > - /* Name area starts just after descriptors */ > - name =3D (u16 *)((u8 *)image_info + sizeof(*image_info) * dfu_num= ); > - next =3D name; > - list_for_each_entry(dfu, &dfu_list, list) { > - image_info[i].image_index =3D dfu->alt + 1; > - image_info[i].image_type_id =3D *image_type; > - image_info[i].image_id =3D dfu->alt; > - > - /* copy the DFU entity name */ > - utf8_utf16_strcpy(&next, dfu->name); > - image_info[i].image_id_name =3D name; > - name =3D ++next; > + for (i =3D 0; i < num_image_type_guids; i++) { > + image_info[i].image_index =3D fw_array[i].image_index; > + image_info[i].image_type_id =3D fw_array[i].image_type_id= ; > + image_info[i].image_id =3D fw_array[i].image_index; > + > + image_info[i].image_id_name =3D fw_array[i].fw_name; > > image_info[i].version =3D 0; /* not supported */ > image_info[i].version_name =3D NULL; /* not supported */ > @@ -202,12 +169,8 @@ static efi_status_t efi_get_dfu_info( > image_info[i].last_attempt_status =3D LAST_ATTEMPT_STATUS= _SUCCESS; > image_info[i].hardware_instance =3D 1; > image_info[i].dependencies =3D NULL; > - > - i++; > } > > - dfu_free_entities(); > - > return EFI_SUCCESS; > } > > @@ -267,11 +230,10 @@ efi_status_t EFIAPI efi_firmware_fit_get_image_info= ( > !descriptor_size || !package_version || !package_version_nam= e)) > return EFI_EXIT(EFI_INVALID_PARAMETER); > > - ret =3D 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 =3D efi_fill_image_desc_array(image_info_size, image_info, > + descriptor_version, descriptor_co= unt, > + descriptor_size, package_version, > + package_version_name); > > return EFI_EXIT(ret); > } > @@ -376,11 +338,10 @@ efi_status_t EFIAPI efi_firmware_raw_get_image_info= ( > !descriptor_size || !package_version || !package_version_nam= e)) > return EFI_EXIT(EFI_INVALID_PARAMETER); > > - ret =3D 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 =3D efi_fill_image_desc_array(image_info_size, image_info, > + descriptor_version, descriptor_co= unt, > + descriptor_size, package_version, > + package_version_name); > > return EFI_EXIT(ret); > } > -- > 2.25.1 > -- Masami Hiramatsu