FIT verification
Subsystems (3)
Joel Stanley
maintainerv3 cover FIT verification
As part of our effort to enable secure boot in openbmc, this turns on FIT verification in the SPL and u-boot.
It adjusts the SRAM layout to accommodate the extra code size, moving the heap to the non-parity checked 24KB of SRAM.
It also modifies the way the SPL is built, including disabling features.
v3 Reorders the patches to put the size reduction changes first, and then enables signature verification to ensure the build can be bisected.
The ymodem disable patch is dropped, as we fit cleanly under the 64KB boundary with the feature enabled.
The general cleanup patch is dropped, except for the DOS_PARTITION change which was added to the SPL cleanup patch. These cleanups will be posted separately at a later date.
Size Delta
HEAD 44054 patch 1 43442 -612 patch 2 42337 -1105 patch 3 42337 0 patch 4 63378 +21041
Joel Stanley (4):
ast2600: Allow selection of SPL boot devices
config: ast2600: Reduce SPL image size
ast2600: Modify SPL SRAM layout
config: ast2600: Enable FIT signature verification
arch/arm/mach-aspeed/ast2600/Kconfig | 12 ++++++++++++ arch/arm/mach-aspeed/ast2600/spl_boot.c | 9 +++++++++ configs/ast2600_openbmc_spl_emmc_defconfig | 9 ++++++++- include/configs/evb_ast2600a1_spl.h | 4 ++-- 4 files changed, 31 insertions(+), 3 deletions(-)
Signature · 1 line
2.29.2
Joel Stanley
maintainerPATCH v3 1/4 ast2600: Allow selection of SPL boot devices
The AST2600 SPL can boot from a number of sources, with or without the AST2600 secure boot feature. It may be desirable to disable some of these, so put them behind the defines for the drivers that are used.
--- arch/arm/mach-aspeed/ast2600/Kconfig | 12 ++++++++++++ arch/arm/mach-aspeed/ast2600/spl_boot.c | 9 +++++++++ 2 files changed, 21 insertions(+)
arch/arm/mach-aspeed/ast2600/Kconfig +12 -0
@@ -53,6 +53,18 @@ config TARGET_SLT_AST2600 endchoice +config ASPEED_SECBOOT_BL2 + bool "ASPEED secure boot BL2 support" + depends on ASPEED_AST2600 + help + Enable ASPEED's "secboot" secure boot support for verifying + the SPL's playload ("BL2"). + + Enable this is if you're using secure boot support in the AST2600 (or similar) + to verify your u-boot proper. + + Disable this is if you are using u-boot's vboot to verify u-boot. + source "board/aspeed/evb_ast2600a0/Kconfig" source "board/aspeed/evb_ast2600a1/Kconfig" source "board/aspeed/ncsi_ast2600a0/Kconfig"
arch/arm/mach-aspeed/ast2600/spl_boot.c +9 -0
@@ -42,6 +42,7 @@ static int aspeed_secboot_spl_ram_load_image(struct spl_image_info *spl_image, }SPL_LOAD_IMAGE_METHOD ("RAM with Aspeed Secure Boot" ,0 ,ASPEED_SECBOOT_DEVICE_RAM , aspeed_secboot_spl_ram_load_image); +#if IS_ENABLED (CONFIG_SPL_MMC_SUPPORT )static int aspeed_spl_mmc_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) {
@@ -101,6 +102,7 @@ static int aspeed_spl_mmc_load_image(struct spl_image_info *spl_image, }SPL_LOAD_IMAGE_METHOD ("MMC" ,0 ,ASPEED_BOOT_DEVICE_MMC , aspeed_spl_mmc_load_image); +#if IS_ENABLED (ASPEED_SECBOOT_BL2 )static int aspeed_secboot_spl_mmc_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) {
@@ -161,7 +163,10 @@ static int aspeed_secboot_spl_mmc_load_image(struct spl_image_info *spl_image,return 0 ; }SPL_LOAD_IMAGE_METHOD ("MMC with Aspeed Secure Boot" ,0 ,ASPEED_SECBOOT_DEVICE_MMC , aspeed_secboot_spl_mmc_load_image); +#endif /* ASPEED_SECBOOT_BL2 */ +#endif +#if IS_ENABLED (CONFIG_SPL_YMODEM_SUPPORT )static int getcymodem (void ) {if (tstc ())
@@ -204,6 +209,8 @@ end_stream: }SPL_LOAD_IMAGE_METHOD ("UART" ,0 ,ASPEED_BOOT_DEVICE_UART , aspeed_spl_ymodem_load_image); + +#if IS_ENABLED (ASPEED_SECBOOT_BL2 )static int aspeed_secboot_spl_ymodem_load_image (struct spl_image_info *spl_image,struct spl_boot_device *bootdev) {
@@ -245,3 +252,5 @@ end_stream:return ret; }SPL_LOAD_IMAGE_METHOD ("UART with Aspeed Secure Boot" ,0 ,ASPEED_SECBOOT_DEVICE_UART , aspeed_secboot_spl_ymodem_load_image); +#endif /* ASPEED_SECBOOT_BL2 */ +#endif
Signature · 1 line
2.29.2
Re: [PATCH u-boot v2019.04-aspeed-openbmc v3 1/4] ast2600: Allow selection of SPL boot devices
Quoted 42 lines · Joel Stanley
The AST2600 SPL can boot from a number of sources, with or without the AST2600 secure boot feature. It may be desirable to disable some of these, so put them behind the defines for the drivers that are used.
Reviewed-by Klaus Heinrich Kiwi <[email protected]>Signed-off-by Joel Stanley <[email protected]>--- arch/arm/mach-aspeed/ast2600/Kconfig | 12 ++++++++++++ arch/arm/mach-aspeed/ast2600/spl_boot.c | 9 +++++++++ 2 files changed, 21 insertions(+)arch/arm/mach-aspeed/ast2600/Kconfig +12
-0@@ -53,6 +53,18 @@ config TARGET_SLT_AST2600 endchoice +config ASPEED_SECBOOT_BL2 + bool "ASPEED secure boot BL2 support" + depends on ASPEED_AST2600 + help + Enable ASPEED's "secboot" secure boot support for verifying + the SPL's playload ("BL2"). + + Enable this is if you're using secure boot support in the AST2600 (or similar) + to verify your u-boot proper. + + Disable this is if you are using u-boot's vboot to verify u-boot. + source "board/aspeed/evb_ast2600a0/Kconfig" source "board/aspeed/evb_ast2600a1/Kconfig"source "board/aspeed/ncsi_ast2600a0/Kconfig"
arch/arm/mach-aspeed/ast2600/spl_boot.c +0
-0
arch/arm/mach-aspeed/ast2600/spl_boot.c static int aspeed_secboot_spl_ram_load_image(struct · line 45
Quoted 4 lines
arch/arm/mach-aspeed/ast2600/spl_boot.c +0
-0@@ -42,6 +42,7 @@ static int aspeed_secboot_spl_ram_load_image(struct spl_image_info *spl_image, }SPL_LOAD_IMAGE_METHOD ("RAM with Aspeed Secure Boot" ,0 ,ASPEED_SECBOOT_DEVICE_RAM , aspeed_secboot_spl_ram_load_image);
The orthogonal groups of MMC/RAM vs secure/not makes it hard to read :( But it looks like your IS_ENABLED(ASPEED_SECBOOT_BL2) #ifdef-ery has missed aspeed_secboot_spl_ram_load_image()?
Andrew
Joel Stanley
maintainerRe: [PATCH u-boot v2019.04-aspeed-openbmc v3 1/4] ast2600: Allow selection of SPL boot devices
Quoted 46 lines · Andrew Jeffery
Quoted 42 lines · Joel Stanley
The AST2600 SPL can boot from a number of sources, with or without the AST2600 secure boot feature. It may be desirable to disable some of these, so put them behind the defines for the drivers that are used.
Reviewed-by Klaus Heinrich Kiwi <[email protected]>Signed-off-by Joel Stanley <[email protected]>--- arch/arm/mach-aspeed/ast2600/Kconfig | 12 ++++++++++++ arch/arm/mach-aspeed/ast2600/spl_boot.c | 9 +++++++++ 2 files changed, 21 insertions(+)arch/arm/mach-aspeed/ast2600/Kconfig +12
-0@@ -53,6 +53,18 @@ config TARGET_SLT_AST2600 endchoice +config ASPEED_SECBOOT_BL2 + bool "ASPEED secure boot BL2 support" + depends on ASPEED_AST2600 + help + Enable ASPEED's "secboot" secure boot support for verifying + the SPL's playload ("BL2"). + + Enable this is if you're using secure boot support in the AST2600 (or similar) + to verify your u-boot proper. + + Disable this is if you are using u-boot's vboot to verify u-boot. + source "board/aspeed/evb_ast2600a0/Kconfig" source "board/aspeed/evb_ast2600a1/Kconfig"source "board/aspeed/ncsi_ast2600a0/Kconfig"
arch/arm/mach-aspeed/ast2600/spl_boot.c +0
-0@@ -42,6 +42,7 @@ static int aspeed_secboot_spl_ram_load_image(struct
Quoted 8 lines
arch/arm/mach-aspeed/ast2600/spl_boot.c static int aspeed_secboot_spl_ram_load_image(struct · line 45
Quoted 4 lines
arch/arm/mach-aspeed/ast2600/spl_boot.c +0
-0spl_image_info *spl_image, }SPL_LOAD_IMAGE_METHOD ("RAM with Aspeed Secure Boot" ,0 ,ASPEED_SECBOOT_DEVICE_RAM , aspeed_secboot_spl_ram_load_image);The orthogonal groups of MMC/RAM vs secure/not makes it hard to read :( But it looks like your
IS_ENABLED(ASPEED_SECBOOT_BL2)#ifdef-ery has missedaspeed_secboot_spl_ram_load_image()?
Yeah, it could include that. I'll send a follow up once this series has gone in.
Cheers,
Joel
Andrew Jeffery
Reviewed-byRe: [PATCH u-boot v2019.04-aspeed-openbmc v3 1/4] ast2600: Allow selection of SPL boot devices
Quoted 56 lines · Joel Stanley
Quoted 46 lines · Andrew Jeffery
Quoted 42 lines · Joel Stanley
The AST2600 SPL can boot from a number of sources, with or without the AST2600 secure boot feature. It may be desirable to disable some of these, so put them behind the defines for the drivers that are used.
Reviewed-by Klaus Heinrich Kiwi <[email protected]>Signed-off-by Joel Stanley <[email protected]>--- arch/arm/mach-aspeed/ast2600/Kconfig | 12 ++++++++++++ arch/arm/mach-aspeed/ast2600/spl_boot.c | 9 +++++++++ 2 files changed, 21 insertions(+)arch/arm/mach-aspeed/ast2600/Kconfig +12
-0@@ -53,6 +53,18 @@ config TARGET_SLT_AST2600 endchoice +config ASPEED_SECBOOT_BL2 + bool "ASPEED secure boot BL2 support" + depends on ASPEED_AST2600 + help + Enable ASPEED's "secboot" secure boot support for verifying + the SPL's playload ("BL2"). + + Enable this is if you're using secure boot support in the AST2600 (or similar) + to verify your u-boot proper. + + Disable this is if you are using u-boot's vboot to verify u-boot. + source "board/aspeed/evb_ast2600a0/Kconfig" source "board/aspeed/evb_ast2600a1/Kconfig"source "board/aspeed/ncsi_ast2600a0/Kconfig"
arch/arm/mach-aspeed/ast2600/spl_boot.c +0
-0@@ -42,6 +42,7 @@ static int aspeed_secboot_spl_ram_load_image(structQuoted 8 lines
arch/arm/mach-aspeed/ast2600/spl_boot.c static int aspeed_secboot_spl_ram_load_image(struct · line 45
Quoted 4 lines
arch/arm/mach-aspeed/ast2600/spl_boot.c +0
-0spl_image_info *spl_image, }SPL_LOAD_IMAGE_METHOD ("RAM with Aspeed Secure Boot" ,0 ,ASPEED_SECBOOT_DEVICE_RAM , aspeed_secboot_spl_ram_load_image);The orthogonal groups of MMC/RAM vs secure/not makes it hard to read :( But it looks like your
IS_ENABLED(ASPEED_SECBOOT_BL2)#ifdef-ery has missedaspeed_secboot_spl_ram_load_image()?
Quoted 2 lines
Yeah, it could include that. I'll send a follow up once this series has gone in.
Okay, well, on that basis:
Joel Stanley
maintainerPATCH v3 2/4 config: ast2600: Reduce SPL image size
In reply to Joel StanleyThis modifies some features of the SPL to ensure it fits in the 64KB payload size once we enable FIT signature verification in the SPL.
We still build with thumb, as this is selected SYS_THUMB_BUILD (ie, the SPL defaults to thumb if u-boot proper is built with thumb).
The not using the arch memcpy/memset changes save 668 bytes. The tiny memset saves 52 bytes. (Anyone who wants to test the runtime impact of these changes should do so!)
The DOS_PARTITION change saves 229 bytes.
In total, this set of options reduces the binary size by 1105 bytes with GCC 10.
--
v3:
- Drop unnecessary TPL banner change
- Clarify thumb build
- Add data on size impact of each change
- Add DOS_PARTITION change to this patch
- Move FIT_TINY to a different patch; with the reordering of patches FIT verification is not yet turned on when applying this patch
--- configs/ast2600_openbmc_spl_emmc_defconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
configs/ast2600_openbmc_spl_emmc_defconfig +4 -1
@@ -2,8 +2,9 @@ CONFIG_ARM=y CONFIG_SYS_CONFIG_NAME="evb_ast2600a1_spl" CONFIG_SYS_DCACHE_OFF=y CONFIG_POSITION_INDEPENDENT=y -CONFIG_SPL_SYS_THUMB_BUILD=y CONFIG_SYS_THUMB_BUILD=y +# CONFIG_SPL_USE_ARCH_MEMCPY is not set +# CONFIG_SPL_USE_ARCH_MEMSET is not set CONFIG_SPL_LDSCRIPT="arch/$(ARCH)/mach-aspeed/ast2600/u-boot-spl.lds" CONFIG_ARCH_ASPEED=y CONFIG_SYS_TEXT_BASE=0x10000
@@ -80,6 +81,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_CMD_MTDPARTS=y +# CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_SPL_OF_CONTROL=y CONFIG_ENV_IS_IN_MMC=y
@@ -125,6 +127,7 @@ CONFIG_DM_SPI=y CONFIG_SYSRESET=y CONFIG_WDT=y CONFIG_USE_TINY_PRINTF=y +CONFIG_SPL_TINY_MEMSET=y CONFIG_TPM=y CONFIG_SPL_TPM=y # CONFIG_EFI_LOADER is not set
Signature · 1 line
2.29.2
Re: [PATCH u-boot v2019.04-aspeed-openbmc v3 2/4] config: ast2600: Reduce SPL image size
Quoted 10 lines · Joel Stanley
This modifies some features of the SPL to ensure it fits in the 64KB payload size once we enable FIT signature verification in the SPL.
We still build with thumb, as this is selected
SYS_THUMB_BUILD(ie, the SPL defaults to thumb if u-boot proper is built with thumb).The not using the arch memcpy/memset changes save 668 bytes. The tiny memset saves 52 bytes. (Anyone who wants to test the runtime impact of these changes should do so!)
Quoted 6 lines
The
DOS_PARTITIONchange saves 229 bytes.In total, this set of options reduces the binary size by 1105 bytes with GCC 10.
Signed-off-by Joel Stanley <[email protected]>
Joel Stanley
maintainerPATCH v3 3/4 ast2600: Modify SPL SRAM layout
In reply to Joel StanleyThe SRAM is 89KB on the A1 and beyond:
0x1000_0000 to 0x1000_ffff: 64KB, with parity check 0x1001_0000 to 0x1001_5fff: 24KB, w/o parity check 0x1001_6000 to 0x1001_63ff: 1KB, w/o parity check, each byte write once
Allow the image to fill the full 64KB payload size (max that secure boot supports) and place the stack at the top of the 24KB of SRAM.
---
v3: reoorder patch
include/configs/evb_ast2600a1_spl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/configs/evb_ast2600a1_spl.h +2 -2
@@ -25,8 +25,8 @@/* SPL */ #define CONFIG_SPL_TEXT_BASE 0x00000000 -#define CONFIG_SPL_MAX_SIZE 0x0000E800 -#define CONFIG_SPL_STACK 0x10010000 +#define CONFIG_SPL_MAX_SIZE 0x00010000 +#define CONFIG_SPL_STACK 0x10016000#define CONFIG_SPL_BSS_START_ADDR 0x90000000#define CONFIG_SPL_BSS_MAX_SIZE 0x00100000
Signature · 1 line
2.29.2
Joel Stanley
maintainerPATCH v3 4/4 config: ast2600: Enable FIT signature verification
In reply to Joel StanleyThis turns on FIT signature verification for the OpenBMC SPL configuration, for both the SPL and u-boot.
This enables rsa and sha algorithms for verifying the signature of the u-boot FIT when loading it.
FIT_IMAGE_TINY is selected to save approx 3KB from the image size.
---
v3: Move SPL_FIT_IMAGE_TINY to this patch
--- configs/ast2600_openbmc_spl_emmc_defconfig | 4 ++++ 1 file changed, 4 insertions(+)
configs/ast2600_openbmc_spl_emmc_defconfig +4 -0
@@ -36,6 +36,9 @@ CONFIG_ARMV7_BOOT_SEC_DEFAULT=y CONFIG_ARMV7_PSCI_NR_CPUS=2 CONFIG_NR_DRAM_BANKS=1 CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +CONFIG_SPL_FIT_SIGNATURE=y +CONFIG_SPL_LOAD_FIT=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyS4,115200n8 root=/dev/ram rw" CONFIG_USE_BOOTCOMMAND=y
@@ -49,6 +52,7 @@ CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SPL_FIT_IMAGE_TINY=y CONFIG_SPL_DM_RESET=y CONFIG_SPL_RAM_SUPPORT=y CONFIG_SPL_RAM_DEVICE=y
Signature · 1 line
2.29.2
Re: [PATCH u-boot v2019.04-aspeed-openbmc v3 4/4] config: ast2600: Enable FIT signature verification
Quoted 9 lines · Joel Stanley
This turns on FIT signature verification for the OpenBMC SPL configuration, for both the SPL and u-boot.
This enables rsa and sha algorithms for verifying the signature of the u-boot FIT when loading it.
FIT_IMAGE_TINYis selected to save approx 3KB from the image size.Signed-off-by Joel Stanley <[email protected]>
Quoted 19 lines · Joel Stanley
As part of our effort to enable secure boot in openbmc, this turns on FIT verification in the SPL and u-boot.
It adjusts the SRAM layout to accommodate the extra code size, moving the heap to the non-parity checked 24KB of SRAM.
It also modifies the way the SPL is built, including disabling features.
v3 Reorders the patches to put the size reduction changes first, and then enables signature verification to ensure the build can be bisected.
The ymodem disable patch is dropped, as we fit cleanly under the 64KB boundary with the feature enabled.
The general cleanup patch is dropped, except for the
DOS_PARTITIONchange which was added to the SPL cleanup patch. These cleanups will be posted separately at a later date.
Quoted 6 lines
Size Delta
HEAD 44054 patch 1 43442 -612 patch 2 42337 -1105 patch 3 42337 0 patch 4 63378 +21041
I've merged this series into the v2019.04-aspeed-openbmc branch and submitted a bump to gerrit:
https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/40076
Cheers,
Joel