Skip to contentSkip to conversation

Add support for secure falcon mode: disable args file

PATCH In review Anshul Dalal 2 participants 7 messages Oct 9, 2025 – Oct 20, 2025

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for secure falcon mode: disable args file

Hi all,

Continuing from the last series[1], this patch series addresses the requirement to disable the args file in falcon mode.

The args file is used in falcon mode for loading the device-tree for the kernel. However in secure falcon mode, the expected payload is a FIT containing a signed device-tree and kernel image. Thus removing the need to load the extra args file in the first place. Also, loading the extra file without any authentication mechanism exposes an attack vector and should therefore be disabled to keep the boot secure.

This patch set builds on the last few to first optionally allow for loading the args file in non-secure falcon boot flow [1/3] and then disable them altogether in the next patch [2/3] for secure falcon mode.

[1]: https://lore.kernel.org/u-boot/[email protected]/
Depends on: https://lore.kernel.org/u-boot/[email protected]/

Regards,
Anshul
---
Changes in v2:
- Address Tom's comments on [1/3]: https://lore.kernel.org/u-boot/20251008163820.GC298503@bill-the-cat/
- Add call to spl_fixup_fdt with OS_BOOT_ARGS unset in [1/3]
- Pick R-by tags on [2/3]
- Add patch [3/3] to the series to fix the args being unset in falcon mode on
certain boot modes

v1: https://lore.kernel.org/u-boot/[email protected]/
---
Anshul Dalal (3):
spl: make args file optional in falcon mode
spl: prevent loading args file in secure falcon mode
spl: set fdt address as spl_image arg in falcon mode

 common/spl/Kconfig         | 22 +++++++++++++++-------
 common/spl/spl.c           |  9 +++++++--
 common/spl/spl_ext.c       |  4 ++++
 common/spl/spl_fat.c       |  5 +++++
 common/spl/spl_nand.c      |  5 ++++-
 common/spl/spl_nor.c       |  4 ----
 common/spl/spl_spi.c       |  5 +++++
 common/spl/spl_ubi.c       |  4 ++++
 common/spl/spl_xip.c       |  1 -
 include/system-constants.h |  2 +-
 10 files changed, 45 insertions(+), 16 deletions(-)
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/3 spl: make args file optional in falcon mode

Falcon mode loads a kernel file and an args file which is the device-tree. However in the case of kernel file being a FIT that contains the device-tree within it, loading the args file is not required.

Therefore, this patch introduces a new SPL_OS_BOOT_ARGS config options that allows us to enable or disable loading of the args file in falcon mode.

---
 common/spl/Kconfig         | 21 ++++++++++++++-------
 common/spl/spl.c           |  8 ++++++--
 common/spl/spl_ext.c       |  4 ++++
 common/spl/spl_fat.c       |  5 +++++
 common/spl/spl_nand.c      |  5 ++++-
 common/spl/spl_spi.c       |  5 +++++
 common/spl/spl_ubi.c       |  4 ++++
 include/system-constants.h |  2 +-
 8 files changed, 43 insertions(+), 11 deletions(-)
common/spl/Kconfig +14 -7
index f20651c3769..22ef43c3a6e 100644
@@ -803,7 +803,7 @@ config SPL_FS_LOAD_KERNEL_NAME
 
 config SPL_FS_LOAD_ARGS_NAME
 	string "File to load for the OS kernel argument parameters from the filesystem"
-	depends on (SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS) && SPL_OS_BOOT
+	depends on (SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS) && SPL_OS_BOOT_ARGS
 	default "args"
 	help
 	  Filename to read to load for the OS kernel argument parameters from
@@ -1121,7 +1121,7 @@ config SPL_UBI_LOAD_KERNEL_ID
 
 config SPL_UBI_LOAD_ARGS_ID
 	int "id of kernel args volume"
-	depends on SPL_OS_BOOT
+	depends on SPL_OS_BOOT_ARGS
 	help
 	  The UBI volume id from which to load the device tree
 
@@ -1214,9 +1214,16 @@ config SPL_OS_BOOT_SECURE
 	  to use falcon mode by disabling certain inherently non-securable options
 	  in the SPL boot flow.
 
+config SPL_OS_BOOT_ARGS
+	bool "Allow SPL to load args for kernel in falcon mode"
+	depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT
+	help
+	  This option enables the SPL to load an args file (usually the FDT)
+	  alongside the kernel image in falcon boot mode.
+
 config SPL_PAYLOAD_ARGS_ADDR
 	hex "Address in memory to load 'args' file for Falcon Mode to"
-	depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT
+	depends on SPL_OS_BOOT_ARGS
 	default 0x88000000 if ARCH_OMAP2PLUS
 	default 0x99000000 if ARCH_SC5XX && SC59X_64
 	default 0xA0000000 if ARCH_SC5XX && TARGET_SC594_SOM_EZKIT
@@ -1256,7 +1263,7 @@ config SYS_MMCSD_RAW_MODE_KERNEL_SECTOR
 
 config SYS_MMCSD_RAW_MODE_ARGS_SECTOR
 	hex "Falcon mode: Sector to load 'args' from MMC"
-	depends on SPL_FALCON_BOOT_MMCSD
+	depends on SPL_FALCON_BOOT_MMCSD && SPL_OS_BOOT_ARGS
 	help
 	  When Falcon mode is used with an MMC or SD media, SPL needs to know
 	  where to look for the OS 'args', typically a device tree. The
@@ -1266,7 +1273,7 @@ config SYS_MMCSD_RAW_MODE_ARGS_SECTOR
 
 config SYS_MMCSD_RAW_MODE_ARGS_SECTORS
 	hex "Falcon mode: Number of sectors to load for 'args' from MMC"
-	depends on SPL_FALCON_BOOT_MMCSD && SYS_MMCSD_RAW_MODE_ARGS_SECTOR != 0x0
+	depends on SPL_FALCON_BOOT_MMCSD && SPL_OS_BOOT_ARGS
 
 config SPL_PAYLOAD
 	string "SPL payload"
@@ -1502,14 +1509,14 @@ config SYS_SPI_KERNEL_OFFS
 
 config SYS_SPI_ARGS_OFFS
 	hex "Falcon mode: address of args payload in SPI flash"
-	depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT
+	depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT_ARGS
 	help
 	 Address within SPI-Flash from where the args payload (usually the
 	 dtb) is fetched in falcon boot.
 
 config SYS_SPI_ARGS_SIZE
 	hex "Falcon mode: size of args payload in SPI flash"
-	depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT
+	depends on SPL_SPI_FLASH_SUPPORT && SPL_OS_BOOT_ARGS
 
 config SPL_THERMAL
 	bool "Driver support for thermal devices"
common/spl/spl.c +6 -2
index 55ad497c86d..f1a1785beef 100644
@@ -692,6 +692,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	spl_jump_to_image_t jumper = &jump_to_image;
 	struct spl_image_info spl_image;
 	int ret, os;
+	void *fdt;
 
 	debug(">>" PHASE_PROMPT "board_init_r()\n");
 
@@ -793,8 +794,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		jumper = &spl_invoke_opensbi;
 	} else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) {
 		debug("Jumping to Linux\n");
-		if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
-			spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR);
+		if (CONFIG_IS_ENABLED(OS_BOOT_ARGS))
+			fdt = (void *)SPL_PAYLOAD_ARGS_ADDR;
+		else
+			fdt = spl_image_fdt_addr(&spl_image);
+		spl_fixup_fdt(fdt);
 		spl_board_prepare_for_linux();
 		jumper = &jump_to_image_linux;
 	} else {
common/spl/spl_ext.c +4 -0
index a3925d38d52..834977f82f5 100644
@@ -105,6 +105,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
 			goto defaults;
 		}
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 		ext4fs_set_blk_dev(block_dev, &part_info);
 		ext4fs_mount();
 		file = env_get("falcon_args_file");
@@ -125,6 +126,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
 		} else {
 			puts("spl: falcon_args_file not set in environment, falling back to default\n");
 		}
+#endif
 	} else {
 		puts("spl: falcon_image_file not set in environment, falling back to default\n");
 	}
@@ -137,6 +139,7 @@ defaults:
 	if (err)
 		return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 	ext4fs_set_blk_dev(block_dev, &part_info);
 	ext4fs_mount();
 	err = ext4fs_open(CONFIG_SPL_FS_LOAD_ARGS_NAME, &filelen);
@@ -153,6 +156,7 @@ defaults:
 #endif
 		return -1;
 	}
+#endif
 
 	return 0;
 }
common/spl/spl_fat.c +5 -0
index 80e800b4755..d66b2f7d5e7 100644
@@ -131,6 +131,7 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
 			goto defaults;
 		}
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 		file = env_get("falcon_args_file");
 		if (file) {
 			err = file_fat_read(
@@ -143,6 +144,8 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
 			return 0;
 		} else
 			puts("spl: falcon_args_file not set in environment, falling back to default\n");
+#endif
+
 	} else
 		puts("spl: falcon_image_file not set in environment, falling back to default\n");
 
@@ -154,6 +157,7 @@ defaults:
 	if (err)
 		return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 	err = file_fat_read(CONFIG_SPL_FS_LOAD_ARGS_NAME,
 			    (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR, 0);
 	if (err <= 0) {
@@ -161,6 +165,7 @@ defaults:
 		       CONFIG_SPL_FS_LOAD_ARGS_NAME, err);
 		return err;
 	}
+#endif
 
 	return 0;
 }
common/spl/spl_nand.c +4 -1
index 93ef2d1c02c..1e5c0fd5be9 100644
@@ -79,7 +79,7 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
 static int spl_nand_load_image_os(struct spl_image_info *spl_image,
 				  struct spl_boot_device *bootdev)
 {
-	int *src, *dst, err;
+	int err;
 	struct legacy_img_hdr *header = spl_get_load_buffer(0, sizeof(*header));
 
 	/* load linux */
@@ -101,12 +101,14 @@ static int spl_nand_load_image_os(struct spl_image_info *spl_image,
 	if (err)
 		return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 	/*
 	 * load parameter image load to temp position since nand_spl_load_image
 	 * reads a whole block which is typically larger than
 	 * CONFIG_CMD_SPL_WRITE_SIZE therefore may overwrite following sections
 	 * like BSS
 	 */
+	int *src, *dst;
 	nand_spl_load_image(CONFIG_CMD_SPL_NAND_OFS, CONFIG_CMD_SPL_WRITE_SIZE,
 			    (void *)CONFIG_TEXT_BASE);
 	/* copy to destintion */
@@ -116,6 +118,7 @@ static int spl_nand_load_image_os(struct spl_image_info *spl_image,
 	     src++, dst++) {
 		writel(readl(src), dst);
 	}
+#endif
 
 	return 0;
 }
common/spl/spl_spi.c +5 -0
index cbc864809fe..e3b2074b527 100644
@@ -61,10 +61,15 @@ static int spl_spi_load_image_os(struct spl_image_info *spl_image,
 	if (err)
 		return err;
 
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 	/* Read device tree. */
 	return spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS,
 			      CONFIG_SYS_SPI_ARGS_SIZE,
 			      (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR);
+#else
+	return 0;
+#endif
+
 }
 #endif
 
common/spl/spl_ubi.c +4 -0
index 3c6f80de7d9..a66ada2166c 100644
@@ -22,10 +22,14 @@ int spl_ubi_load_image_os(struct spl_image_info *spl_image,
 
 	volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID;
 	volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR;
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 	volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID;
 	volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
 
 	err = ubispl_load_volumes(info, volumes, 2);
+#else
+	err = ubispl_load_volumes(info, volumes, 1);
+#endif
 	if (err)
 		return err;
 
include/system-constants.h +1 -1
index e09fc418a47..908bf16d0b4 100644
@@ -37,7 +37,7 @@
 	IF_ENABLED_INT(CONFIG_SPL_SYS_MALLOC, CONFIG_SPL_SYS_MALLOC_SIZE)
 
 /* deal with an optional value */
-#ifdef CONFIG_SPL_OS_BOOT
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_ARGS)
 #define SPL_PAYLOAD_ARGS_ADDR	CONFIG_SPL_PAYLOAD_ARGS_ADDR
 #else
 #define SPL_PAYLOAD_ARGS_ADDR	0
Signature · 1 line
2.51.0
#2 lore raw

PATCH v2 2/3 spl: prevent loading args file in secure falcon mode

In reply to Anshul Dalal

The expected payload for the SPL in secure falcon mode is a fitImage that contains the kernel image and the DT. This removes the need to load an additional args file, which exposes an additional attack vector since it can not be verified.

Therefore this patch disables loading of the arg file when SPL_OS_BOOT_SECURE is set.

---
 common/spl/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/spl/Kconfig +2 -1
index 22ef43c3a6e..59be80dc55b 100644
@@ -796,6 +796,7 @@ config SPL_FS_LOAD_PAYLOAD_NAME
 config SPL_FS_LOAD_KERNEL_NAME
 	string "File to load for the OS kernel from the filesystem"
 	depends on (SPL_FS_EXT4 || SPL_FS_FAT || SPL_FS_SQUASHFS) && SPL_OS_BOOT
+	default "fitImage" if SPL_OS_BOOT_SECURE
 	default "uImage"
 	help
 	  Filename to read to load for the OS kernel when reading from the
@@ -1216,7 +1217,7 @@ config SPL_OS_BOOT_SECURE
 
 config SPL_OS_BOOT_ARGS
 	bool "Allow SPL to load args for kernel in falcon mode"
-	depends on SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT
+	depends on (SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT) && !SPL_OS_BOOT_SECURE
 	help
 	  This option enables the SPL to load an args file (usually the FDT)
 	  alongside the kernel image in falcon boot mode.
Signature · 1 line
2.51.0
#3 lore raw

PATCH v2 3/3 spl: set fdt address as spl_image arg in falcon mode

In reply to Anshul Dalal

The arg field of struct spl_image_info is used by jump_to_image_linux as the argument for the kernel in falcon mode.

Since commit 601cebc29d2a ("cmd: spl: Remove ATAG support from this command"), fdt is the only valid argument for kernel in falcon mode.

However fdt was only being set as the argument in nor and xip boot modes, this patch fixes it for all boot modes and removes the now redundant code from spl_nor and spl_xip.

---
 common/spl/spl.c     | 1 +
 common/spl/spl_nor.c | 4 ----
 common/spl/spl_xip.c | 1 -
 3 files changed, 1 insertion(+), 5 deletions(-)
common/spl/spl.c +1 -0
index f1a1785beef..8c20b75b178 100644
@@ -800,6 +800,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 			fdt = spl_image_fdt_addr(&spl_image);
 		spl_fixup_fdt(fdt);
 		spl_board_prepare_for_linux();
+		spl_image.arg = fdt;
 		jumper = &jump_to_image_linux;
 	} else {
 		debug("Unsupported OS image.. Jumping nevertheless..\n");
common/spl/spl_nor.c +0 -4
index 6f9ff91bef7..d18cdc07569 100644
@@ -69,10 +69,6 @@ static int spl_nor_load_image_os(struct spl_image_info *spl_image,
 	       (void *)(CONFIG_SYS_OS_BASE + sizeof(struct legacy_img_hdr)),
 	       spl_image->size);
 
-#ifdef CONFIG_SPL_PAYLOAD_ARGS_ADDR
-	spl_image->arg = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
-#endif
-
 	return 0;
 }
 #endif
common/spl/spl_xip.c +0 -1
index 1465c3e46b9..90b4102a749 100644
@@ -14,7 +14,6 @@ static int spl_xip(struct spl_image_info *spl_image,
 {
 #if CONFIG_IS_ENABLED(OS_BOOT)
 	if (!spl_start_uboot()) {
-		spl_image->arg = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR;
 		spl_image->name = "Linux";
 		spl_image->os = IH_OS_LINUX;
 		spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
Signature · 1 line
2.51.0
#4 lore raw

PATCH 1/1 spl: Restore args file being default in falcon mode

In reply to Anshul Dalal

When falcon mode is enabled and SPL_OS_BOOT_SECURE is not enabled, restore the previous default behavior of having an args file be expected. Platforms which are using a FIT image here and do not need this can update at their convenience to disable this option now.

Fixes b1a3ed068869 ("spl: make args file optional in falcon mode")
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)
common/spl/Kconfig +1 -0
index 0fe5db43d5d8..24d6ce5d7399 100644
@@ -1219,6 +1219,7 @@ config SPL_OS_BOOT_SECURE
 config SPL_OS_BOOT_ARGS
 	bool "Allow SPL to load args for kernel in falcon mode"
 	depends on (SPL_OS_BOOT || SPL_LOAD_FIT_OPENSBI_OS_BOOT) && !SPL_OS_BOOT_SECURE
+	default y if !SPL_OS_BOOT_SECURE
 	help
 	  This option enables the SPL to load an args file (usually the FDT)
 	  alongside the kernel image in falcon boot mode.
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH] spl: Restore args file being default in falcon mode

Quoted 6 lines · Tom Rini

When falcon mode is enabled and SPL_OS_BOOT_SECURE is not enabled, restore the previous default behavior of having an args file be expected. Platforms which are using a FIT image here and do not need this can update at their convenience to disable this option now.

Applied to u-boot/master, thanks!

[1/1] spl: Restore args file being default in falcon mode

      commit: 0f865ab5d68484b4dc1724809de1be06edc85df1
Signature · 1 line
Tom
#6 lore raw
In reply to Anshul Dalal
Quoted 11 lines · Anshul Dalal

Continuing from the last series[1], this patch series addresses the requirement to disable the args file in falcon mode.

The args file is used in falcon mode for loading the device-tree for the kernel. However in secure falcon mode, the expected payload is a FIT containing a signed device-tree and kernel image. Thus removing the need to load the extra args file in the first place. Also, loading the extra file without any authentication mechanism exposes an attack vector and should therefore be disabled to keep the boot secure.

[...]

Applied to u-boot/master, thanks!

[1/3] spl: make args file optional in falcon mode

      commit: b1a3ed068869d7289747dddd6dc13ecb9f9840a6
[2/3] spl: prevent loading args file in secure falcon mode
      commit: 82e04e768fc21c1ac43df5d5a68ec8aaf008c0a8
[3/3] spl: set fdt address as spl_image arg in falcon mode
      commit: f851171e14ac1b1910c549879a9b82060cc4cdba
Signature · 1 line
Tom