From patchwork Fri Apr 15 05:59:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 561928 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp76916map; Thu, 14 Apr 2022 23:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ2lOsIm6IzpjqdV5CaiSZyOwTKS3OXQEglVt93FcNJwAFkMSqhrnrvwUpxSKUlQacX4tC X-Received: by 2002:a17:907:6d2a:b0:6df:e513:5410 with SMTP id sa42-20020a1709076d2a00b006dfe5135410mr4889965ejc.544.1650002438559; Thu, 14 Apr 2022 23:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650002438; cv=none; d=google.com; s=arc-20160816; b=r8sDMs5gLbGbY22lNZFehrNkIG0QdsWm81iJX6rV1eSqooTEBnxy/epw+jZdwfK8Qg 9bZonW6FuKwLMhV0Y/hlm3166wHkGTF2dVWRosLimKooXjpCyV1jRWosDvtXPNZJH1QF EP4757P33u/2yBWo9eQh+hspQeWVv/e/6z5s86T0LxHeiuTzNyPGniPi5GpTdPhb8KUt GE4uhvumiFNVacXM2jSBu9+SPB5tz+y2FN92Ee1j5oUSvvdS4B+BgyZVVykXdFzy9e7b rK2Eepul+UWn0ggfd36e+rxvguPvlnjoeeAJc139Y52CqPj0sYMoCD90H2NbUuzOAsTh iArg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=YXv0EcA1UW3ufbS7GAqJimhh7+XpNeZcEaJFtoW/d6k=; b=Ma1uPly7zAeuEkzk2dR4tA6YeKquS4JoUXX0B5DytE84IuyWzIl8wZa7FXQcr8As7N 8eTOmnlxEg7oOsVYo4VIOlVKZflACRdxfe4GUk6t2J7wFtG1a6Z5Kvz18u/5LasR7Aty sdi12d+8epXyH1Brhp+6A6cBpwVokBHVbnBngVJxQ9kpT9lHrjNxH4ly7gAuuzpT2mxt qTShwa9sW0tq5cDLNvNRwTIJ6nQC8lTDmnKdWob93mdDMUQRW0zri1oiMsQLOA2ThbQg 7zOeTAy86zoXI4AJRyNP37GRUt6VDa37U87QHFIra2AoZ4nm+0apzVc+Ya/gVycHrYVo RGng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id d16-20020a05640208d000b00419c71133ddsi435106edz.540.2022.04.14.23.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 23:00:38 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A26BF83AD0; Fri, 15 Apr 2022 08:00:20 +0200 (CEST) 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 Received: by phobos.denx.de (Postfix, from userid 109) id D656583894; Fri, 15 Apr 2022 08:00:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL,T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 1DD058390C for ; Fri, 15 Apr 2022 08:00:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6D04B139F; Thu, 14 Apr 2022 23:00:08 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 23E2F3F5A1; Thu, 14 Apr 2022 23:00:03 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , AKASHI Takahiro , Ying-Chun Liu , Tuomas Tynkkynen , Heiko Thiery , Frieder Schrempf , Michael Walle , Masami Hiramatsu , Jassi Brar , Michal Simek , Michal Simek , Sughosh Ganu Subject: [PATCH v8 2/8] capsule: FMP: Populate the image descriptor array from platform data Date: Fri, 15 Apr 2022 11:29:35 +0530 Message-Id: <20220415055941.609416-3-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220415055941.609416-1-sughosh.ganu@linaro.org> References: <20220415055941.609416-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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 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 Reviewed-by: Masami Hiramatsu --- Changes since V7: * Fix a typo in the function description of efi_fill_image_desc_array lib/efi_loader/efi_firmware.c | 98 +++++++++++------------------------ 1 file changed, 29 insertions(+), 69 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index a5ff32f121..56bd113de1 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -97,91 +97,57 @@ efi_status_t EFIAPI efi_firmware_set_package_info_unsupported( } /** - * efi_get_dfu_info - return information about the current firmware image - * @this: Protocol instance + * efi_fill_image_desc_array - populate image descriptor array * @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. + * Return information about 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_image array. * * 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; - - 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(); + size_t total_size; + struct efi_fw_image *fw_array; + int i; - return EFI_SUCCESS; - } + fw_array = update_info.images; + *descriptor_count = num_image_type_guids; + + total_size = sizeof(*image_info) * num_image_type_guids; - 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 < num_image_type_guids; 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 = fw_array[i].fw_name; image_info[i].version = 0; /* not supported */ image_info[i].version_name = NULL; /* not supported */ @@ -202,12 +168,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 +229,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 +337,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); }