vbe: Series part G
cover vbe: Series part G
This includes the VBE ABrec (A/B/recovery) implementation as well as a number of patches needed to make it work:
- marking some code as used by SPL_RELOC
- selection of images from a FIT based on the boot phase
- removal of unwanted hash code which increases code-size too much
- a few Kconfig-related additions for VPL
Note: The goal for the next series (part H) is to enable VBE on rk3399-generic, i.e. able to boot on multiple rk3399-based boards with only the TPL phase being different for each board.
Simon Glass (19):
mbedtls: Add SHA symbols for VPL
sandbox: Update sandbox_vpl to select sha1 and sha256
mmc: Allow controlling DM_MMC for VPL builds
lib: Allow crc16 code to be dropped
spl: Adjust debugging and xPL symbols
spl: Avoid including hash algorithms which are not wanted
spl: Support selecting images based on phase in simple FIT
vbe: Support selecting images based on phase in FIT
spl: Allow spl_load() to be controlled in any xPL phase
spl: Provide a way to mark code needed for relocation
lib: Mark crc8 as relocation code
lib: Mark lz4 as relocation code
lib: Mark memcpy() and memmove() as relocation code
lib: Mark gunzip as relocation code
vbe: Support providing a linker script
vbe: Provide VPL binman-symbols for the next phase
vbe: Tidy up a few comments
vbe: Allow VBE to disable adding loadables to the FDT
vbe: Add an implementation of VBE-ABrec
MAINTAINERS | 7 + boot/Kconfig | 73 +++++++++ boot/Makefile | 4 + boot/image-fit.c | 29 ++-- boot/vbe_abrec.c | 83 ++++++++++ boot/vbe_abrec.h | 115 ++++++++++++++ boot/vbe_abrec_fw.c | 276 +++++++++++++++++++++++++++++++++ boot/vbe_common.c | 24 +-- boot/vbe_common.h | 43 +++++ common/hash.c | 17 +- common/spl/Kconfig.vpl | 13 ++ common/spl/spl.c | 26 +++- common/spl/spl_fit.c | 40 +++-- common/spl/spl_reloc.c | 2 +- configs/sandbox_vpl_defconfig | 2 + drivers/mmc/dw_mmc.c | 4 +- include/asm-generic/sections.h | 16 ++ include/spl.h | 19 ++- include/spl_load.h | 9 +- include/vbe.h | 21 +++ lib/Kconfig | 10 ++ lib/Makefile | 11 +- lib/crc8.c | 5 +- lib/gunzip.c | 9 +- lib/lz4.c | 37 +++-- lib/lz4_wrapper.c | 2 +- lib/mbedtls/Kconfig | 40 +++++ lib/string.c | 5 +- lib/zlib/inflate.c | 18 ++- tools/Kconfig | 5 + 30 files changed, 879 insertions(+), 86 deletions(-) create mode 100644 boot/vbe_abrec.c create mode 100644 boot/vbe_abrec.h create mode 100644 boot/vbe_abrec_fw.c
Signature · 1 line
2.43.0
PATCH 1/19 mbedtls: Add SHA symbols for VPL
Add some symbols for supporting SHA1 etc. for VPL.
---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
lib/mbedtls/Kconfig +40 -0
@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library. + +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL + endif # LEGACY_CRYPTO_BASIC config LEGACY_CRYPTO_CERT
Signature · 1 line
2.43.0
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.
lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +
Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/
My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Regards,
Raymond
Quoted 6 lines
lib/mbedtls/Kconfig +0
-1endif # LEGACY_CRYPTO_BASIC config LEGACY_CRYPTO_CERT --2.43.0
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
Quoted 65 lines · Raymond Mao
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/
Quoted 3 lines
My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Actually, can you work on top of this one please Raymond? I tried yours out now and it results in ~4KiB growth so something isn't right there, but Simon's is fine atm. Thanks!
Signature · 1 line
Tom
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
Hi Tom,
Quoted 67 lines · Tom Rini
Quoted 65 lines · Raymond Mao
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/
Quoted 7 lines
Quoted 3 lines
My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Actually, can you work on top of this one please Raymond? I tried yours out now and it results in ~4KiB growth so something isn't right there, but Simon's is fine atm. Thanks!
Sorry I didn't reply in time....I'm happy with either.
Regards,
SImon
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
Hi Simon,
Quoted 75 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Raymond Mao
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Quoted 6 lines
Quoted 3 lines
Actually, can you work on top of this one please Raymond? I tried yours out now and it results in ~4KiB growth so something isn't right there, but Simon's is fine atm. Thanks!
Sorry I didn't reply in time....I'm happy with either.
If you are ready to merge, no worries, please go ahead and I can rebase on yours.
Raymond
Quoted 2 lines
Regards,
SImon
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
In reply to Tom RiniHi Tom,
Quoted 67 lines · Tom Rini
Quoted 65 lines · Raymond Mao
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/
Quoted 8 lines
Quoted 3 lines
My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Actually, can you work on top of this one please Raymond? I tried yours out now and it results in ~4KiB growth so something isn't right there, but Simon's is fine atm. Thanks!
The reason is that I set MbedTLS crypto as default when MBEDTLS_LIB is selected, which sounds more logically reasonable.
If users enable MBEDTLS_LIB_CRYPTO_ALT at the same time with MBEDTLS_LIB, which means using U-Boot legacy crypto as MbedTLS alternatives, the growth should be gone.
Do you want me to select MBEDTLS_LIB_CRYPTO_ALT for qemu or should we leave this for the user to determine?
Regards,
Raymond
Quoted 2 lines
--
Tom
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
Quoted 78 lines · Raymond Mao
Hi Tom,
Quoted 67 lines · Tom Rini
Quoted 65 lines · Raymond Mao
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/Quoted 8 lines
Quoted 3 lines
My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Actually, can you work on top of this one please Raymond? I tried yours out now and it results in ~4KiB growth so something isn't right there, but Simon's is fine atm. Thanks!
Quoted 8 lines
The reason is that I set MbedTLS crypto as default when
MBEDTLS_LIBis selected, which sounds more logically reasonable.
If users enableMBEDTLS_LIB_CRYPTO_ALTat the same time withMBEDTLS_LIB, which means using U-Boot legacy crypto as MbedTLS alternatives, the growth should be gone.Do you want me to select
MBEDTLS_LIB_CRYPTO_ALTfor qemu or should we leave this for the user to determine?
No, I guess you're right, that's fine. Still better to do this on top of Simon's series however please, thanks.
Signature · 1 line
Tom
Re: [PATCH 01/19] mbedtls: Add SHA symbols for VPL
Hi Tom,
Quoted 86 lines · Tom Rini
Quoted 84 lines · Raymond Mao
Hi Tom,
Quoted 67 lines · Tom Rini
Quoted 65 lines · Raymond Mao
Hi Simon,
Quoted 47 lines · Simon Glass
Add some symbols for supporting SHA1 etc. for VPL.
Signed-off-by Simon Glass <[email protected]>---
lib/mbedtls/Kconfig | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)lib/mbedtls/Kconfig +30
-0@@ -112,6 +112,46 @@ config SPL_MD5_LEGACY endif # SPL +if VPL + +config VPL_SHA1_LEGACY + bool "Enable SHA1 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA1 + help + This option enables support of hashing using SHA1 algorithm + with legacy crypto library. + +config VPL_SHA256_LEGACY + bool "Enable SHA256 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA256 + help + This option enables support of hashing using SHA256 algorithm + with legacy crypto library. + +config VPL_SHA512_LEGACY + bool "Enable SHA512 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA512 + help + This option enables support of hashing using SHA512 algorithm + with legacy crypto library. + +config VPL_SHA384_LEGACY + bool "Enable SHA384 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_SHA384 + select VPL_SHA512_LEGACY + help + This option enables support of hashing using SHA384 algorithm + with legacy crypto library.lib/mbedtls/Kconfig config SPL_MD5_LEGACY · line 154
Quoted 10 lines
lib/mbedtls/Kconfig +10
-0+ +config VPL_MD5_LEGACY + bool "Enable MD5 support in VPL with legacy crypto library" + depends on LEGACY_CRYPTO_BASIC && VPL_MD5 + help + This option enables support of hashing using MD5 algorithm + with legacy crypto library. + +endif # VPL +Do you mind rebasing this patch on top of my series below?
https://lore.kernel.org/u-boot/[email protected]/Quoted 8 lines
Quoted 3 lines
My one has refactored the entire mbedtls kconfig submenu, makefile and default config file to adapt with XPL, so that users can have independent config options in both U-Boot proper and XPLs.
Actually, can you work on top of this one please Raymond? I tried yours out now and it results in ~4KiB growth so something isn't right there, but Simon's is fine atm. Thanks!
The reason is that I set MbedTLS crypto as default when
MBEDTLS_LIBis selected, which sounds more logically reasonable.
If users enableMBEDTLS_LIB_CRYPTO_ALTat the same time withMBEDTLS_LIB, which means using U-Boot legacy crypto as MbedTLS alternatives, the growth should be gone.
Quoted 6 lines
Quoted 2 lines
Do you want me to select
MBEDTLS_LIB_CRYPTO_ALTfor qemu or should we leave this for the user to determine?No, I guess you're right, that's fine. Still better to do this on top of Simon's series however please, thanks.
I have rebased my one on Simon's and v2 was posted:
https://lore.kernel.org/u-boot/[email protected]/
On top of that I added the ones for TPL as well.
Regards,
Raymond
Quoted 2 lines
--
Tom
PATCH 2/19 sandbox: Update sandbox_vpl to select sha1 and sha256
In reply to Simon GlassThese algorithms are used in VPL, so enable them.
---
configs/sandbox_vpl_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/sandbox_vpl_defconfig +2 -0
@@ -252,6 +252,8 @@ CONFIG_FS_CBFS=y CONFIG_FS_CRAMFS=y # CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_CMD_DHRYSTONE=y +CONFIG_VPL_SHA1_LEGACY=y +CONFIG_VPL_SHA256_LEGACY=y CONFIG_RSA_VERIFY_WITH_PKEY=y CONFIG_TPM=y CONFIG_ZSTD=y
Signature · 1 line
2.43.0
PATCH 3/19 mmc: Allow controlling DM_MMC for VPL builds
In reply to Simon GlassVPL may want to use driver model for MMC even if TPL does not. Update the rule in this driver to support that.
---
drivers/mmc/dw_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/dw_mmc.c +2 -2
@@ -724,7 +724,7 @@ static int dwmci_init(struct mmc *mmc)return 0 ; } -#ifdef CONFIG_DM_MMC +#if CONFIG_IS_ENABLED (DM_MMC )int dwmci_probe (struct udevice *dev) {struct mmc *mmc =mmc_get_mmc_dev (dev);
@@ -749,7 +749,7 @@ void dwmci_setup_cfg(struct mmc_config *cfg, struct dwmci_host *host, u32 max_clk, u32 min_clk) { cfg->name = host->name; -#ifndef CONFIG_DM_MMC +#if !CONFIG_IS_ENABLED (DM_MMC ) cfg->ops = &dwmci_ops;#endif cfg->f_min = min_clk;
Signature · 1 line
2.43.0
Re: [PATCH 03/19] mmc: Allow controlling DM_MMC for VPL builds
Quoted 4 lines · Simon Glass
VPL may want to use driver model for MMC even if TPL does not. Update the rule in this driver to support that.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH 4/19 lib: Allow crc16 code to be dropped
In reply to Simon GlassThis code is not necessarily needed in VPL, even if SPL uses it, so adjust the rules to allow it to be dropped.
Do the same for the hash API.
---
common/hash.c | 17 +++++++++++------ lib/Kconfig | 10 ++++++++++ lib/Makefile | 3 +-- tools/Kconfig | 5 +++++ 4 files changed, 27 insertions(+), 8 deletions(-)
common/hash.c +11 -6
@@ -143,7 +143,8 @@ static int __maybe_unused hash_finish_sha512(struct hash_algo *algo, void *ctx,return 0 ; } -static int hash_init_crc16_ccitt (struct hash_algo *algo,void **ctxp) +static int __maybe_unused hash_init_crc16_ccitt (struct hash_algo *algo, +void **ctxp) {uint16_t *ctx =malloc (sizeof (uint16_t )); *ctx =0 ;
@@ -151,16 +152,18 @@ static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp)return 0 ; } -static int hash_update_crc16_ccitt (struct hash_algo *algo,void *ctx, -const void *buf,unsigned int size, -int is_last) +static int __maybe_unused hash_update_crc16_ccitt (struct hash_algo *algo, +void *ctx,const void *buf, +unsigned int size, +int is_last) { *((uint16_t *)ctx) =crc16_ccitt (*((uint16_t *)ctx), buf, size);return 0 ; } -static int hash_finish_crc16_ccitt (struct hash_algo *algo,void *ctx, -void *dest_buf,int size) +static int __maybe_unused hash_finish_crc16_ccitt (struct hash_algo *algo, +void *ctx,void *dest_buf, +int size) {if (size < algo->digest_size)return -1 ;
@@ -295,6 +298,7 @@ static struct hash_algo hash_algo[] = {#endif },#endif +#if CONFIG_IS_ENABLED (CRC16 ) { .name = "crc16-ccitt", .digest_size = 2,
@@ -304,6 +308,7 @@ static struct hash_algo hash_algo[] = { .hash_update = hash_update_crc16_ccitt, .hash_finish = hash_finish_crc16_ccitt, }, +#endif #if CONFIG_IS_ENABLED (CRC8 ) &&IS_ENABLED (CONFIG_HASH_CRC8 ) { .name = "crc8",
lib/Kconfig +10 -0
@@ -737,6 +737,16 @@ config VPL_CRC8 checksum with feedback to produce an 8-bit result. The code is small and it does not require a lookup table (unlike CRC32). +config CRC16 + bool "Support CRC16" + default y + help + Enables CRC16 support. This is normally required. Two algorithms are + provided: + + - CCITT, with a polynomical x^16 + x^12 + x^5 + 1 + - standard, with polynomial x^16 + x^15 + x^2 + 1 (0x8005) + config SPL_CRC16 bool "Support CRC16 in SPL" depends on SPL
lib/Makefile +1 -2
@@ -35,8 +35,6 @@ obj-$(CONFIG_CIRCBUF) += circbuf.o endif obj-y += crc8.o -obj-y += crc16.o -obj-y += crc16-ccitt.o obj-$(CONFIG_ERRNO_STR) += errno_str.o obj-$(CONFIG_FIT) += fdtdec_common.o obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
@@ -66,6 +64,7 @@ endif obj-$(CONFIG_$(PHASE_)CRC8) += crc8.o obj-$(CONFIG_$(PHASE_)CRC16) += crc16.o +obj-$(CONFIG_$(PHASE_)CRC16) += crc16-ccitt.o obj-y += crypto/
tools/Kconfig +5 -0
@@ -9,6 +9,11 @@ config MKIMAGE_DTC_PATH some cases the system dtc may not support all required features and the path to a different version should be given here. +config TOOLS_CRC16 + def_bool y + help + Enable CRC32 support in the tools builds + config TOOLS_CRC32 def_bool y help
Signature · 1 line
2.43.0
Re: [PATCH 04/19] lib: Allow crc16 code to be dropped
Quoted 6 lines · Simon Glass
This code is not necessarily needed in VPL, even if SPL uses it, so adjust the rules to allow it to be dropped.
Do the same for the hash API.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH 5/19 spl: Adjust debugging and xPL symbols
In reply to Simon GlassThe size of some malloc() fields has reduced on 64-bit machines, but the spl_reloc code was not updated. Fix this to avoid a compiler warning.
Also update for the new xPL naming.
---
common/spl/spl_reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl_reloc.c +1 -1
@@ -154,7 +154,7 @@ int spl_reloc_jump(struct spl_image_info *image, spl_jump_to_image_t jump)rcode_func loader;int ret; -log_debug ("malloc usage %lx bytes (%ld KB of %d KB)\n" , gd->malloc_ptr, +log_debug ("malloc usage %x bytes (%d KB of %d KB)\n" , gd->malloc_ptr, gd->malloc_ptr /1024 ,CONFIG_VAL (SYS_MALLOC_F_LEN ) /1024 );if (*image->stack_prot !=STACK_PROT_VALUE ) {
Signature · 1 line
2.43.0
Re: [PATCH 05/19] spl: Adjust debugging and xPL symbols
Quoted 5 lines · Simon Glass
The size of some
malloc()fields has reduced on 64-bit machines, but thespl_reloccode was not updated. Fix this to avoid a compiler warning.Also update for the new xPL naming.
There's no naming change made, otherwise:
Quoted 23 lines
Signed-off-by Simon Glass <[email protected]>---
common/spl/spl_reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)common/spl/spl_reloc.c +1
-1@@ -154,7 +154,7 @@ int spl_reloc_jump(struct spl_image_info *image, spl_jump_to_image_t jump)rcode_func loader;int ret; -log_debug ("malloc usage %lx bytes (%ld KB of %d KB)\n" , gd->malloc_ptr, +log_debug ("malloc usage %x bytes (%d KB of %d KB)\n" , gd->malloc_ptr, gd->malloc_ptr /1024 ,CONFIG_VAL (SYS_MALLOC_F_LEN ) /1024 );if (*image->stack_prot !=STACK_PROT_VALUE ) {Signature · 1 line
2.43.0
Signature · 1 line
Tom
PATCH 6/19 spl: Avoid including hash algorithms which are not wanted
In reply to Simon GlassUpdate the build rule so that hash algorithms are only included in an SPL build if they are requested. This helps to reduce code size.
---
lib/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
lib/Makefile +4 -4
@@ -74,10 +74,10 @@ obj-$(CONFIG_$(XPL_)RSA) += rsa/ obj-$(CONFIG_HASH) += hash-checksum.o obj-$(CONFIG_BLAKE2) += blake2/blake2b.o -obj-$(CONFIG_$(XPL_)MD5_LEGACY) += md5.o -obj-$(CONFIG_$(XPL_)SHA1_LEGACY) += sha1.o -obj-$(CONFIG_$(XPL_)SHA256_LEGACY) += sha256.o -obj-$(CONFIG_$(XPL_)SHA512_LEGACY) += sha512.o +obj-$(CONFIG_$(PHASE_)MD5_LEGACY) += md5.o +obj-$(CONFIG_$(PHASE_)SHA1_LEGACY) += sha1.o +obj-$(CONFIG_$(PHASE_)SHA256_LEGACY) += sha256.o +obj-$(CONFIG_$(PHASE_)SHA512_LEGACY) += sha512.o obj-$(CONFIG_CRYPT_PW) += crypt/ obj-$(CONFIG_$(XPL_)ASN1_DECODER_LEGACY) += asn1_decoder.o
Signature · 1 line
2.43.0
Re: [PATCH 06/19] spl: Avoid including hash algorithms which are not wanted
Quoted 4 lines · Simon Glass
Update the build rule so that hash algorithms are only included in an SPL build if they are requested. This helps to reduce code size.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH 7/19 spl: Support selecting images based on phase in simple FIT
In reply to Simon GlassAt present the simple FIT-loader always loads images, ignoring whether they are intended for the next phase or not.
VBE packages up several images in the same FIT, some destined for VPL and some for SPL. Add logic to check the phase before loading the image. Return -EPERM in that case and handle it gracefully.
Fix a unnecessary re-computation of read_offset while here.
---
common/spl/spl_fit.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-)
common/spl/spl_fit.c +27 -7
@@ -199,7 +199,9 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,* the image gets loaded to the address pointed to by the * load_addr member in this struct, if load_addr is not 0 * -* Return: 0 on success or a negative error number. +* Return: 0 on success, -EPERM if this image is not the correct phase +* (for CONFIG_BOOTMETH_VBE_SIMPLE_FW), or another negative error number on +* other error. */ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset, const struct spl_fit_info *ctx, int node,
@@ -218,6 +220,25 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,const void *fit = ctx->fit;bool external_data = false; +log_debug ("starting\n" ); +if (CONFIG_IS_ENABLED (BOOTMETH_VBE ) && +xpl_get_phase (info) !=IH_PHASE_NONE ) { +enum image_phase_t phase; +int ret; + + ret =fit_image_get_phase (fit, node, &phase); +/* if the image is for any phase, let's use it */ +if (ret == -ENOENT || phase ==xpl_get_phase (info)) { +log_debug ("found\n" ); + }else if (ret <0 ) { +log_debug ("err=%d\n" , ret); +return ret; + }else { +log_debug ("- phase mismatch, skipping this image\n" ); +return -EPERM ; + } + } +if (IS_ENABLED (CONFIG_SPL_FPGA ) || (IS_ENABLED (CONFIG_SPL_OS_BOOT ) &&spl_decompression_enabled ())) {if (fit_image_get_type (fit, node, &type))
@@ -278,10 +299,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,log_debug ("reading from offset %x / %lx size %lx to %p: " , offset, read_offset, size, src_ptr); -if (info->read (info, - fit_offset + -get_aligned_image_offset (info, offset), size, - src_ptr) < length) +if (info->read (info, read_offset, size, src_ptr) < length)return -EIO ; debug("External data: dst=%p, offset=%x, size=%lx\n",
@@ -456,7 +474,9 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image, image_info.load_addr = (ulong )tmpbuffer; ret =load_simple_fit (info, offset, ctx, node, &image_info); -if (ret <0 ) +if (ret == -EPERM ) +continue ; +else if (ret <0 )break ;/* Make room in FDT for changes from the overlay */
@@ -817,7 +837,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, image_info.load_addr =0 ; ret =load_simple_fit (info, offset, &ctx, node, &image_info); -if (ret <0 ) { +if (ret <0 && ret != -EPERM ) {printf ("%s: can't load image loadables index %d (ret = %d)\n" , __func__, index, ret);return ret;
Signature · 1 line
2.43.0
PATCH 8/19 vbe: Support selecting images based on phase in FIT
In reply to Simon GlassWith SPL we want to specify the phase of the image to be loaded. Add support for this.
This is the implementation of a FIT feature added to the spec a few years ago and entails a small code-size increase, about 70 bytes on Thumb2.
---
boot/image-fit.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
boot/image-fit.c +19 -10
@@ -1908,24 +1908,30 @@ int fit_conf_get_prop_node(const void *fit, int noffset, const char *prop_name, count =fit_conf_get_prop_node_count (fit, noffset, prop_name);if (count <0 )return count; +log_debug ("looking for %s (%s, image-count %d):\n" , prop_name, +genimg_get_phase_name (image_ph_phase (sel_phase)), count);/* check each image in the list */ for (i =0 ; i < count; i++) { -enum image_phase_t phase; +enum image_phase_t phase =IH_PHASE_NONE ;int ret, node; node =fit_conf_get_prop_node_index (fit, noffset, prop_name, i); ret =fit_image_get_phase (fit, node, &phase); +log_debug ("- %s (%s): " ,fdt_get_name (fit, node,NULL ), +genimg_get_phase_name (phase));/* if the image is for any phase, let's use it */ -if (ret == -ENOENT ) +if (ret == -ENOENT || phase == sel_phase) { +log_debug ("found\n" );return node; -else if (ret <0 ) + }else if (ret <0 ) { +log_debug ("err=%d\n" , ret);return ret; - -if (phase == sel_phase) -return node; + } +log_debug ("no match\n" ); } +log_debug ("- not found\n" );return -ENOENT ; }
@@ -2013,13 +2019,15 @@ int fit_get_node_from_config(struct bootm_headers *images, }/** -* fit_get_image_type_property() - get property name for IH_TYPE_... +* fit_get_image_type_property() - get property name for sel_phase * * Return: the properly name where we expect to find the image in the * config node */ -static const char *fit_get_image_type_property (int type) +static const char *fit_get_image_type_property (int ph_type) { +int type =image_ph_type (ph_type); +/* * This is sort-of available in the uimage_type[] table in image.c * but we don't have access to the short name, and "fdt" is different
@@ -2071,8 +2079,9 @@ int fit_image_load(struct bootm_headers *images, ulong addr, fit_uname = fit_unamep ? *fit_unamep :NULL ; fit_uname_config = fit_uname_configp ? *fit_uname_configp :NULL ; fit_base_uname_config =NULL ; - prop_name =fit_get_image_type_property (image_type); -printf ("## Loading %s from FIT Image at %08lx ...\n" , prop_name, addr); + prop_name =fit_get_image_type_property (ph_type); +printf ("## Loading %s (%s) from FIT Image at %08lx ...\n" , + prop_name,genimg_get_phase_name (image_ph_phase (ph_type)), addr);bootstage_mark (bootstage_id +BOOTSTAGE_SUB_FORMAT ); ret =fit_check_format (fit,IMAGE_SIZE_INVAL );
Signature · 1 line
2.43.0
PATCH 9/19 spl: Allow spl_load() to be controlled in any xPL phase
In reply to Simon GlassSome phases may wish to use full FIT-loading and others not, so allow this to be controlled.
Add some debugging while we are here.
---
include/spl_load.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
include/spl_load.h +7 -2
@@ -20,13 +20,15 @@ static inline int _spl_load(struct spl_image_info *spl_image,ulong base_offset, image_offset, overhead;int read, ret; +log_debug ("\nloading hdr from %lx to %p\n" , (ulong )offset, header); read = info->read (info, offset,ALIGN (sizeof (*header),spl_get_bl_len (info)), header);if (read < (int )sizeof (*header))return -EIO ;if (image_get_magic (header) ==FDT_MAGIC ) { -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT_FULL )) { +log_debug ("Found FIT\n" ); +if (CONFIG_IS_ENABLED (LOAD_FIT_FULL )) {void *buf;/*
@@ -48,9 +50,12 @@ static inline int _spl_load(struct spl_image_info *spl_image,return spl_parse_image_header (spl_image, bootdev, buf); } -if (IS_ENABLED (CONFIG_SPL_LOAD_FIT )) +if (CONFIG_IS_ENABLED (LOAD_FIT )) { +log_debug ("Simple loading\n" );return spl_load_simple_fit (spl_image, info, offset, header); + } +log_debug ("No FIT support\n" ); } if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER) &&
Signature · 1 line
2.43.0
PATCH 10/19 spl: Provide a way to mark code needed for relocation
In reply to Simon GlassAdd a linker symbol which can be used to mark relocation code, so it can be collected by the linker and copied into a suitable place and executed when needed.
---
include/asm-generic/sections.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/asm-generic/sections.h +16 -0
@@ -67,6 +67,9 @@ extern char __text_start[];/* This marks the text region which must be relocated */ extern char __image_copy_start[], __image_copy_end[]; +/* This marks the rcode region used for SPL relocation */ +extern char _rcode_start[], _rcode_end[]; +extern char __bss_end[];extern char __rel_dyn_start[], __rel_dyn_end[];extern char _image_binary_end[];
@@ -78,4 +81,17 @@ extern char __dtb[];*/ extern void _start (void ); +#ifndef USE_HOSTCC +#if CONFIG_IS_ENABLED (RELOC_LOADER ) +#define __rcode __section(".text.rcode") +#define __rdata __section(".text.rdata") +#else +#define __rcode +#define __rdata +#endif +#else +#define __rcode +#define __rdata +#endif +#endif /* _ASM_GENERIC_SECTIONS_H_ */
Signature · 1 line
2.43.0
PATCH 11/19 lib: Mark crc8 as relocation code
In reply to Simon GlassMark the crc8 code as needed by relocation. This is used as a simple check against corruption of the code when copying.
---
lib/crc8.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/crc8.c +3 -2
@@ -6,11 +6,12 @@#ifdef USE_HOSTCC #include <arpa/inet.h> #endif +#include <asm/sections.h> #include <u-boot/crc.h> #define POLY (0x1070U << 3) -static unsigned char _crc8 (unsigned short data) +__rcode static unsigned char _crc8(unsigned short data) {int i;
@@ -23,7 +24,7 @@ static unsigned char _crc8(unsigned short data)return (unsigned char )(data >>8 ); } -unsigned int crc8 (unsigned int crc,const unsigned char *vptr,int len) +__rcode unsigned int crc8(unsigned int crc, const unsigned char *vptr, int len) {int i;
Signature · 1 line
2.43.0
PATCH 12/19 lib: Mark lz4 as relocation code
In reply to Simon GlassMark the lz4 decompression code as needed by relocation. This is used to decompress the next-phase image.
Drop the 'safe' versions from SPL as they are not needed. Change the static array to a local one, to avoid a crash errors when trying to access the data from relocated code. Make this conditional to avoid a code-size increase when SPL_RELOC is not used/
---
lib/lz4.c | 37 ++++++++++++++++++++++++++----------- lib/lz4_wrapper.c | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-)
lib/lz4.c +26 -11
@@ -33,15 +33,16 @@#include <linux/bug.h> #include <asm/unaligned.h> #include <u-boot/lz4.h> +#include <asm/sections.h> #define FORCE_INLINE inline __attribute__((always_inline)) -static FORCE_INLINE u16 LZ4_readLE16(const void *src) +__rcode static FORCE_INLINE u16 LZ4_readLE16(const void *src) {return get_unaligned_le16 (src); } -static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) +__rcode static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) {put_unaligned (get_unaligned ((const u64 *)src), (u64 *)dst); }
@@ -53,7 +54,7 @@ typedef int32_t S32;typedef uint64_t U64 ;typedef uintptr_t uptrval ; -static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value) +__rcode static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value) {put_unaligned (value, (U32 *)memPtr); }
@@ -63,7 +64,7 @@ static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value)**************************************/ /* customized version of memcpy, which may overwrite up to 7 bytes beyond dstEnd */ -static void LZ4_wildCopy (void * dstPtr,const void * srcPtr,void * dstEnd) +__rcode static void LZ4_wildCopy(void *dstPtr, const void *srcPtr, void *dstEnd) {BYTE * d = (BYTE *)dstPtr;const BYTE * s = (const BYTE *)srcPtr;
@@ -111,6 +112,17 @@ typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive;#define assert (condition) ((void)0)#endif +/* +* spl_reloc needs all necessary data to be set up within its code, since the +* code is relocated at runtime. Unfortunately this increase code-size slightly +* so only do it if spl_reloc is enabled +*/ +#if CONFIG_IS_ENABLED (RELOC_LOADER ) +#define STATIC +#else +#define STATIC static +#endif +/* * LZ4_decompress_generic() : * This generic decompression function covers all use cases.
@@ -118,7 +130,7 @@ typedef enum { decode_full_block = 0, partial_decode = 1 } earlyEnd_directive;* Note that it is important for performance that this function really get inlined, * in order to remove useless branches during compilation optimization. */ -static FORCE_INLINE int LZ4_decompress_generic( +__rcode static FORCE_INLINE int LZ4_decompress_generic( const char * const src, char * const dst, int srcSize,
@@ -141,6 +153,8 @@ static FORCE_INLINE int LZ4_decompress_generic(const size_t dictSize ) { + STATIC const unsigned int inc32table[8] = {0, 1, 2, 1, 0, 4, 4, 4}; + STATIC const int dec64table[8] = {0, 0, 0, -1, -4, 1, 2, 3};const BYTE *ip = (const BYTE *) src;const BYTE *const iend = ip + srcSize;
@@ -149,8 +163,6 @@ static FORCE_INLINE int LZ4_decompress_generic(BYTE *cpy;const BYTE *const dictEnd = (const BYTE *)dictStart + dictSize; -static const unsigned int inc32table[8 ] = {0 ,1 ,2 ,1 ,0 ,4 ,4 ,4 }; -static const int dec64table[8 ] = {0 ,0 ,0 ,-1 ,-4 ,1 ,2 ,3 };const int safeDecode = (endOnInput == endOnInputSize);const int checkOffset = ((safeDecode) && (dictSize < (int )(64 *KB )));
@@ -514,8 +526,9 @@ _output_error:return (int ) (-(((const char *)ip) - src)) -1 ; } -int LZ4_decompress_safe (const char *source,char *dest, -int compressedSize,int maxDecompressedSize) +#ifndef CONFIG_SPL_BUILD +__rcode int LZ4_decompress_safe(const char *source, char *dest, +int compressedSize,int maxDecompressedSize) { return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize,
@@ -523,11 +536,13 @@ int LZ4_decompress_safe(const char *source, char *dest, noDict, (BYTE *)dest, NULL, 0); } -int LZ4_decompress_safe_partial (const char *src,char *dst, -int compressedSize,int targetOutputSize,int dstCapacity) +__rcode int LZ4_decompress_safe_partial(const char *src, char *dst, +int compressedSize, +int targetOutputSize,int dstCapacity) { dstCapacity =min (targetOutputSize, dstCapacity);return LZ4_decompress_generic (src, dst, compressedSize, dstCapacity, endOnInputSize, partial_decode, noDict, (BYTE *)dst,NULL ,0 ); } +#endif
lib/lz4_wrapper.c +1 -1
@@ -15,7 +15,7 @@#define LZ4F_BLOCKUNCOMPRESSED_FLAG 0x80000000U -int ulz4fn (const void *src,size_t srcn,void *dst,size_t *dstn) +__rcode int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn) {const void *end = dst + *dstn;const void *in = src;
Signature · 1 line
2.43.0
PATCH 13/19 lib: Mark memcpy() and memmove() as relocation code
In reply to Simon GlassMark these functions as needed by relocation. These functions are used to copy data while relocating the next-phase image.
Drop the 'safe' versions from SPL as they are not needed. Change the static array to a local one, to avoid link errors when trying to access the data.
---
lib/string.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/string.c +3 -2
@@ -21,6 +21,7 @@#include <linux/string.h> #include <linux/ctype.h> #include <malloc.h> +#include <asm/sections.h> /** * strncasecmp - Case insensitive, length-limited string comparison
@@ -559,7 +560,7 @@ __used void * memset(void * s,int c,size_t count)* You should not use this function to access IO space, use memcpy_toio() * or memcpy_fromio() instead. */ -__used void *memcpy (void *dest,const void *src,size_t count) +__rcode __used void *memcpy(void *dest, const void *src, size_t count) {unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;char *d8, *s8;
@@ -593,7 +594,7 @@ __used void * memcpy(void *dest, const void *src, size_t count)* * Unlike memcpy(), memmove() copes with overlapping areas. */ -__used void *memmove (void * dest,const void *src,size_t count) +__rcode __used void *memmove(void *dest, const void *src, size_t count) {char *tmp, *s;
Signature · 1 line
2.43.0
PATCH 14/19 lib: Mark gunzip as relocation code
In reply to Simon GlassMark the gunzip code as needed by relocation. This is used to decompress the next-phase image.
---
lib/gunzip.c | 9 +++++---- lib/zlib/inflate.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-)
lib/gunzip.c +5 -4
@@ -15,6 +15,7 @@#include <u-boot/crc.h> #include <watchdog.h> #include <u-boot/zlib.h> +#include <asm/sections.h> #define HEADER0 '\x1f'#define HEADER1 '\x8b'
@@ -43,7 +44,7 @@ void gzfree(void *x, void *addr, unsigned nb)free (addr); } -int gzip_parse_header (const unsigned char *src,unsigned long len) +__rcode int gzip_parse_header(const unsigned char *src, unsigned long len) {int i, flags;
@@ -71,7 +72,7 @@ int gzip_parse_header(const unsigned char *src, unsigned long len)return i; } -int gunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp) +__rcode int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp) {int offset =gzip_parse_header (src, *lenp);
@@ -274,8 +275,8 @@ out:/* * Uncompress blocks compressed with zlib without headers */ -int zunzip (void *dst,int dstlen,unsigned char *src,unsigned long *lenp, -int stoponerr,int offset) +__rcode int zunzip(void *dst, int dstlen, unsigned char *src, +unsigned long *lenp,int stoponerr,int offset) {z_stream s;int err =0 ;
lib/zlib/inflate.c +10 -8
@@ -2,10 +2,12 @@* Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ +#include <asm/sections.h> + local void fixedtables OF((struct inflate_state FAR *state)); local int updatewindow OF((z_streamp strm, unsigned out)); -int ZEXPORT inflateReset(z_streamp strm) +__rcode int ZEXPORT inflateReset(z_streamp strm) { struct inflate_state FAR *state;
@@ -30,8 +32,8 @@ int ZEXPORT inflateReset(z_streamp strm)return Z_OK ; } -int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, -int stream_size) +__rcode int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, +int stream_size) { struct inflate_state FAR *state;
@@ -67,12 +69,12 @@ int ZEXPORT inflateInit2_(z_streamp strm, int windowBits,return inflateReset (strm); } -int ZEXPORT inflateInit_(z_streamp strm, int stream_size) +__rcode int ZEXPORT inflateInit_(z_streamp strm, int stream_size) {return inflateInit2_ (strm,DEF_WBITS , stream_size); } -local void fixedtables(struct inflate_state FAR *state) +__rcode local void fixedtables(struct inflate_state FAR *state) { state->lencode = lenfix; state->lenbits =9 ;
@@ -94,7 +96,7 @@ local void fixedtables(struct inflate_state FAR *state)output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(z_streamp strm, unsigned out) +__rcode local int updatewindow(z_streamp strm, unsigned int out) { struct inflate_state FAR *state;unsigned copy, dist;
@@ -322,7 +324,7 @@ local int updatewindow(z_streamp strm, unsigned out)when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int ZEXPORT inflate(z_streamp strm, int flush) +__rcode int ZEXPORT inflate(z_streamp strm, int flush) { struct inflate_state FAR *state; unsigned char FAR *next; /* next input */
@@ -924,7 +926,7 @@ int ZEXPORT inflate(z_streamp strm, int flush)return ret; } -int ZEXPORT inflateEnd(z_streamp strm) +__rcode int ZEXPORT inflateEnd(z_streamp strm) { struct inflate_state FAR *state;if (strm ==Z_NULL || strm->state ==Z_NULL || strm->zfree == (free_func )0 )
Signature · 1 line
2.43.0
PATCH 15/19 vbe: Support providing a linker script
In reply to Simon GlassAllow a linker script to be provided for VPL as it is for other U-Boot phases.
---
common/spl/Kconfig.vpl | 13 +++++++++++++ 1 file changed, 13 insertions(+)
common/spl/Kconfig.vpl +13 -0
@@ -9,6 +9,19 @@ config VPL_BANNER_PRINT info. Disabling this option could be useful to reduce VPL boot time (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud). +config VPL_LDSCRIPT + string "Linker script for the VPL stage" + default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64 + default "arch/\$(ARCH)/cpu/u-boot-spl.lds" + help + The TPL stage will usually require a different linker-script + (as it runs from a different memory region) than the regular + U-Boot stage. Set this to the path of the linker-script to + be used for TPL. + + May be left empty to trigger the Makefile infrastructure to + fall back to the linker-script used for the SPL stage. + config VPL_BOARD_INIT bool "Call board-specific initialization in VPL" help
Signature · 1 line
2.43.0
Re: [PATCH 15/19] vbe: Support providing a linker script
Quoted 2 lines · Simon Glass
Allow a linker script to be provided for VPL as it is for other U-Boot phases.
[snip]
common/spl/Kconfig.vpl config VPL_BANNER_PRINT · line 23
Quoted 12 lines
common/spl/Kconfig.vpl +12
-0+config VPL_LDSCRIPT + string "Linker script for the VPL stage" + default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64 + default "arch/\$(ARCH)/cpu/u-boot-spl.lds" + help + The TPL stage will usually require a different linker-script + (as it runs from a different memory region) than the regular + U-Boot stage. Set this to the path of the linker-script to + be used for TPL. + + May be left empty to trigger the Makefile infrastructure to + fall back to the linker-script used for the SPL stage.
This should say VPL not TPL in the help, yes?
Signature · 1 line
Tom
PATCH 16/19 vbe: Provide VPL binman-symbols for the next phase
In reply to Simon GlassAdd support for moving from TPL->VPL->SPL so that the VPL build can fit properly into the boot flow.
Use #ifdefs to avoid creating unwanted symbols which Binman would then try (and perhaps fail) to provide.
Add debugging to indicate the next phase.
---
common/spl/spl.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
common/spl/spl.c +20 -6
@@ -50,8 +50,10 @@ u32 *boot_params_ptr = NULL;#if CONFIG_IS_ENABLED (BINMAN_UBOOT_SYMBOLS )/* See spl.h for information about this */ +#if defined(CONFIG_SPL_BUILD )binman_sym_declare (ulong, u_boot_any, image_pos);binman_sym_declare (ulong, u_boot_any, size); +#endif #ifdef CONFIG_TPL binman_sym_declare (ulong, u_boot_spl_any, image_pos);
@@ -179,9 +181,15 @@ ulong spl_get_image_pos(void)if (xpl_next_phase () ==PHASE_VPL )return binman_sym (ulong, u_boot_vpl_any, image_pos);#endif -return xpl_next_phase () ==PHASE_SPL ? -binman_sym (ulong, u_boot_spl_any, image_pos) : -binman_sym (ulong, u_boot_any, image_pos); +#if defined(CONFIG_TPL ) && !defined(CONFIG_VPL ) +if (xpl_next_phase () ==PHASE_SPL ) +return binman_sym (ulong, u_boot_spl_any, image_pos); +#endif +#if defined(CONFIG_SPL_BUILD ) +return binman_sym (ulong, u_boot_any, image_pos); +#endif + +return BINMAN_SYM_MISSING ; }ulong spl_get_image_size (void )
@@ -263,14 +271,20 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)*/ if (u_boot_pos && u_boot_pos !=BINMAN_SYM_MISSING ) {/* Binman does not support separated entry addresses */ - spl_image->entry_point = u_boot_pos; - spl_image->load_addr = u_boot_pos; + spl_image->entry_point =spl_get_image_text_base (); + spl_image->load_addr =spl_get_image_text_base (); + spl_image->size =spl_get_image_size (); +log_debug ("Next load addr %lx\n" , spl_image->load_addr); }else { spl_image->entry_point =CONFIG_SYS_UBOOT_START ; spl_image->load_addr =CONFIG_TEXT_BASE ; +log_debug ("Default load addr %x (u_boot_pos=%lx)\n" , +CONFIG_TEXT_BASE , u_boot_pos); } spl_image->os =IH_OS_U_BOOT ; - spl_image->name ="U-Boot" ; + spl_image->name =xpl_name (xpl_next_phase ()); +log_debug ("Next phase: %s at %lx size %lx\n" , spl_image->name, + spl_image->load_addr, (ulong )spl_image->size); } __weak int spl_parse_board_header(struct spl_image_info *spl_image,
Signature · 1 line
2.43.0
PATCH 17/19 vbe: Tidy up a few comments
In reply to Simon GlassJoin the comment block for the fit_image_load() call back to where it should be. Also fix a debug statement.
---
boot/vbe_common.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
boot/vbe_common.c +9 -9
@@ -202,14 +202,6 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size, phase =IS_ENABLED (CONFIG_TPL_BUILD ) ?IH_PHASE_NONE :IS_ENABLED (CONFIG_VPL_BUILD ) ?IH_PHASE_SPL :IH_PHASE_U_BOOT ; -/* -* Load the image from the FIT. We ignore any load-address information -* so in practice this simply locates the image in the external-data -* region and returns its address and size. Since we only loaded the FIT -* itself, only a part of the image will be present, at best. -*/ - fit_uname =NULL ; - fit_uname_config =NULL ;log_debug ("loading FIT\n" );if (xpl_phase () ==PHASE_SPL && !IS_ENABLED (CONFIG_SANDBOX )) {
@@ -220,11 +212,19 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,log_debug ("doing SPL from %s blksz %lx log2blksz %x area_offset %lx + fdt_size %lx\n" , blk->name, desc->blksz, desc->log2blksz, area_offset,ALIGN (size,4 )); ret =spl_load_simple_fit (image, &info, area_offset, buf); -log_debug ("spl_load_abrec_fit() ret=%d\n" , ret); +log_debug ("spl_load_simple_fit() ret=%d\n" , ret);return ret; } +/* +* Load the image from the FIT. We ignore any load-address information +* so in practice this simply locates the image in the external-data +* region and returns its address and size. Since we only loaded the FIT +* itself, only a part of the image will be present, at best. +*/ + fit_uname =NULL ; + fit_uname_config =NULL ; ret = fit_image_load(&images, addr, &fit_uname, &fit_uname_config, IH_ARCH_DEFAULT, image_ph(phase, IH_TYPE_FIRMWARE), BOOTSTAGE_ID_FIT_SPL_START, FIT_LOAD_IGNORED,
Signature · 1 line
2.43.0
PATCH 18/19 vbe: Allow VBE to disable adding loadables to the FDT
In reply to Simon GlassWhen VBE operates within VPL it does not want the FDT to be changed. Provide a way to disable this feature.
Move the FIT_IMAGE_TINY condition out of spl_fit_record_loadable() so that both conditions are together. This makes the code easier to understand.
Replace the existing fit_loaded member, which is no-longer used.
---
boot/vbe_common.c | 1 + common/spl/spl_fit.c | 6 ++---- include/spl.h | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-)
boot/vbe_common.c +1 -0
@@ -208,6 +208,7 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,struct spl_load_info info;spl_load_init (&info, h_vbe_load_read, desc, desc->blksz); +xpl_set_fdt_update (&info, false);xpl_set_phase (&info,IH_PHASE_U_BOOT );log_debug ("doing SPL from %s blksz %lx log2blksz %x area_offset %lx + fdt_size %lx\n" , blk->name, desc->blksz, desc->log2blksz, area_offset,ALIGN (size,4 ));
common/spl/spl_fit.c +2 -4
@@ -515,9 +515,6 @@ static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index,const char *name;int node; -if (CONFIG_IS_ENABLED (FIT_IMAGE_TINY )) -return 0 ; - ret =spl_fit_get_image_name (ctx,"loadables" , index, &name);if (ret <0 )return ret;
@@ -863,7 +860,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->entry_point = image_info.entry_point;/* Record our loadables into the FDT */ -if (spl_image->fdt_addr) +if (!CONFIG_IS_ENABLED (FIT_IMAGE_TINY ) && +xpl_get_fdt_update (info) && spl_image->fdt_addr)spl_fit_record_loadable (&ctx, index, spl_image->fdt_addr, &image_info);
include/spl.h +14 -5
@@ -345,7 +345,7 @@ typedef ulong (*spl_load_reader)(struct spl_load_info *load, ulong sector,* @priv: Private data for the device * @bl_len: Block length for reading in bytes * @phase: Image phase to load -* @fit_loaded: true if the FIT has been loaded, except for external data +* @no_fdt_update: true to update the FDT with any loadables that are loaded */ struct spl_load_info {spl_load_reader read;
@@ -355,7 +355,7 @@ struct spl_load_info {#endif #if CONFIG_IS_ENABLED (BOOTMETH_VBE )u8 phase; -u8 fit_loaded; +u8 fdt_update;#endif };
@@ -395,12 +395,20 @@ static inline enum image_phase_t xpl_get_phase(struct spl_load_info *info)#endif } -static inline bool xpl_get_fit_loaded (struct spl_load_info *info) +static inline void xpl_set_fdt_update (struct spl_load_info *info, +bool fdt_update) {#if CONFIG_IS_ENABLED (BOOTMETH_VBE ) -return info->fit_loaded; + info->fdt_update = fdt_update; +#endif +} + +static inline enum image_phase_t xpl_get_fdt_update (struct spl_load_info *info) +{ +#if CONFIG_IS_ENABLED (BOOTMETH_VBE ) +return info->fdt_update;#else -return false; +return true;#endif }
@@ -415,6 +423,7 @@ static inline void spl_load_init(struct spl_load_info *load, load->priv = priv;spl_set_bl_len (load, bl_len);xpl_set_phase (load,IH_PHASE_NONE ); +xpl_set_fdt_update (load, true); }/*
Signature · 1 line
2.43.0
PATCH 19/19 vbe: Add an implementation of VBE-ABrec
In reply to Simon GlassSo far only VBE-simple is implemented in U-Boot. This supports a single image which can be updated in situ.
It is often necessary to support two images (A and B) so that the board is not bricked if the update is interrupted or is bad.
In some cases, a non-updatable recovery image is desirable, so that the board can be returned to a known-good state in the event of a serious failure.
Introduce ABrec which provides these features. It supports three independent images and the logic to select the desired one on boot.
While we are here, fix a debug message to indicate the function it called. Provide a maintainers entry for VBE.
Note that fwupdated only supports VBE-simple so far, but supports for ABrec will appear in time.
---
MAINTAINERS | 7 ++ boot/Kconfig | 73 ++++++++++++ boot/Makefile | 4 + boot/vbe_abrec.c | 83 +++++++++++++ boot/vbe_abrec.h | 115 ++++++++++++++++++ boot/vbe_abrec_fw.c | 276 ++++++++++++++++++++++++++++++++++++++++++++ boot/vbe_common.c | 5 + boot/vbe_common.h | 43 +++++++ include/vbe.h | 21 ++++ 9 files changed, 627 insertions(+) create mode 100644 boot/vbe_abrec.c create mode 100644 boot/vbe_abrec.h create mode 100644 boot/vbe_abrec_fw.c
MAINTAINERS +7 -0
@@ -1802,6 +1802,13 @@ M: Abdellatif El Khlifi <[email protected]> S: Maintained F: test/lib/uuid.c +VBE +M: Simon Glass <[email protected]> +S: Maintained +F: boot/vbe* +F: common/spl_reloc.c +F: include/vbe.h + VIDEO M: Anatolij Gustschin <[email protected]> S: Maintained
boot/Kconfig +73 -0
85 lines not on this page · raw message
boot/Makefile +4 -0
@@ -71,3 +71,7 @@ obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_FW) += vbe_simple_fw.o obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_SIMPLE_OS) += vbe_simple_os.o obj-$(CONFIG_$(PHASE_)BOOTMETH_ANDROID) += bootmeth_android.o + +obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_ABREC) += vbe_abrec.o vbe_common.o +obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_ABREC_FW) += vbe_abrec_fw.o +obj-$(CONFIG_$(PHASE_)BOOTMETH_VBE_ABREC_OS) += vbe_abrec_os.o
boot/vbe_abrec.c new file +83 -0
83 lines not on this page · raw message
boot/vbe_abrec.h new file +115 -0
115 lines not on this page · raw message
boot/vbe_abrec_fw.c new file +276 -0
276 lines not on this page · raw message
boot/vbe_common.c +5 -0
@@ -374,3 +374,8 @@ int vbe_read_fit(struct udevice *blk, ulong area_offset, ulong area_size,return 0 ; } + +ofnode vbe_get_node (void ) +{ +return ofnode_path ("/bootstd/firmware0" ); +}
boot/vbe_common.h +43 -0
59 lines not on this page · raw message
include/vbe.h +21 -0
@@ -10,6 +10,8 @@#ifndef __VBE_H#define __VBE_H +#include <linux/types.h> +/** * enum vbe_phase_t - current phase of VBE *
@@ -25,13 +27,32 @@ enum vbe_phase_t { VBE_PHASE_OS, }; +/** +* enum vbe_pick_t - indicates which firmware is picked +* +* @VBEFT_A: Firmware A +* @VBEFT_B: Firmware B +* @VBEFT_RECOVERY: Recovery firmware +*/ +enum vbe_pick_t { +VBEP_A , +VBEP_B , +VBEP_RECOVERY , +}; +/** * struct vbe_handoff - information about VBE progress * +* @offset: Offset of the FIT to use for SPL onwards +* @size: Size of the area containing the FIT * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...) +* @pick: Indicates which firmware pick was used (enum vbe_pick_t) */ struct vbe_handoff { +ulong offset; +ulong size;u8 phases; +u8 pick; };/**
Signature · 1 line
2.43.0
Quoted 11 lines · Simon Glass
This includes the VBE ABrec (A/B/recovery) implementation as well as a number of patches needed to make it work:
- marking some code as used by
SPL_RELOC
- selection of images from a FIT based on the boot phase
- removal of unwanted hash code which increases code-size too much
- a few Kconfig-related additions for VPLNote: The goal for the next series (part H) is to enable VBE on rk3399-generic, i.e. able to boot on multiple rk3399-based boards with only the TPL phase being different for each board.
Size-wise, this seems fine and it's nice to be able to drop crc16 from SPL from some platforms. I'll try and find time to look at the patches themselves as well soon.
Signature · 1 line
Tom
Quoted 11 lines · Simon Glass
This includes the VBE ABrec (A/B/recovery) implementation as well as a number of patches needed to make it work:
- marking some code as used by
SPL_RELOC
- selection of images from a FIT based on the boot phase
- removal of unwanted hash code which increases code-size too much
- a few Kconfig-related additions for VPLNote: The goal for the next series (part H) is to enable VBE on rk3399-generic, i.e. able to boot on multiple rk3399-based boards with only the TPL phase being different for each board.
For the series, applied to u-boot/master, thanks!
Signature · 1 line
Tom