Skip to contentSkip to conversation

Allow disabling non-FIT image loading from SPL

PATCH Superseded Andrew F. Davis 3 participants 11 messages Aug 1, 2016 – Aug 5, 2016

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Allow disabling non-FIT image loading from SPL

Hello all,

To address a needed feature brought up by Andreas[0], we need a way to disable SPL from loading non-FIT images.

The function spl_parse_image_header is common to all SPL loading paths (common/spl/spl_(nand|net|nor|etc..)) so we add the check here, much like the existing CONFIG_SPL_PANIC_ON_RAW_IMAGE.

My original attempt was to add CONFIG_SPL_PANIC_ON_MKIMAGE, but then if other formats are added, flaws in restricting image types may be introduced, so we would like a single option to restrict all non-FIT types vs disabling types individually.

Thanks,
Andrew

[0]: https://www.mail-archive.com/u-boot at lists.denx.de/msg219253.html

Andrew F. Davis (4):
Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE
ARM: AM57xx: Disable non-FIT based image loading for HS devices
ARM: AM437x: Disable non-FIT based image loading for HS devices
ARM: DRA7xx: Disable non-FIT based image loading for HS devices

 Kconfig                         | 8 ++++++++
 common/spl/spl.c                | 4 ++++
 configs/am43xx_hs_evm_defconfig | 1 +
 configs/am57xx_hs_evm_defconfig | 1 +
 configs/dra7xx_hs_evm_defconfig | 1 +
 5 files changed, 15 insertions(+)
Signature · 1 line
2.9.2
#1 lore raw

PATCH 1/4 Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE

Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE. An SPL which define this will panic() if the image it has loaded is not a FIT image.

---
 Kconfig          | 8 ++++++++
 common/spl/spl.c | 4 ++++
 2 files changed, 12 insertions(+)
Kconfig +8 -0
index ef12f9f..4c03716 100644
@@ -336,6 +336,14 @@ config SPL_FIT_IMAGE_POST_PROCESS
 	  injected into the FIT creation (i.e. the blobs would have been pre-
 	  processed before being added to the FIT image).
 
+config SPL_PANIC_ON_NON_FIT_IMAGE
+	bool "Disable SPL loading of non-FIT images"
+	help
+	  SPL will panic() if the image loaded is not a FIT image. This is
+	  useful for devices that only support authentication/encryption
+	  through SPL FIT loading paths and do not want SPL falling back
+	  to legacy image loading when a non-FIT image is present.
+
 config SYS_CLK_FREQ
 	depends on ARC || ARCH_SUNXI
 	int "CPU clock frequency"
common/spl/spl.c +4 -0
index b7ec333..7a30c7d 100644
@@ -93,6 +93,9 @@ void spl_set_header_raw_uboot(void)
 
 int spl_parse_image_header(const struct image_header *header)
 {
+#ifdef CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE
+	panic("** non-FIT images are not supported");
+#else
 	u32 header_size = sizeof(struct image_header);
 
 	if (image_get_magic(header) == IH_MAGIC) {
@@ -153,6 +156,7 @@ int spl_parse_image_header(const struct image_header *header)
 		spl_set_header_raw_uboot();
 #endif
 	}
+#endif
 	return 0;
 }
 
Signature · 1 line
2.9.2
#4 lore raw

PATCH 2/4 ARM: AM57xx: Disable non-FIT based image loading for HS devices

In reply to Andrew F. Davis

Disable support for loading non-FIT images for AM57xx platforms using the high-security (HS) device variant.

---
 configs/am57xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am57xx_hs_evm_defconfig +1 -0
index a4bfdd5..e6f3ebc 100644
@@ -41,6 +41,7 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
 CONFIG_DM_I2C=y
 CONFIG_DM_SPI=y
Signature · 1 line
2.9.2
#9 lore raw

PATCH 3/4 ARM: AM437x: Disable non-FIT based image loading for HS devices

In reply to Andrew F. Davis

Disable support for loading non-FIT images for AM437x platforms using the high-security (HS) device variant.

---
 configs/am43xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am43xx_hs_evm_defconfig +1 -0
index c8ce723..fc2b8b0 100644
@@ -14,6 +14,7 @@ CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1, NAND"
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMLS is not set
Signature · 1 line
2.9.2
#10 lore raw

PATCH 4/4 ARM: DRA7xx: Disable non-FIT based image loading for HS devices

In reply to Andrew F. Davis

Disable support for loading non-FIT images for DRA7xx platforms using the high-security (HS) device variant.

---
 configs/dra7xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/dra7xx_hs_evm_defconfig +1 -0
index faf9cd5..63801fe 100644
@@ -59,5 +59,6 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_OF_LIST="dra7-evm dra72-evm"
 CONFIG_DM_I2C=y
Signature · 1 line
2.9.2
#2 lore raw

PATCH 1/4 Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE

In reply to Andrew F. Davis
Quoted 14 lines · Andrew F. Davis

Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE. An SPL which define this will panic() if the image it has loaded is not a FIT image.

---
 Kconfig          | 8 ++++++++
 common/spl/spl.c | 4 ++++
 2 files changed, 12 insertions(+)
Kconfig +0 -0
index ef12f9f..4c03716 100644

Kconfig config SPL_FIT_IMAGE_POST_PROCESS · line 340

Quoted 5 lines
Kconfig +2 -0
@@ -336,6 +336,14 @@ config SPL_FIT_IMAGE_POST_PROCESS
 	  injected into the FIT creation (i.e. the blobs would have been pre-
 	  processed before being added to the FIT image).
 
+config SPL_PANIC_ON_NON_FIT_IMAGE
+	bool "Disable SPL loading of non-FIT images"

I think we should make this default y if SPL_FIT_SIGNATURE since the point of enabling these options is that you want to be verified or failing. During development you can disable this easily enough.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160801/4998d2da/attachment.sig>
#3 lore raw

PATCH 1/4 Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE

Hi,

Quoted 19 lines · Tom Rini
Quoted 17 lines · Andrew F. Davis

Introduce CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE. An SPL which define this will panic() if the image it has loaded is not a FIT image.

---
 Kconfig          | 8 ++++++++
 common/spl/spl.c | 4 ++++
 2 files changed, 12 insertions(+)
Kconfig +0 -0
index ef12f9f..4c03716 100644
@@ -336,6 +336,14 @@ config SPL_FIT_IMAGE_POST_PROCESS
        injected into the FIT creation (i.e. the blobs would have been pre-
        processed before being added to the FIT image).
 
Quoted 6 lines

Kconfig config SPL_FIT_IMAGE_POST_PROCESS · line 340

Quoted 2 lines
Kconfig +2 -0
+config SPL_PANIC_ON_NON_FIT_IMAGE
+     bool "Disable SPL loading of non-FIT images"

I think we should make this default y if SPL_FIT_SIGNATURE since the point of enabling these options is that you want to be verified or failing. During development you can disable this easily enough.

Also can we reuse CONFIG_IMAGE_FORMAT_LEGACY?

Regards,
Simon

#5 lore raw

PATCH 2/4 ARM: AM57xx: Disable non-FIT based image loading for HS devices

In reply to Andrew F. Davis

Hi Andrew,

Quoted 21 lines · Andrew F. Davis

Disable support for loading non-FIT images for AM57xx platforms using the high-security (HS) device variant.

---
 configs/am57xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am57xx_hs_evm_defconfig +1 -1
index a4bfdd5..e6f3ebc 100644
@@ -41,6 +41,7 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
 CONFIG_DM_I2C=y
 CONFIG_DM_SPI=y
--
Quoted 2 lines

2.9.2

Why do we need to panic? Can we use something like CONFIG_IMAGE_FORMAT_LEGACY?

Regards,
Simon

#6 lore raw

PATCH 2/4 ARM: AM57xx: Disable non-FIT based image loading for HS devices

Quoted 11 lines · Simon Glass

Hi Andrew,

Quoted 8 lines · Andrew F. Davis

Disable support for loading non-FIT images for AM57xx platforms using the high-security (HS) device variant.

---
 configs/am57xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

configs/am57xx_hs_evm_defconfig CONFIG_FIT=y · line 47

Quoted 12 lines
configs/am57xx_hs_evm_defconfig +1 -0
index a4bfdd5..e6f3ebc 100644
@@ -41,6 +41,7 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
 CONFIG_DM_I2C=y
 CONFIG_DM_SPI=y

Why do we need to panic? Can we use something like CONFIG_IMAGE_FORMAT_LEGACY?

The need to panic is because if we cannot authenticate we are to fail as this is a secure device.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160803/aaaee169/attachment.sig>
#7 lore raw

PATCH 2/4 ARM: AM57xx: Disable non-FIT based image loading for HS devices

Hi Tom,

Quoted 27 lines · Tom Rini
Quoted 11 lines · Simon Glass

Hi Andrew,

Quoted 8 lines · Andrew F. Davis

Disable support for loading non-FIT images for AM57xx platforms using the high-security (HS) device variant.

---
 configs/am57xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

configs/am57xx_hs_evm_defconfig CONFIG_FIT=y · line 47

Quoted 12 lines
configs/am57xx_hs_evm_defconfig +1 -0
index a4bfdd5..e6f3ebc 100644
@@ -41,6 +41,7 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
 CONFIG_DM_I2C=y
 CONFIG_DM_SPI=y

Why do we need to panic? Can we use something like CONFIG_IMAGE_FORMAT_LEGACY?

Quoted 2 lines

The need to panic is because if we cannot authenticate we are to fail as this is a secure device.

We already have a hang in board_init_r() (SPL: failed to boot from all boot devices). I'm suggesting that instead of panic we just return an error from spl_parse_image_header() and let things work in the normal way.

Anyway, I don't mind if people prefer this approach.

It's strange that this patch does not seem to be in patchwork.

Regards,
Simon

#8 lore raw

PATCH 2/4 ARM: AM57xx: Disable non-FIT based image loading for HS devices

Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 27 lines · Tom Rini
Quoted 25 lines · Simon Glass

Hi Andrew,

Quoted 13 lines · Andrew F. Davis

Disable support for loading non-FIT images for AM57xx platforms using the high-security (HS) device variant.

---
 configs/am57xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am57xx_hs_evm_defconfig +0 -0
index a4bfdd5..e6f3ebc 100644

configs/am57xx_hs_evm_defconfig CONFIG_FIT=y · line 47

Quoted 7 lines
configs/am57xx_hs_evm_defconfig +1 -0
@@ -41,6 +41,7 @@ CONFIG_FIT=y
 CONFIG_SPL_OF_LIBFDT=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y
+CONFIG_SPL_PANIC_ON_NON_FIT_IMAGE=y
 CONFIG_OF_LIST="am57xx-beagle-x15"
 CONFIG_DM_I2C=y
 CONFIG_DM_SPI=y

Why do we need to panic? Can we use something like CONFIG_IMAGE_FORMAT_LEGACY?

Quoted 8 lines
Quoted 2 lines

The need to panic is because if we cannot authenticate we are to fail as this is a secure device.

We already have a hang in board_init_r() (SPL: failed to boot from all boot devices). I'm suggesting that instead of panic we just return an error from spl_parse_image_header() and let things work in the normal way.

I think this will work also, it looks like CONFIG_IMAGE_FORMAT_LEGACY was made for a similar reason as we have here just for the non-SPL u-boot case.

Quoted 2 lines

Anyway, I don't mind if people prefer this approach.

I'll investigate this and see if it can be made into an SPL equivalent version.

Thanks,
Andrew

Quoted 5 lines

It's strange that this patch does not seem to be in patchwork.

Regards,
Simon