Fix FIT hash algos in SPL (Fixes v2021.10-rc2)
Subsystems (7)
cover Fix FIT hash algos in SPL (Fixes v2021.10-rc2)
Simon and I recently worked on killing a bunch extra definitions. One of the side-effects is that certain hash algorithms won't work in SPL when used in the context of FIT verification.
For example, in FIT verification, CONFIG_IS_ENABLED(SHA256) is used (good), but there is no corresponding CONFIG_SPL_SHA256 (bad). This will always be false for SPL, hence certain "hash" algos are broken.
This series resolves the selection by replacing the broken selection with hash_lookup_algo(), which does not have the aforementioned problem. This at the very least allows 'algo = "sha256"' FIT nodes to work in SPL.
This series does not attempt to add individual SHA/CRC/MD5 configs for SPL. Hash algo selection for SPL has been problematic even before. This series is meant as an emergency fix, so it does not attempt to tackle general refactoring issues.
Alexandru Gagniuc (5):
common: Remove unused CONFIG_FIT_SHAxxx selectors
lib: Drop SHA512_ALGO in lieu of SHA512 common/spl: Drop SPL_HASH_SUPPORT in favor of SPL_HASH
image: Drop if/elseif hash selection in calculate_hash()
image: Drop IMAGE_ENABLE_{MD5, CRC32} #defines
arch/arm/mach-socfpga/Kconfig | 2 +- common/Kconfig.boot | 32 ++--------- common/Makefile | 3 +- common/image-fit.c | 45 +++++++--------- common/spl/Kconfig | 54 +------------------ ...s1021atwr_sdcard_ifc_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_nand_SECURE_BOOT_defconfig | 2 +- .../ls1043ardb_sdcard_SECURE_BOOT_defconfig | 2 +- .../ls1046ardb_sdcard_SECURE_BOOT_defconfig | 2 +- ...1088ardb_sdcard_qspi_SECURE_BOOT_defconfig | 2 +- configs/mt8516_pumpkin_defconfig | 2 +- include/configs/xilinx_zynqmp.h | 2 +- include/image.h | 23 -------- lib/Kconfig | 12 ++--- lib/Makefile | 2 +- lib/crypt/Kconfig | 2 +- lib/efi_loader/Kconfig | 2 +- lib/sha512.c | 2 - 18 files changed, 39 insertions(+), 154 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/5 common: Remove unused CONFIG_FIT_SHAxxx selectors
Originally CONFIG_FIT_SHAxxx enabled specific SHA algos for and only for has_calculate() in common/image-fit.c. However, since commit 14f061dcb1 ("image: Drop IMAGE_ENABLE_SHAxxx"),
the correct selector was changed to CONFIG_SHAxxx.
The extra "_FIT_" variants are neither used, nor needed. Remove them. One defconfig disables FIT_SHA256, which is now changed to 'SHA256'.
Note that SHA selection in SPL is broken for this exact reason. There is no corresponding SPL_SHAxxx. Fixing this is is beyond the scope of this change.
--- common/Kconfig.boot | 28 --------------------- common/spl/Kconfig | 42 -------------------------------- configs/mt8516_pumpkin_defconfig | 2 +- include/image.h | 3 --- 4 files changed, 1 insertion(+), 74 deletions(-)
common/Kconfig.boot +0 -28
@@ -35,34 +35,6 @@ config FIT_EXTERNAL_OFFSET could be put in the hole between data payload and fit image header, such as CSF data on i.MX platform. -config FIT_SHA256 - bool "Support SHA256 checksum of FIT image contents" - default y - select SHA256 - help - Enable this to support SHA256 checksum of FIT image contents. A - SHA256 checksum is a 256-bit (32-byte) hash value used to check that - the image contents have not been corrupted. - -config FIT_SHA384 - bool "Support SHA384 checksum of FIT image contents" - default n - select SHA384 - help - Enable this to support SHA384 checksum of FIT image contents. A - SHA384 checksum is a 384-bit (48-byte) hash value used to check that - the image contents have not been corrupted. Use this for the highest - security. - -config FIT_SHA512 - bool "Support SHA512 checksum of FIT image contents" - default n - select SHA512 - help - Enable this to support SHA512 checksum of FIT image contents. A - SHA512 checksum is a 512-bit (64-byte) hash value used to check that - the image contents have not been corrupted. - config FIT_FULL_CHECK bool "Do a full check of the FIT before using it" default y
common/spl/Kconfig +0 -42
48 lines not on this page · raw message
configs/mt8516_pumpkin_defconfig +1 -1
@@ -13,7 +13,7 @@ CONFIG_DEBUG_UART_CLOCK=26000000 # CONFIG_PSCI_RESET is not set CONFIG_DEBUG_UART=y CONFIG_FIT=y -# CONFIG_FIT_SHA256 is not set +# CONFIG_SHA256 is not set # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set CONFIG_DEFAULT_FDT_FILE="mt8516-pumpkin" # CONFIG_DISPLAY_BOARDINFO is not set
include/image.h +0 -3
@@ -31,9 +31,6 @@ struct fdt_region;#define IMAGE_ENABLE_OF_LIBFDT 1#define CONFIG_FIT_VERBOSE 1/* enable fit_format_{error,warning}() */ #define CONFIG_FIT_RSASSA_PSS 1 -#define CONFIG_FIT_SHA256 -#define CONFIG_FIT_SHA384 -#define CONFIG_FIT_SHA512 #define CONFIG_SHA1 #define CONFIG_SHA256 #define CONFIG_SHA384
Signature · 1 line
2.31.1
PATCH 2/5 lib: Drop SHA512_ALGO in lieu of SHA512
In reply to Alexandru GagniucSHA512_ALGO was used as a "either SHA512 or SHA384", although the implementations of these two algorithms share a majority of code.
From a Kconfig interface perspective, it makes sense to present two distinct options. This requires #ifdefing out the SHA512 implementation from sha512.c. The latter doesn't make any sense.
It's reasonable to say in Kconfig that SHA384 depends on SHA512, and seems to be the more polite way to handle the selection.
Thus, automatically select SHA512 when SHA384 is enabled.
--- arch/arm/mach-socfpga/Kconfig | 2 +- lib/Kconfig | 12 ++++-------- lib/Makefile | 2 +- lib/crypt/Kconfig | 2 +- lib/efi_loader/Kconfig | 2 +- lib/sha512.c | 2 -- 6 files changed, 8 insertions(+), 14 deletions(-)
arch/arm/mach-socfpga/Kconfig +1 -1
@@ -11,7 +11,7 @@ config SOCFPGA_SECURE_VAB_AUTH depends on TARGET_SOCFPGA_AGILEX select FIT_IMAGE_POST_PROCESS select SHA384 - select SHA512_ALGO + select SHA512 select SPL_FIT_IMAGE_POST_PROCESS help All images loaded from FIT will be authenticated by Secure Device
lib/Kconfig +4 -8
@@ -375,14 +375,9 @@ config SHA256 The SHA256 algorithm produces a 256-bit (32-byte) hash value (digest). -config SHA512_ALGO - bool "Enable SHA512 algorithm" - help - This option enables support of internal SHA512 algorithm. config SHA512 bool "Enable SHA512 support" - depends on SHA512_ALGO help This option enables support of hashing using SHA512 algorithm. The hash is calculated in software.
@@ -391,10 +386,11 @@ config SHA512 config SHA384 bool "Enable SHA384 support" - depends on SHA512_ALGO + select SHA512 help This option enables support of hashing using SHA384 algorithm. - The hash is calculated in software. + The hash is calculated in software. This is also selects SHA512, + because these implementations share the bulk of the code.. The SHA384 algorithm produces a 384-bit (48-byte) hash value (digest).
@@ -409,7 +405,7 @@ if SHA_HW_ACCEL config SHA512_HW_ACCEL bool "Enable hardware acceleration for SHA512" - depends on SHA512_ALGO + depends on SHA512 help This option enables hardware acceleration for the SHA384 and SHA512 hashing algorithms. This affects the 'hash' command and also the
lib/Makefile +1 -1
@@ -65,7 +65,7 @@ obj-$(CONFIG_$(SPL_)RSA) += rsa/ obj-$(CONFIG_HASH) += hash-checksum.o obj-$(CONFIG_SHA1) += sha1.o obj-$(CONFIG_SHA256) += sha256.o -obj-$(CONFIG_SHA512_ALGO) += sha512.o +obj-$(CONFIG_SHA512) += sha512.o obj-$(CONFIG_CRYPT_PW) += crypt/ obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
lib/crypt/Kconfig +1 -1
@@ -20,7 +20,7 @@ config CRYPT_PW_SHA256 config CRYPT_PW_SHA512 bool "Provide sha512crypt" select SHA512 - select SHA512_ALGO + select SHA512 help Enables support for the sha512crypt password-hashing algorithm. The prefix is "$6$".
lib/efi_loader/Kconfig +1 -1
@@ -323,7 +323,7 @@ config EFI_TCG2_PROTOCOL depends on TPM_V2 select SHA1 select SHA256 - select SHA512_ALGO + select SHA512 select SHA384 select SHA512 select HASH
lib/sha512.c +0 -2
@@ -320,7 +320,6 @@ void sha384_csum_wd(const unsigned char *input, unsigned int ilen,#endif -#if defined(CONFIG_SHA512 )void sha512_starts (sha512_context * ctx) { ctx->state[0 ] =SHA512_H0 ;
@@ -381,4 +380,3 @@ void sha512_csum_wd(const unsigned char *input, unsigned int ilen,sha512_finish (&ctx, output); } -#endif
Signature · 1 line
2.31.1
PATCH 3/5 common/spl: Drop SPL_HASH_SUPPORT in favor of SPL_HASH
In reply to Alexandru GagniucBoth these configs exist. Stick to using CONFIG_SPL_HASH, and drop all references to CONFIG_SPL_HASH_SUPPORT.
--- common/Kconfig.boot | 2 +- common/Makefile | 3 +-- common/spl/Kconfig | 12 +----------- configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_nand_SECURE_BOOT_defconfig | 2 +- configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig | 2 +- configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig | 2 +- configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig | 2 +- include/configs/xilinx_zynqmp.h | 2 +- 9 files changed, 9 insertions(+), 20 deletions(-)
common/Kconfig.boot +1 -1
@@ -157,7 +157,7 @@ config SPL_FIT_SIGNATURE select FIT_SIGNATURE select SPL_FIT select SPL_CRYPTO - select SPL_HASH_SUPPORT + select SPL_HASH imply SPL_RSA imply SPL_RSA_VERIFY select SPL_IMAGE_SIGN_INFO
common/Makefile +1 -2
@@ -8,7 +8,7 @@ ifndef CONFIG_SPL_BUILD obj-y += init/ obj-y += main.o obj-y += exports.o -obj-$(CONFIG_HASH) += hash.o +obj-$(CONFIG_$(SPL_)HASH) += hash.o obj-$(CONFIG_HUSH_PARSER) += cli_hush.o obj-$(CONFIG_AUTOBOOT) += autoboot.o
@@ -66,7 +66,6 @@ ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_DFU obj-$(CONFIG_DFU_OVER_USB) += dfu.o endif -obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_TPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
common/spl/Kconfig +1 -11
@@ -477,16 +477,6 @@ config SPL_CRYPTO this option to build the drivers in drivers/crypto as part of an SPL build. -config SPL_HASH_SUPPORT - bool "Support hashing drivers" - select SHA1 - select SHA256 - help - Enable hashing drivers in SPL. These drivers can be used to - accelerate secure boot processing in secure applications. Enable - this option to build system-specific drivers for hash acceleration - as part of an SPL build. - config TPL_HASH_SUPPORT bool "Support hashing drivers in TPL" depends on TPL
@@ -1193,7 +1183,7 @@ config SPL_USB_ETHER config SPL_DFU bool "Support DFU (Device Firmware Upgrade)" - select SPL_HASH_SUPPORT + select SPL_HASH select SPL_DFU_NO_RESET depends on SPL_RAM_SUPPORT help
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig +1 -1
@@ -31,7 +31,7 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xe8 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH_SUPPORT=y +CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
configs/ls1043ardb_nand_SECURE_BOOT_defconfig +1 -1
@@ -27,7 +27,7 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xf0 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH_SUPPORT=y +CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_SPL_NAND_SUPPORT=y
configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig +1 -1
@@ -27,7 +27,7 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x110 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH_SUPPORT=y +CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_SPL_WATCHDOG=y
configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig +1 -1
@@ -27,7 +27,7 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x110 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH_SUPPORT=y +CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig +1 -1
@@ -33,7 +33,7 @@ CONFIG_MISC_INIT_R=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x8b0 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH_SUPPORT=y +CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
include/configs/xilinx_zynqmp.h +1 -1
@@ -258,7 +258,7 @@#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_DFU )# define CONFIG_SPL_ENV_SUPPORT -# define CONFIG_SPL_HASH_SUPPORT +# define CONFIG_SPL_HASH # define CONFIG_ENV_MAX_ENTRIES 10#endif
Signature · 1 line
2.31.1
Re: [PATCH 3/5] common/spl: Drop SPL_HASH_SUPPORT in favor of SPL_HASH
Quoted 4 lines · Alexandru Gagniuc
Both these configs exist. Stick to using
CONFIG_SPL_HASH, and drop all references toCONFIG_SPL_HASH_SUPPORT.Signed-off-by Alexandru Gagniuc <[email protected]>
This isn't quite enough and causes a bunch of platforms like ls1043ardb_sdcard_SECURE_BOOT to blow up. I'm adding the following and will update the commit message as that fixes at least the first set of problems I've observed:
board/freescale/common/Kconfig +1 -0
@@ -4,6 +4,7 @@ config CHAIN_OF_TRUST imply CMD_HASH if ARM select FSL_CAAM select SPL_BOARD_INIT if (ARM && SPL) + select SPL_HASH if (ARM && SPL) select SHA_HW_ACCEL select SHA_PROG_HW_ACCEL select ENV_IS_NOWHERE
common/Makefile +1 -2
@@ -8,7 +8,6 @@ ifndef CONFIG_SPL_BUILD obj-y += init/ obj-y += main.o obj-y += exports.o -obj-$(CONFIG_$(SPL_)HASH) += hash.o obj-$(CONFIG_HUSH_PARSER) += cli_hush.o obj-$(CONFIG_AUTOBOOT) += autoboot.o
@@ -66,7 +65,6 @@ ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_DFU obj-$(CONFIG_DFU_OVER_USB) += dfu.o endif -obj-$(CONFIG_TPL_HASH_SUPPORT) += hash.o obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
@@ -104,6 +102,7 @@ endif endif obj-y += image.o +obj-$(CONFIG_$(SPL_TPL_)HASH) += hash.o obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
common/spl/Kconfig +0 -11
@@ -477,17 +477,6 @@ config SPL_CRYPTO this option to build the drivers in drivers/crypto as part of an SPL build. -config TPL_HASH_SUPPORT - bool "Support hashing drivers in TPL" - depends on TPL - select SHA1 - select SHA256 - help - Enable hashing drivers in SPL. These drivers can be used to - accelerate secure boot processing in secure applications. Enable - this option to build system-specific drivers for hash acceleration - as part of an SPL build. - config SPL_DMA bool "Support DMA drivers" help
configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig +0 -1
@@ -31,7 +31,6 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xe8 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
configs/ls1043ardb_nand_SECURE_BOOT_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xf0 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_SPL_NAND_SUPPORT=y
configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x110 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y CONFIG_SPL_WATCHDOG=y
configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_SPL_FSL_PBL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x110 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
configs/ls1088ardb_sdcard_qspi_SECURE_BOOT_defconfig +0 -1
@@ -33,7 +33,6 @@ CONFIG_MISC_INIT_R=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x8b0 CONFIG_SPL_CRYPTO=y -CONFIG_SPL_HASH=y CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C=y CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
lib/Makefile +1 -1
@@ -87,7 +87,7 @@ endif ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o -obj-$(CONFIG_$(SPL_TPL_)HASH_SUPPORT) += crc16.o +obj-$(CONFIG_$(SPL_TPL_)HASH) += crc16.o obj-y += net_utils.o endif obj-$(CONFIG_ADDR_MAP) += addr_map.o
Signature · 1 line
Tom
Re: [PATCH 3/5] common/spl: Drop SPL_HASH_SUPPORT in favor of SPL_HASH
In reply to Alexandru GagniucQuoted 4 lines · Alexandru Gagniuc
Both these configs exist. Stick to using
CONFIG_SPL_HASH, and drop all references toCONFIG_SPL_HASH_SUPPORT.Signed-off-by Alexandru Gagniuc <[email protected]>
In addition to what I sent already this also needs:
cmd/mvebu/Kconfig +1 -0
@@ -3,6 +3,7 @@ depends on ARCH_MVEBU config CMD_MVEBU_BUBT bool "bubt" + select SHA256 default n help bubt - Burn a u-boot image to flash
Signature · 1 line
Tom
Re: [PATCH 3/5] common/spl: Drop SPL_HASH_SUPPORT in favor of SPL_HASH
In reply to Alexandru GagniucQuoted 4 lines · Alexandru Gagniuc
Both these configs exist. Stick to using
CONFIG_SPL_HASH, and drop all references toCONFIG_SPL_HASH_SUPPORT.Signed-off-by Alexandru Gagniuc <[email protected]>
[snip]
Quoted 7 lines
common/spl/Kconfig +0
-0@@ -477,16 +477,6 @@ config SPL_CRYPTO this option to build the drivers in drivers/crypto as part of an SPL build.
common/spl/Kconfig config SPL_CRYPTO · line 488
Quoted 10 lines
common/spl/Kconfig +0
-9-config SPL_HASH_SUPPORT - bool "Support hashing drivers" - select SHA1 - select SHA256 - help - Enable hashing drivers in SPL. These drivers can be used to - accelerate secure boot processing in secure applications. Enable - this option to build system-specific drivers for hash acceleration - as part of an SPL build.
There's a lot more work to be done around platforms that enabled sha1/sha256 this way and confirming that it was actually unusable code. For example, (as it was where I stopped paging at in less just now) ls1043aqds_nor_ddr3 drops sha256 and md5 algorithm support, I suspect because of this hunk, but could be some other part of the series. Using buildman's --show-sizes --bloat can be really handy to see when a patch drops out a bunch of code, or adds it in.
Signature · 1 line
Tom
PATCH 4/5 image: Drop if/elseif hash selection in calculate_hash()
In reply to Alexandru Gagniuccalculate_hash() would try to select the appropriate hashing function by a if/elseif contruct. But that is exactly why hash_lookup_algo() exists, so use it instead.
This does mean that we now have to 'select HASH' to make sure we get the hash_lookup_algo() symbol. However, the change makes sense because even basic FITs will have to deal with "hash" nodes.
My only concern is that the 'select SPL_HASH' might cause some platform to grow above its SPL size allowance
--- common/Kconfig.boot | 2 ++ common/image-fit.c | 45 +++++++++++++++++++-------------------------- 2 files changed, 21 insertions(+), 26 deletions(-)
common/Kconfig.boot +2 -0
@@ -13,6 +13,7 @@ config FIT bool "Support Flattened Image Tree" select MD5 select SHA1 + select HASH help This option allows you to boot the new uImage structure, Flattened Image Tree. FIT is formally a FDT, which can include
@@ -133,6 +134,7 @@ if SPL config SPL_FIT bool "Support Flattened Image Tree within SPL" depends on SPL + select SPL_HASH select SPL_OF_LIBFDT config SPL_FIT_PRINT
common/image-fit.c +19 -26
62 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH 4/5] image: Drop if/elseif hash selection in calculate_hash()
Quoted 4 lines · Alexandru Gagniuc
calculate_hash()would try to select the appropriate hashing function by a if/elseif contruct. But that is exactly whyhash_lookup_algo()exists, so use it instead.
Quoted 8 lines
This does mean that we now have to 'select HASH' to make sure we get the
hash_lookup_algo()symbol. However, the change makes sense because even basic FITs will have to deal with "hash" nodes.My only concern is that the 'select
SPL_HASH' might cause some platform to grow above its SPL size allowanceSigned-off-by Alexandru Gagniuc <[email protected]>
Two problems. The easy to fix problem is that we need:
commit 7dbac59f6655e928d11708948f34e779b03bb3d2
Author: Alexandru Gagniuc <[email protected]> Date: Mon Aug 23 19:53:19 2021 -0500
image: Drop if/elseif hash selection in calculate_hash()
calculate_hash() would try to select the appropriate hashing function by a if/elseif contruct. But that is exactly why hash_lookup_algo() exists, so use it instead.
This does mean that we now have to 'select HASH' to make sure we get the hash_lookup_algo() symbol. However, the change makes sense because even basic FITs will have to deal with "hash" nodes.
My only concern is that the 'select SPL_HASH' might cause some platform to grow above its SPL size allowance
drivers/crypto/fsl/Kconfig +1 -0
@@ -1,6 +1,7 @@ config FSL_CAAM bool "Freescale Crypto Driver Support" select SHA_HW_ACCEL + select SPL_CRYPTO if (ARM && SPL) imply CMD_HASH help Enables the Freescale's Cryptographic Accelerator and Assurance
to fix a handful of platforms. The harder to fix problem is that changing how the algorithm is selected seems to break mkimage on for example xilinx_zynqmp_virt. Please fix and resubmit, and run it all past CI as well. Thanks!
Signature · 1 line
Tom
PATCH 5/5 image: Drop IMAGE_ENABLE_{MD5, CRC32} #defines
In reply to Alexandru GagniucThese are no longer used, so drop them.
--- include/image.h | 20 -------------------- 1 file changed, 20 deletions(-)
include/image.h +0 -20
@@ -59,26 +59,6 @@ struct fdt_region;#include <hash.h> #include <linux/libfdt.h> #include <fdt_support.h> -# ifdef CONFIG_SPL_BUILD -# ifdef CONFIG_SPL_CRC32 -# define IMAGE_ENABLE_CRC32 1 -# endif -# ifdef CONFIG_SPL_MD5 -# define IMAGE_ENABLE_MD5 1 -# endif -# else -# define IMAGE_ENABLE_CRC32 1 -# define IMAGE_ENABLE_MD5 1 -# endif - -#ifndef IMAGE_ENABLE_CRC32 -#define IMAGE_ENABLE_CRC32 0 -#endif - -#ifndef IMAGE_ENABLE_MD5 -#define IMAGE_ENABLE_MD5 0 -#endif -#endif /* IMAGE_ENABLE_FIT */ #ifdef CONFIG_SYS_BOOT_GET_CMDLINE
Signature · 1 line
2.31.1