From patchwork Wed Mar 30 14:50:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 555110 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp1314239mag; Wed, 30 Mar 2022 07:51:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsWXtTSh34TcGdgDNfBCtfMfdQzCwmZUY/yd+Qg4UqnKlZBoZXP+w7+J9iO223jclIDdyl X-Received: by 2002:a05:6402:26c3:b0:419:2e13:27fd with SMTP id x3-20020a05640226c300b004192e1327fdmr11281134edd.210.1648651910631; Wed, 30 Mar 2022 07:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648651910; cv=none; d=google.com; s=arc-20160816; b=qhauifpFcv70b3wmBoP0XnhCPRvAhenGB1uoG7UE4dm0uXV8sHd/kyIq2UV+yAVvnn T5jjeaVRYxLX2OcXCqFmwtZJDrB+bZ+cQOn7MB8FB/Z0EXb0d/Gn3evN9VEhBQ+bpYzO vqSLeD/LuO4Z0KbuRgFUbvT0A0w89OnfcfgRoyDml4JL3jZW8mXRsem1hlX3D8/MQwsQ mwPM2UVxsPJ3x10UZTEMO8MacBRTaN74sWK8A/4mlFhcN1oYMAZnuuUn6ZHn5vK3lGSa RJBBpPPDGUY36lSQttPn4dPN65ecrz1Cr5v4cY8VG+aupUbBImsSqO+ZUKqX+U9+Xee2 eSCw== 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:message-id:date:subject:cc:to:from; bh=8A9IInjTOifvVr7GZl3ettoLQh9ZxPjYLmtm5WKGEOw=; b=J7PKUhuPehgqPl6V5jIksnLwyB/A22V2mLY4Bn0fkw7izlIU8tZRlcUPjNxD626w/O ciCOBOY6Jc7prfWAjv9X1MI4m00Nd08SCM6AlR6bWeSLhm/ty8ofmUGW0b3s7OcvjMLO Bbmsfda3cx6NJjC+e3JfaypW0o42tlM6nOpjgm/emJ0F1C2QrAsukymG+lKcLuvj4Lig T1fqanPTVDSqsOBv60U6ec86g3QQ96uXxKk+3aLkNdB5Qf8knifLaBPQB+HsU/YXhm2U 0///9bucrsfPa71dCJMFRNP/pJngGepuEM+U6vlJHR00+3BgQrl2D6tWu4zlobVMTUFw E+eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id hc9-20020a170907168900b006df76385bddsi26345033ejc.125.2022.03.30.07.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 07:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 7AB32840F6; Wed, 30 Mar 2022 16:51:42 +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 DBC73840FC; Wed, 30 Mar 2022 16:51:40 +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_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 DD14C840F5 for ; Wed, 30 Mar 2022 16:51:36 +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 4C17823A; Wed, 30 Mar 2022 07:51:35 -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 A45163F73B; Wed, 30 Mar 2022 07:51:31 -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 Subject: [PATCH v3 0/9] efi: capsule: Capsule Update fixes and enhancements Date: Wed, 30 Mar 2022 20:20:54 +0530 Message-Id: <20220330145103.1435736-1-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 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 This series is cleaning up the usage of the image GUIDs that are used in capsule update and the EFI System Resource Table(ESRT). There are some other enhancements being made to the capsule update code to make it more robust. Firstly, an overview of the fixes being made. Currently, there are two instances of the Firmware Management Protocol(FMP), one defined for updating the FIT images, and the other for updating raw images. The FMP code defines two GUID values, one for all FIT images, and one for raw images. Depending on the FMP instance used on a platform, the platform needs to use the corresponding image GUID value for all images on the platform, and also across platforms. A few issues are being fixed through the patch series. One, that an image for a different platform can be flashed on another platform if both the platforms are using the same FMP instance. So, for e.g. a capsule generated for the Socionext DeveloperBox platform can be flashed on the ZynqMP platform, since both the platforms use the CONFIG_EFI_CAPSULE_FIRMWARE_RAW instance of the FMP. This can be corrected if each firmware image that can be updated through the capsule update mechanism has it's own unique image GUID. The second issue that this patch series fixes is the value of FwClass in the ESRT. With the current logic, all firmware image entries in the ESRT display the same GUID value -- either the FIT GUID or the raw GUID. This is not in compliance with the UEFI specification, as the specification requires all entries to have unique GUID values. The third issue being fixed is the population of the EFI_FIRMWARE_IMAGE_DESCRIPTOR array. The current code uses the dfu framework for populating the image descriptor array. However, there might be other images that are not to be updated through the capsule update mechanism also registered with the dfu framework. As a result of this, the ESRT will show up entries of images that are not to be targeted by the capsule update mechanism. These issues are being fixed by defining a structure, efi_fw_images. A platform can then define image related information like the image GUID and image name. Every platform that uses capsule update mechanism needs to define fw_images array. This array will then be used to populate the image descriptor array, and also in determining if a particular capsule's payload can be used for updating an image on the platform. The other part of the patches are some enhancements being made to the capsule update code to make it more robust. The first enhancement being made is to have a check for the image index being passed through the capsule header. The capsule update code uses the image index value as the dfu alt number, which points to the partition to which the update must be made. The platform is supposed to define the image index value for the updatable firmare images as part of the fw_images array. This value must correspond to the dfu alt num for the corresponding image, and can be obtained by checking the output of the 'dfu list' u-boot command. At the time of update, the image index being passed through the capsule is checked against the image index value obtained from the platform. The second enhancement made is the retrieval of the dfu_alt_info variable from the set_dfu_alt_info function defined in the board file. The dfu framework checks for the existence of this function, and if the function is not defined, gets the value from the environment. This can cause in an incorrect update if the environment variable value is incorrect. By mandating all the platforms which enable the capsule update feature to define set_dfu_alt_info function, the variable is then obtained from the board file rather than the environment. Changes since V2: * Add a new member image_index to the struct efi_fw_images to allow the platforms to define the values for images. * Address review comments from Michal Simek for the xilinx boards. * Fix double inclusion of efi_loader.h as was pointed out by Heiko Thiery. * Use the image index values defined in the platform's fw_images array for the image descriptors * Add a description for adding image index value and definition of set_dfu_alt_info function for the capsule updates. The first patch adds the structure efi_fw_images and defines an array fw_images on all platforms which enable capsule update feature The second patch populates the image descriptor array in the GetImageInfo function with the values from the fw_images array The third patch adds a check for the image index value from the capsule header against the value obtained from the fw_images array for the corresponding image The fourth patch defines the function set_dfu_alt_info for all the platforms which enable capsule update feature. The fifth patch selects SET_DFU_ALT_INFO config symbol for all platforms that enable capsule update feature. The sixth patch splits the capsule update test script into two, one for FMP for raw images, and one for FMP for FIT images. The test for FIT images is being enabled on the sandbox_flattree variant. The seventh patch removes the now unused FIT and raw image GUID values from the FMP module. The eighth patch removes the --raw and --fit command line parameters in the mkeficapsule utility. The ninth patch makes corresponding changes in the capsule update related documentation. Sughosh Ganu (9): capsule: Add Image GUIDs and image index for platforms using capsule updates capsule: FMP: Populate the image descriptor array from platform data capsule: Put a check for image index before the update board: Define set_dfu_alt_info() for boards with UEFI capsule update enabled capsule: kconfig: Select SET_DFU_ALT_INFO config symbol for capsule update test: capsule: Modify the capsule tests to use GUID values for sandbox FMP: Remove GUIDs for FIT and raw images mkeficapsule: Remove raw and FIT GUID types doc: uefi: Update the capsule update related documentation .../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 44 +++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 43 ++++ board/emulation/common/qemu_dfu.c | 6 +- board/emulation/qemu-arm/qemu-arm.c | 20 ++ board/kontron/pitx_imx8m/pitx_imx8m.c | 40 +++- board/kontron/sl-mx8mm/sl-mx8mm.c | 39 ++++ board/kontron/sl28/sl28.c | 40 ++++ board/sandbox/sandbox.c | 54 +++++ board/socionext/developerbox/developerbox.c | 52 +++++ board/xilinx/common/board.c | 24 +++ board/xilinx/zynq/board.c | 5 +- board/xilinx/zynqmp/zynqmp.c | 5 +- configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - configs/sandbox_flattree_defconfig | 5 + doc/develop/uefi/uefi.rst | 22 ++- include/configs/imx8mm-cl-iot-gate.h | 11 +- include/configs/imx8mp_rsb3720.h | 11 +- include/configs/kontron-sl-mx8mm.h | 7 +- include/configs/kontron_pitx_imx8m.h | 7 +- include/configs/kontron_sl28.h | 8 +- include/configs/qemu-arm.h | 10 + include/configs/sandbox.h | 14 ++ include/configs/synquacer.h | 18 +- include/configs/xilinx_versal.h | 6 + include/configs/xilinx_zynqmp.h | 10 + include/configs/zynq-common.h | 10 + include/efi_api.h | 8 - include/efi_loader.h | 21 ++ lib/efi_loader/Kconfig | 2 + lib/efi_loader/efi_capsule.c | 8 +- lib/efi_loader/efi_firmware.c | 95 +++------ test/py/tests/test_efi_capsule/conftest.py | 21 +- .../test_capsule_firmware_fit.py | 186 ++++++++++++++++++ ...rmware.py => test_capsule_firmware_raw.py} | 159 +++++---------- tools/eficapsule.h | 8 - tools/mkeficapsule.c | 26 +-- 37 files changed, 799 insertions(+), 248 deletions(-) create mode 100644 test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py rename test/py/tests/test_efi_capsule/{test_capsule_firmware.py => test_capsule_firmware_raw.py} (75%)