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.g...@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

Reply via email to