All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Masahisa Kojima <masahisa.kojima@linaro.org>
Cc: u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Simon Glass <sjg@chromium.org>,
	Takahiro Akashi <takahiro.akashi@linaro.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>,
	"Ying-Chun Liu (PaulLiu)" <paul.liu@linaro.org>,
	Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>,
	Heiko Thiery <heiko.thiery@gmail.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Michael Walle <michael@walle.cc>, Mario Six <mario.six@gdsys.cc>,
	Jassi Brar <jaswinder.singh@linaro.org>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Michal Simek <michal.simek@amd.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Etienne Carriere <etienne.carriere@linaro.org>,
	"moderated list:STM32MP1 BOARD"
	<uboot-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH v6 1/8] efi_loader: add the number of image entries in efi_capsule_update_info
Date: Mon, 22 May 2023 10:34:13 +0300	[thread overview]
Message-ID: <ZGsa9SldhGqh+vS1@hera> (raw)
In-Reply-To: <20230519103214.1239656-2-masahisa.kojima@linaro.org>

On Fri, May 19, 2023 at 07:32:07PM +0900, Masahisa Kojima wrote:
> The number of image array entries global variable is required
> to support EFI capsule update. This information is exposed as a
> num_image_type_guids variable, but this information
> should be included in the efi_capsule_update_info structure.
>
> This commit adds the num_images member in the
> efi_capsule_update_info structure. All board files supporting
> EFI capsule update are updated.
>
> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> ---
> Newly created in v6
>
>  arch/arm/mach-rockchip/board.c                         | 4 ++--
>  board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c    | 2 +-
>  board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 2 +-
>  board/emulation/qemu-arm/qemu-arm.c                    | 2 +-
>  board/kontron/pitx_imx8m/pitx_imx8m.c                  | 2 +-
>  board/kontron/sl-mx8mm/sl-mx8mm.c                      | 2 +-
>  board/kontron/sl28/sl28.c                              | 2 +-
>  board/rockchip/evb_rk3399/evb-rk3399.c                 | 2 +-
>  board/sandbox/sandbox.c                                | 2 +-
>  board/socionext/developerbox/developerbox.c            | 2 +-
>  board/st/stm32mp1/stm32mp1.c                           | 2 +-
>  board/xilinx/common/board.c                            | 2 +-
>  include/efi_loader.h                                   | 3 ++-
>  lib/efi_loader/efi_firmware.c                          | 6 +++---
>  lib/fwu_updates/fwu.c                                  | 2 +-
>  15 files changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
> index f1f70c81d0..8daa74b3eb 100644
> --- a/arch/arm/mach-rockchip/board.c
> +++ b/arch/arm/mach-rockchip/board.c
> @@ -41,7 +41,7 @@ static bool updatable_image(struct disk_partition *info)
>  	uuid_str_to_bin(info->type_guid, image_type_guid.b,
>  			UUID_STR_FORMAT_GUID);
>
> -	for (i = 0; i < num_image_type_guids; i++) {
> +	for (i = 0; i < update_info.num_images; i++) {
>  		if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) {
>  			ret = true;
>  			break;
> @@ -59,7 +59,7 @@ static void set_image_index(struct disk_partition *info, int index)
>  	uuid_str_to_bin(info->type_guid, image_type_guid.b,
>  			UUID_STR_FORMAT_GUID);
>
> -	for (i = 0; i < num_image_type_guids; i++) {
> +	for (i = 0; i < update_info.num_images; i++) {
>  		if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) {
>  			fw_images[i].image_index = index;
>  			break;
> diff --git a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c
> index 466174679e..b79a2380aa 100644
> --- a/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c
> +++ b/board/advantech/imx8mp_rsb3720a1/imx8mp_rsb3720a1.c
> @@ -54,10 +54,10 @@ struct efi_fw_image fw_images[] = {
>
>  struct efi_capsule_update_info update_info = {
>  	.dfu_string = "mmc 2=flash-bin raw 0 0x1B00 mmcpart 1",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>
> 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 b373e45df9..af070ec315 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
> @@ -50,10 +50,10 @@ struct efi_fw_image fw_images[] = {
>
>  struct efi_capsule_update_info update_info = {
>  	.dfu_string = "mmc 2=flash-bin raw 0x42 0x1D00 mmcpart 1",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  int board_phys_sdram_size(phys_size_t *size)
> diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c
> index 34ed3e8ae6..dfea0d92a3 100644
> --- a/board/emulation/qemu-arm/qemu-arm.c
> +++ b/board/emulation/qemu-arm/qemu-arm.c
> @@ -47,10 +47,10 @@ struct efi_fw_image fw_images[] = {
>  };
>
>  struct efi_capsule_update_info update_info = {
> +	.num_images = ARRAY_SIZE(fw_images)
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  static struct mm_region qemu_arm64_mem_map[] = {
> diff --git a/board/kontron/pitx_imx8m/pitx_imx8m.c b/board/kontron/pitx_imx8m/pitx_imx8m.c
> index fcda86bc1b..4548e7c1df 100644
> --- a/board/kontron/pitx_imx8m/pitx_imx8m.c
> +++ b/board/kontron/pitx_imx8m/pitx_imx8m.c
> @@ -43,10 +43,10 @@ struct efi_fw_image fw_images[] = {
>
>  struct efi_capsule_update_info update_info = {
>  	.dfu_string = "mmc 0=flash-bin raw 0x42 0x1000 mmcpart 1",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  int board_early_init_f(void)
> diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c
> index 250195694b..ddb509eb66 100644
> --- a/board/kontron/sl-mx8mm/sl-mx8mm.c
> +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c
> @@ -29,10 +29,10 @@ struct efi_fw_image fw_images[] = {
>
>  struct efi_capsule_update_info update_info = {
>  	.dfu_string = "sf 0:0=flash-bin raw 0x400 0x1f0000",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  int board_phys_sdram_size(phys_size_t *size)
> diff --git a/board/kontron/sl28/sl28.c b/board/kontron/sl28/sl28.c
> index 89948e087f..4ab221c12b 100644
> --- a/board/kontron/sl28/sl28.c
> +++ b/board/kontron/sl28/sl28.c
> @@ -40,10 +40,10 @@ struct efi_fw_image fw_images[] = {
>  struct efi_capsule_update_info update_info = {
>  	.dfu_string = "sf 0:0=u-boot-bin raw 0x210000 0x1d0000;"
>  			"u-boot-env raw 0x3e0000 0x20000",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  int board_early_init_f(void)
> diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c b/board/rockchip/evb_rk3399/evb-rk3399.c
> index c99ffdd75e..3c773d0930 100644
> --- a/board/rockchip/evb_rk3399/evb-rk3399.c
> +++ b/board/rockchip/evb_rk3399/evb-rk3399.c
> @@ -18,10 +18,10 @@
>  static struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
>
>  struct efi_capsule_update_info update_info = {
> +	.num_images = ROCKPI4_UPDATABLE_IMAGES,
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ROCKPI4_UPDATABLE_IMAGES;
>  #endif
>
>  #ifndef CONFIG_SPL_BUILD
> diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
> index 2e44bdf0df..c7b6cb78ff 100644
> --- a/board/sandbox/sandbox.c
> +++ b/board/sandbox/sandbox.c
> @@ -67,10 +67,10 @@ struct efi_fw_image fw_images[] = {
>  struct efi_capsule_update_info update_info = {
>  	.dfu_string = "sf 0:0=u-boot-bin raw 0x100000 0x50000;"
>  		"u-boot-env raw 0x150000 0x200000",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  #if !CONFIG_IS_ENABLED(OF_PLATDATA)
> diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c
> index 16e14d4f7f..d92e1d0962 100644
> --- a/board/socionext/developerbox/developerbox.c
> +++ b/board/socionext/developerbox/developerbox.c
> @@ -41,10 +41,10 @@ struct efi_capsule_update_info update_info = {
>  	.dfu_string = "mtd nor1=u-boot.bin raw 200000 100000;"
>  			"fip.bin raw 180000 78000;"
>  			"optee.bin raw 500000 100000",
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  static struct mm_region sc2a11_mem_map[] = {
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 1a1b1844c8..5b28ccd32e 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -92,10 +92,10 @@
>  struct efi_fw_image fw_images[1];
>
>  struct efi_capsule_update_info update_info = {
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  int board_early_init_f(void)
> diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
> index d071ebfb9c..0328d68e75 100644
> --- a/board/xilinx/common/board.c
> +++ b/board/xilinx/common/board.c
> @@ -52,10 +52,10 @@ struct efi_fw_image fw_images[] = {
>  };
>
>  struct efi_capsule_update_info update_info = {
> +	.num_images = ARRAY_SIZE(fw_images),
>  	.images = fw_images,
>  };
>
> -u8 num_image_type_guids = ARRAY_SIZE(fw_images);
>  #endif /* EFI_HAVE_CAPSULE_SUPPORT */
>
>  #define EEPROM_HEADER_MAGIC		0xdaaddeed
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index b395eef9e7..941d63467c 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -1078,15 +1078,16 @@ struct efi_fw_image {
>   * platforms which enable capsule updates
>   *
>   * @dfu_string:		String used to populate dfu_alt_info
> + * @num_images:		The number of images array entries
>   * @images:		Pointer to an array of updatable images
>   */
>  struct efi_capsule_update_info {
>  	const char *dfu_string;
> +	int num_images;
>  	struct efi_fw_image *images;
>  };
>
>  extern struct efi_capsule_update_info update_info;
> -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 93e2b01c07..cc650e1443 100644
> --- a/lib/efi_loader/efi_firmware.c
> +++ b/lib/efi_loader/efi_firmware.c
> @@ -131,7 +131,7 @@ static efi_status_t efi_fill_image_desc_array(
>  	struct efi_fw_image *fw_array;
>  	int i;
>
> -	total_size = sizeof(*image_info) * num_image_type_guids;
> +	total_size = sizeof(*image_info) * update_info.num_images;
>
>  	if (*image_info_size < total_size) {
>  		*image_info_size = total_size;
> @@ -141,13 +141,13 @@ static efi_status_t efi_fill_image_desc_array(
>  	*image_info_size = total_size;
>
>  	fw_array = update_info.images;
> -	*descriptor_count = num_image_type_guids;
> +	*descriptor_count = update_info.num_images;
>  	*descriptor_version = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
>  	*descriptor_size = sizeof(*image_info);
>  	*package_version = 0xffffffff; /* not supported */
>  	*package_version_name = NULL; /* not supported */
>
> -	for (i = 0; i < num_image_type_guids; i++) {
> +	for (i = 0; i < update_info.num_images; i++) {
>  		image_info[i].image_index = fw_array[i].image_index;
>  		image_info[i].image_type_id = fw_array[i].image_type_id;
>  		image_info[i].image_id = fw_array[i].image_index;
> diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
> index 5313d07302..3b1785e7b1 100644
> --- a/lib/fwu_updates/fwu.c
> +++ b/lib/fwu_updates/fwu.c
> @@ -151,7 +151,7 @@ static int fwu_get_image_type_id(u8 *image_index, efi_guid_t *image_type_id)
>
>  	index = *image_index;
>  	image = update_info.images;
> -	for (i = 0; i < num_image_type_guids; i++) {
> +	for (i = 0; i < update_info.num_images; i++) {
>  		if (index == image[i].image_index) {
>  			guidcpy(image_type_id, &image[i].image_type_id);
>  			return 0;
> --
> 2.17.1
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>


  reply	other threads:[~2023-05-22  7:34 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 10:32 [PATCH v6 0/8] FMP versioning support Masahisa Kojima
2023-05-19 10:32 ` [PATCH v6 1/8] efi_loader: add the number of image entries in efi_capsule_update_info Masahisa Kojima
2023-05-22  7:34   ` Ilias Apalodimas [this message]
2023-05-22 20:42   ` Ilias Apalodimas
2023-05-19 10:32 ` [PATCH v6 2/8] efi_loader: store firmware version into FmpState variable Masahisa Kojima
2023-05-22 21:24   ` Ilias Apalodimas
2023-05-23  1:55     ` Masahisa Kojima
2023-05-28  8:39   ` Heinrich Schuchardt
2023-05-30  0:31     ` Masahisa Kojima
2023-05-19 10:32 ` [PATCH v6 3/8] efi_loader: versioning support in GetImageInfo Masahisa Kojima
2023-05-22 21:29   ` Ilias Apalodimas
2023-05-19 10:32 ` [PATCH v6 4/8] efi_loader: get lowest supported version from device tree Masahisa Kojima
2023-05-22 21:33   ` Ilias Apalodimas
2023-05-19 10:32 ` [PATCH v6 5/8] efi_loader: check lowest supported version Masahisa Kojima
2023-05-22 21:36   ` Ilias Apalodimas
2023-05-23  1:56     ` Masahisa Kojima
2023-05-19 10:32 ` [PATCH v6 6/8] mkeficapsule: add FMP Payload Header Masahisa Kojima
2023-05-22 21:29   ` Ilias Apalodimas
2023-05-19 10:32 ` [PATCH v6 7/8] doc: uefi: add firmware versioning documentation Masahisa Kojima
2023-05-22  0:35   ` Takahiro Akashi
2023-05-22  4:25     ` Masahisa Kojima
2023-05-19 10:32 ` [PATCH v6 8/8] doc: uefi: add anti-rollback documentation Masahisa Kojima
2023-05-22  0:27   ` Takahiro Akashi
2023-05-22  4:30     ` Masahisa Kojima
2023-05-22  4:32 ` [PATCH v6 0/8] FMP versioning support Masahisa Kojima
2023-05-28  8:54 ` Heinrich Schuchardt
2023-05-30  0:32   ` Masahisa Kojima

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZGsa9SldhGqh+vS1@hera \
    --to=ilias.apalodimas@linaro.org \
    --cc=etienne.carriere@linaro.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=heiko.thiery@gmail.com \
    --cc=jaswinder.singh@linaro.org \
    --cc=kever.yang@rock-chips.com \
    --cc=mario.six@gdsys.cc \
    --cc=masahisa.kojima@linaro.org \
    --cc=michael@walle.cc \
    --cc=michal.simek@amd.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=paul.liu@linaro.org \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=tuomas.tynkkynen@iki.fi \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-stm32@st-md-mailman.stormreply.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.