[RFC PATCH 0/6] efi: capsule: Image GUID usage cleanup

This series is cleaning up the usage of the image GUIDs that are used in capsule update and the EFI System Resource Table(ESRT).
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 first patch of this series adds the fw_images array in all platforms which are using UEFI capsule updates
The second patch of the series changes the logic for populating the image descriptor array, using the information from the fw_images array defined by the platform.
The third patch of the series removes the test cases using the --raw and --fit parameters, removes test case for FIT images, and adds a test case for checking that the update happens only with the correct image GUID value in the capsule.
The fourth patch of the series makes corresponding changes in the capsule update related documentation.
The fifth patch of the series removes the now unused FIT and raw image GUID values from the FMP module.
The sixth patch of the series removes the --raw and --fit command line parameters in the mkeficapsule utility.
Sughosh Ganu (6): capsule: Add Image GUIDs for platforms using capsule updates capsule: FMP: Populate the image descriptor array from platform data test: capsule: Modify the capsule tests to use GUID values for sandbox doc: uefi: Update the capsule update related documentation FMP: Remove GUIDs for FIT and raw images mkeficapsule: Remove raw and FIT GUID types
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 ++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 ++ board/emulation/qemu-arm/qemu-arm.c | 20 +++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 ++ board/kontron/sl28/sl28.c | 14 ++ board/sandbox/sandbox.c | 17 ++ board/socionext/developerbox/developerbox.c | 23 +++ board/xilinx/common/board.h | 18 ++ board/xilinx/zynq/board.c | 18 ++ board/xilinx/zynqmp/zynqmp.c | 18 ++ configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - doc/develop/uefi/uefi.rst | 10 +- include/configs/imx8mm-cl-iot-gate.h | 10 ++ include/configs/imx8mp_rsb3720.h | 10 ++ include/configs/kontron-sl-mx8mm.h | 6 + include/configs/kontron_pitx_imx8m.h | 6 + include/configs/kontron_sl28.h | 6 + include/configs/qemu-arm.h | 10 ++ include/configs/sandbox.h | 10 ++ include/configs/synquacer.h | 14 ++ include/efi_api.h | 8 - include/efi_loader.h | 18 ++ lib/efi_loader/efi_firmware.c | 95 +++------- test/py/tests/test_efi_capsule/conftest.py | 20 +-- .../test_efi_capsule/test_capsule_firmware.py | 167 ++++++------------ tools/eficapsule.h | 8 - tools/mkeficapsule.c | 26 +-- 29 files changed, 384 insertions(+), 236 deletions(-)

Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- .../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { +#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G) + .image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID, +#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G) + .image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID, +#endif + .fw_name = u"IMX8MP-RSB3720-FIT" + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + + int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { +#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE) + .image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID, +#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) + .image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID, +#endif + .fw_name = u"IMX8MM-CL-IOT-GATE-FIT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h> + #ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { +#if defined(CONFIG_TARGET_QEMU_ARM_32BIT) + .image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID, +#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT) + .image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID, +#endif + .fw_name = u"Qemu-Arm-UBOOT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h> - +#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID, + .fw_name = u"KONTRON-PITX-IMX8M-UBOOT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID, + .fw_name = u"KONTROL-SL-MX8MM-UBOOT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = KONTRON_SL28_FIT_IMAGE_GUID, + .fw_name = u"KONTRON-SL28-FIT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = SANDBOX_UBOOT_IMAGE_GUID, + .fw_name = u"SANDBOX-UBOOT", + }, + { + .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID, + .fw_name = u"SANDBOX-UBOOT-ENV", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + #if !CONFIG_IS_ENABLED(OF_PLATDATA) /* * Add a simple GPIO device (don't use with of-platdata as it interferes with diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h> + +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID, + .fw_name = u"DEVELOPERBOX-UBOOT", + }, + { + .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID, + .fw_name = u"DEVELOPERBOX-FIP", + }, + { + .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID, + .fw_name = u"DEVELOPERBOX-OPTEE", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \ + EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \ + 0xe8, 0x61, 0x21, 0x61, 0x86, 0x64) + +#define ZYNQ_UBOOT_IMAGE_GUID \ + EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \ + 0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05) + +#define ZYNQMP_BOOT_IMAGE_GUID \ + EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \ + 0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf) + +#define ZYNQMP_UBOOT_IMAGE_GUID \ + EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \ + 0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = ZYNQ_BOOT_IMAGE_GUID, + .fw_name = u"ZYNQ-BOOT-IMAGE", + }, + { + .image_type_id = ZYNQ_UBOOT_IMAGE_GUID, + .fw_name = u"ZYNQ-UBOOT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = { + { + .image_type_id = ZYNQMP_BOOT_IMAGE_GUID, + .fw_name = u"ZYNQMP-BOOT-IMAGE", + }, + { + .image_type_id = ZYNQMP_UBOOT_IMAGE_GUID, + .fw_name = u"ZYNQMP-UBOOT", + }, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \ + EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \ + 0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46) + +#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \ + EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \ + 0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + #if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \ + EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \ + 0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65) + +#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \ + EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \ + 0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9) +#endif /* EFI_HAVE_CAPSULE_SUPPORT*/ + #ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \ + EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \ + 0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + #ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \ + EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \ + 0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + #ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \ + EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \ + 0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + /* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \ + EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \ + 0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c) + +#define QEMU_ARM64_UBOOT_IMAGE_GUID \ + EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \ + 0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + /* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \ + EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \ + 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8) + +#define SANDBOX_UBOOT_ENV_IMAGE_GUID \ + EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \ + 0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + /* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \ + EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \ + 0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00) + +#define DEVELOPERBOX_FIP_IMAGE_GUID \ + EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \ + 0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98) + +#define DEVELOPERBOX_OPTEE_IMAGE_GUID \ + EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \ + 0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30) +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ + /* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/** + * struct efi_fw_images - List of firmware images updatable through capsule + * update + * + * This structure gives information about the firmware images on the platform + * which can be updated through the capsule update mechanism + * + * @image_type_id: Image GUID. Same value is to be used in the capsule + * @fw_name: Name of the firmware image + */ +struct efi_fw_images { + efi_guid_t image_type_id; + const u16 *fw_name; +}; + /** * Install the ESRT system table. *

On 3/24/22 13:38, Sughosh Ganu wrote:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc =
diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
- #ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */
diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR;
diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR);
diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- int board_early_init_f(void) { fsl_lsch3_early_init_f();
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
- },
- {
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- #if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
- {
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
- },
- {
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
- },
- {
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
- },
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
- static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL,
diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
- EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
- EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
- EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
- EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
I can't see any benefit to have it defined here for all. Directly in board or in include/configs/* seems to be better option.
M

On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:38, Sughosh Ganu wrote:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
<snip>
diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
I can't see any benefit to have it defined here for all. Directly in board or in include/configs/* seems to be better option.
I had initially put these definitions in include/configs/zynq-common.h, but that breaks the build for both zynq_virt and zynqmp_virt, since this file does not get included in the corresponding board file. Which is why I put these under board/xilinx/common/board.h, as this gets included in both the board files. I don't see any other zynq* file under include/configs/. Can you suggest one for both the platforms.
-sughosh

On 3/24/22 15:44, Sughosh Ganu wrote:
On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:38, Sughosh Ganu wrote:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
<snip>
diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
I can't see any benefit to have it defined here for all. Directly in board or in include/configs/* seems to be better option.
I had initially put these definitions in include/configs/zynq-common.h, but that breaks the build for both zynq_virt and zynqmp_virt, since this file does not get included in the corresponding board file. Which is why I put these under board/xilinx/common/board.h, as this gets included in both the board files. I don't see any other zynq* file under include/configs/. Can you suggest one for both the platforms.
This is for zynq include/configs/zynq-common.h
This is for zynqmp include/configs/xilinx_zynqmp.h
there is also one for versal which doesn't have capsule enabled yet include/configs/xilinx_versal.h
but maybe make sense to add fw_images structure to board/xilinx/common/board.c
and define that macros in headers above with generic macro name XILINX_BOOT_IMAGE_GUID and XILINX_UBOOT_IMAGE_GUID and fw_name and XILINX-BOOT and XILINX-UBOOT to have it ready for versal.
Thanks, Michal

On Thu, 24 Mar 2022 at 20:21, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 15:44, Sughosh Ganu wrote:
On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:38, Sughosh Ganu wrote:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
<snip>
diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
I can't see any benefit to have it defined here for all. Directly in board or in include/configs/* seems to be better option.
I had initially put these definitions in include/configs/zynq-common.h, but that breaks the build for both zynq_virt and zynqmp_virt, since this file does not get included in the corresponding board file. Which is why I put these under board/xilinx/common/board.h, as this gets included in both the board files. I don't see any other zynq* file under include/configs/. Can you suggest one for both the platforms.
This is for zynq include/configs/zynq-common.h
This is for zynqmp include/configs/xilinx_zynqmp.h
there is also one for versal which doesn't have capsule enabled yet include/configs/xilinx_versal.h
but maybe make sense to add fw_images structure to board/xilinx/common/board.c
Okay, I will move the array definition to the suggested file in the next version.
and define that macros in headers above with generic macro name XILINX_BOOT_IMAGE_GUID and XILINX_UBOOT_IMAGE_GUID and fw_name and XILINX-BOOT and XILINX-UBOOT to have it ready for versal.
Okay, will do as you suggest.
-sughosh

Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct? I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order. Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
#ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
},
{
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
},
{
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
},
{
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQ_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-BOOT-IMAGE",
},
{
.image_type_id = ZYNQ_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQMP_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-BOOT-IMAGE",
},
{
.image_type_id = ZYNQMP_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \
EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \
0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46)
+#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \
EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \
0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \
EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \
0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65)
+#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \
EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \
0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT*/
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \
EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \
0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \
EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \
0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \
EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \
0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \
EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \
0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c)
+#define QEMU_ARM64_UBOOT_IMAGE_GUID \
EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \
0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
+#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
+#define DEVELOPERBOX_FIP_IMAGE_GUID \
EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
+#define DEVELOPERBOX_OPTEE_IMAGE_GUID \
EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/**
- struct efi_fw_images - List of firmware images updatable through capsule
update
- This structure gives information about the firmware images on the platform
- which can be updated through the capsule update mechanism
- @image_type_id: Image GUID. Same value is to be used in the capsule
- @fw_name: Name of the firmware image
- */
+struct efi_fw_images {
efi_guid_t image_type_id;
const u16 *fw_name;
+};
/**
- Install the ESRT system table.
-- 2.25.1

hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
-sughosh
Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
#ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
},
{
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
},
{
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
},
{
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQ_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-BOOT-IMAGE",
},
{
.image_type_id = ZYNQ_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQMP_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-BOOT-IMAGE",
},
{
.image_type_id = ZYNQMP_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \
EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \
0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46)
+#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \
EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \
0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \
EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \
0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65)
+#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \
EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \
0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT*/
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \
EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \
0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \
EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \
0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \
EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \
0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \
EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \
0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c)
+#define QEMU_ARM64_UBOOT_IMAGE_GUID \
EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \
0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
+#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
+#define DEVELOPERBOX_FIP_IMAGE_GUID \
EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
+#define DEVELOPERBOX_OPTEE_IMAGE_GUID \
EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/**
- struct efi_fw_images - List of firmware images updatable through capsule
update
- This structure gives information about the firmware images on the platform
- which can be updated through the capsule update mechanism
- @image_type_id: Image GUID. Same value is to be used in the capsule
- @fw_name: Name of the firmware image
- */
+struct efi_fw_images {
efi_guid_t image_type_id;
const u16 *fw_name;
+};
/**
- Install the ESRT system table.
-- 2.25.1
-- Masami Hiramatsu

Hi Sughosh,
2022年3月24日(木) 23:40 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
At least for the DeveloperBox, it looks good to me. (Hopefully, if you comment the string formatted GUID in the code for mkeficapsule, that is perfect. :) )
I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
I meant, the order of the fw_images array needs to be same as dfu_alt_info entries and the firmware entries for dfu_alt_info must be the first, because finally we will use the index of the fw_images array, which matched to given image type GUID, for specifying dfu_alt_info entry. Or, without dfu_alt_info, your new fw_images can update the firmware? I would like to see such *relationship* at least in the patch description and the documentation.
Thank you,
-sughosh
Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
#ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
},
{
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
},
{
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
},
{
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQ_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-BOOT-IMAGE",
},
{
.image_type_id = ZYNQ_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQMP_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-BOOT-IMAGE",
},
{
.image_type_id = ZYNQMP_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \
EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \
0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46)
+#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \
EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \
0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \
EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \
0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65)
+#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \
EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \
0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT*/
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \
EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \
0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \
EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \
0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \
EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \
0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \
EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \
0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c)
+#define QEMU_ARM64_UBOOT_IMAGE_GUID \
EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \
0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
+#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
+#define DEVELOPERBOX_FIP_IMAGE_GUID \
EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
+#define DEVELOPERBOX_OPTEE_IMAGE_GUID \
EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/**
- struct efi_fw_images - List of firmware images updatable through capsule
update
- This structure gives information about the firmware images on the platform
- which can be updated through the capsule update mechanism
- @image_type_id: Image GUID. Same value is to be used in the capsule
- @fw_name: Name of the firmware image
- */
+struct efi_fw_images {
efi_guid_t image_type_id;
const u16 *fw_name;
+};
/**
- Install the ESRT system table.
-- 2.25.1
-- Masami Hiramatsu
-- Masami Hiramatsu

Hi Sughosh,
OK I understand that if the platform uses the FIT capsule, the fw_images[] must have 1 entry and it is completely non relationship with dfu_alt_info... We may need a document for this case too.
Thanks,
2022年3月25日(金) 10:09 Masami Hiramatsu masami.hiramatsu@linaro.org:
Hi Sughosh,
2022年3月24日(木) 23:40 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
At least for the DeveloperBox, it looks good to me. (Hopefully, if you comment the string formatted GUID in the code for mkeficapsule, that is perfect. :) )
I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
I meant, the order of the fw_images array needs to be same as dfu_alt_info entries and the firmware entries for dfu_alt_info must be the first, because finally we will use the index of the fw_images array, which matched to given image type GUID, for specifying dfu_alt_info entry. Or, without dfu_alt_info, your new fw_images can update the firmware? I would like to see such *relationship* at least in the patch description and the documentation.
Thank you,
-sughosh
Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
#ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
},
{
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
},
{
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
},
{
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQ_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-BOOT-IMAGE",
},
{
.image_type_id = ZYNQ_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQMP_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-BOOT-IMAGE",
},
{
.image_type_id = ZYNQMP_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \
EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \
0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46)
+#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \
EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \
0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \
EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \
0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65)
+#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \
EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \
0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT*/
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \
EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \
0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \
EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \
0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \
EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \
0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \
EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \
0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c)
+#define QEMU_ARM64_UBOOT_IMAGE_GUID \
EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \
0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
+#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
+#define DEVELOPERBOX_FIP_IMAGE_GUID \
EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
+#define DEVELOPERBOX_OPTEE_IMAGE_GUID \
EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/**
- struct efi_fw_images - List of firmware images updatable through capsule
update
- This structure gives information about the firmware images on the platform
- which can be updated through the capsule update mechanism
- @image_type_id: Image GUID. Same value is to be used in the capsule
- @fw_name: Name of the firmware image
- */
+struct efi_fw_images {
efi_guid_t image_type_id;
const u16 *fw_name;
+};
/**
- Install the ESRT system table.
-- 2.25.1
-- Masami Hiramatsu
-- Masami Hiramatsu

hi Masami,
On Fri, 25 Mar 2022 at 10:58, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
OK I understand that if the platform uses the FIT capsule, the fw_images[] must have 1 entry and it is completely non relationship with dfu_alt_info... We may need a document for this case too.
Actually, what you are stating above applies to both raw images as well as FIT images. I have added a paragraph in the capsule update related section in the uefi.rst. Can you check my patch 4 of this series. Thanks.
-sughosh
Thanks,
2022年3月25日(金) 10:09 Masami Hiramatsu masami.hiramatsu@linaro.org:
Hi Sughosh,
2022年3月24日(木) 23:40 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
At least for the DeveloperBox, it looks good to me. (Hopefully, if you comment the string formatted GUID in the code for mkeficapsule, that is perfect. :) )
I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
I meant, the order of the fw_images array needs to be same as dfu_alt_info entries and the firmware entries for dfu_alt_info must be the first, because finally we will use the index of the fw_images array, which matched to given image type GUID, for specifying dfu_alt_info entry. Or, without dfu_alt_info, your new fw_images can update the firmware? I would like to see such *relationship* at least in the patch description and the documentation.
Thank you,
-sughosh
Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
#ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
},
{
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
},
{
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
},
{
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQ_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-BOOT-IMAGE",
},
{
.image_type_id = ZYNQ_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQMP_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-BOOT-IMAGE",
},
{
.image_type_id = ZYNQMP_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \
EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \
0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46)
+#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \
EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \
0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \
EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \
0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65)
+#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \
EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \
0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT*/
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \
EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \
0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \
EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \
0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \
EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \
0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \
EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \
0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c)
+#define QEMU_ARM64_UBOOT_IMAGE_GUID \
EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \
0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
+#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
+#define DEVELOPERBOX_FIP_IMAGE_GUID \
EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
+#define DEVELOPERBOX_OPTEE_IMAGE_GUID \
EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/**
- struct efi_fw_images - List of firmware images updatable through capsule
update
- This structure gives information about the firmware images on the platform
- which can be updated through the capsule update mechanism
- @image_type_id: Image GUID. Same value is to be used in the capsule
- @fw_name: Name of the firmware image
- */
+struct efi_fw_images {
efi_guid_t image_type_id;
const u16 *fw_name;
+};
/**
- Install the ESRT system table.
-- 2.25.1
-- Masami Hiramatsu
-- Masami Hiramatsu
-- Masami Hiramatsu

Hi Sughosh,
2022年3月25日(金) 18:59 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Fri, 25 Mar 2022 at 10:58, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
OK I understand that if the platform uses the FIT capsule, the fw_images[] must have 1 entry and it is completely non relationship with dfu_alt_info... We may need a document for this case too.
Actually, what you are stating above applies to both raw images as well as FIT images. I have added a paragraph in the capsule update related section in the uefi.rst. Can you check my patch 4 of this series. Thanks.
I've checked that you didn't change the FMP::set_image(), but updated FMP::get_image_info() to use the per-platform GUID list. Thus, the efi_fmp_find() ensures that the image type GUID in the capsule image is *included* in the platform GUID list (fw_images[] array).
OK, at this point, it filters out the firmware image which is not supported on the platform.
However, since you didn't update the FMP::set_image() and efi_capsule_update_firmware(), it directly uses the *index* number in the capsule image for updating the firmware. Is that correct?
If so, if the platform supports several image types, the problem happens. Suppose that if the platform has TF-A and U-Boot, the DFU entity index are 1 and 2. And user missed to make a capsule file with index 1 for U-Boot image with U-Boot image type GUID of that platform. This capsule file passed the check in the efi_fmp_find(), because the GUID is included in the platform supported GUID list. However, FMP::set_image() will overwrite the TF-A with given U-Boot image without any error.
I think we need one more patch to check the given image-index in the capsule image is correctly matched to the image-type GUID for safety.
Thank you,
-sughosh
Thanks,
2022年3月25日(金) 10:09 Masami Hiramatsu masami.hiramatsu@linaro.org:
Hi Sughosh,
2022年3月24日(木) 23:40 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org:
Currently, all platforms that enable capsule updates do so using either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware Management Protocol(FMP) instance used on the platform. However, this means that all platforms that enable a particular FMP instance have the same GUID value for all the updatable images, either the FIT image GUID or the raw image GUID, and that an image for some platform can be updated on any other platform which uses the same FMP instance. Another issue with this implementation is that the ESRT table shows the same GUID value for all images on the platform and also across platforms, which is not in compliance with the UEFI specification.
Fix this by defining image GUID values and firmware names for individual images per platform. The GetImageInfo FMP hook would then populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
At least for the DeveloperBox, it looks good to me. (Hopefully, if you comment the string formatted GUID in the code for mkeficapsule, that is perfect. :) )
I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
I meant, the order of the fw_images array needs to be same as dfu_alt_info entries and the firmware entries for dfu_alt_info must be the first, because finally we will use the index of the fw_images array, which matched to given image type GUID, for specifying dfu_alt_info entry. Or, without dfu_alt_info, your new fw_images can update the firmware? I would like to see such *relationship* at least in the patch description and the documentation.
Thank you,
-sughosh
Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ board/kontron/sl28/sl28.c | 14 +++++++++++ board/sandbox/sandbox.c | 17 ++++++++++++++ board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ board/xilinx/common/board.h | 18 +++++++++++++++ board/xilinx/zynq/board.c | 18 +++++++++++++++ board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ include/configs/imx8mp_rsb3720.h | 10 ++++++++ include/configs/kontron-sl-mx8mm.h | 6 +++++ include/configs/kontron_pitx_imx8m.h | 6 +++++ include/configs/kontron_sl28.h | 6 +++++ include/configs/qemu-arm.h | 10 ++++++++ include/configs/sandbox.h | 10 ++++++++ include/configs/synquacer.h | 14 +++++++++++ include/efi_loader.h | 15 ++++++++++++ 20 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c index 16566092bd..6b534660fe 100644 --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c @@ -6,6 +6,8 @@
#include <common.h> #include <dwc3-uboot.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <miiphy.h> #include <netdev.h> @@ -21,6 +23,7 @@ #include <asm/arch/clock.h> #include <asm/mach-imx/dma.h> #include <linux/delay.h> +#include <linux/kernel.h> #include <power/pmic.h>
DECLARE_GLOBAL_DATA_PTR; @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) } #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G)
.image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G)
.image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MP-RSB3720-FIT"
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index 7e2d88f449..ec73d75db3 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -5,6 +5,8 @@ */
#include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <extension_board.h> #include <hang.h> @@ -21,11 +23,27 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/mxc_i2c.h> #include <asm/sections.h> +#include <linux/kernel.h>
#include "ddr/ddr.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE)
.image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE)
.image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID,
+#endif
.fw_name = u"IMX8MM-CL-IOT-GATE-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { struct lpddr4_tcm_desc *lpddr4_tcm_desc = diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index 16d5a97167..99872ce0b8 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -6,15 +6,35 @@ #include <common.h> #include <cpu_func.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> +#include <efi_loader.h> #include <fdtdec.h> #include <init.h> #include <log.h> #include <virtio_types.h> #include <virtio.h>
+#include <linux/kernel.h>
#ifdef CONFIG_ARM64 #include <asm/armv8/mmu.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
+#if defined(CONFIG_TARGET_QEMU_ARM_32BIT)
.image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID,
+#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT)
.image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID,
+#endif
.fw_name = u"Qemu-Arm-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region qemu_arm64_mem_map[] = { { /* Flash */ diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c index d655fe099b..c3af951b14 100644 --- a/board/kontron/pitx_imx8m/pitx_imx8m.c +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c @@ -2,6 +2,8 @@
#include "pitx_misc.h" #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <init.h> #include <mmc.h> #include <miiphy.h> @@ -12,7 +14,7 @@ #include <asm/mach-imx/gpio.h> #include <asm/mach-imx/iomux-v3.h> #include <linux/delay.h>
+#include <linux/kernel.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-PITX-IMX8M-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index 48376cb826..4d25618895 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -6,12 +6,26 @@ #include <asm/arch/imx-regs.h> #include <asm/global_data.h> #include <asm/io.h> +#include <efi.h> +#include <efi_loader.h> #include <fdt_support.h> #include <linux/errno.h> +#include <linux/kernel.h> #include <net.h>
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID,
.fw_name = u"KONTROL-SL-MX8MM-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_phys_sdram_size(phys_size_t *size) { u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c index 3c48a9141d..a4985df4ea 100644 --- a/board/kontron/sl28/sl28.c +++ b/board/kontron/sl28/sl28.c @@ -3,11 +3,14 @@ #include <common.h> #include <dm.h> #include <malloc.h> +#include <efi.h> +#include <efi_loader.h> #include <errno.h> #include <fsl_ddr.h> #include <fdt_support.h> #include <asm/global_data.h> #include <linux/libfdt.h> +#include <linux/kernel.h> #include <env_internal.h> #include <asm/arch-fsl-layerscape/soc.h> #include <asm/arch-fsl-layerscape/fsl_icid.h> @@ -23,6 +26,17 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = KONTRON_SL28_FIT_IMAGE_GUID,
.fw_name = u"KONTRON-SL28-FIT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_early_init_f(void) { fsl_lsch3_early_init_f(); diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 5d9a945d64..8b0f3de1ea 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -7,6 +7,8 @@ #include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <init.h> #include <led.h> @@ -25,6 +27,21 @@ */ gd_t *gd;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = SANDBOX_UBOOT_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT",
},
{
.image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID,
.fw_name = u"SANDBOX-UBOOT-ENV",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !CONFIG_IS_ENABLED(OF_PLATDATA) /*
- Add a simple GPIO device (don't use with of-platdata as it interferes with
diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c index 9552bfcdc3..4df26f4019 100644 --- a/board/socionext/developerbox/developerbox.c +++ b/board/socionext/developerbox/developerbox.c @@ -10,10 +10,33 @@ #include <asm/global_data.h> #include <asm/io.h> #include <common.h> +#include <efi.h> +#include <efi_loader.h> #include <env_internal.h> #include <fdt_support.h> #include <log.h>
+#include <linux/kernel.h>
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-UBOOT",
},
{
.image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-FIP",
},
{
.image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
.fw_name = u"DEVELOPERBOX-OPTEE",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
static struct mm_region sc2a11_mem_map[] = { { .virt = 0x0UL, diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h index 69e642429b..9bcac14946 100644 --- a/board/xilinx/common/board.h +++ b/board/xilinx/common/board.h @@ -7,6 +7,24 @@ #ifndef _BOARD_XILINX_COMMON_BOARD_H #define _BOARD_XILINX_COMMON_BOARD_H
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define ZYNQ_BOOT_IMAGE_GUID \
EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \
0xe8, 0x61, 0x21, 0x61, 0x86, 0x64)
+#define ZYNQ_UBOOT_IMAGE_GUID \
EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \
0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05)
+#define ZYNQMP_BOOT_IMAGE_GUID \
EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \
0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf)
+#define ZYNQMP_UBOOT_IMAGE_GUID \
EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \
0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
int board_late_init_xilinx(void);
int xilinx_read_eeprom(void); diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 26ef048835..0aa51a3e6d 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -8,6 +8,8 @@ #include <init.h> #include <log.h> #include <dm/uclass.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <fdtdec.h> @@ -21,10 +23,26 @@ #include <asm/global_data.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> +#include <linux/kernel.h> #include "../common/board.h"
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQ_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-BOOT-IMAGE",
},
{
.image_type_id = ZYNQ_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQ-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) void board_debug_uart_init(void) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 70b3c81f12..b232f7ac4f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -9,6 +9,8 @@ #include <cpu_func.h> #include <debug_uart.h> #include <dfu.h> +#include <efi.h> +#include <efi_loader.h> #include <env.h> #include <env_internal.h> #include <init.h> @@ -40,6 +42,7 @@ #include <linux/bitops.h> #include <linux/delay.h> #include <linux/sizes.h> +#include <linux/kernel.h> #include "../common/board.h"
#include "pm_cfg_obj.h" @@ -54,6 +57,21 @@
DECLARE_GLOBAL_DATA_PTR;
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_images fw_images[] = {
{
.image_type_id = ZYNQMP_BOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-BOOT-IMAGE",
},
{
.image_type_id = ZYNQMP_UBOOT_IMAGE_GUID,
.fw_name = u"ZYNQMP-UBOOT",
},
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC;
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h index 7e6be6050c..35df2e755e 100644 --- a/include/configs/imx8mm-cl-iot-gate.h +++ b/include/configs/imx8mm-cl-iot-gate.h @@ -31,6 +31,16 @@
#endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \
EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \
0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46)
+#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \
EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \
0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#if CONFIG_IS_ENABLED(CMD_MMC) # define BOOT_TARGET_MMC(func) \ func(MMC, mmc, 2) \ diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h index ac4a7d0cb3..a5a845c2da 100644 --- a/include/configs/imx8mp_rsb3720.h +++ b/include/configs/imx8mp_rsb3720.h @@ -21,6 +21,16 @@ #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \
EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \
0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65)
+#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \
EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \
0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT*/
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x960000 diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h index 788ae77cd3..aff1b90010 100644 --- a/include/configs/kontron-sl-mx8mm.h +++ b/include/configs/kontron-sl-mx8mm.h @@ -38,6 +38,12 @@ #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \
EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \
0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifndef CONFIG_SPL_BUILD #define BOOT_TARGET_DEVICES(func) \ func(MMC, mmc, 1) \ diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h index 0f96b905ab..678364e367 100644 --- a/include/configs/kontron_pitx_imx8m.h +++ b/include/configs/kontron_pitx_imx8m.h @@ -14,6 +14,12 @@ #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \
EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \
0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#ifdef CONFIG_SPL_BUILD #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" #define CONFIG_SPL_STACK 0x187FF0 diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h index 448749a7f8..97d0d365f6 100644 --- a/include/configs/kontron_sl28.h +++ b/include/configs/kontron_sl28.h @@ -57,6 +57,12 @@ #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 #define CONFIG_SYS_MONITOR_LEN (1024 * 1024)
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define KONTRON_SL28_FIT_IMAGE_GUID \
EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \
0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* environment */ /* see include/configs/ti_armv7_common.h */ #define ENV_MEM_LAYOUT_SETTINGS \ diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index d45f606860..2f2abc746d 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -17,6 +17,16 @@
#define CONFIG_SYS_BOOTM_LEN SZ_64M
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define QEMU_ARM_UBOOT_IMAGE_GUID \
EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \
0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c)
+#define QEMU_ARM64_UBOOT_IMAGE_GUID \
EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \
0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */
/* Environment options */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 75efbf3448..d06c3de2e0 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -14,6 +14,16 @@
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define SANDBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \
0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8)
+#define SANDBOX_UBOOT_ENV_IMAGE_GUID \
EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \
0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Size of our emulated memory */ #define SB_CONCAT(x, y) x ## y #define SB_TO_UL(s) SB_CONCAT(s, UL) diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h index 8dd092fc59..07e1f56e3d 100644 --- a/include/configs/synquacer.h +++ b/include/configs/synquacer.h @@ -51,6 +51,20 @@ "fip.bin raw 180000 78000;" \ "optee.bin raw 500000 100000\0"
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \
EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \
0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00)
+#define DEVELOPERBOX_FIP_IMAGE_GUID \
EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \
0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98)
+#define DEVELOPERBOX_OPTEE_IMAGE_GUID \
EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \
0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30)
+#endif /* EFI_HAVE_CAPSULE_SUPPORT */
/* Distro boot settings */ #ifndef CONFIG_SPL_BUILD #ifdef CONFIG_CMD_USB diff --git a/include/efi_loader.h b/include/efi_loader.h index af36639ec6..1965b5a28f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule,
#define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\"
+/**
- struct efi_fw_images - List of firmware images updatable through capsule
update
- This structure gives information about the firmware images on the platform
- which can be updated through the capsule update mechanism
- @image_type_id: Image GUID. Same value is to be used in the capsule
- @fw_name: Name of the firmware image
- */
+struct efi_fw_images {
efi_guid_t image_type_id;
const u16 *fw_name;
+};
/**
- Install the ESRT system table.
-- 2.25.1
-- Masami Hiramatsu
-- Masami Hiramatsu
-- Masami Hiramatsu

hi Masami,
On Sat, 26 Mar 2022 at 16:17, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月25日(金) 18:59 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Fri, 25 Mar 2022 at 10:58, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
OK I understand that if the platform uses the FIT capsule, the fw_images[] must have 1 entry and it is completely non relationship with dfu_alt_info... We may need a document for this case too.
Actually, what you are stating above applies to both raw images as well as FIT images. I have added a paragraph in the capsule update related section in the uefi.rst. Can you check my patch 4 of this series. Thanks.
I've checked that you didn't change the FMP::set_image(), but updated FMP::get_image_info() to use the per-platform GUID list. Thus, the efi_fmp_find() ensures that the image type GUID in the capsule image is *included* in the platform GUID list (fw_images[] array).
OK, at this point, it filters out the firmware image which is not supported on the platform.
However, since you didn't update the FMP::set_image() and efi_capsule_update_firmware(), it directly uses the *index* number in the capsule image for updating the firmware. Is that correct?
Yes, your observation is correct. The aim of this series is to fix the issue of using a common GUID value across images and platforms for a given FMP instance.
If so, if the platform supports several image types, the problem happens. Suppose that if the platform has TF-A and U-Boot, the DFU entity index are 1 and 2. And user missed to make a capsule file with index 1 for U-Boot image with U-Boot image type GUID of that platform. This capsule file passed the check in the efi_fmp_find(), because the GUID is included in the platform supported GUID list. However, FMP::set_image() will overwrite the TF-A with given U-Boot image without any error.
I think we need one more patch to check the given image-index in the capsule image is correctly matched to the image-type GUID for safety.
Yes, this is very much in the pipeline. I will be working on extending the struct efi_fw_images to have information on the image index as part of the structure. But please note that what you mention above is just making the process of capsule update more robust -- the current implementation that we have in the capsule update module where the image_index value is taken from the capsule is very much in compliance with the UEFI specification. The current patch series is fixing an issue which was not compliant with the spec. But what you are suggesting above is on my Todo list, just that it is a separate task, and not a fix as such.
-sughosh
Thank you,
-sughosh
Thanks,
2022年3月25日(金) 10:09 Masami Hiramatsu masami.hiramatsu@linaro.org:
Hi Sughosh,
2022年3月24日(木) 23:40 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org: > > Currently, all platforms that enable capsule updates do so using > either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or > EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware > Management Protocol(FMP) instance used on the platform. However, this > means that all platforms that enable a particular FMP instance have > the same GUID value for all the updatable images, either the FIT image > GUID or the raw image GUID, and that an image for some platform can be > updated on any other platform which uses the same FMP instance. Another > issue with this implementation is that the ESRT table shows the same > GUID value for all images on the platform and also across platforms, > which is not in compliance with the UEFI specification. > > Fix this by defining image GUID values and firmware names for > individual images per platform. The GetImageInfo FMP hook would then > populate these values in the image descriptor array.
OK, so you have generated GUIDs for each "dfu_alt_info" entry on the platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
At least for the DeveloperBox, it looks good to me. (Hopefully, if you comment the string formatted GUID in the code for mkeficapsule, that is perfect. :) )
I think you should explain that those GUIDs (fw_images[] entries) must be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
I meant, the order of the fw_images array needs to be same as dfu_alt_info entries and the firmware entries for dfu_alt_info must be the first, because finally we will use the index of the fw_images array, which matched to given image type GUID, for specifying dfu_alt_info entry. Or, without dfu_alt_info, your new fw_images can update the firmware? I would like to see such *relationship* at least in the patch description and the documentation.
Thank you,
-sughosh
Without that, it is hard to understand why the next patch ([2/6]) works :-)
Thank you,
> > Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org > --- > .../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ > .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ > board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ > board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- > board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ > board/kontron/sl28/sl28.c | 14 +++++++++++ > board/sandbox/sandbox.c | 17 ++++++++++++++ > board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ > board/xilinx/common/board.h | 18 +++++++++++++++ > board/xilinx/zynq/board.c | 18 +++++++++++++++ > board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ > include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ > include/configs/imx8mp_rsb3720.h | 10 ++++++++ > include/configs/kontron-sl-mx8mm.h | 6 +++++ > include/configs/kontron_pitx_imx8m.h | 6 +++++ > include/configs/kontron_sl28.h | 6 +++++ > include/configs/qemu-arm.h | 10 ++++++++ > include/configs/sandbox.h | 10 ++++++++ > include/configs/synquacer.h | 14 +++++++++++ > include/efi_loader.h | 15 ++++++++++++ > 20 files changed, 280 insertions(+), 1 deletion(-) > > diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > index 16566092bd..6b534660fe 100644 > --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > @@ -6,6 +6,8 @@ > > #include <common.h> > #include <dwc3-uboot.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <errno.h> > #include <miiphy.h> > #include <netdev.h> > @@ -21,6 +23,7 @@ > #include <asm/arch/clock.h> > #include <asm/mach-imx/dma.h> > #include <linux/delay.h> > +#include <linux/kernel.h> > #include <power/pmic.h> > > DECLARE_GLOBAL_DATA_PTR; > @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) > } > #endif > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > +#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G) > + .image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID, > +#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G) > + .image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID, > +#endif > + .fw_name = u"IMX8MP-RSB3720-FIT" > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > + > int board_early_init_f(void) > { > struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; > diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c > index 7e2d88f449..ec73d75db3 100644 > --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c > +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c > @@ -5,6 +5,8 @@ > */ > > #include <common.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <env.h> > #include <extension_board.h> > #include <hang.h> > @@ -21,11 +23,27 @@ > #include <asm/mach-imx/gpio.h> > #include <asm/mach-imx/mxc_i2c.h> > #include <asm/sections.h> > +#include <linux/kernel.h> > > #include "ddr/ddr.h" > > DECLARE_GLOBAL_DATA_PTR; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > +#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE) > + .image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID, > +#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) > + .image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID, > +#endif > + .fw_name = u"IMX8MM-CL-IOT-GATE-FIT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > int board_phys_sdram_size(phys_size_t *size) > { > struct lpddr4_tcm_desc *lpddr4_tcm_desc = > diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c > index 16d5a97167..99872ce0b8 100644 > --- a/board/emulation/qemu-arm/qemu-arm.c > +++ b/board/emulation/qemu-arm/qemu-arm.c > @@ -6,15 +6,35 @@ > #include <common.h> > #include <cpu_func.h> > #include <dm.h> > +#include <efi.h> > +#include <efi_loader.h> > +#include <efi_loader.h> > #include <fdtdec.h> > #include <init.h> > #include <log.h> > #include <virtio_types.h> > #include <virtio.h> > > +#include <linux/kernel.h> > + > #ifdef CONFIG_ARM64 > #include <asm/armv8/mmu.h> > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > +#if defined(CONFIG_TARGET_QEMU_ARM_32BIT) > + .image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID, > +#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT) > + .image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID, > +#endif > + .fw_name = u"Qemu-Arm-UBOOT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > static struct mm_region qemu_arm64_mem_map[] = { > { > /* Flash */ > diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c > index d655fe099b..c3af951b14 100644 > --- a/board/kontron/pitx_imx8m/pitx_imx8m.c > +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c > @@ -2,6 +2,8 @@ > > #include "pitx_misc.h" > #include <common.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <init.h> > #include <mmc.h> > #include <miiphy.h> > @@ -12,7 +14,7 @@ > #include <asm/mach-imx/gpio.h> > #include <asm/mach-imx/iomux-v3.h> > #include <linux/delay.h> > - > +#include <linux/kernel.h> > > DECLARE_GLOBAL_DATA_PTR; > > @@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { > IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), > }; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID, > + .fw_name = u"KONTRON-PITX-IMX8M-UBOOT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > int board_early_init_f(void) > { > struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; > diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c > index 48376cb826..4d25618895 100644 > --- a/board/kontron/sl-mx8mm/sl-mx8mm.c > +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c > @@ -6,12 +6,26 @@ > #include <asm/arch/imx-regs.h> > #include <asm/global_data.h> > #include <asm/io.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <fdt_support.h> > #include <linux/errno.h> > +#include <linux/kernel.h> > #include <net.h> > > DECLARE_GLOBAL_DATA_PTR; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID, > + .fw_name = u"KONTROL-SL-MX8MM-UBOOT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > int board_phys_sdram_size(phys_size_t *size) > { > u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); > diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c > index 3c48a9141d..a4985df4ea 100644 > --- a/board/kontron/sl28/sl28.c > +++ b/board/kontron/sl28/sl28.c > @@ -3,11 +3,14 @@ > #include <common.h> > #include <dm.h> > #include <malloc.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <errno.h> > #include <fsl_ddr.h> > #include <fdt_support.h> > #include <asm/global_data.h> > #include <linux/libfdt.h> > +#include <linux/kernel.h> > #include <env_internal.h> > #include <asm/arch-fsl-layerscape/soc.h> > #include <asm/arch-fsl-layerscape/fsl_icid.h> > @@ -23,6 +26,17 @@ > > DECLARE_GLOBAL_DATA_PTR; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = KONTRON_SL28_FIT_IMAGE_GUID, > + .fw_name = u"KONTRON-SL28-FIT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > int board_early_init_f(void) > { > fsl_lsch3_early_init_f(); > diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c > index 5d9a945d64..8b0f3de1ea 100644 > --- a/board/sandbox/sandbox.c > +++ b/board/sandbox/sandbox.c > @@ -7,6 +7,8 @@ > #include <cpu_func.h> > #include <cros_ec.h> > #include <dm.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <env_internal.h> > #include <init.h> > #include <led.h> > @@ -25,6 +27,21 @@ > */ > gd_t *gd; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = SANDBOX_UBOOT_IMAGE_GUID, > + .fw_name = u"SANDBOX-UBOOT", > + }, > + { > + .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID, > + .fw_name = u"SANDBOX-UBOOT-ENV", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > #if !CONFIG_IS_ENABLED(OF_PLATDATA) > /* > * Add a simple GPIO device (don't use with of-platdata as it interferes with > diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c > index 9552bfcdc3..4df26f4019 100644 > --- a/board/socionext/developerbox/developerbox.c > +++ b/board/socionext/developerbox/developerbox.c > @@ -10,10 +10,33 @@ > #include <asm/global_data.h> > #include <asm/io.h> > #include <common.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <env_internal.h> > #include <fdt_support.h> > #include <log.h> > > +#include <linux/kernel.h> > + > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID, > + .fw_name = u"DEVELOPERBOX-UBOOT", > + }, > + { > + .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID, > + .fw_name = u"DEVELOPERBOX-FIP", > + }, > + { > + .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID, > + .fw_name = u"DEVELOPERBOX-OPTEE", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > static struct mm_region sc2a11_mem_map[] = { > { > .virt = 0x0UL, > diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h > index 69e642429b..9bcac14946 100644 > --- a/board/xilinx/common/board.h > +++ b/board/xilinx/common/board.h > @@ -7,6 +7,24 @@ > #ifndef _BOARD_XILINX_COMMON_BOARD_H > #define _BOARD_XILINX_COMMON_BOARD_H > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define ZYNQ_BOOT_IMAGE_GUID \ > + EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \ > + 0xe8, 0x61, 0x21, 0x61, 0x86, 0x64) > + > +#define ZYNQ_UBOOT_IMAGE_GUID \ > + EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \ > + 0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05) > + > +#define ZYNQMP_BOOT_IMAGE_GUID \ > + EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \ > + 0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf) > + > +#define ZYNQMP_UBOOT_IMAGE_GUID \ > + EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \ > + 0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > int board_late_init_xilinx(void); > > int xilinx_read_eeprom(void); > diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c > index 26ef048835..0aa51a3e6d 100644 > --- a/board/xilinx/zynq/board.c > +++ b/board/xilinx/zynq/board.c > @@ -8,6 +8,8 @@ > #include <init.h> > #include <log.h> > #include <dm/uclass.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <env.h> > #include <env_internal.h> > #include <fdtdec.h> > @@ -21,10 +23,26 @@ > #include <asm/global_data.h> > #include <asm/arch/hardware.h> > #include <asm/arch/sys_proto.h> > +#include <linux/kernel.h> > #include "../common/board.h" > > DECLARE_GLOBAL_DATA_PTR; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = ZYNQ_BOOT_IMAGE_GUID, > + .fw_name = u"ZYNQ-BOOT-IMAGE", > + }, > + { > + .image_type_id = ZYNQ_UBOOT_IMAGE_GUID, > + .fw_name = u"ZYNQ-UBOOT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) > void board_debug_uart_init(void) > { > diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c > index 70b3c81f12..b232f7ac4f 100644 > --- a/board/xilinx/zynqmp/zynqmp.c > +++ b/board/xilinx/zynqmp/zynqmp.c > @@ -9,6 +9,8 @@ > #include <cpu_func.h> > #include <debug_uart.h> > #include <dfu.h> > +#include <efi.h> > +#include <efi_loader.h> > #include <env.h> > #include <env_internal.h> > #include <init.h> > @@ -40,6 +42,7 @@ > #include <linux/bitops.h> > #include <linux/delay.h> > #include <linux/sizes.h> > +#include <linux/kernel.h> > #include "../common/board.h" > > #include "pm_cfg_obj.h" > @@ -54,6 +57,21 @@ > > DECLARE_GLOBAL_DATA_PTR; > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +struct efi_fw_images fw_images[] = { > + { > + .image_type_id = ZYNQMP_BOOT_IMAGE_GUID, > + .fw_name = u"ZYNQMP-BOOT-IMAGE", > + }, > + { > + .image_type_id = ZYNQMP_UBOOT_IMAGE_GUID, > + .fw_name = u"ZYNQMP-UBOOT", > + }, > +}; > + > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) > static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; > > diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h > index 7e6be6050c..35df2e755e 100644 > --- a/include/configs/imx8mm-cl-iot-gate.h > +++ b/include/configs/imx8mm-cl-iot-gate.h > @@ -31,6 +31,16 @@ > > #endif > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \ > + EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \ > + 0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46) > + > +#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \ > + EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \ > + 0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > #if CONFIG_IS_ENABLED(CMD_MMC) > # define BOOT_TARGET_MMC(func) \ > func(MMC, mmc, 2) \ > diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h > index ac4a7d0cb3..a5a845c2da 100644 > --- a/include/configs/imx8mp_rsb3720.h > +++ b/include/configs/imx8mp_rsb3720.h > @@ -21,6 +21,16 @@ > #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 > #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512) > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \ > + EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \ > + 0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65) > + > +#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \ > + EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \ > + 0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT*/ > + > #ifdef CONFIG_SPL_BUILD > #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" > #define CONFIG_SPL_STACK 0x960000 > diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h > index 788ae77cd3..aff1b90010 100644 > --- a/include/configs/kontron-sl-mx8mm.h > +++ b/include/configs/kontron-sl-mx8mm.h > @@ -38,6 +38,12 @@ > #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 > #endif > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \ > + EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \ > + 0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > #ifndef CONFIG_SPL_BUILD > #define BOOT_TARGET_DEVICES(func) \ > func(MMC, mmc, 1) \ > diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h > index 0f96b905ab..678364e367 100644 > --- a/include/configs/kontron_pitx_imx8m.h > +++ b/include/configs/kontron_pitx_imx8m.h > @@ -14,6 +14,12 @@ > #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR > #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \ > + EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \ > + 0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > #ifdef CONFIG_SPL_BUILD > #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" > #define CONFIG_SPL_STACK 0x187FF0 > diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h > index 448749a7f8..97d0d365f6 100644 > --- a/include/configs/kontron_sl28.h > +++ b/include/configs/kontron_sl28.h > @@ -57,6 +57,12 @@ > #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 > #define CONFIG_SYS_MONITOR_LEN (1024 * 1024) > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define KONTRON_SL28_FIT_IMAGE_GUID \ > + EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \ > + 0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > /* environment */ > /* see include/configs/ti_armv7_common.h */ > #define ENV_MEM_LAYOUT_SETTINGS \ > diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h > index d45f606860..2f2abc746d 100644 > --- a/include/configs/qemu-arm.h > +++ b/include/configs/qemu-arm.h > @@ -17,6 +17,16 @@ > > #define CONFIG_SYS_BOOTM_LEN SZ_64M > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define QEMU_ARM_UBOOT_IMAGE_GUID \ > + EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \ > + 0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c) > + > +#define QEMU_ARM64_UBOOT_IMAGE_GUID \ > + EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \ > + 0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > /* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */ > > /* Environment options */ > diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h > index 75efbf3448..d06c3de2e0 100644 > --- a/include/configs/sandbox.h > +++ b/include/configs/sandbox.h > @@ -14,6 +14,16 @@ > > #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define SANDBOX_UBOOT_IMAGE_GUID \ > + EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \ > + 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8) > + > +#define SANDBOX_UBOOT_ENV_IMAGE_GUID \ > + EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \ > + 0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > /* Size of our emulated memory */ > #define SB_CONCAT(x, y) x ## y > #define SB_TO_UL(s) SB_CONCAT(s, UL) > diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h > index 8dd092fc59..07e1f56e3d 100644 > --- a/include/configs/synquacer.h > +++ b/include/configs/synquacer.h > @@ -51,6 +51,20 @@ > "fip.bin raw 180000 78000;" \ > "optee.bin raw 500000 100000\0" > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \ > + EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \ > + 0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00) > + > +#define DEVELOPERBOX_FIP_IMAGE_GUID \ > + EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \ > + 0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98) > + > +#define DEVELOPERBOX_OPTEE_IMAGE_GUID \ > + EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \ > + 0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30) > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > + > /* Distro boot settings */ > #ifndef CONFIG_SPL_BUILD > #ifdef CONFIG_CMD_USB > diff --git a/include/efi_loader.h b/include/efi_loader.h > index af36639ec6..1965b5a28f 100644 > --- a/include/efi_loader.h > +++ b/include/efi_loader.h > @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule, > > #define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\" > > +/** > + * struct efi_fw_images - List of firmware images updatable through capsule > + * update > + * > + * This structure gives information about the firmware images on the platform > + * which can be updated through the capsule update mechanism > + * > + * @image_type_id: Image GUID. Same value is to be used in the capsule > + * @fw_name: Name of the firmware image > + */ > +struct efi_fw_images { > + efi_guid_t image_type_id; > + const u16 *fw_name; > +}; > + > /** > * Install the ESRT system table. > * > -- > 2.25.1 >
-- Masami Hiramatsu
-- Masami Hiramatsu
-- Masami Hiramatsu
-- Masami Hiramatsu

Hi Sughosh,
2022年3月27日(日) 18:11 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Sat, 26 Mar 2022 at 16:17, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
2022年3月25日(金) 18:59 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Fri, 25 Mar 2022 at 10:58, Masami Hiramatsu masami.hiramatsu@linaro.org wrote:
Hi Sughosh,
OK I understand that if the platform uses the FIT capsule, the fw_images[] must have 1 entry and it is completely non relationship with dfu_alt_info... We may need a document for this case too.
Actually, what you are stating above applies to both raw images as well as FIT images. I have added a paragraph in the capsule update related section in the uefi.rst. Can you check my patch 4 of this series. Thanks.
I've checked that you didn't change the FMP::set_image(), but updated FMP::get_image_info() to use the per-platform GUID list. Thus, the efi_fmp_find() ensures that the image type GUID in the capsule image is *included* in the platform GUID list (fw_images[] array).
OK, at this point, it filters out the firmware image which is not supported on the platform.
However, since you didn't update the FMP::set_image() and efi_capsule_update_firmware(), it directly uses the *index* number in the capsule image for updating the firmware. Is that correct?
Yes, your observation is correct. The aim of this series is to fix the issue of using a common GUID value across images and platforms for a given FMP instance.
OK, but I think this has made the thing complicated. Without this series, user will only care about the index number to make the capsule image and the GUID is correct for the platform, since the platform chooses FIP or RAW.
With this series, user additionally needs to care about the combination of the index and the GUID of image type, because the U-Boot doesn't check the combination is correct or not.
I would like to ask you to add this note in the document. Even if the U-Boot checks the combination, user still need to check it when making the capsule file.
If so, if the platform supports several image types, the problem happens. Suppose that if the platform has TF-A and U-Boot, the DFU entity index are 1 and 2. And user missed to make a capsule file with index 1 for U-Boot image with U-Boot image type GUID of that platform. This capsule file passed the check in the efi_fmp_find(), because the GUID is included in the platform supported GUID list. However, FMP::set_image() will overwrite the TF-A with given U-Boot image without any error.
I think we need one more patch to check the given image-index in the capsule image is correctly matched to the image-type GUID for safety.
Yes, this is very much in the pipeline. I will be working on extending the struct efi_fw_images to have information on the image index as part of the structure.
That is great! BTW, if we have 2 different dfu_alt_info entries for the same type of firmware, should we have different GUIDs for those?
But please note that what you mention above is just making the process of capsule update more robust -- the current implementation that we have in the capsule update module where the image_index value is taken from the capsule is very much in compliance with the UEFI specification. The current patch series is fixing an issue which was not compliant with the spec. But what you are suggesting above is on my Todo list, just that it is a separate task, and not a fix as such.
OK, I don't mind the actual robustness change, but please describe this scenario as a notice for users so that they can make capsule files correctly.
Thank you,
-sughosh
Thank you,
-sughosh
Thanks,
2022年3月25日(金) 10:09 Masami Hiramatsu masami.hiramatsu@linaro.org:
Hi Sughosh,
2022年3月24日(木) 23:40 Sughosh Ganu sughosh.ganu@linaro.org:
hi Masami,
On Thu, 24 Mar 2022 at 19:14, Masami Hiramatsu masami.hiramatsu@linaro.org wrote: > > Hi Sughosh, > > 2022年3月24日(木) 21:39 Sughosh Ganu sughosh.ganu@linaro.org: > > > > Currently, all platforms that enable capsule updates do so using > > either EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID or > > EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID. This is based on the Firmware > > Management Protocol(FMP) instance used on the platform. However, this > > means that all platforms that enable a particular FMP instance have > > the same GUID value for all the updatable images, either the FIT image > > GUID or the raw image GUID, and that an image for some platform can be > > updated on any other platform which uses the same FMP instance. Another > > issue with this implementation is that the ESRT table shows the same > > GUID value for all images on the platform and also across platforms, > > which is not in compliance with the UEFI specification. > > > > Fix this by defining image GUID values and firmware names for > > individual images per platform. The GetImageInfo FMP hook would then > > populate these values in the image descriptor array. > > OK, so you have generated GUIDs for each "dfu_alt_info" entry on the > platforms, correct?
No, I have generated the fw_images array based on the information that I found in the dfu_alt_info variable for the platform. But this is not correlated to the dfu_alt_info variable. If you think that the array should have more/different entries for your platform, please let me know, and I will change it.
At least for the DeveloperBox, it looks good to me. (Hopefully, if you comment the string formatted GUID in the code for mkeficapsule, that is perfect. :) )
> I think you should explain that those GUIDs (fw_images[] entries) must > be corresponding to the dfu_alt_info entries, in the same order.
The dfu_alt_info can have more entries than the firmware images that are updatable through capsule update. One example is the ST platforms which have additional entries in the dfu_alt_info. The image descriptor array should only contain entries of images which are updatable through capsule update, since the same information is also used for generating the ESRT. Which is why I have changed the logic to populate the image descriptors through the fw_images array rather than the dfu_alt_info.
I meant, the order of the fw_images array needs to be same as dfu_alt_info entries and the firmware entries for dfu_alt_info must be the first, because finally we will use the index of the fw_images array, which matched to given image type GUID, for specifying dfu_alt_info entry. Or, without dfu_alt_info, your new fw_images can update the firmware? I would like to see such *relationship* at least in the patch description and the documentation.
Thank you,
-sughosh
> Without that, it is hard to understand why the next patch ([2/6]) works :-) > > Thank you, > > > > > Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org > > --- > > .../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 +++++++++++++++ > > .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 +++++++++++++++ > > board/emulation/qemu-arm/qemu-arm.c | 20 ++++++++++++++++ > > board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +++++++++++- > > board/kontron/sl-mx8mm/sl-mx8mm.c | 14 +++++++++++ > > board/kontron/sl28/sl28.c | 14 +++++++++++ > > board/sandbox/sandbox.c | 17 ++++++++++++++ > > board/socionext/developerbox/developerbox.c | 23 +++++++++++++++++++ > > board/xilinx/common/board.h | 18 +++++++++++++++ > > board/xilinx/zynq/board.c | 18 +++++++++++++++ > > board/xilinx/zynqmp/zynqmp.c | 18 +++++++++++++++ > > include/configs/imx8mm-cl-iot-gate.h | 10 ++++++++ > > include/configs/imx8mp_rsb3720.h | 10 ++++++++ > > include/configs/kontron-sl-mx8mm.h | 6 +++++ > > include/configs/kontron_pitx_imx8m.h | 6 +++++ > > include/configs/kontron_sl28.h | 6 +++++ > > include/configs/qemu-arm.h | 10 ++++++++ > > include/configs/sandbox.h | 10 ++++++++ > > include/configs/synquacer.h | 14 +++++++++++ > > include/efi_loader.h | 15 ++++++++++++ > > 20 files changed, 280 insertions(+), 1 deletion(-) > > > > diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > > index 16566092bd..6b534660fe 100644 > > --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > > +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c > > @@ -6,6 +6,8 @@ > > > > #include <common.h> > > #include <dwc3-uboot.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <errno.h> > > #include <miiphy.h> > > #include <netdev.h> > > @@ -21,6 +23,7 @@ > > #include <asm/arch/clock.h> > > #include <asm/mach-imx/dma.h> > > #include <linux/delay.h> > > +#include <linux/kernel.h> > > #include <power/pmic.h> > > > > DECLARE_GLOBAL_DATA_PTR; > > @@ -44,6 +47,22 @@ static void setup_gpmi_nand(void) > > } > > #endif > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > +#if defined(CONFIG_TARGET_IMX8MP_RSB3720A1_4G) > > + .image_type_id = IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID, > > +#elif defined(CONFIG_TARGET_IMX8MP_RSB3720A1_6G) > > + .image_type_id = IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID, > > +#endif > > + .fw_name = u"IMX8MP-RSB3720-FIT" > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > + > > int board_early_init_f(void) > > { > > struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; > > diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c > > index 7e2d88f449..ec73d75db3 100644 > > --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c > > +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c > > @@ -5,6 +5,8 @@ > > */ > > > > #include <common.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <env.h> > > #include <extension_board.h> > > #include <hang.h> > > @@ -21,11 +23,27 @@ > > #include <asm/mach-imx/gpio.h> > > #include <asm/mach-imx/mxc_i2c.h> > > #include <asm/sections.h> > > +#include <linux/kernel.h> > > > > #include "ddr/ddr.h" > > > > DECLARE_GLOBAL_DATA_PTR; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > +#if defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE) > > + .image_type_id = IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID, > > +#elif defined(CONFIG_TARGET_IMX8MM_CL_IOT_GATE_OPTEE) > > + .image_type_id = IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID, > > +#endif > > + .fw_name = u"IMX8MM-CL-IOT-GATE-FIT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > int board_phys_sdram_size(phys_size_t *size) > > { > > struct lpddr4_tcm_desc *lpddr4_tcm_desc = > > diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c > > index 16d5a97167..99872ce0b8 100644 > > --- a/board/emulation/qemu-arm/qemu-arm.c > > +++ b/board/emulation/qemu-arm/qemu-arm.c > > @@ -6,15 +6,35 @@ > > #include <common.h> > > #include <cpu_func.h> > > #include <dm.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > +#include <efi_loader.h> > > #include <fdtdec.h> > > #include <init.h> > > #include <log.h> > > #include <virtio_types.h> > > #include <virtio.h> > > > > +#include <linux/kernel.h> > > + > > #ifdef CONFIG_ARM64 > > #include <asm/armv8/mmu.h> > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > +#if defined(CONFIG_TARGET_QEMU_ARM_32BIT) > > + .image_type_id = QEMU_ARM_UBOOT_IMAGE_GUID, > > +#elif defined(CONFIG_TARGET_QEMU_ARM_64BIT) > > + .image_type_id = QEMU_ARM64_UBOOT_IMAGE_GUID, > > +#endif > > + .fw_name = u"Qemu-Arm-UBOOT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > static struct mm_region qemu_arm64_mem_map[] = { > > { > > /* Flash */ > > diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c > > index d655fe099b..c3af951b14 100644 > > --- a/board/kontron/pitx_imx8m/pitx_imx8m.c > > +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c > > @@ -2,6 +2,8 @@ > > > > #include "pitx_misc.h" > > #include <common.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <init.h> > > #include <mmc.h> > > #include <miiphy.h> > > @@ -12,7 +14,7 @@ > > #include <asm/mach-imx/gpio.h> > > #include <asm/mach-imx/iomux-v3.h> > > #include <linux/delay.h> > > - > > +#include <linux/kernel.h> > > > > DECLARE_GLOBAL_DATA_PTR; > > > > @@ -30,6 +32,17 @@ static iomux_v3_cfg_t const uart_pads[] = { > > IMX8MQ_PAD_ECSPI1_MISO__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL), > > }; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = KONTRON_PITX_IMX8M_FIT_IMAGE_GUID, > > + .fw_name = u"KONTRON-PITX-IMX8M-UBOOT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > int board_early_init_f(void) > > { > > struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; > > diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c > > index 48376cb826..4d25618895 100644 > > --- a/board/kontron/sl-mx8mm/sl-mx8mm.c > > +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c > > @@ -6,12 +6,26 @@ > > #include <asm/arch/imx-regs.h> > > #include <asm/global_data.h> > > #include <asm/io.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <fdt_support.h> > > #include <linux/errno.h> > > +#include <linux/kernel.h> > > #include <net.h> > > > > DECLARE_GLOBAL_DATA_PTR; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = KONTRON_SL_MX8MM_FIT_IMAGE_GUID, > > + .fw_name = u"KONTROL-SL-MX8MM-UBOOT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > int board_phys_sdram_size(phys_size_t *size) > > { > > u32 ddr_size = readl(M4_BOOTROM_BASE_ADDR); > > diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c > > index 3c48a9141d..a4985df4ea 100644 > > --- a/board/kontron/sl28/sl28.c > > +++ b/board/kontron/sl28/sl28.c > > @@ -3,11 +3,14 @@ > > #include <common.h> > > #include <dm.h> > > #include <malloc.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <errno.h> > > #include <fsl_ddr.h> > > #include <fdt_support.h> > > #include <asm/global_data.h> > > #include <linux/libfdt.h> > > +#include <linux/kernel.h> > > #include <env_internal.h> > > #include <asm/arch-fsl-layerscape/soc.h> > > #include <asm/arch-fsl-layerscape/fsl_icid.h> > > @@ -23,6 +26,17 @@ > > > > DECLARE_GLOBAL_DATA_PTR; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = KONTRON_SL28_FIT_IMAGE_GUID, > > + .fw_name = u"KONTRON-SL28-FIT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > int board_early_init_f(void) > > { > > fsl_lsch3_early_init_f(); > > diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c > > index 5d9a945d64..8b0f3de1ea 100644 > > --- a/board/sandbox/sandbox.c > > +++ b/board/sandbox/sandbox.c > > @@ -7,6 +7,8 @@ > > #include <cpu_func.h> > > #include <cros_ec.h> > > #include <dm.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <env_internal.h> > > #include <init.h> > > #include <led.h> > > @@ -25,6 +27,21 @@ > > */ > > gd_t *gd; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = SANDBOX_UBOOT_IMAGE_GUID, > > + .fw_name = u"SANDBOX-UBOOT", > > + }, > > + { > > + .image_type_id = SANDBOX_UBOOT_ENV_IMAGE_GUID, > > + .fw_name = u"SANDBOX-UBOOT-ENV", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > #if !CONFIG_IS_ENABLED(OF_PLATDATA) > > /* > > * Add a simple GPIO device (don't use with of-platdata as it interferes with > > diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c > > index 9552bfcdc3..4df26f4019 100644 > > --- a/board/socionext/developerbox/developerbox.c > > +++ b/board/socionext/developerbox/developerbox.c > > @@ -10,10 +10,33 @@ > > #include <asm/global_data.h> > > #include <asm/io.h> > > #include <common.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <env_internal.h> > > #include <fdt_support.h> > > #include <log.h> > > > > +#include <linux/kernel.h> > > + > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID, > > + .fw_name = u"DEVELOPERBOX-UBOOT", > > + }, > > + { > > + .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID, > > + .fw_name = u"DEVELOPERBOX-FIP", > > + }, > > + { > > + .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID, > > + .fw_name = u"DEVELOPERBOX-OPTEE", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > static struct mm_region sc2a11_mem_map[] = { > > { > > .virt = 0x0UL, > > diff --git a/board/xilinx/common/board.h b/board/xilinx/common/board.h > > index 69e642429b..9bcac14946 100644 > > --- a/board/xilinx/common/board.h > > +++ b/board/xilinx/common/board.h > > @@ -7,6 +7,24 @@ > > #ifndef _BOARD_XILINX_COMMON_BOARD_H > > #define _BOARD_XILINX_COMMON_BOARD_H > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define ZYNQ_BOOT_IMAGE_GUID \ > > + EFI_GUID(0x1ba29a15, 0x9969, 0x40aa, 0xb4, 0x24, \ > > + 0xe8, 0x61, 0x21, 0x61, 0x86, 0x64) > > + > > +#define ZYNQ_UBOOT_IMAGE_GUID \ > > + EFI_GUID(0x1a5178f0, 0x87d3, 0x4f36, 0xac, 0x63, \ > > + 0x3b, 0x31, 0xa2, 0x3b, 0xe3, 0x05) > > + > > +#define ZYNQMP_BOOT_IMAGE_GUID \ > > + EFI_GUID(0xde6066e8, 0x0256, 0x4fad, 0x82, 0x38, \ > > + 0xe4, 0x06, 0xe2, 0x74, 0xc4, 0xcf) > > + > > +#define ZYNQMP_UBOOT_IMAGE_GUID \ > > + EFI_GUID(0xcf9ecfd4, 0x938b, 0x41c5, 0x85, 0x51, \ > > + 0x1f, 0x88, 0x3a, 0xb7, 0xdc, 0x18) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > int board_late_init_xilinx(void); > > > > int xilinx_read_eeprom(void); > > diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c > > index 26ef048835..0aa51a3e6d 100644 > > --- a/board/xilinx/zynq/board.c > > +++ b/board/xilinx/zynq/board.c > > @@ -8,6 +8,8 @@ > > #include <init.h> > > #include <log.h> > > #include <dm/uclass.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <env.h> > > #include <env_internal.h> > > #include <fdtdec.h> > > @@ -21,10 +23,26 @@ > > #include <asm/global_data.h> > > #include <asm/arch/hardware.h> > > #include <asm/arch/sys_proto.h> > > +#include <linux/kernel.h> > > #include "../common/board.h" > > > > DECLARE_GLOBAL_DATA_PTR; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = ZYNQ_BOOT_IMAGE_GUID, > > + .fw_name = u"ZYNQ-BOOT-IMAGE", > > + }, > > + { > > + .image_type_id = ZYNQ_UBOOT_IMAGE_GUID, > > + .fw_name = u"ZYNQ-UBOOT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_DEBUG_UART_BOARD_INIT) > > void board_debug_uart_init(void) > > { > > diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c > > index 70b3c81f12..b232f7ac4f 100644 > > --- a/board/xilinx/zynqmp/zynqmp.c > > +++ b/board/xilinx/zynqmp/zynqmp.c > > @@ -9,6 +9,8 @@ > > #include <cpu_func.h> > > #include <debug_uart.h> > > #include <dfu.h> > > +#include <efi.h> > > +#include <efi_loader.h> > > #include <env.h> > > #include <env_internal.h> > > #include <init.h> > > @@ -40,6 +42,7 @@ > > #include <linux/bitops.h> > > #include <linux/delay.h> > > #include <linux/sizes.h> > > +#include <linux/kernel.h> > > #include "../common/board.h" > > > > #include "pm_cfg_obj.h" > > @@ -54,6 +57,21 @@ > > > > DECLARE_GLOBAL_DATA_PTR; > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +struct efi_fw_images fw_images[] = { > > + { > > + .image_type_id = ZYNQMP_BOOT_IMAGE_GUID, > > + .fw_name = u"ZYNQMP-BOOT-IMAGE", > > + }, > > + { > > + .image_type_id = ZYNQMP_UBOOT_IMAGE_GUID, > > + .fw_name = u"ZYNQMP-UBOOT", > > + }, > > +}; > > + > > +u8 num_image_type_guids = ARRAY_SIZE(fw_images); > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) > > static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; > > > > diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h > > index 7e6be6050c..35df2e755e 100644 > > --- a/include/configs/imx8mm-cl-iot-gate.h > > +++ b/include/configs/imx8mm-cl-iot-gate.h > > @@ -31,6 +31,16 @@ > > > > #endif > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define IMX8MM_CL_IOT_GATE_FIT_IMAGE_GUID \ > > + EFI_GUID(0x7a32a939, 0xab92, 0x467b, 0x91, 0x52, \ > > + 0x74, 0x77, 0x1b, 0x95, 0xe6, 0x46) > > + > > +#define IMX8MM_CL_IOT_GATE_OPTEE_FIT_IMAGE_GUID \ > > + EFI_GUID(0x0bf1165c, 0x1831, 0x4864, 0x94, 0x5e, \ > > + 0xac, 0x3d, 0x38, 0x48, 0xf4, 0x99) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > #if CONFIG_IS_ENABLED(CMD_MMC) > > # define BOOT_TARGET_MMC(func) \ > > func(MMC, mmc, 2) \ > > diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h > > index ac4a7d0cb3..a5a845c2da 100644 > > --- a/include/configs/imx8mp_rsb3720.h > > +++ b/include/configs/imx8mp_rsb3720.h > > @@ -21,6 +21,16 @@ > > #define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION 1 > > #define CONFIG_SYS_UBOOT_BASE (QSPI0_AMBA_BASE + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512) > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define IMX8MP_RSB3720A1_4G_FIT_IMAGE_GUID \ > > + EFI_GUID(0xb1251e89, 0x384a, 0x4635, 0xa8, 0x06, \ > > + 0x3a, 0xa0, 0xb0, 0xe9, 0xf9, 0x65) > > + > > +#define IMX8MP_RSB3720A1_6G_FIT_IMAGE_GUID \ > > + EFI_GUID(0xb5fb6f08, 0xe142, 0x4db1, 0x97, 0xea, \ > > + 0x5f, 0xd3, 0x6b, 0x9b, 0xe5, 0xb9) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT*/ > > + > > #ifdef CONFIG_SPL_BUILD > > #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" > > #define CONFIG_SPL_STACK 0x960000 > > diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h > > index 788ae77cd3..aff1b90010 100644 > > --- a/include/configs/kontron-sl-mx8mm.h > > +++ b/include/configs/kontron-sl-mx8mm.h > > @@ -38,6 +38,12 @@ > > #define CONFIG_USB_MAX_CONTROLLER_COUNT 2 > > #endif > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define KONTRON_SL_MX8MM_FIT_IMAGE_GUID \ > > + EFI_GUID(0xd488e45a, 0x4929, 0x4b55, 0x8c, 0x14, \ > > + 0x86, 0xce, 0xa2, 0xcd, 0x66, 0x29) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > #ifndef CONFIG_SPL_BUILD > > #define BOOT_TARGET_DEVICES(func) \ > > func(MMC, mmc, 1) \ > > diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h > > index 0f96b905ab..678364e367 100644 > > --- a/include/configs/kontron_pitx_imx8m.h > > +++ b/include/configs/kontron_pitx_imx8m.h > > @@ -14,6 +14,12 @@ > > #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR > > #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define KONTRON_PITX_IMX8M_FIT_IMAGE_GUID \ > > + EFI_GUID(0xc898e959, 0x5b1f, 0x4e6d, 0x88, 0xe0, \ > > + 0x40, 0xd4, 0x5c, 0xca, 0x13, 0x99) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > #ifdef CONFIG_SPL_BUILD > > #define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv8/u-boot-spl.lds" > > #define CONFIG_SPL_STACK 0x187FF0 > > diff --git a/include/configs/kontron_sl28.h b/include/configs/kontron_sl28.h > > index 448749a7f8..97d0d365f6 100644 > > --- a/include/configs/kontron_sl28.h > > +++ b/include/configs/kontron_sl28.h > > @@ -57,6 +57,12 @@ > > #define CONFIG_SYS_SPL_MALLOC_START 0x80200000 > > #define CONFIG_SYS_MONITOR_LEN (1024 * 1024) > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define KONTRON_SL28_FIT_IMAGE_GUID \ > > + EFI_GUID(0x86ebd44f, 0xfeb8, 0x466f, 0x8b, 0xb8, \ > > + 0x89, 0x06, 0x18, 0x45, 0x6d, 0x8b) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > /* environment */ > > /* see include/configs/ti_armv7_common.h */ > > #define ENV_MEM_LAYOUT_SETTINGS \ > > diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h > > index d45f606860..2f2abc746d 100644 > > --- a/include/configs/qemu-arm.h > > +++ b/include/configs/qemu-arm.h > > @@ -17,6 +17,16 @@ > > > > #define CONFIG_SYS_BOOTM_LEN SZ_64M > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define QEMU_ARM_UBOOT_IMAGE_GUID \ > > + EFI_GUID(0xf885b085, 0x99f8, 0x45af, 0x84, 0x7d, \ > > + 0xd5, 0x14, 0x10, 0x7a, 0x4a, 0x2c) > > + > > +#define QEMU_ARM64_UBOOT_IMAGE_GUID \ > > + EFI_GUID(0x058b7d83, 0x50d5, 0x4c47, 0xa1, 0x95, \ > > + 0x60, 0xd8, 0x6a, 0xd3, 0x41, 0xc4) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > /* For timer, QEMU emulates an ARMv7/ARMv8 architected timer */ > > > > /* Environment options */ > > diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h > > index 75efbf3448..d06c3de2e0 100644 > > --- a/include/configs/sandbox.h > > +++ b/include/configs/sandbox.h > > @@ -14,6 +14,16 @@ > > > > #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define SANDBOX_UBOOT_IMAGE_GUID \ > > + EFI_GUID(0x09d7cf52, 0x0720, 0x4710, 0x91, 0xd1, \ > > + 0x08, 0x46, 0x9b, 0x7f, 0xe9, 0xc8) > > + > > +#define SANDBOX_UBOOT_ENV_IMAGE_GUID \ > > + EFI_GUID(0x5a7021f5, 0xfef2, 0x48b4, 0xaa, 0xba, \ > > + 0x83, 0x2e, 0x77, 0x74, 0x18, 0xc0) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > /* Size of our emulated memory */ > > #define SB_CONCAT(x, y) x ## y > > #define SB_TO_UL(s) SB_CONCAT(s, UL) > > diff --git a/include/configs/synquacer.h b/include/configs/synquacer.h > > index 8dd092fc59..07e1f56e3d 100644 > > --- a/include/configs/synquacer.h > > +++ b/include/configs/synquacer.h > > @@ -51,6 +51,20 @@ > > "fip.bin raw 180000 78000;" \ > > "optee.bin raw 500000 100000\0" > > > > +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) > > +#define DEVELOPERBOX_UBOOT_IMAGE_GUID \ > > + EFI_GUID(0x53a92e83, 0x4ef4, 0x473a, 0x8b, 0x0d, \ > > + 0xb5, 0xd8, 0xc7, 0xb2, 0xd6, 0x00) > > + > > +#define DEVELOPERBOX_FIP_IMAGE_GUID \ > > + EFI_GUID(0x880866e9, 0x84ba, 0x4793, 0xa9, 0x08, \ > > + 0x33, 0xe0, 0xb9, 0x16, 0xf3, 0x98) > > + > > +#define DEVELOPERBOX_OPTEE_IMAGE_GUID \ > > + EFI_GUID(0xc1b629f1, 0xce0e, 0x4894, 0x82, 0xbf, \ > > + 0xf0, 0xa3, 0x83, 0x87, 0xe6, 0x30) > > +#endif /* EFI_HAVE_CAPSULE_SUPPORT */ > > + > > /* Distro boot settings */ > > #ifndef CONFIG_SPL_BUILD > > #ifdef CONFIG_CMD_USB > > diff --git a/include/efi_loader.h b/include/efi_loader.h > > index af36639ec6..1965b5a28f 100644 > > --- a/include/efi_loader.h > > +++ b/include/efi_loader.h > > @@ -979,6 +979,21 @@ efi_status_t efi_capsule_authenticate(const void *capsule, > > > > #define EFI_CAPSULE_DIR u"\EFI\UpdateCapsule\" > > > > +/** > > + * struct efi_fw_images - List of firmware images updatable through capsule > > + * update > > + * > > + * This structure gives information about the firmware images on the platform > > + * which can be updated through the capsule update mechanism > > + * > > + * @image_type_id: Image GUID. Same value is to be used in the capsule > > + * @fw_name: Name of the firmware image > > + */ > > +struct efi_fw_images { > > + efi_guid_t image_type_id; > > + const u16 *fw_name; > > +}; > > + > > /** > > * Install the ESRT system table. > > * > > -- > > 2.25.1 > > > > > -- > Masami Hiramatsu
-- Masami Hiramatsu
-- Masami Hiramatsu
-- Masami Hiramatsu

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 sughosh.ganu@linaro.org --- 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 1965b5a28f..e8f7234230 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -994,6 +994,9 @@ struct efi_fw_images { const u16 *fw_name; };
+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..13cb492092 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]; + *descriptor_count = image_count = num_image_type_guids; 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 = i + 1; + image_info[i].image_type_id = fw_array[i].image_type_id; + image_info[i].image_id = i + 1; + + image_info[i].image_id_name = (u16 *)fw_array[i].fw_name;
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); }

The current UEFI capsule updation code uses two GUID values, one for FIT images, and one for raw images across platforms. This logic is being changed to have GUID values per image, per platform. Change the tests for the capsule update code to reflect this change. The GUID values now used are the ones specific to the sandbox platform -- one for the u-boot image, and another for the u-boot environment image.
The UEFI specification does not allow installation of multiple Firmware Management Protocols(FMP) at the same time. Install only the FMP instance for raw images for testing the capsule update code.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - test/py/tests/test_efi_capsule/conftest.py | 20 +-- .../test_efi_capsule/test_capsule_firmware.py | 167 ++++++------------ 4 files changed, 65 insertions(+), 124 deletions(-)
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 7c157a23d0..1111f93040 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -246,7 +246,6 @@ CONFIG_LZ4=y CONFIG_ERRNO_STR=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y -CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 7ebeb89264..0a601361b6 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -318,7 +318,6 @@ CONFIG_LZ4=y CONFIG_ERRNO_STR=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y -CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y CONFIG_EFI_SECURE_BOOT=y CONFIG_TEST_FDTDEC=y diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 9076087a12..5d9f680d14 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -72,21 +72,15 @@ def efi_capsule_data(request, u_boot_config):
# Create capsule files # two regions: one for u-boot.bin and the other for u-boot.env - check_call('cd %s; echo -n u-boot:Old > u-boot.bin.old; echo -n u-boot:New > u-boot.bin.new; echo -n u-boot-env:Old -> u-boot.env.old; echo -n u-boot-env:New > u-boot.env.new' % data_dir, + check_call('cd %s; echo -n u-boot:Old > u-boot.bin.old; echo -n u-boot:New > u-boot.bin.new; echo -n u-boot-env:Old > u-boot.env.old; echo -n u-boot-env:New > u-boot.env.new' % data_dir, shell=True) - check_call('sed -e "s?BINFILE1?u-boot.bin.new?" -e "s?BINFILE2?u-boot.env.new?" %s/test/py/tests/test_efi_capsule/uboot_bin_env.its > %s/uboot_bin_env.its' % - (u_boot_config.source_dir, data_dir), - shell=True) - check_call('cd %s; %s/tools/mkimage -f uboot_bin_env.its uboot_bin_env.itb' % - (data_dir, u_boot_config.build_dir), - shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --fit uboot_bin_env.itb Test01' % + check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 u-boot.bin.new Test01' % (data_dir, u_boot_config.build_dir), shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --raw u-boot.bin.new Test02' % + check_call('cd %s; %s/tools/mkeficapsule --index 2 --guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 u-boot.env.new Test02' % (data_dir, u_boot_config.build_dir), shell=True) - check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid E2BB9C06-70E9-4B14-97A3-5A7913176E3F u-boot.bin.new Test03' % + check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid 058B7D83-50D5-4C47-A195-60D86AD341C4 u-boot.bin.new Test03' % (data_dir, u_boot_config.build_dir), shell=True) if capsule_auth_enabled: @@ -94,7 +88,8 @@ def efi_capsule_data(request, u_boot_config): check_call('cd %s; ' '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' '--private-key SIGNER.key --certificate SIGNER.crt ' - '--raw u-boot.bin.new Test11' + '--guid 09D7DF52-0720-4710-91D1-08469B7FE9C8 ' + 'u-boot.bin.new Test11' % (data_dir, u_boot_config.build_dir), shell=True) # firmware signed with *mal* key @@ -102,7 +97,8 @@ def efi_capsule_data(request, u_boot_config): '%s/tools/mkeficapsule --index 1 --monotonic-count 1 ' '--private-key SIGNER2.key ' '--certificate SIGNER2.crt ' - '--raw u-boot.bin.new Test12' + '--guid 09D7DF52-0720-4710-91D1-08469B7FE9C8 ' + 'u-boot.bin.new Test12' % (data_dir, u_boot_config.build_dir), shell=True)
diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py b/test/py/tests/test_efi_capsule/test_capsule_firmware.py index 1dcf1c70f4..daf0669c01 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -14,7 +14,6 @@ from capsule_defs import *
@pytest.mark.boardspec('sandbox') -@pytest.mark.buildconfigspec('efi_capsule_firmware_fit') @pytest.mark.buildconfigspec('efi_capsule_firmware_raw') @pytest.mark.buildconfigspec('efi_capsule_on_disk') @pytest.mark.buildconfigspec('dfu') @@ -25,12 +24,12 @@ from capsule_defs import * @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow -class TestEfiCapsuleFirmwareFit(object): +class TestEfiCapsuleFirmwareRaw(object): def test_efi_capsule_fw1( self, u_boot_config, u_boot_console, efi_capsule_data): """ Test Case 1 - Update U-Boot and U-Boot environment on SPI Flash - but with OsIndications unset + but with an incorrect GUID value in the capsule No update should happen 0x100000-0x150000: U-Boot binary (but dummy) 0x150000-0x200000: U-Boot environment (but dummy) @@ -41,7 +40,7 @@ class TestEfiCapsuleFirmwareFit(object): 'host bind 0 %s' % disk_img, 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""', 'efidebug boot order 1', - 'env set -e OsIndications', + 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'env save'])
@@ -63,16 +62,19 @@ class TestEfiCapsuleFirmwareFit(object):
# place a capsule file output = u_boot_console.run_command_list([ - 'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR, - 'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR, + 'fatload host 0:1 4000000 %s/Test03' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test03 $filesize' % CAPSULE_INSTALL_DIR, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test01' in ''.join(output) - - # reboot - u_boot_console.restart_uboot() + assert 'Test03' in ''.join(output)
capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') + capsule_auth = u_boot_config.buildconfig.get( + 'config_efi_capsule_authenticate') + + # reboot + u_boot_console.restart_uboot(expect_reset = capsule_early) + with u_boot_console.log.section('Test Case 1-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -81,16 +83,11 @@ class TestEfiCapsuleFirmwareFit(object): 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'host bind 0 %s' % disk_img, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test01' in ''.join(output) + assert 'Test03' in ''.join(output)
# need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000') - - output = u_boot_console.run_command_list([ - 'host bind 0 %s' % disk_img, - 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test01' in ''.join(output) + 'env print -e Capsule0000', wait_for_reboot = True)
output = u_boot_console.run_command_list([ 'sf probe 0:0', @@ -107,6 +104,8 @@ class TestEfiCapsuleFirmwareFit(object): self, u_boot_config, u_boot_console, efi_capsule_data): """ Test Case 2 - Update U-Boot and U-Boot environment on SPI Flash + but with OsIndications unset + No update should happen 0x100000-0x150000: U-Boot binary (but dummy) 0x150000-0x200000: U-Boot environment (but dummy) """ @@ -116,7 +115,7 @@ class TestEfiCapsuleFirmwareFit(object): 'host bind 0 %s' % disk_img, 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""', 'efidebug boot order 1', - 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', + 'env set -e OsIndications', 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'env save'])
@@ -136,21 +135,24 @@ class TestEfiCapsuleFirmwareFit(object): 'md.b 5000000 10']) assert 'Old' in ''.join(output)
- # place a capsule file + # place the capsule files output = u_boot_console.run_command_list([ 'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR, 'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test01' in ''.join(output)
- capsule_early = u_boot_config.buildconfig.get( - 'config_efi_capsule_on_disk_early') - capsule_auth = u_boot_config.buildconfig.get( - 'config_efi_capsule_authenticate') + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test02' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test02 $filesize' % CAPSULE_INSTALL_DIR, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test02' in ''.join(output)
# reboot - u_boot_console.restart_uboot(expect_reset = capsule_early) + u_boot_console.restart_uboot()
+ capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') with u_boot_console.log.section('Test Case 2-b, after reboot'): if not capsule_early: # make sure that dfu_alt_info exists even persistent variables @@ -160,32 +162,28 @@ class TestEfiCapsuleFirmwareFit(object): 'host bind 0 %s' % disk_img, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) assert 'Test01' in ''.join(output) + assert 'Test02' in ''.join(output)
# need to run uefi command to initiate capsule handling output = u_boot_console.run_command( - 'env print -e Capsule0000', wait_for_reboot = True) + 'env print -e Capsule0000')
output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test01' not in ''.join(output) + assert 'Test01' in ''.join(output) + assert 'Test02' in ''.join(output)
output = u_boot_console.run_command_list([ 'sf probe 0:0', 'sf read 4000000 100000 10', 'md.b 4000000 10']) - if capsule_auth: - assert 'u-boot:Old' in ''.join(output) - else: - assert 'u-boot:New' in ''.join(output) + assert 'u-boot:Old' in ''.join(output)
output = u_boot_console.run_command_list([ 'sf read 4000000 150000 10', 'md.b 4000000 10']) - if capsule_auth: - assert 'u-boot-env:Old' in ''.join(output) - else: - assert 'u-boot-env:New' in ''.join(output) + assert 'u-boot-env:Old' in ''.join(output)
def test_efi_capsule_fw3( self, u_boot_config, u_boot_console, efi_capsule_data): @@ -203,7 +201,7 @@ class TestEfiCapsuleFirmwareFit(object): 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'env save'])
- # initialize content + # initialize contents output = u_boot_console.run_command_list([ 'sf probe 0:0', 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, @@ -212,7 +210,21 @@ class TestEfiCapsuleFirmwareFit(object): 'md.b 5000000 10']) assert 'Old' in ''.join(output)
- # place a capsule file + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.env.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 150000 10', + 'sf read 5000000 100000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + + # place the capsule files + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test01' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test01 $filesize' % CAPSULE_INSTALL_DIR, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) + output = u_boot_console.run_command_list([ 'fatload host 0:1 4000000 %s/Test02' % CAPSULE_DATA_DIR, 'fatwrite host 0:1 4000000 %s/Test02 $filesize' % CAPSULE_INSTALL_DIR, @@ -235,6 +247,7 @@ class TestEfiCapsuleFirmwareFit(object): 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'host bind 0 %s' % disk_img, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' in ''.join(output) assert 'Test02' in ''.join(output)
# need to run uefi command to initiate capsule handling @@ -246,15 +259,16 @@ class TestEfiCapsuleFirmwareFit(object): 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', 'efidebug capsule esrt'])
- # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID is in the ESRT. - assert 'AE13FF2D-9AD4-4E25-9AC8-6D80B3B22147' in ''.join(output) + # ensure that SANDBOX_UBOOT_ENV_IMAGE_GUID is in the ESRT. + assert '5A7021F5-FEF2-48B4-AABA-832E777418C0' in ''.join(output)
- # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID is in the ESRT. - assert 'E2BB9C06-70E9-4B14-97A3-5A7913176E3F' in ''.join(output) + # ensure that SANDBOX_UBOOT_IMAGE_GUID is in the ESRT. + assert '09D7CF52-0720-4710-91D1-08469B7FE9C8' in ''.join(output)
output = u_boot_console.run_command_list([ 'host bind 0 %s' % disk_img, 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test01' not in ''.join(output) assert 'Test02' not in ''.join(output)
output = u_boot_console.run_command_list([ @@ -266,78 +280,11 @@ class TestEfiCapsuleFirmwareFit(object): else: assert 'u-boot:New' in ''.join(output)
- def test_efi_capsule_fw4( - self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 4 - Test "--guid" option of mkeficapsule - The test scenario is the same as Case 3. - """ - disk_img = efi_capsule_data - with u_boot_console.log.section('Test Case 4-a, before reboot'): - output = u_boot_console.run_command_list([ - 'host bind 0 %s' % disk_img, - 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""', - 'efidebug boot order 1', - 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', - 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', - 'env save']) - - # initialize content output = u_boot_console.run_command_list([ 'sf probe 0:0', - 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, - 'sf write 4000000 100000 10', - 'sf read 5000000 100000 10', - 'md.b 5000000 10']) - assert 'Old' in ''.join(output) - - # place a capsule file - output = u_boot_console.run_command_list([ - 'fatload host 0:1 4000000 %s/Test03' % CAPSULE_DATA_DIR, - 'fatwrite host 0:1 4000000 %s/Test03 $filesize' % CAPSULE_INSTALL_DIR, - 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test03' in ''.join(output) - - capsule_early = u_boot_config.buildconfig.get( - 'config_efi_capsule_on_disk_early') - capsule_auth = u_boot_config.buildconfig.get( - 'config_efi_capsule_authenticate') - - # reboot - u_boot_console.restart_uboot(expect_reset = capsule_early) - - with u_boot_console.log.section('Test Case 4-b, after reboot'): - if not capsule_early: - # make sure that dfu_alt_info exists even persistent variables - # are not available. - output = u_boot_console.run_command_list([ - 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', - 'host bind 0 %s' % disk_img, - 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test03' in ''.join(output) - - # need to run uefi command to initiate capsule handling - output = u_boot_console.run_command( - 'env print -e Capsule0000', wait_for_reboot = True) - - # make sure the dfu_alt_info exists because it is required for making ESRT. - output = u_boot_console.run_command_list([ - 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', - 'efidebug capsule esrt']) - - # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID is in the ESRT. - assert 'E2BB9C06-70E9-4B14-97A3-5A7913176E3F' in ''.join(output) - - output = u_boot_console.run_command_list([ - 'host bind 0 %s' % disk_img, - 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) - assert 'Test03' not in ''.join(output) - - output = u_boot_console.run_command_list([ - 'sf probe 0:0', - 'sf read 4000000 100000 10', + 'sf read 4000000 150000 10', 'md.b 4000000 10']) if capsule_auth: - assert 'u-boot:Old' in ''.join(output) + assert 'u-boot-env:Old' in ''.join(output) else: - assert 'u-boot:New' in ''.join(output) + assert 'u-boot-env:New' in ''.join(output)

Update the capsule update functionality related documentation to refect the fact that a unique image GUID is to be used per image that forms part of the capsule file.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- doc/develop/uefi/uefi.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index fe337c88bd..0d2825ce88 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -312,8 +312,8 @@ Run the following command .. code-block:: console
$ mkeficapsule \ - --index 1 --instance 0 \ - [--fit <FIT image> | --raw <raw image>] \ + --index <index> --instance 0 \ + --guid <image GUID> \ <capsule_file_name>
Performing the update @@ -333,6 +333,12 @@ won't be taken over across the reboot. If this is the case, you can skip this feature check with the Kconfig option (CONFIG_EFI_IGNORE_OSINDICATIONS) set.
+Define GUID values of the images that are to be updated through the +capsule update feature in the platform file. The GUID values are to be +defined as part of the fw_images array. These GUID values would be +used by the Firmware Management Protocol(FMP) to populate the image +descriptor array and also displayed as part of the ESRT table. + Finally, the capsule update can be initiated by rebooting the board.
Enabling Capsule Authentication

The capsule update code has been modified for getting the image GUID values from the platform code. With this, each image now has a unique GUID value. With this change, there is no longer a need for defining GUIDs for FIT and raw images. Remove these GUID values.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- include/efi_api.h | 8 -------- lib/efi_loader/efi_firmware.c | 4 ---- 2 files changed, 12 deletions(-)
diff --git a/include/efi_api.h b/include/efi_api.h index 982c200172..c7f7873b5d 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1967,14 +1967,6 @@ struct efi_signature_list { EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \ 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \ - EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \ - 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47) - -#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \ - EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \ - 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f) - #define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 13cb492092..9fbedaf023 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -185,8 +185,6 @@ static efi_status_t efi_fill_image_desc_array( * - versioning of firmware image * - package information */ -const efi_guid_t efi_firmware_image_type_uboot_fit = - EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
/** * efi_firmware_fit_get_image_info - return information about the current @@ -293,8 +291,6 @@ const struct efi_firmware_management_protocol efi_fmp_fit = { * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update * method with raw data. */ -const efi_guid_t efi_firmware_image_type_uboot_raw = - EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
/** * efi_firmware_raw_get_image_info - return information about the current

On Thu, 24 Mar 2022 at 14:39, Sughosh Ganu sughosh.ganu@linaro.org wrote:
The capsule update code has been modified for getting the image GUID values from the platform code. With this, each image now has a unique GUID value. With this change, there is no longer a need for defining GUIDs for FIT and raw images. Remove these GUID values.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
include/efi_api.h | 8 -------- lib/efi_loader/efi_firmware.c | 4 ---- 2 files changed, 12 deletions(-)
diff --git a/include/efi_api.h b/include/efi_api.h index 982c200172..c7f7873b5d 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1967,14 +1967,6 @@ struct efi_signature_list { EFI_GUID(0x86c77a67, 0x0b97, 0x4633, 0xa1, 0x87, \ 0x49, 0x10, 0x4d, 0x06, 0x85, 0xc7)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE 0x0000000000000001 #define IMAGE_ATTRIBUTE_RESET_REQUIRED 0x0000000000000002 #define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED 0x0000000000000004 diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 13cb492092..9fbedaf023 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -185,8 +185,6 @@ static efi_status_t efi_fill_image_desc_array(
- versioning of firmware image
- package information
*/ -const efi_guid_t efi_firmware_image_type_uboot_fit =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
/**
- efi_firmware_fit_get_image_info - return information about the current
@@ -293,8 +291,6 @@ const struct efi_firmware_management_protocol efi_fmp_fit = {
- This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update
- method with raw data.
*/ -const efi_guid_t efi_firmware_image_type_uboot_raw =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
/**
- efi_firmware_raw_get_image_info - return information about the current
-- 2.25.1
Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org

While building a capsule, the GUID value of that specific image is to be passed through the --guid command option to the mkeficapsule tool. This renders the EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID and EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID values superfluous. Remove the --raw and --fit command line options as well.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- tools/eficapsule.h | 8 -------- tools/mkeficapsule.c | 26 +------------------------- 2 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 69c9c58c2f..d63b831443 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -37,14 +37,6 @@ typedef struct { EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \ - EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \ - 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47) - -#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \ - EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \ - 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f) - #define EFI_CERT_TYPE_PKCS7_GUID \ EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7) diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c118335b93..5f74d23b9e 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -27,17 +27,11 @@ static const char *tool_name = "mkeficapsule";
efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -efi_guid_t efi_guid_image_type_uboot_fit = - EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID; -efi_guid_t efi_guid_image_type_uboot_raw = - EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID; efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
-static const char *opts_short = "frg:i:I:v:p:c:m:dh"; +static const char *opts_short = "g:i:I:v:p:c:m:dh";
static struct option options[] = { - {"fit", no_argument, NULL, 'f'}, - {"raw", no_argument, NULL, 'r'}, {"guid", required_argument, NULL, 'g'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'}, @@ -54,8 +48,6 @@ static void print_usage(void) fprintf(stderr, "Usage: %s [options] <image blob> <output file>\n" "Options:\n"
- "\t-f, --fit FIT image type\n" - "\t-r, --raw raw image type\n" "\t-g, --guid <guid string> guid for image blob type\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n" @@ -606,22 +598,6 @@ int main(int argc, char **argv) break;
switch (c) { - case 'f': - if (guid) { - fprintf(stderr, - "Image type already specified\n"); - exit(EXIT_FAILURE); - } - guid = &efi_guid_image_type_uboot_fit; - break; - case 'r': - if (guid) { - fprintf(stderr, - "Image type already specified\n"); - exit(EXIT_FAILURE); - } - guid = &efi_guid_image_type_uboot_raw; - break; case 'g': if (guid) { fprintf(stderr,

On 3/24/22 13:39, Sughosh Ganu wrote:
While building a capsule, the GUID value of that specific image is to be passed through the --guid command option to the mkeficapsule tool. This renders the EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID and EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID values superfluous. Remove the --raw and --fit command line options as well.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
tools/eficapsule.h | 8 -------- tools/mkeficapsule.c | 26 +------------------------- 2 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 69c9c58c2f..d63b831443 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -37,14 +37,6 @@ typedef struct { EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
- EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
- EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
- #define EFI_CERT_TYPE_PKCS7_GUID \ EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c118335b93..5f74d23b9e 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -27,17 +27,11 @@ static const char *tool_name = "mkeficapsule";
efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -efi_guid_t efi_guid_image_type_uboot_fit =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
-efi_guid_t efi_guid_image_type_uboot_raw =
efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
-static const char *opts_short = "frg:i:I:v:p:c:m:dh"; +static const char *opts_short = "g:i:I:v:p:c:m:dh";
static struct option options[] = {
- {"fit", no_argument, NULL, 'f'},
- {"raw", no_argument, NULL, 'r'}, {"guid", required_argument, NULL, 'g'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'},
@@ -54,8 +48,6 @@ static void print_usage(void) fprintf(stderr, "Usage: %s [options] <image blob> <output file>\n" "Options:\n"
"\t-f, --fit FIT image type\n"
"\t-g, --guid <guid string> guid for image blob type\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n""\t-r, --raw raw image type\n"
@@ -606,22 +598,6 @@ int main(int argc, char **argv) break;
switch (c) {
case 'f':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_fit;
break;
case 'r':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_raw;
case 'g': if (guid) { fprintf(stderr,break;
Can you please find a way how to export guid based on what you build? I think the best would be when capsules are enable to generated them directly as the part of build process with proper guids.
Thanks, Michal

On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:39, Sughosh Ganu wrote:
While building a capsule, the GUID value of that specific image is to be passed through the --guid command option to the mkeficapsule tool. This renders the EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID and EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID values superfluous. Remove the --raw and --fit command line options as well.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
tools/eficapsule.h | 8 -------- tools/mkeficapsule.c | 26 +------------------------- 2 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 69c9c58c2f..d63b831443 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -37,14 +37,6 @@ typedef struct { EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
- #define EFI_CERT_TYPE_PKCS7_GUID \ EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c118335b93..5f74d23b9e 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -27,17 +27,11 @@ static const char *tool_name = "mkeficapsule";
efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -efi_guid_t efi_guid_image_type_uboot_fit =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
-efi_guid_t efi_guid_image_type_uboot_raw =
efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
-static const char *opts_short = "frg:i:I:v:p:c:m:dh"; +static const char *opts_short = "g:i:I:v:p:c:m:dh";
static struct option options[] = {
{"fit", no_argument, NULL, 'f'},
{"raw", no_argument, NULL, 'r'}, {"guid", required_argument, NULL, 'g'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'},
@@ -54,8 +48,6 @@ static void print_usage(void) fprintf(stderr, "Usage: %s [options] <image blob> <output file>\n" "Options:\n"
"\t-f, --fit FIT image type\n"
"\t-r, --raw raw image type\n" "\t-g, --guid <guid string> guid for image blob type\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n"
@@ -606,22 +598,6 @@ int main(int argc, char **argv) break;
switch (c) {
case 'f':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_fit;
break;
case 'r':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_raw;
break; case 'g': if (guid) { fprintf(stderr,
Can you please find a way how to export guid based on what you build? I think the best would be when capsules are enable to generated them directly as the part of build process with proper guids.
I don't know how that can be done in a generic way. A platform might have more than one updatable image. So for doing what you are suggesting, we will need to a) pass the board for which the capsule is generated, and b) for which image in that board is the capsule generated. Currently, the mkeficapsule command parameters are on pretty much similar lines to what we have in the EDK2 GenerateCapsule tool. Can you not have a script for the xilinx boards which does what you are suggesting. That script can populate the GUID and image index values and then call the mkeficapsule tool.
-sughosh

On 3/24/22 15:51, Sughosh Ganu wrote:
On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:39, Sughosh Ganu wrote:
While building a capsule, the GUID value of that specific image is to be passed through the --guid command option to the mkeficapsule tool. This renders the EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID and EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID values superfluous. Remove the --raw and --fit command line options as well.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
tools/eficapsule.h | 8 -------- tools/mkeficapsule.c | 26 +------------------------- 2 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 69c9c58c2f..d63b831443 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -37,14 +37,6 @@ typedef struct { EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
- #define EFI_CERT_TYPE_PKCS7_GUID \ EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c118335b93..5f74d23b9e 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -27,17 +27,11 @@ static const char *tool_name = "mkeficapsule";
efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -efi_guid_t efi_guid_image_type_uboot_fit =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
-efi_guid_t efi_guid_image_type_uboot_raw =
efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
-static const char *opts_short = "frg:i:I:v:p:c:m:dh"; +static const char *opts_short = "g:i:I:v:p:c:m:dh";
static struct option options[] = {
{"fit", no_argument, NULL, 'f'},
{"raw", no_argument, NULL, 'r'}, {"guid", required_argument, NULL, 'g'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'},
@@ -54,8 +48,6 @@ static void print_usage(void) fprintf(stderr, "Usage: %s [options] <image blob> <output file>\n" "Options:\n"
"\t-f, --fit FIT image type\n"
"\t-r, --raw raw image type\n" "\t-g, --guid <guid string> guid for image blob type\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n"
@@ -606,22 +598,6 @@ int main(int argc, char **argv) break;
switch (c) {
case 'f':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_fit;
break;
case 'r':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_raw;
break; case 'g': if (guid) { fprintf(stderr,
Can you please find a way how to export guid based on what you build? I think the best would be when capsules are enable to generated them directly as the part of build process with proper guids.
I don't know how that can be done in a generic way. A platform might have more than one updatable image. So for doing what you are suggesting, we will need to a) pass the board for which the capsule is generated, and b) for which image in that board is the capsule generated. Currently, the mkeficapsule command parameters are on pretty much similar lines to what we have in the EDK2 GenerateCapsule tool. Can you not have a script for the xilinx boards which does what you are suggesting. That script can populate the GUID and image index values and then call the mkeficapsule tool.
Custom script in board can of course do it but pretty much all information is just added by your support for all boards. guid should also dictates image index.
That's why if this is done in a generic way the same script can be used by all platforms. It means exported file with guid, file name. If that file exists mkeficapsule can read it and just create capsules based on it.
It is not a must but I think it is good time to think about how this can be done because there are likely a lot of similarities across boards. And we shouldn't end up in situation where every board has own (pretty much similar) script which generates capsules.
Thanks, Michal

On Thu, 24 Mar 2022 at 20:40, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 15:51, Sughosh Ganu wrote:
On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:39, Sughosh Ganu wrote:
While building a capsule, the GUID value of that specific image is to be passed through the --guid command option to the mkeficapsule tool. This renders the EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID and EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID values superfluous. Remove the --raw and --fit command line options as well.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
tools/eficapsule.h | 8 -------- tools/mkeficapsule.c | 26 +------------------------- 2 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 69c9c58c2f..d63b831443 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -37,14 +37,6 @@ typedef struct { EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
- #define EFI_CERT_TYPE_PKCS7_GUID \ EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c118335b93..5f74d23b9e 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -27,17 +27,11 @@ static const char *tool_name = "mkeficapsule";
efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -efi_guid_t efi_guid_image_type_uboot_fit =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
-efi_guid_t efi_guid_image_type_uboot_raw =
efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
-static const char *opts_short = "frg:i:I:v:p:c:m:dh"; +static const char *opts_short = "g:i:I:v:p:c:m:dh";
static struct option options[] = {
{"fit", no_argument, NULL, 'f'},
{"raw", no_argument, NULL, 'r'}, {"guid", required_argument, NULL, 'g'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'},
@@ -54,8 +48,6 @@ static void print_usage(void) fprintf(stderr, "Usage: %s [options] <image blob> <output file>\n" "Options:\n"
"\t-f, --fit FIT image type\n"
"\t-r, --raw raw image type\n" "\t-g, --guid <guid string> guid for image blob type\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n"
@@ -606,22 +598,6 @@ int main(int argc, char **argv) break;
switch (c) {
case 'f':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_fit;
break;
case 'r':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_raw;
break; case 'g': if (guid) { fprintf(stderr,
Can you please find a way how to export guid based on what you build? I think the best would be when capsules are enable to generated them directly as the part of build process with proper guids.
I don't know how that can be done in a generic way. A platform might have more than one updatable image. So for doing what you are suggesting, we will need to a) pass the board for which the capsule is generated, and b) for which image in that board is the capsule generated. Currently, the mkeficapsule command parameters are on pretty much similar lines to what we have in the EDK2 GenerateCapsule tool. Can you not have a script for the xilinx boards which does what you are suggesting. That script can populate the GUID and image index values and then call the mkeficapsule tool.
Custom script in board can of course do it but pretty much all information is just added by your support for all boards. guid should also dictates image index.
That's why if this is done in a generic way the same script can be used by all platforms. It means exported file with guid, file name. If that file exists mkeficapsule can read it and just create capsules based on it.
It is not a must but I think it is good time to think about how this can be done because there are likely a lot of similarities across boards. And we shouldn't end up in situation where every board has own (pretty much similar) script which generates capsules.
Yes, it can indeed be made generic across platforms. Only have it separate from the mkeficapsule tool.
-sughosh
Thanks, Michal

Hi,
On Thu, 24 Mar 2022 at 17:34, Sughosh Ganu sughosh.ganu@linaro.org wrote:
On Thu, 24 Mar 2022 at 20:40, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 15:51, Sughosh Ganu wrote:
On Thu, 24 Mar 2022 at 19:55, Michal Simek michal.simek@xilinx.com wrote:
On 3/24/22 13:39, Sughosh Ganu wrote:
While building a capsule, the GUID value of that specific image is to be passed through the --guid command option to the mkeficapsule tool. This renders the EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID and EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID values superfluous. Remove the --raw and --fit command line options as well.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
tools/eficapsule.h | 8 -------- tools/mkeficapsule.c | 26 +------------------------- 2 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/tools/eficapsule.h b/tools/eficapsule.h index 69c9c58c2f..d63b831443 100644 --- a/tools/eficapsule.h +++ b/tools/eficapsule.h @@ -37,14 +37,6 @@ typedef struct { EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
-#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
- #define EFI_CERT_TYPE_PKCS7_GUID \ EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index c118335b93..5f74d23b9e 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -27,17 +27,11 @@ static const char *tool_name = "mkeficapsule";
efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -efi_guid_t efi_guid_image_type_uboot_fit =
EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID;
-efi_guid_t efi_guid_image_type_uboot_raw =
efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID;
-static const char *opts_short = "frg:i:I:v:p:c:m:dh"; +static const char *opts_short = "g:i:I:v:p:c:m:dh";
static struct option options[] = {
{"fit", no_argument, NULL, 'f'},
{"raw", no_argument, NULL, 'r'}, {"guid", required_argument, NULL, 'g'}, {"index", required_argument, NULL, 'i'}, {"instance", required_argument, NULL, 'I'},
@@ -54,8 +48,6 @@ static void print_usage(void) fprintf(stderr, "Usage: %s [options] <image blob> <output file>\n" "Options:\n"
"\t-f, --fit FIT image type\n"
"\t-r, --raw raw image type\n" "\t-g, --guid <guid string> guid for image blob type\n" "\t-i, --index <index> update image index\n" "\t-I, --instance <instance> update hardware instance\n"
@@ -606,22 +598,6 @@ int main(int argc, char **argv) break;
switch (c) {
case 'f':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_fit;
break;
case 'r':
if (guid) {
fprintf(stderr,
"Image type already specified\n");
exit(EXIT_FAILURE);
}
guid = &efi_guid_image_type_uboot_raw;
break; case 'g': if (guid) { fprintf(stderr,
Can you please find a way how to export guid based on what you build? I think the best would be when capsules are enable to generated them directly as the part of build process with proper guids.
I don't know how that can be done in a generic way. A platform might have more than one updatable image. So for doing what you are suggesting, we will need to a) pass the board for which the capsule is generated, and b) for which image in that board is the capsule generated. Currently, the mkeficapsule command parameters are on pretty much similar lines to what we have in the EDK2 GenerateCapsule tool. Can you not have a script for the xilinx boards which does what you are suggesting. That script can populate the GUID and image index values and then call the mkeficapsule tool.
Custom script in board can of course do it but pretty much all information is just added by your support for all boards. guid should also dictates image index.
That's why if this is done in a generic way the same script can be used by all platforms. It means exported file with guid, file name. If that file exists mkeficapsule can read it and just create capsules based on it.
It is not a must but I think it is good time to think about how this can be done because there are likely a lot of similarities across boards. And we shouldn't end up in situation where every board has own (pretty much similar) script which generates capsules.
Yes, it can indeed be made generic across platforms. Only have it separate from the mkeficapsule tool.
As long as boards define GUIDs in their internal header files, I can't think of a sane way doing that. And we certainly cant start greping random header files to derive the UUIDs and the number of firmware images we need to update. What could be done is maybe define the UUIDs in Kconfig (comma separated?) and then autogenerate a header file with the 'struct efi_fw_images fw_images' we need per board. In that case we could get all the info in a single header file, which arguably we can try to grep and create a capsule. But I don't really have a strong opinion if that's worth the pain or not. We can always add instructions for capsule generation on per board READMEs
Cheers /Ilias
-sughosh
Thanks, Michal

Sughosh,
On Thu, Mar 24, 2022 at 06:08:55PM +0530, Sughosh Ganu wrote:
This series is cleaning up the usage of the image GUIDs that are used in capsule update and the EFI System Resource Table(ESRT).
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.
Ok although the specification doesn't explicitly require the uniqueness "across platforms".
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.
Well, this is *not* a problem of fit FMP driver, but a matter of how ESRT is populated. Table 23-16 "ESRT and FMP Fields" says, The ImageTypeId GUID from the Firmware Management Protocol instance for a device is used as the Firmware Class GUID in the ESRT. Where there are multiple identical devices in the system, system firmware must create a mapping to ensure that the ESRT FwClass GUIDs are unique and consistent. The second sentence suggests that UEFI implementation, i.e. efi_esrt_populate(), may and should allow some *mapping*.
That said, I basically accept the requirement that you mention above.
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.
When ESRT support patch was posted, I proposed that we should have a kind of configuration table that defines all the firmware on the system for ESRT, but this proposal was rejected. Your efi_fw_images[] looks quite similar as what I had in mind. Why not define efi_fw_images[] as ESRT itself. (Of course, some fields in an entry can still be populated through GetImageInfo API.)
The first patch of this series adds the fw_images array in all platforms which are using UEFI capsule updates
The second patch of the series changes the logic for populating the image descriptor array, using the information from the fw_images array defined by the platform.
So a FIT image can still work as a single binary of firmware under FIT FMP driver. Correct?
The third patch of the series removes the test cases using the --raw and --fit parameters, removes test case for FIT images, and adds a test case for checking that the update happens only with the correct image GUID value in the capsule.
Your change in test_capsule_firmware.py tries to remove FIT FMP driver test and it eventually hides the fact that FIT driver may get broken.
I expect that you should maintain FIT FMP driver properly and it be tested as before. # Moreover, you have not yet added capsule authentication support to FIT FMP driver.
-Takahiro Akashi
The fourth patch of the series makes corresponding changes in the capsule update related documentation.
The fifth patch of the series removes the now unused FIT and raw image GUID values from the FMP module.
The sixth patch of the series removes the --raw and --fit command line parameters in the mkeficapsule utility.
Sughosh Ganu (6): capsule: Add Image GUIDs for platforms using capsule updates capsule: FMP: Populate the image descriptor array from platform data test: capsule: Modify the capsule tests to use GUID values for sandbox doc: uefi: Update the capsule update related documentation FMP: Remove GUIDs for FIT and raw images mkeficapsule: Remove raw and FIT GUID types
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 ++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 ++ board/emulation/qemu-arm/qemu-arm.c | 20 +++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 ++ board/kontron/sl28/sl28.c | 14 ++ board/sandbox/sandbox.c | 17 ++ board/socionext/developerbox/developerbox.c | 23 +++ board/xilinx/common/board.h | 18 ++ board/xilinx/zynq/board.c | 18 ++ board/xilinx/zynqmp/zynqmp.c | 18 ++ configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - doc/develop/uefi/uefi.rst | 10 +- include/configs/imx8mm-cl-iot-gate.h | 10 ++ include/configs/imx8mp_rsb3720.h | 10 ++ include/configs/kontron-sl-mx8mm.h | 6 + include/configs/kontron_pitx_imx8m.h | 6 + include/configs/kontron_sl28.h | 6 + include/configs/qemu-arm.h | 10 ++ include/configs/sandbox.h | 10 ++ include/configs/synquacer.h | 14 ++ include/efi_api.h | 8 - include/efi_loader.h | 18 ++ lib/efi_loader/efi_firmware.c | 95 +++------- test/py/tests/test_efi_capsule/conftest.py | 20 +-- .../test_efi_capsule/test_capsule_firmware.py | 167 ++++++------------ tools/eficapsule.h | 8 - tools/mkeficapsule.c | 26 +-- 29 files changed, 384 insertions(+), 236 deletions(-)
-- 2.25.1

hi Takahiro,
On Fri, 25 Mar 2022 at 10:23, AKASHI Takahiro takahiro.akashi@linaro.org wrote:
Sughosh,
On Thu, Mar 24, 2022 at 06:08:55PM +0530, Sughosh Ganu wrote:
This series is cleaning up the usage of the image GUIDs that are used in capsule update and the EFI System Resource Table(ESRT).
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.
Ok although the specification doesn't explicitly require the uniqueness "across platforms".
Yes, but unless we have a single image running on multiple platforms, we do need different GUID values across platforms.
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.
Well, this is *not* a problem of fit FMP driver, but a matter of how ESRT is populated. Table 23-16 "ESRT and FMP Fields" says, The ImageTypeId GUID from the Firmware Management Protocol instance for a device is used as the Firmware Class GUID in the ESRT. Where there are multiple identical devices in the system, system firmware must create a mapping to ensure that the ESRT FwClass GUIDs are unique and consistent. The second sentence suggests that UEFI implementation, i.e. efi_esrt_populate(), may and should allow some *mapping*.
That said, I basically accept the requirement that you mention above.
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.
When ESRT support patch was posted, I proposed that we should have a kind of configuration table that defines all the firmware on the system for ESRT, but this proposal was rejected. Your efi_fw_images[] looks quite similar as what I had in mind. Why not define efi_fw_images[] as ESRT itself. (Of course, some fields in an entry can still be populated through GetImageInfo API.)
Currently, with this patch series, that is what is happening. The efi_fw_images array gets read by the GetImageInfo function, and that information gets used for populating the ESRT. Btw, I also want to extend this structure as part of a separate task, where we have information related to the dfu framework as part of the structure. Then the capsule related dfu information can be populated from this structure, instead of the dfu_alt_info env variable. This is what Ilias has suggested. But I will take this up as a separate exercise.
The first patch of this series adds the fw_images array in all platforms which are using UEFI capsule updates
The second patch of the series changes the logic for populating the image descriptor array, using the information from the fw_images array defined by the platform.
So a FIT image can still work as a single binary of firmware under FIT FMP driver. Correct?
Yes, this will still work. Only change is that every platform will have a separate image GUID for the FIT image.
The third patch of the series removes the test cases using the --raw and --fit parameters, removes test case for FIT images, and adds a test case for checking that the update happens only with the correct image GUID value in the capsule.
Your change in test_capsule_firmware.py tries to remove FIT FMP driver test and it eventually hides the fact that FIT driver may get broken.
Yes, I am aware of this. I was required to do this since we cannot have both instances of the FMP. I will move the FIT test into a separate script.
I expect that you should maintain FIT FMP driver properly and it be tested as before.
Okay. Although, I wanted to check if you think we need to have support for updating the FIT image. The individual images can very much be updated through the raw FMP instance. And the raw images also map to the ESRT, which is not the case with the FIT image.
# Moreover, you have not yet added capsule authentication support to FIT FMP driver.
Yes, I have not used an FIT image in my testing up until now, although it should not be very difficult. I will keep this on my Todo list and will add support once this gets upstreamed.
-sughosh
-Takahiro Akashi
The fourth patch of the series makes corresponding changes in the capsule update related documentation.
The fifth patch of the series removes the now unused FIT and raw image GUID values from the FMP module.
The sixth patch of the series removes the --raw and --fit command line parameters in the mkeficapsule utility.
Sughosh Ganu (6): capsule: Add Image GUIDs for platforms using capsule updates capsule: FMP: Populate the image descriptor array from platform data test: capsule: Modify the capsule tests to use GUID values for sandbox doc: uefi: Update the capsule update related documentation FMP: Remove GUIDs for FIT and raw images mkeficapsule: Remove raw and FIT GUID types
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 ++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 ++ board/emulation/qemu-arm/qemu-arm.c | 20 +++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 ++ board/kontron/sl28/sl28.c | 14 ++ board/sandbox/sandbox.c | 17 ++ board/socionext/developerbox/developerbox.c | 23 +++ board/xilinx/common/board.h | 18 ++ board/xilinx/zynq/board.c | 18 ++ board/xilinx/zynqmp/zynqmp.c | 18 ++ configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - doc/develop/uefi/uefi.rst | 10 +- include/configs/imx8mm-cl-iot-gate.h | 10 ++ include/configs/imx8mp_rsb3720.h | 10 ++ include/configs/kontron-sl-mx8mm.h | 6 + include/configs/kontron_pitx_imx8m.h | 6 + include/configs/kontron_sl28.h | 6 + include/configs/qemu-arm.h | 10 ++ include/configs/sandbox.h | 10 ++ include/configs/synquacer.h | 14 ++ include/efi_api.h | 8 - include/efi_loader.h | 18 ++ lib/efi_loader/efi_firmware.c | 95 +++------- test/py/tests/test_efi_capsule/conftest.py | 20 +-- .../test_efi_capsule/test_capsule_firmware.py | 167 ++++++------------ tools/eficapsule.h | 8 - tools/mkeficapsule.c | 26 +-- 29 files changed, 384 insertions(+), 236 deletions(-)
-- 2.25.1

Sughosh,
On Fri, Mar 25, 2022 at 03:14:20PM +0530, Sughosh Ganu wrote:
hi Takahiro,
On Fri, 25 Mar 2022 at 10:23, AKASHI Takahiro takahiro.akashi@linaro.org wrote:
Sughosh,
On Thu, Mar 24, 2022 at 06:08:55PM +0530, Sughosh Ganu wrote:
This series is cleaning up the usage of the image GUIDs that are used in capsule update and the EFI System Resource Table(ESRT).
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.
Ok although the specification doesn't explicitly require the uniqueness "across platforms".
Yes, but unless we have a single image running on multiple platforms, we do need different GUID values across platforms.
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.
Well, this is *not* a problem of fit FMP driver, but a matter of how ESRT is populated. Table 23-16 "ESRT and FMP Fields" says, The ImageTypeId GUID from the Firmware Management Protocol instance for a device is used as the Firmware Class GUID in the ESRT. Where there are multiple identical devices in the system, system firmware must create a mapping to ensure that the ESRT FwClass GUIDs are unique and consistent. The second sentence suggests that UEFI implementation, i.e. efi_esrt_populate(), may and should allow some *mapping*.
That said, I basically accept the requirement that you mention above.
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.
When ESRT support patch was posted, I proposed that we should have a kind of configuration table that defines all the firmware on the system for ESRT, but this proposal was rejected. Your efi_fw_images[] looks quite similar as what I had in mind. Why not define efi_fw_images[] as ESRT itself. (Of course, some fields in an entry can still be populated through GetImageInfo API.)
Currently, with this patch series, that is what is happening. The efi_fw_images array gets read by the GetImageInfo function, and that information gets used for populating the ESRT. Btw, I also want to extend this structure as part of a separate task, where we have information related to the dfu framework as part of the structure. Then the capsule related dfu information can be populated from this structure, instead of the dfu_alt_info env variable. This is what Ilias has suggested. But I will take this up as a separate exercise.
The first patch of this series adds the fw_images array in all platforms which are using UEFI capsule updates
The second patch of the series changes the logic for populating the image descriptor array, using the information from the fw_images array defined by the platform.
So a FIT image can still work as a single binary of firmware under FIT FMP driver. Correct?
Yes, this will still work. Only change is that every platform will have a separate image GUID for the FIT image.
Ok.
The third patch of the series removes the test cases using the --raw and --fit parameters, removes test case for FIT images, and adds a test case for checking that the update happens only with the correct image GUID value in the capsule.
Your change in test_capsule_firmware.py tries to remove FIT FMP driver test and it eventually hides the fact that FIT driver may get broken.
Yes, I am aware of this. I was required to do this since we cannot have both instances of the FMP. I will move the FIT test into a separate script.
Instead, please add a *new* test script, or separate test "class", for your changes.
I think that you should mention remaining issues or TODO items in your cover letter.
I expect that you should maintain FIT FMP driver properly and it be tested as before.
Okay. Although, I wanted to check if you think we need to have support for updating the FIT image.
Yes, I think so. FIT format has been long used, recognized as a standard on U-Boot and well integrated with DFU framework. That is why we can simply call fit_update() in SetImage API. So having FIT FMP driver is a good migration path. Moreover, treating binaries as a single capsule ensures that all the firmware can and should be updated atomically and simultaneously.
-Takahiro Akashi
The individual images can very much be updated through the raw FMP instance. And the raw images also map to the ESRT, which is not the case with the FIT image.
# Moreover, you have not yet added capsule authentication support to FIT FMP driver.
Yes, I have not used an FIT image in my testing up until now, although it should not be very difficult. I will keep this on my Todo list and will add support once this gets upstreamed.
-sughosh
-Takahiro Akashi
The fourth patch of the series makes corresponding changes in the capsule update related documentation.
The fifth patch of the series removes the now unused FIT and raw image GUID values from the FMP module.
The sixth patch of the series removes the --raw and --fit command line parameters in the mkeficapsule utility.
Sughosh Ganu (6): capsule: Add Image GUIDs for platforms using capsule updates capsule: FMP: Populate the image descriptor array from platform data test: capsule: Modify the capsule tests to use GUID values for sandbox doc: uefi: Update the capsule update related documentation FMP: Remove GUIDs for FIT and raw images mkeficapsule: Remove raw and FIT GUID types
.../imx8mp_rsb3720a1/imx8mp_rsb3720a1.c | 19 ++ .../imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 18 ++ board/emulation/qemu-arm/qemu-arm.c | 20 +++ board/kontron/pitx_imx8m/pitx_imx8m.c | 15 +- board/kontron/sl-mx8mm/sl-mx8mm.c | 14 ++ board/kontron/sl28/sl28.c | 14 ++ board/sandbox/sandbox.c | 17 ++ board/socionext/developerbox/developerbox.c | 23 +++ board/xilinx/common/board.h | 18 ++ board/xilinx/zynq/board.c | 18 ++ board/xilinx/zynqmp/zynqmp.c | 18 ++ configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - doc/develop/uefi/uefi.rst | 10 +- include/configs/imx8mm-cl-iot-gate.h | 10 ++ include/configs/imx8mp_rsb3720.h | 10 ++ include/configs/kontron-sl-mx8mm.h | 6 + include/configs/kontron_pitx_imx8m.h | 6 + include/configs/kontron_sl28.h | 6 + include/configs/qemu-arm.h | 10 ++ include/configs/sandbox.h | 10 ++ include/configs/synquacer.h | 14 ++ include/efi_api.h | 8 - include/efi_loader.h | 18 ++ lib/efi_loader/efi_firmware.c | 95 +++------- test/py/tests/test_efi_capsule/conftest.py | 20 +-- .../test_efi_capsule/test_capsule_firmware.py | 167 ++++++------------ tools/eficapsule.h | 8 - tools/mkeficapsule.c | 26 +-- 29 files changed, 384 insertions(+), 236 deletions(-)
-- 2.25.1
participants (5)
-
AKASHI Takahiro
-
Ilias Apalodimas
-
Masami Hiramatsu
-
Michal Simek
-
Sughosh Ganu