All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Simplify image size checks
@ 2025-09-03 10:56 Philip Oberfichtner
  2025-09-03 10:56 ` [PATCH v3 1/5] Image size checks: Move all configs in one place Philip Oberfichtner
                   ` (4 more replies)
  0 siblings, 5 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-03 10:56 UTC (permalink / raw)
  To: u-boot
  Cc: Philip Oberfichtner, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Marek Vasut, Nathan Barrett-Morrison,
	Oliver Gaskell, Paul Barker, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

This patch series aims at simplifying and harmonizing image size checks,
which are currently represented by the following Kconfig symbols:

	CONFIG_HAS_BOARD_SIZE_LIMIT
	CONFIG_BOARD_SIZE_LIMIT
	CONFIG_SPL_SIZE_LIMIT
	CONFIG_TPL_SIZE_LIMIT
	CONFIG_VPL_SIZE_LIMIT

After this series, we would have
	- Less code duplication in the toplevel Makefile
	- Consistent logic for all the different CONFIGS
	- All related options in one place

Changes in v3:
	V3 is a complete remake of the series. In the discussions on V2 we
	decided to follow the approach of using CONFIG_HAS_XXX_SIZE_LIMIT
	instead of my initial proposal, which was to disable a size check
	by setting its limit to zero.

Changes in v2:
	- Rebase on current master
	- Rebase on my pending mips patch series (linked above)
	- Incorporated Heinrich's Review

Philip Oberfichtner (5):
  Image size checks: Move all configs in one place
  Image size checks: Use HAS_SIZE_LIMIT consistently
  Image size checks: Use consistent help texts
  Image size checks: Deduplicate Makefile
  Image size checks: Simplify SPL_SIZE_LIMIT logic

 Kconfig                                   | 73 ++++++++++++++++++++++-
 Makefile                                  | 45 ++++----------
 arch/arm/mach-socfpga/Kconfig             |  5 +-
 arch/mips/mach-mtmips/Kconfig             |  5 +-
 arch/x86/cpu/apollolake/Kconfig           |  5 +-
 common/spl/Kconfig                        | 38 ------------
 common/spl/Kconfig.tpl                    |  7 ---
 common/spl/Kconfig.vpl                    |  7 ---
 configs/am62ax_evm_r5_defconfig           |  1 +
 configs/am62px_evm_r5_defconfig           |  1 +
 configs/am62x_beagleplay_a53_defconfig    |  1 +
 configs/am62x_beagleplay_r5_defconfig     |  1 +
 configs/am62x_evm_a53_defconfig           |  1 +
 configs/am62x_evm_a53_ethboot_defconfig   |  1 +
 configs/am62x_evm_r5_defconfig            |  1 +
 configs/am64x_evm_r5_defconfig            |  1 +
 configs/am65x_evm_r5_defconfig            |  1 +
 configs/am65x_evm_r5_usbmsc_defconfig     |  1 +
 configs/am67a_beagley_ai_r5_defconfig     |  1 +
 configs/brcp150_defconfig                 |  1 +
 configs/brcp170_defconfig                 |  1 +
 configs/brcp1_1r_defconfig                |  1 +
 configs/brcp1_1r_switch_defconfig         |  1 +
 configs/brcp1_2r_defconfig                |  1 +
 configs/brsmarc2_defconfig                |  1 +
 configs/evb-ast2600_defconfig             |  1 +
 configs/evb-rk3288_defconfig              |  1 +
 configs/firefly-rk3288_defconfig          |  1 +
 configs/ibex-ast2700_defconfig            |  1 +
 configs/ibm-sbp1_defconfig                |  1 +
 configs/imx28_btt3_defconfig              |  1 +
 configs/imx28_xea_defconfig               |  1 +
 configs/imx6q_bosch_acc_defconfig         |  1 +
 configs/imxrt1020-evk_defconfig           |  1 +
 configs/imxrt1050-evk_defconfig           |  1 +
 configs/imxrt1050-evk_fspi_defconfig      |  1 +
 configs/imxrt1170-evk_defconfig           |  1 +
 configs/j721e_beagleboneai64_r5_defconfig |  1 +
 configs/j721e_evm_r5_defconfig            |  1 +
 configs/j721s2_evm_r5_defconfig           |  1 +
 configs/j722s_evm_r5_defconfig            |  1 +
 configs/j784s4_evm_r5_defconfig           |  1 +
 configs/kontron_sl28_defconfig            |  1 +
 configs/phycore_am62ax_r5_defconfig       |  1 +
 configs/phycore_am62x_a53_defconfig       |  1 +
 configs/phycore_am62x_r5_defconfig        |  1 +
 configs/phycore_am64x_r5_defconfig        |  1 +
 configs/stm32746g-eval_spl_defconfig      |  1 +
 configs/stm32f746-disco_spl_defconfig     |  1 +
 configs/stm32f769-disco_spl_defconfig     |  1 +
 configs/tinker-rk3288_defconfig           |  1 +
 configs/tinker-s-rk3288_defconfig         |  1 +
 configs/verdin-am62_a53_defconfig         |  1 +
 configs/verdin-am62_r5_defconfig          |  1 +
 configs/verdin-am62p_a53_defconfig        |  1 +
 configs/verdin-am62p_r5_defconfig         |  1 +
 configs/xilinx_mbv32_defconfig            |  1 +
 configs/xilinx_mbv32_smode_defconfig      |  1 +
 configs/xilinx_mbv64_defconfig            |  1 +
 configs/xilinx_mbv64_smode_defconfig      |  1 +
 configs/xilinx_zynqmp_kria_defconfig      |  1 +
 configs/xilinx_zynqmp_virt_defconfig      |  1 +
 tools/spl_size_limit.c                    |  4 +-
 63 files changed, 151 insertions(+), 92 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-03 10:56 [PATCH v3 0/5] Simplify image size checks Philip Oberfichtner
@ 2025-09-03 10:56 ` Philip Oberfichtner
  2025-09-03 12:50   ` Marek Vasut
  2025-09-03 10:56 ` [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently Philip Oberfichtner
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-03 10:56 UTC (permalink / raw)
  To: u-boot
  Cc: Philip Oberfichtner, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Marek Vasut, Nathan Barrett-Morrison,
	Oliver Gaskell, Paul Barker, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

How image size limiting works in U-Boot should be easier to grasp if we
have all related options in one place.

Signed-off-by: Philip Oberfichtner <pro@denx.de>
---
 Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
 common/spl/Kconfig     | 38 ---------------------------
 common/spl/Kconfig.tpl |  7 -----
 common/spl/Kconfig.vpl |  7 -----
 4 files changed, 59 insertions(+), 52 deletions(-)

diff --git a/Kconfig b/Kconfig
index 70125c4e5a6..f1a6be299e8 100644
--- a/Kconfig
+++ b/Kconfig
@@ -535,6 +535,8 @@ config BUILD_TARGET
 	  special image will be automatically built upon calling
 	  make / buildman.
 
+menu "Image size limits"
+
 config HAS_BOARD_SIZE_LIMIT
 	bool "Define a maximum size for the U-Boot image"
 	depends on !COMPILE_TEST
@@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
 	  include SPL nor TPL, on platforms that use that functionality, they
 	  have separate options to restrict size.
 
+config VPL_SIZE_LIMIT
+	depends on VPL
+	hex "Maximum size of VPL image"
+	default 0x0
+	help
+	  Specifies the maximum length of the U-Boot VPL image.
+	  If this value is zero, it is ignored.
+
+config TPL_SIZE_LIMIT
+	depends on TPL
+	hex "Maximum size of TPL image"
+	default 0x0
+	help
+	  Specifies the maximum length of the U-Boot TPL image.
+	  If this value is zero, it is ignored.
+
+config SPL_SIZE_LIMIT
+	depends on SPL
+	hex "Maximum size of SPL image"
+	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
+	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
+	default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
+	default 0x0
+	help
+	  Specifies the maximum length of the U-Boot SPL image.
+	  If this value is zero, it is ignored.
+
+config SPL_SIZE_LIMIT_SUBTRACT_GD
+	bool "SPL image size check: provide space for global data"
+	depends on SPL_SIZE_LIMIT > 0
+	help
+	  If enabled, aligned size of global data is reserved in
+	  SPL_SIZE_LIMIT check to ensure such an image does not overflow SRAM
+	  if SPL_SIZE_LIMIT describes the size of SRAM available for SPL when
+	  pre-reloc global data is put into this SRAM, too.
+
+config SPL_SIZE_LIMIT_SUBTRACT_MALLOC
+	bool "SPL image size check: provide space for malloc() pool before relocation"
+	depends on SPL_SIZE_LIMIT > 0
+	help
+	  If enabled, SPL_SYS_MALLOC_F_LEN is reserved in SPL_SIZE_LIMIT check
+	  to ensure such an image does not overflow SRAM if SPL_SIZE_LIMIT
+	  describes the size of SRAM available for SPL when pre-reloc malloc
+	  pool is put into this SRAM, too.
+
+config SPL_SIZE_LIMIT_PROVIDE_STACK
+	hex "SPL image size check: provide stack space before relocation"
+	depends on SPL_SIZE_LIMIT > 0
+	default 0x0
+	help
+	  If set, this size is reserved in SPL_SIZE_LIMIT check to ensure such
+	  an image does not overflow SRAM if SPL_SIZE_LIMIT describes the size
+	  of SRAM available for SPL when the stack required before reolcation
+	  uses this SRAM, too.
+
+endmenu
+
 config SYS_CUSTOM_LDSCRIPT
 	bool "Use a custom location for the U-Boot linker script"
 	depends on !COMPILE_TEST
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index ab05536bd02..87a56bd8f8a 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -36,44 +36,6 @@ config SPL_FRAMEWORK_BOARD_INIT_F
 	  - initialize the serial (preloader_console_init)
 	  Unless you want to provide your own board_init_f, you should say Y.
 
-config SPL_SIZE_LIMIT
-	hex "Maximum size of SPL image"
-	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
-	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
-	default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
-	default 0x0
-	help
-	  Specifies the maximum length of the U-Boot SPL image.
-	  If this value is zero, it is ignored.
-
-config SPL_SIZE_LIMIT_SUBTRACT_GD
-	bool "SPL image size check: provide space for global data"
-	depends on SPL_SIZE_LIMIT > 0
-	help
-	  If enabled, aligned size of global data is reserved in
-	  SPL_SIZE_LIMIT check to ensure such an image does not overflow SRAM
-	  if SPL_SIZE_LIMIT describes the size of SRAM available for SPL when
-	  pre-reloc global data is put into this SRAM, too.
-
-config SPL_SIZE_LIMIT_SUBTRACT_MALLOC
-	bool "SPL image size check: provide space for malloc() pool before relocation"
-	depends on SPL_SIZE_LIMIT > 0
-	help
-	  If enabled, SPL_SYS_MALLOC_F_LEN is reserved in SPL_SIZE_LIMIT check
-	  to ensure such an image does not overflow SRAM if SPL_SIZE_LIMIT
-	  describes the size of SRAM available for SPL when pre-reloc malloc
-	  pool is put into this SRAM, too.
-
-config SPL_SIZE_LIMIT_PROVIDE_STACK
-	hex "SPL image size check: provide stack space before relocation"
-	depends on SPL_SIZE_LIMIT > 0
-	default 0x0
-	help
-	  If set, this size is reserved in SPL_SIZE_LIMIT check to ensure such
-	  an image does not overflow SRAM if SPL_SIZE_LIMIT describes the size
-	  of SRAM available for SPL when the stack required before reolcation
-	  uses this SRAM, too.
-
 config SPL_MAX_SIZE
 	hex "Maximum size of the SPL image, excluding BSS"
 	default 0x30000 if ARCH_MX6 && MX6_OCRAM_256KB
diff --git a/common/spl/Kconfig.tpl b/common/spl/Kconfig.tpl
index a535b61ecd3..515bbeec685 100644
--- a/common/spl/Kconfig.tpl
+++ b/common/spl/Kconfig.tpl
@@ -1,13 +1,6 @@
 menu "TPL configuration options"
 	depends on TPL
 
-config TPL_SIZE_LIMIT
-	hex "Maximum size of TPL image"
-	default 0x0
-	help
-	  Specifies the maximum length of the U-Boot TPL image.
-	  If this value is zero, it is ignored.
-
 config TPL_BINMAN_SYMBOLS
 	bool "Support binman symbols in TPL"
 	depends on TPL_FRAMEWORK && BINMAN
diff --git a/common/spl/Kconfig.vpl b/common/spl/Kconfig.vpl
index 434562443ac..739f2805315 100644
--- a/common/spl/Kconfig.vpl
+++ b/common/spl/Kconfig.vpl
@@ -220,13 +220,6 @@ config VPL_SERIAL
 	  Enable support for serial in VPL. See SPL_SERIAL for
 	  details.
 
-config VPL_SIZE_LIMIT
-	hex "Maximum size of VPL image"
-	default 0x0
-	help
-	  Specifies the maximum length of the U-Boot VPL image.
-	  If this value is zero, it is ignored.
-
 config VPL_SPI
 	bool "Support SPI drivers"
 	help
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-03 10:56 [PATCH v3 0/5] Simplify image size checks Philip Oberfichtner
  2025-09-03 10:56 ` [PATCH v3 1/5] Image size checks: Move all configs in one place Philip Oberfichtner
@ 2025-09-03 10:56 ` Philip Oberfichtner
  2025-09-03 12:51   ` Marek Vasut
  2025-09-05 14:19   ` Tom Rini
  2025-09-03 10:56 ` [PATCH v3 3/5] Image size checks: Use consistent help texts Philip Oberfichtner
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-03 10:56 UTC (permalink / raw)
  To: u-boot
  Cc: Philip Oberfichtner, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Marek Vasut, Nathan Barrett-Morrison,
	Oliver Gaskell, Paul Barker, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

Use a consistent logic for image size checks. No functional change.

Before this commit, there were two concurrent approaches of how image
size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
dedicated Kconfig symbol to achieve this, all the other size checks were
disabled by assigning them a limit of zero bytes.

By this commit we achieve a consistent logic for size limiting, by
introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
have it yet.

Signed-off-by: Philip Oberfichtner <pro@denx.de>
---
 Kconfig                                   | 30 ++++++++++++++++-------
 Makefile                                  |  6 ++---
 arch/arm/mach-socfpga/Kconfig             |  5 +++-
 arch/mips/mach-mtmips/Kconfig             |  5 +++-
 arch/x86/cpu/apollolake/Kconfig           |  5 +++-
 configs/am62ax_evm_r5_defconfig           |  1 +
 configs/am62px_evm_r5_defconfig           |  1 +
 configs/am62x_beagleplay_a53_defconfig    |  1 +
 configs/am62x_beagleplay_r5_defconfig     |  1 +
 configs/am62x_evm_a53_defconfig           |  1 +
 configs/am62x_evm_a53_ethboot_defconfig   |  1 +
 configs/am62x_evm_r5_defconfig            |  1 +
 configs/am64x_evm_r5_defconfig            |  1 +
 configs/am65x_evm_r5_defconfig            |  1 +
 configs/am65x_evm_r5_usbmsc_defconfig     |  1 +
 configs/am67a_beagley_ai_r5_defconfig     |  1 +
 configs/brcp150_defconfig                 |  1 +
 configs/brcp170_defconfig                 |  1 +
 configs/brcp1_1r_defconfig                |  1 +
 configs/brcp1_1r_switch_defconfig         |  1 +
 configs/brcp1_2r_defconfig                |  1 +
 configs/brsmarc2_defconfig                |  1 +
 configs/evb-ast2600_defconfig             |  1 +
 configs/evb-rk3288_defconfig              |  1 +
 configs/firefly-rk3288_defconfig          |  1 +
 configs/ibex-ast2700_defconfig            |  1 +
 configs/ibm-sbp1_defconfig                |  1 +
 configs/imx28_btt3_defconfig              |  1 +
 configs/imx28_xea_defconfig               |  1 +
 configs/imx6q_bosch_acc_defconfig         |  1 +
 configs/imxrt1020-evk_defconfig           |  1 +
 configs/imxrt1050-evk_defconfig           |  1 +
 configs/imxrt1050-evk_fspi_defconfig      |  1 +
 configs/imxrt1170-evk_defconfig           |  1 +
 configs/j721e_beagleboneai64_r5_defconfig |  1 +
 configs/j721e_evm_r5_defconfig            |  1 +
 configs/j721s2_evm_r5_defconfig           |  1 +
 configs/j722s_evm_r5_defconfig            |  1 +
 configs/j784s4_evm_r5_defconfig           |  1 +
 configs/kontron_sl28_defconfig            |  1 +
 configs/phycore_am62ax_r5_defconfig       |  1 +
 configs/phycore_am62x_a53_defconfig       |  1 +
 configs/phycore_am62x_r5_defconfig        |  1 +
 configs/phycore_am64x_r5_defconfig        |  1 +
 configs/stm32746g-eval_spl_defconfig      |  1 +
 configs/stm32f746-disco_spl_defconfig     |  1 +
 configs/stm32f769-disco_spl_defconfig     |  1 +
 configs/tinker-rk3288_defconfig           |  1 +
 configs/tinker-s-rk3288_defconfig         |  1 +
 configs/verdin-am62_a53_defconfig         |  1 +
 configs/verdin-am62_r5_defconfig          |  1 +
 configs/verdin-am62p_a53_defconfig        |  1 +
 configs/verdin-am62p_r5_defconfig         |  1 +
 configs/xilinx_mbv32_defconfig            |  1 +
 configs/xilinx_mbv32_smode_defconfig      |  1 +
 configs/xilinx_mbv64_defconfig            |  1 +
 configs/xilinx_mbv64_smode_defconfig      |  1 +
 configs/xilinx_zynqmp_kria_defconfig      |  1 +
 configs/xilinx_zynqmp_virt_defconfig      |  1 +
 59 files changed, 90 insertions(+), 15 deletions(-)

diff --git a/Kconfig b/Kconfig
index f1a6be299e8..e73dd91a408 100644
--- a/Kconfig
+++ b/Kconfig
@@ -556,36 +556,48 @@ config BOARD_SIZE_LIMIT
 	  include SPL nor TPL, on platforms that use that functionality, they
 	  have separate options to restrict size.
 
-config VPL_SIZE_LIMIT
+config HAS_VPL_SIZE_LIMIT
+	bool "Enable size limit check for the VPL image"
+	depends on !COMPILE_TEST
 	depends on VPL
+
+config VPL_SIZE_LIMIT
 	hex "Maximum size of VPL image"
-	default 0x0
+	depends on HAS_VPL_SIZE_LIMIT
 	help
 	  Specifies the maximum length of the U-Boot VPL image.
 	  If this value is zero, it is ignored.
 
-config TPL_SIZE_LIMIT
+config HAS_TPL_SIZE_LIMIT
+	bool "Enable size limit check for the TPL image"
+	depends on !COMPILE_TEST
 	depends on TPL
+
+config TPL_SIZE_LIMIT
 	hex "Maximum size of TPL image"
-	default 0x0
+	depends on HAS_TPL_SIZE_LIMIT
 	help
 	  Specifies the maximum length of the U-Boot TPL image.
 	  If this value is zero, it is ignored.
 
-config SPL_SIZE_LIMIT
+config HAS_SPL_SIZE_LIMIT
+	bool "Enable size limit check for the SPL image"
+	depends on !COMPILE_TEST
 	depends on SPL
+
+config SPL_SIZE_LIMIT
 	hex "Maximum size of SPL image"
+	depends on HAS_SPL_SIZE_LIMIT
 	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
 	default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
-	default 0x0
 	help
 	  Specifies the maximum length of the U-Boot SPL image.
 	  If this value is zero, it is ignored.
 
 config SPL_SIZE_LIMIT_SUBTRACT_GD
 	bool "SPL image size check: provide space for global data"
-	depends on SPL_SIZE_LIMIT > 0
+	depends on HAS_SPL_SIZE_LIMIT
 	help
 	  If enabled, aligned size of global data is reserved in
 	  SPL_SIZE_LIMIT check to ensure such an image does not overflow SRAM
@@ -594,7 +606,7 @@ config SPL_SIZE_LIMIT_SUBTRACT_GD
 
 config SPL_SIZE_LIMIT_SUBTRACT_MALLOC
 	bool "SPL image size check: provide space for malloc() pool before relocation"
-	depends on SPL_SIZE_LIMIT > 0
+	depends on HAS_SPL_SIZE_LIMIT
 	help
 	  If enabled, SPL_SYS_MALLOC_F_LEN is reserved in SPL_SIZE_LIMIT check
 	  to ensure such an image does not overflow SRAM if SPL_SIZE_LIMIT
@@ -603,7 +615,7 @@ config SPL_SIZE_LIMIT_SUBTRACT_MALLOC
 
 config SPL_SIZE_LIMIT_PROVIDE_STACK
 	hex "SPL image size check: provide stack space before relocation"
-	depends on SPL_SIZE_LIMIT > 0
+	depends on HAS_SPL_SIZE_LIMIT
 	default 0x0
 	help
 	  If set, this size is reserved in SPL_SIZE_LIMIT check to ensure such
diff --git a/Makefile b/Makefile
index b4f10c08d75..a17d8b57196 100644
--- a/Makefile
+++ b/Makefile
@@ -1109,19 +1109,19 @@ else
 BOARD_SIZE_CHECK =
 endif
 
-ifneq ($(CONFIG_SPL_SIZE_LIMIT),0x0)
+ifneq ($(CONFIG_SPL_SIZE_LIMIT),)
 SPL_SIZE_CHECK = @$(call size_check,$@,$$(tools/spl_size_limit))
 else
 SPL_SIZE_CHECK =
 endif
 
-ifneq ($(CONFIG_TPL_SIZE_LIMIT),0x0)
+ifneq ($(CONFIG_TPL_SIZE_LIMIT),)
 TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))
 else
 TPL_SIZE_CHECK =
 endif
 
-ifneq ($(CONFIG_VPL_SIZE_LIMIT),0x0)
+ifneq ($(CONFIG_VPL_SIZE_LIMIT),)
 VPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_VPL_SIZE_LIMIT))
 else
 VPL_SIZE_CHECK =
diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index f2e959b5662..d4d46100736 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -22,8 +22,11 @@ config SOCFPGA_SECURE_VAB_AUTH_ALLOW_NON_FIT_IMAGE
 	bool "Allow non-FIT VAB signed images"
 	depends on SOCFPGA_SECURE_VAB_AUTH
 
+config HAS_SPL_SIZE_LIMIT
+	default y if TARGET_SOCFPGA_GEN5
+
 config SPL_SIZE_LIMIT
-	default 0x10000 if TARGET_SOCFPGA_GEN5
+	default 0x10000 if TARGET_SOCFPGA_GEN5 && HAS_SPL_SIZE_LIMIT
 
 config SPL_SIZE_LIMIT_PROVIDE_STACK
 	default 0x200 if TARGET_SOCFPGA_GEN5
diff --git a/arch/mips/mach-mtmips/Kconfig b/arch/mips/mach-mtmips/Kconfig
index 3fcd0b8465b..d2a1652954c 100644
--- a/arch/mips/mach-mtmips/Kconfig
+++ b/arch/mips/mach-mtmips/Kconfig
@@ -36,8 +36,11 @@ config SPL_TEXT_BASE
 	default 0x9c000000 if !SOC_MT7621
 	default 0x80100000 if SOC_MT7621
 
+config HAS_SPL_SIZE_LIMIT
+	default y if SOC_MT7621
+
 config SPL_SIZE_LIMIT
-	default 0x30000 if SOC_MT7621
+	default 0x30000 if SOC_MT7621 && HAS_SPL_SIZE_LIMIT
 
 config TPL_TEXT_BASE
 	default 0xbfc00000 if SOC_MT7621
diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
index 5dd866ffcfe..d70e8def36f 100644
--- a/arch/x86/cpu/apollolake/Kconfig
+++ b/arch/x86/cpu/apollolake/Kconfig
@@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
 	hex
 	default 0xe0000000
 
+config HAS_TPL_SIZE_LIMIT
+	default y
+
 config TPL_SIZE_LIMIT
-	default 0x7800
+	default 0x7800 if HAS_TPL_SIZE_LIMIT
 
 config CPU_ADDR_BITS
 	default 39
diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig
index 64886986c42..003e35d32dd 100644
--- a/configs/am62ax_evm_r5_defconfig
+++ b/configs/am62ax_evm_r5_defconfig
@@ -20,6 +20,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3A7F0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am62px_evm_r5_defconfig b/configs/am62px_evm_r5_defconfig
index c9592d7b6c4..ad56354a252 100644
--- a/configs/am62px_evm_r5_defconfig
+++ b/configs/am62px_evm_r5_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c4b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3C000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x5000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am62x_beagleplay_a53_defconfig b/configs/am62x_beagleplay_a53_defconfig
index 05853317fea..dfac96379ce 100644
--- a/configs/am62x_beagleplay_a53_defconfig
+++ b/configs/am62x_beagleplay_a53_defconfig
@@ -20,6 +20,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x80c80000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x800
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am62x_beagleplay_r5_defconfig b/configs/am62x_beagleplay_r5_defconfig
index ce503000e4c..3f5d1642b29 100644
--- a/configs/am62x_beagleplay_r5_defconfig
+++ b/configs/am62x_beagleplay_r5_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3A7F0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
index 4da668396d0..d368cc99c84 100644
--- a/configs/am62x_evm_a53_defconfig
+++ b/configs/am62x_evm_a53_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x80c80000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x800
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am62x_evm_a53_ethboot_defconfig b/configs/am62x_evm_a53_ethboot_defconfig
index 9d3c6b889f0..5d073bebb9a 100644
--- a/configs/am62x_evm_a53_ethboot_defconfig
+++ b/configs/am62x_evm_a53_ethboot_defconfig
@@ -6,6 +6,7 @@ CONFIG_SOC_K3_AM625=y
 CONFIG_TARGET_AM625_A53_EVM=y
 CONFIG_DEFAULT_DEVICE_TREE="ti/k3-am625-sk"
 CONFIG_SPL_STACK_R_ADDR=0x83000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x80000
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_BOARD_INIT=y
diff --git a/configs/am62x_evm_r5_defconfig b/configs/am62x_evm_r5_defconfig
index 18ffc991b25..4eaa8d3e3ac 100644
--- a/configs/am62x_evm_r5_defconfig
+++ b/configs/am62x_evm_r5_defconfig
@@ -25,6 +25,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3A7F0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am64x_evm_r5_defconfig b/configs/am64x_evm_r5_defconfig
index 491e0dd102e..b49370d2a34 100644
--- a/configs/am64x_evm_r5_defconfig
+++ b/configs/am64x_evm_r5_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_BSS_START_ADDR=0x7019b800
 CONFIG_SPL_BSS_MAX_SIZE=0x4000
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x400000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x190000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am65x_evm_r5_defconfig b/configs/am65x_evm_r5_defconfig
index 6733dcfdd85..8d368ce9f19 100644
--- a/configs/am65x_evm_r5_defconfig
+++ b/configs/am65x_evm_r5_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x41c7effc
 CONFIG_SPL_BSS_MAX_SIZE=0xc00
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x7ec00
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x2000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am65x_evm_r5_usbmsc_defconfig b/configs/am65x_evm_r5_usbmsc_defconfig
index 37b5c6a43e7..df4c1faae96 100644
--- a/configs/am65x_evm_r5_usbmsc_defconfig
+++ b/configs/am65x_evm_r5_usbmsc_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x41c7effc
 CONFIG_SPL_BSS_MAX_SIZE=0xc00
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x7ec00
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x2000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/am67a_beagley_ai_r5_defconfig b/configs/am67a_beagley_ai_r5_defconfig
index 00c6ba6e2b5..7d461fb93bb 100644
--- a/configs/am67a_beagley_ai_r5_defconfig
+++ b/configs/am67a_beagley_ai_r5_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c7b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3C000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x5000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/brcp150_defconfig b/configs/brcp150_defconfig
index 6d2b92e1ec3..68d7ba2a507 100644
--- a/configs/brcp150_defconfig
+++ b/configs/brcp150_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x600000
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x2000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x30000
diff --git a/configs/brcp170_defconfig b/configs/brcp170_defconfig
index 44460c510f1..b92db4dc6d4 100644
--- a/configs/brcp170_defconfig
+++ b/configs/brcp170_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x600000
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x2000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x30000
diff --git a/configs/brcp1_1r_defconfig b/configs/brcp1_1r_defconfig
index 684800228ef..050c743641d 100644
--- a/configs/brcp1_1r_defconfig
+++ b/configs/brcp1_1r_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x600000
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x2000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x30000
diff --git a/configs/brcp1_1r_switch_defconfig b/configs/brcp1_1r_switch_defconfig
index 9b45961ef8e..79b7bea5935 100644
--- a/configs/brcp1_1r_switch_defconfig
+++ b/configs/brcp1_1r_switch_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x600000
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x2000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x30000
diff --git a/configs/brcp1_2r_defconfig b/configs/brcp1_2r_defconfig
index 357eef38601..bbc3756bcf9 100644
--- a/configs/brcp1_2r_defconfig
+++ b/configs/brcp1_2r_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x600000
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x2000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x30000
diff --git a/configs/brsmarc2_defconfig b/configs/brsmarc2_defconfig
index 2ed54817af4..b460ee11ea6 100644
--- a/configs/brsmarc2_defconfig
+++ b/configs/brsmarc2_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x600000
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x2000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x30000
diff --git a/configs/evb-ast2600_defconfig b/configs/evb-ast2600_defconfig
index 16e8a58ccc0..393ed3e1873 100644
--- a/configs/evb-ast2600_defconfig
+++ b/configs/evb-ast2600_defconfig
@@ -26,6 +26,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x1000000
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x10000
 CONFIG_SPL=y
 # CONFIG_ARMV7_NONSEC is not set
diff --git a/configs/evb-rk3288_defconfig b/configs/evb-rk3288_defconfig
index 02347b58c22..3f8bb365cde 100644
--- a/configs/evb-rk3288_defconfig
+++ b/configs/evb-rk3288_defconfig
@@ -20,6 +20,7 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_SYS_LOAD_ADDR=0x800800
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x4b000
 CONFIG_DEBUG_UART_BASE=0xff690000
 CONFIG_DEBUG_UART_CLOCK=24000000
diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig
index d7b01e67db9..35ade7f99a3 100644
--- a/configs/firefly-rk3288_defconfig
+++ b/configs/firefly-rk3288_defconfig
@@ -13,6 +13,7 @@ CONFIG_ROCKCHIP_RK3288=y
 CONFIG_TARGET_FIREFLY_RK3288=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_SYS_LOAD_ADDR=0x800800
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_DEBUG_UART_BASE=0xff690000
 CONFIG_DEBUG_UART_CLOCK=24000000
diff --git a/configs/ibex-ast2700_defconfig b/configs/ibex-ast2700_defconfig
index 8e8259f291d..5c6b31944c5 100644
--- a/configs/ibex-ast2700_defconfig
+++ b/configs/ibex-ast2700_defconfig
@@ -16,6 +16,7 @@ CONFIG_SPL_TEXT_BASE=0x14bc0080
 CONFIG_SPL_BSS_START_ADDR=0x14bd7800
 CONFIG_SPL_BSS_MAX_SIZE=0x800
 CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x16000
 CONFIG_SPL=y
 CONFIG_SYS_MEM_TOP_HIDE=0x10000000
diff --git a/configs/ibm-sbp1_defconfig b/configs/ibm-sbp1_defconfig
index 5f16301e5b5..26420c6f831 100644
--- a/configs/ibm-sbp1_defconfig
+++ b/configs/ibm-sbp1_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x1000000
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x2000000
 CONFIG_SYS_LOAD_ADDR=0x83000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x10000
 CONFIG_SPL=y
 # CONFIG_ARMV7_NONSEC is not set
diff --git a/configs/imx28_btt3_defconfig b/configs/imx28_btt3_defconfig
index 07c805faa2f..87db48a2ac5 100644
--- a/configs/imx28_btt3_defconfig
+++ b/configs/imx28_btt3_defconfig
@@ -25,6 +25,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x1000
 CONFIG_SPL_TEXT_BASE=0x1000
 CONFIG_SYS_LOAD_ADDR=0x42000000
 CONFIG_SF_DEFAULT_BUS=2
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0xa000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x90000
diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig
index 8715893bbcc..2ba2b7f72af 100644
--- a/configs/imx28_xea_defconfig
+++ b/configs/imx28_xea_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x1000
 CONFIG_SPL_TEXT_BASE=0x1000
 CONFIG_SYS_LOAD_ADDR=0x42000000
 CONFIG_SF_DEFAULT_BUS=2
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0xa000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x90000
diff --git a/configs/imx6q_bosch_acc_defconfig b/configs/imx6q_bosch_acc_defconfig
index 6f0ef2eaee3..30b2af737b1 100644
--- a/configs/imx6q_bosch_acc_defconfig
+++ b/configs/imx6q_bosch_acc_defconfig
@@ -18,6 +18,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_BOOTCOUNT_BOOTLIMIT=8
 CONFIG_WATCHDOG_TIMEOUT_MSECS=60000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=69632
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x1ff000
diff --git a/configs/imxrt1020-evk_defconfig b/configs/imxrt1020-evk_defconfig
index 17c650e6950..7fc6afafc1b 100644
--- a/configs/imxrt1020-evk_defconfig
+++ b/configs/imxrt1020-evk_defconfig
@@ -17,6 +17,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_TEXT_BASE=0x20209000
 CONFIG_SYS_LOAD_ADDR=0x20209000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_HAVE_SYS_UBOOT_START=y
diff --git a/configs/imxrt1050-evk_defconfig b/configs/imxrt1050-evk_defconfig
index 5faf964759d..6ba608f20a4 100644
--- a/configs/imxrt1050-evk_defconfig
+++ b/configs/imxrt1050-evk_defconfig
@@ -19,6 +19,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_TEXT_BASE=0x20002000
 CONFIG_SYS_LOAD_ADDR=0x20002000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_HAVE_SYS_UBOOT_START=y
diff --git a/configs/imxrt1050-evk_fspi_defconfig b/configs/imxrt1050-evk_fspi_defconfig
index cc7e8a3e10b..7d6a41403fc 100644
--- a/configs/imxrt1050-evk_fspi_defconfig
+++ b/configs/imxrt1050-evk_fspi_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_TEXT_BASE=0x20002000
 CONFIG_SYS_LOAD_ADDR=0x20002000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_HAVE_SYS_UBOOT_START=y
diff --git a/configs/imxrt1170-evk_defconfig b/configs/imxrt1170-evk_defconfig
index 9bd3874143c..4f7e6104c78 100644
--- a/configs/imxrt1170-evk_defconfig
+++ b/configs/imxrt1170-evk_defconfig
@@ -19,6 +19,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL_TEXT_BASE=0x202C0000
 CONFIG_SYS_LOAD_ADDR=0x202C0000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_HAVE_SYS_UBOOT_START=y
diff --git a/configs/j721e_beagleboneai64_r5_defconfig b/configs/j721e_beagleboneai64_r5_defconfig
index 50a9d95d7bf..8e9450326b1 100644
--- a/configs/j721e_beagleboneai64_r5_defconfig
+++ b/configs/j721e_beagleboneai64_r5_defconfig
@@ -23,6 +23,7 @@ CONFIG_SPL_BSS_START_ADDR=0x41cf59f0
 CONFIG_SPL_BSS_MAX_SIZE=0xa000
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0xf59f0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index ceb2e273b54..4499073c5d9 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -25,6 +25,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x41cf59f0
 CONFIG_SPL_BSS_MAX_SIZE=0xa000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0xf59f0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/j721s2_evm_r5_defconfig b/configs/j721s2_evm_r5_defconfig
index aaf8fd32879..9cbb841ce49 100644
--- a/configs/j721s2_evm_r5_defconfig
+++ b/configs/j721s2_evm_r5_defconfig
@@ -25,6 +25,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x41c76000
 CONFIG_SPL_BSS_MAX_SIZE=0xa000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x80000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/j722s_evm_r5_defconfig b/configs/j722s_evm_r5_defconfig
index 8e2741c8d42..590bb9452df 100644
--- a/configs/j722s_evm_r5_defconfig
+++ b/configs/j722s_evm_r5_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c7b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3C000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x5000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/j784s4_evm_r5_defconfig b/configs/j784s4_evm_r5_defconfig
index cc340a2fe76..21b040d6399 100644
--- a/configs/j784s4_evm_r5_defconfig
+++ b/configs/j784s4_evm_r5_defconfig
@@ -26,6 +26,7 @@ CONFIG_SPL_BSS_START_ADDR=0x41c76000
 CONFIG_SPL_BSS_MAX_SIZE=0xa000
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x80000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/kontron_sl28_defconfig b/configs/kontron_sl28_defconfig
index e97534ecc0a..cb57538b597 100644
--- a/configs/kontron_sl28_defconfig
+++ b/configs/kontron_sl28_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_BSS_START_ADDR=0x80100000
 CONFIG_SPL_BSS_MAX_SIZE=0x100000
 CONFIG_SYS_BOOTM_LEN=0x800000
 CONFIG_SYS_LOAD_ADDR=0x82000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x20000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x3f0000
diff --git a/configs/phycore_am62ax_r5_defconfig b/configs/phycore_am62ax_r5_defconfig
index 01d100842de..657c2fe2612 100644
--- a/configs/phycore_am62ax_r5_defconfig
+++ b/configs/phycore_am62ax_r5_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3A7F0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/phycore_am62x_a53_defconfig b/configs/phycore_am62x_a53_defconfig
index fdbe79d3e32..f146ee30488 100644
--- a/configs/phycore_am62x_a53_defconfig
+++ b/configs/phycore_am62x_a53_defconfig
@@ -27,6 +27,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x80c80000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x80000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x800
 CONFIG_ENV_OFFSET_REDUND=0x6c0000
diff --git a/configs/phycore_am62x_r5_defconfig b/configs/phycore_am62x_r5_defconfig
index 0368d4ef474..a41c09569df 100644
--- a/configs/phycore_am62x_r5_defconfig
+++ b/configs/phycore_am62x_r5_defconfig
@@ -26,6 +26,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3A7F0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/phycore_am64x_r5_defconfig b/configs/phycore_am64x_r5_defconfig
index d1ac992dc7a..4bbe38536d1 100644
--- a/configs/phycore_am64x_r5_defconfig
+++ b/configs/phycore_am64x_r5_defconfig
@@ -26,6 +26,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x7019b800
 CONFIG_SPL_BSS_MAX_SIZE=0x4000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x190000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x4000
 CONFIG_SPL_FS_FAT=y
diff --git a/configs/stm32746g-eval_spl_defconfig b/configs/stm32746g-eval_spl_defconfig
index 432d35d0d5a..5ce93a34b9e 100644
--- a/configs/stm32746g-eval_spl_defconfig
+++ b/configs/stm32746g-eval_spl_defconfig
@@ -16,6 +16,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_TEXT_BASE=0x8000000
 CONFIG_SYS_LOAD_ADDR=0x8009000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x9000
 CONFIG_STM32F7=y
 CONFIG_TARGET_STM32F746_DISCO=y
diff --git a/configs/stm32f746-disco_spl_defconfig b/configs/stm32f746-disco_spl_defconfig
index 699ae9d08fc..b629c5eeefd 100644
--- a/configs/stm32f746-disco_spl_defconfig
+++ b/configs/stm32f746-disco_spl_defconfig
@@ -16,6 +16,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_TEXT_BASE=0x8000000
 CONFIG_SYS_LOAD_ADDR=0x8009000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x9000
 CONFIG_STM32F7=y
 CONFIG_TARGET_STM32F746_DISCO=y
diff --git a/configs/stm32f769-disco_spl_defconfig b/configs/stm32f769-disco_spl_defconfig
index 74210fe8252..f82bcd9d937 100644
--- a/configs/stm32f769-disco_spl_defconfig
+++ b/configs/stm32f769-disco_spl_defconfig
@@ -16,6 +16,7 @@ CONFIG_SPL_SERIAL=y
 CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_TEXT_BASE=0x8000000
 CONFIG_SYS_LOAD_ADDR=0x8009000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x9000
 CONFIG_STM32F7=y
 CONFIG_TARGET_STM32F746_DISCO=y
diff --git a/configs/tinker-rk3288_defconfig b/configs/tinker-rk3288_defconfig
index afbb394228f..9c56fe10bfd 100644
--- a/configs/tinker-rk3288_defconfig
+++ b/configs/tinker-rk3288_defconfig
@@ -12,6 +12,7 @@ CONFIG_ROCKCHIP_RK3288=y
 CONFIG_TARGET_TINKER_RK3288=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_SYS_LOAD_ADDR=0x800800
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x4b000
 CONFIG_DEBUG_UART_BASE=0xff690000
 CONFIG_DEBUG_UART_CLOCK=24000000
diff --git a/configs/tinker-s-rk3288_defconfig b/configs/tinker-s-rk3288_defconfig
index 876086573d3..2f830eb8c88 100644
--- a/configs/tinker-s-rk3288_defconfig
+++ b/configs/tinker-s-rk3288_defconfig
@@ -12,6 +12,7 @@ CONFIG_ROCKCHIP_RK3288=y
 CONFIG_TARGET_TINKER_RK3288=y
 CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_SYS_LOAD_ADDR=0x800800
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x4b000
 CONFIG_DEBUG_UART_BASE=0xff690000
 CONFIG_DEBUG_UART_CLOCK=24000000
diff --git a/configs/verdin-am62_a53_defconfig b/configs/verdin-am62_a53_defconfig
index 2c0573cd54e..f7cbcd2e48a 100644
--- a/configs/verdin-am62_a53_defconfig
+++ b/configs/verdin-am62_a53_defconfig
@@ -25,6 +25,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_BOOTM_LEN=0x40000000
 CONFIG_SYS_LOAD_ADDR=0x88200000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x800
 CONFIG_SYS_MEMTEST_START=0x80000000
diff --git a/configs/verdin-am62_r5_defconfig b/configs/verdin-am62_r5_defconfig
index efba857ad70..d2fcd38a161 100644
--- a/configs/verdin-am62_r5_defconfig
+++ b/configs/verdin-am62_r5_defconfig
@@ -22,6 +22,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3A7F0
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x3500
 CONFIG_SPL_LIBDISK_SUPPORT=y
diff --git a/configs/verdin-am62p_a53_defconfig b/configs/verdin-am62p_a53_defconfig
index c46b883a9c6..f04e184a079 100644
--- a/configs/verdin-am62p_a53_defconfig
+++ b/configs/verdin-am62p_a53_defconfig
@@ -24,6 +24,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_BOOTM_LEN=0x40000000
 CONFIG_SYS_LOAD_ADDR=0x88200000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x80000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x800
 CONFIG_SYS_MEMTEST_START=0x80000000
diff --git a/configs/verdin-am62p_r5_defconfig b/configs/verdin-am62p_r5_defconfig
index a8b0e942b61..076111b30d9 100644
--- a/configs/verdin-am62p_r5_defconfig
+++ b/configs/verdin-am62p_r5_defconfig
@@ -22,6 +22,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c4b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_STACK_R=y
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x3C000
 CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK=0x5000
 CONFIG_SPL_LIBDISK_SUPPORT=y
diff --git a/configs/xilinx_mbv32_defconfig b/configs/xilinx_mbv32_defconfig
index e3341179a68..94cd6c7112b 100644
--- a/configs/xilinx_mbv32_defconfig
+++ b/configs/xilinx_mbv32_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_BSS_START_ADDR=0x84000000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SYS_BOOTM_LEN=0x800000
 CONFIG_SYS_LOAD_ADDR=0x80200000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL=y
 CONFIG_DEBUG_UART_BASE=0x40600000
diff --git a/configs/xilinx_mbv32_smode_defconfig b/configs/xilinx_mbv32_smode_defconfig
index c95b4497395..9058bdf8030 100644
--- a/configs/xilinx_mbv32_smode_defconfig
+++ b/configs/xilinx_mbv32_smode_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_BSS_START_ADDR=0x84000000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SYS_BOOTM_LEN=0x800000
 CONFIG_SYS_LOAD_ADDR=0x80200000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL=y
 CONFIG_DEBUG_UART_BASE=0x40600000
diff --git a/configs/xilinx_mbv64_defconfig b/configs/xilinx_mbv64_defconfig
index a3cc1a5669e..2f00466ff9e 100644
--- a/configs/xilinx_mbv64_defconfig
+++ b/configs/xilinx_mbv64_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_BSS_START_ADDR=0x84000000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SYS_BOOTM_LEN=0x800000
 CONFIG_SYS_LOAD_ADDR=0x80200000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL=y
 CONFIG_DEBUG_UART_BASE=0x40600000
diff --git a/configs/xilinx_mbv64_smode_defconfig b/configs/xilinx_mbv64_smode_defconfig
index 3d49670c60c..ec5598025bf 100644
--- a/configs/xilinx_mbv64_smode_defconfig
+++ b/configs/xilinx_mbv64_smode_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_BSS_START_ADDR=0x84000000
 CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SYS_BOOTM_LEN=0x800000
 CONFIG_SYS_LOAD_ADDR=0x80200000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x40000
 CONFIG_SPL=y
 CONFIG_DEBUG_UART_BASE=0x40600000
diff --git a/configs/xilinx_zynqmp_kria_defconfig b/configs/xilinx_zynqmp_kria_defconfig
index 3e2ac614405..d1238687ce3 100644
--- a/configs/xilinx_zynqmp_kria_defconfig
+++ b/configs/xilinx_zynqmp_kria_defconfig
@@ -19,6 +19,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_BOOTM_LEN=0x6400000
 CONFIG_SYS_LOAD_ADDR=0x8000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x2a000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x2220000
diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig
index 65c8a4bbaad..11a39595680 100644
--- a/configs/xilinx_zynqmp_virt_defconfig
+++ b/configs/xilinx_zynqmp_virt_defconfig
@@ -14,6 +14,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x80000
 CONFIG_SPL_STACK_R=y
 CONFIG_SYS_BOOTM_LEN=0x6400000
 CONFIG_SYS_LOAD_ADDR=0x8000000
+CONFIG_HAS_SPL_SIZE_LIMIT=y
 CONFIG_SPL_SIZE_LIMIT=0x2a000
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x1E80000
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 3/5] Image size checks: Use consistent help texts
  2025-09-03 10:56 [PATCH v3 0/5] Simplify image size checks Philip Oberfichtner
  2025-09-03 10:56 ` [PATCH v3 1/5] Image size checks: Move all configs in one place Philip Oberfichtner
  2025-09-03 10:56 ` [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently Philip Oberfichtner
@ 2025-09-03 10:56 ` Philip Oberfichtner
  2025-09-03 12:54   ` Marek Vasut
  2025-09-03 10:56 ` [PATCH v3 4/5] Image size checks: Deduplicate Makefile Philip Oberfichtner
  2025-09-03 10:56 ` [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic Philip Oberfichtner
  4 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-03 10:56 UTC (permalink / raw)
  To: u-boot
  Cc: Philip Oberfichtner, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Marek Vasut, Nathan Barrett-Morrison,
	Oliver Gaskell, Paul Barker, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

The multiple XXX_SIZE_LIMIT options use slightly varying help texts.
Their similarities and differences should become more clear if we use
consistent help texts.

Signed-off-by: Philip Oberfichtner <pro@denx.de>
---
 Kconfig | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Kconfig b/Kconfig
index e73dd91a408..aa00669ba20 100644
--- a/Kconfig
+++ b/Kconfig
@@ -538,7 +538,7 @@ config BUILD_TARGET
 menu "Image size limits"
 
 config HAS_BOARD_SIZE_LIMIT
-	bool "Define a maximum size for the U-Boot image"
+	bool "Enable size limit check for the U-Boot image"
 	depends on !COMPILE_TEST
 	default y if RCAR_32 || RCAR_64
 	help
@@ -562,11 +562,11 @@ config HAS_VPL_SIZE_LIMIT
 	depends on VPL
 
 config VPL_SIZE_LIMIT
-	hex "Maximum size of VPL image"
+	hex "Maximum size of VPL image in bytes"
 	depends on HAS_VPL_SIZE_LIMIT
 	help
-	  Specifies the maximum length of the U-Boot VPL image.
-	  If this value is zero, it is ignored.
+	  Maximum size of the VPL image. When defined, the build system checks
+	  that the actual size does not exceed it.
 
 config HAS_TPL_SIZE_LIMIT
 	bool "Enable size limit check for the TPL image"
@@ -574,11 +574,11 @@ config HAS_TPL_SIZE_LIMIT
 	depends on TPL
 
 config TPL_SIZE_LIMIT
-	hex "Maximum size of TPL image"
+	hex "Maximum size of TPL image in bytes"
 	depends on HAS_TPL_SIZE_LIMIT
 	help
-	  Specifies the maximum length of the U-Boot TPL image.
-	  If this value is zero, it is ignored.
+	  Maximum size of the TPL image. When defined, the build system checks
+	  that the actual size does not exceed it.
 
 config HAS_SPL_SIZE_LIMIT
 	bool "Enable size limit check for the SPL image"
@@ -586,14 +586,14 @@ config HAS_SPL_SIZE_LIMIT
 	depends on SPL
 
 config SPL_SIZE_LIMIT
-	hex "Maximum size of SPL image"
+	hex "Maximum size of SPL image in bytes"
 	depends on HAS_SPL_SIZE_LIMIT
 	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
 	default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
 	help
-	  Specifies the maximum length of the U-Boot SPL image.
-	  If this value is zero, it is ignored.
+	  Maximum size of the SPL image. When defined, the build system checks
+	  that the actual size does not exceed it.
 
 config SPL_SIZE_LIMIT_SUBTRACT_GD
 	bool "SPL image size check: provide space for global data"
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 4/5] Image size checks: Deduplicate Makefile
  2025-09-03 10:56 [PATCH v3 0/5] Simplify image size checks Philip Oberfichtner
                   ` (2 preceding siblings ...)
  2025-09-03 10:56 ` [PATCH v3 3/5] Image size checks: Use consistent help texts Philip Oberfichtner
@ 2025-09-03 10:56 ` Philip Oberfichtner
  2025-09-03 13:02   ` Marek Vasut
  2025-09-03 10:56 ` [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic Philip Oberfichtner
  4 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-03 10:56 UTC (permalink / raw)
  To: u-boot
  Cc: Philip Oberfichtner, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Marek Vasut, Nathan Barrett-Morrison,
	Oliver Gaskell, Paul Barker, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

Deduplicate some redundancies within the SIZE_CHECK code in the toplevel
Makefile. No functional changes.

Note: To make this work for the special case of SPL, spl_size_limit.c
has to print an empty string "" instead of zero when there is no size
limit in place.

Signed-off-by: Philip Oberfichtner <pro@denx.de>
---
 Makefile               | 45 +++++++++++-------------------------------
 tools/spl_size_limit.c |  4 ++--
 2 files changed, 13 insertions(+), 36 deletions(-)

diff --git a/Makefile b/Makefile
index a17d8b57196..b6f01591ee9 100644
--- a/Makefile
+++ b/Makefile
@@ -428,8 +428,9 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 # Check ths size of a binary:
 # Args:
 #   $1: File to check
-#   #2: Size limit in bytes (decimal or 0xhex)
+#   #2: Size limit in bytes (decimal or 0xhex), always return OK if undefined
 define size_check
+	test -z "$2" && exit 0; \
 	actual=$$( wc -c $1 | awk '{print $$1}'); \
 	limit=$$( printf "%d" $2 ); \
 	if test $$actual -gt $$limit; then \
@@ -1103,30 +1104,6 @@ LDPPFLAGS += \
 #########################################################################
 #########################################################################
 
-ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
-BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
-else
-BOARD_SIZE_CHECK =
-endif
-
-ifneq ($(CONFIG_SPL_SIZE_LIMIT),)
-SPL_SIZE_CHECK = @$(call size_check,$@,$$(tools/spl_size_limit))
-else
-SPL_SIZE_CHECK =
-endif
-
-ifneq ($(CONFIG_TPL_SIZE_LIMIT),)
-TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))
-else
-TPL_SIZE_CHECK =
-endif
-
-ifneq ($(CONFIG_VPL_SIZE_LIMIT),)
-VPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_VPL_SIZE_LIMIT))
-else
-VPL_SIZE_CHECK =
-endif
-
 # Statically apply RELA-style relocations (currently arm64 only)
 # This is useful for arm64 where static relocation needs to be performed on
 # the raw binary, but certain simulators only accept an ELF file (but don't
@@ -1470,7 +1447,7 @@ endif
 
 %.imx: $(IMX_DEPS) %.bin
 	$(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
-	$(BOARD_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
 
 %.vyb: %.imx
 	$(Q)$(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $@
@@ -1571,11 +1548,11 @@ endif
 
 u-boot-nodtb.bin: u-boot FORCE
 	$(call if_changed,objcopy_uboot)
-	$(BOARD_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
 
 u-boot.ldr:	u-boot
 		$(LDR) -T $(CONFIG_LDR_CPU) -c $@ $< $(LDR_FLAGS)
-		$(BOARD_SIZE_CHECK)
+		@$(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
 
 # binman
 # ---------------------------------------------------------------------------
@@ -1702,7 +1679,7 @@ u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \
 			$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \
 		,$(UBOOT_BIN)) FORCE
 	$(call if_changed,mkimage)
-	$(BOARD_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
 
 ifeq ($(CONFIG_SPL_LOAD_FIT_FULL),y)
 MKIMAGEFLAGS_u-boot.itb =
@@ -1717,12 +1694,12 @@ u-boot.itb: u-boot-nodtb.bin \
 		$(if $(CONFIG_MULTI_DTB_FIT),$(FINAL_DTB_CONTAINER)) \
 		$(U_BOOT_ITS) FORCE
 	$(call if_changed,mkfitimage)
-	$(BOARD_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
 endif
 
 u-boot-with-spl.kwb: u-boot.bin spl/u-boot-spl.bin FORCE
 	$(call if_changed,mkimage)
-	$(BOARD_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
 
 u-boot.dis:	u-boot
 		$(OBJDUMP) -d $< > $@
@@ -2346,7 +2323,7 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
 
 spl/u-boot-spl.bin: spl/u-boot-spl
 	@:
-	$(SPL_SIZE_CHECK)
+	@$(call size_check,$@,$$(tools/spl_size_limit))
 
 spl/u-boot-spl-dtb.bin: spl/u-boot-spl
 	@:
@@ -2371,14 +2348,14 @@ spl/boot.bin: spl/u-boot-spl
 
 tpl/u-boot-tpl.bin: tpl/u-boot-tpl
 	@:
-	$(TPL_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT))
 
 tpl/u-boot-tpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
 	$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.xpl all
 
 vpl/u-boot-vpl.bin: vpl/u-boot-vpl
 	@:
-	$(VPL_SIZE_CHECK)
+	@$(call size_check,$@,$(CONFIG_VPL_SIZE_LIMIT))
 
 vpl/u-boot-vpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb)
 	$(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.xpl all
diff --git a/tools/spl_size_limit.c b/tools/spl_size_limit.c
index c6c139e834f..c956a0e2624 100644
--- a/tools/spl_size_limit.c
+++ b/tools/spl_size_limit.c
@@ -10,9 +10,9 @@
 
 int main(int argc, char *argv[])
 {
+#ifdef CONFIG_SPL_SIZE_LIMIT
 	int spl_size_limit = 0;
 
-#ifdef CONFIG_SPL_SIZE_LIMIT
 	spl_size_limit = CONFIG_SPL_SIZE_LIMIT;
 #if defined(CONFIG_IMX_HAB) && defined(CONFIG_CSF_SIZE)
 	spl_size_limit -= CONFIG_CSF_SIZE;
@@ -25,9 +25,9 @@ int main(int argc, char *argv[])
 #endif
 #ifdef CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK
 	spl_size_limit -= CONFIG_SPL_SIZE_LIMIT_PROVIDE_STACK;
-#endif
 #endif
 
 	printf("%d", spl_size_limit);
+#endif
 	return 0;
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-03 10:56 [PATCH v3 0/5] Simplify image size checks Philip Oberfichtner
                   ` (3 preceding siblings ...)
  2025-09-03 10:56 ` [PATCH v3 4/5] Image size checks: Deduplicate Makefile Philip Oberfichtner
@ 2025-09-03 10:56 ` Philip Oberfichtner
  2025-09-03 12:08   ` Heinrich Schuchardt
  2025-09-03 12:59   ` Marek Vasut
  4 siblings, 2 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-03 10:56 UTC (permalink / raw)
  To: u-boot
  Cc: Philip Oberfichtner, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Marek Vasut, Nathan Barrett-Morrison,
	Oliver Gaskell, Paul Barker, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.

Signed-off-by: Philip Oberfichtner <pro@denx.de>
---
 Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Kconfig b/Kconfig
index aa00669ba20..343299eed50 100644
--- a/Kconfig
+++ b/Kconfig
@@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
 config SPL_SIZE_LIMIT
 	hex "Maximum size of SPL image in bytes"
 	depends on HAS_SPL_SIZE_LIMIT
-	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
 	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
+	default 0x11000 if ARCH_MX6
 	default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
 	help
 	  Maximum size of the SPL image. When defined, the build system checks
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-03 10:56 ` [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic Philip Oberfichtner
@ 2025-09-03 12:08   ` Heinrich Schuchardt
  2025-09-03 12:59   ` Marek Vasut
  1 sibling, 0 replies; 34+ messages in thread
From: Heinrich Schuchardt @ 2025-09-03 12:08 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Ilias Apalodimas, Jerome Forissier, Marek Vasut,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li, u-boot

On 9/3/25 12:56, Philip Oberfichtner wrote:
> Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.
> 
> Signed-off-by: Philip Oberfichtner <pro@denx.de>
> ---
>   Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Kconfig b/Kconfig
> index aa00669ba20..343299eed50 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
>   config SPL_SIZE_LIMIT
>   	hex "Maximum size of SPL image in bytes"
>   	depends on HAS_SPL_SIZE_LIMIT
> -	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
>   	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> +	default 0x11000 if ARCH_MX6
>   	default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
>   	help
>   	  Maximum size of the SPL image. When defined, the build system checks

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-03 10:56 ` [PATCH v3 1/5] Image size checks: Move all configs in one place Philip Oberfichtner
@ 2025-09-03 12:50   ` Marek Vasut
  2025-09-04  8:12     ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-03 12:50 UTC (permalink / raw)
  To: Philip Oberfichtner, u-boot
  Cc: Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> How image size limiting works in U-Boot should be easier to grasp if we
> have all related options in one place.
> 
> Signed-off-by: Philip Oberfichtner <pro@denx.de>
> ---
>   Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
>   common/spl/Kconfig     | 38 ---------------------------
>   common/spl/Kconfig.tpl |  7 -----
>   common/spl/Kconfig.vpl |  7 -----
>   4 files changed, 59 insertions(+), 52 deletions(-)
> 
> diff --git a/Kconfig b/Kconfig
> index 70125c4e5a6..f1a6be299e8 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -535,6 +535,8 @@ config BUILD_TARGET
>   	  special image will be automatically built upon calling
>   	  make / buildman.
>   
> +menu "Image size limits"
> +
>   config HAS_BOARD_SIZE_LIMIT
>   	bool "Define a maximum size for the U-Boot image"
>   	depends on !COMPILE_TEST
> @@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
>   	  include SPL nor TPL, on platforms that use that functionality, they
>   	  have separate options to restrict size.
>   
> +config VPL_SIZE_LIMIT
> +	depends on VPL
> +	hex "Maximum size of VPL image"
> +	default 0x0
> +	help
> +	  Specifies the maximum length of the U-Boot VPL image.
> +	  If this value is zero, it is ignored.
> +
> +config TPL_SIZE_LIMIT
> +	depends on TPL
> +	hex "Maximum size of TPL image"
> +	default 0x0
> +	help
> +	  Specifies the maximum length of the U-Boot TPL image.
> +	  If this value is zero, it is ignored.
The point of separate common/spl/Kconfig.tpl and common/spl/Kconfig.vpl 
files is to group SPL / TPL / VPL symbols in those files .

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-03 10:56 ` [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently Philip Oberfichtner
@ 2025-09-03 12:51   ` Marek Vasut
  2025-09-04  8:19     ` Philip Oberfichtner
  2025-09-05 14:19   ` Tom Rini
  1 sibling, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-03 12:51 UTC (permalink / raw)
  To: Philip Oberfichtner, u-boot
  Cc: Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/3/25 12:56 PM, Philip Oberfichtner wrote:

> diff --git a/configs/am62x_beagleplay_a53_defconfig b/configs/am62x_beagleplay_a53_defconfig
> index 05853317fea..dfac96379ce 100644
> --- a/configs/am62x_beagleplay_a53_defconfig
> +++ b/configs/am62x_beagleplay_a53_defconfig
> @@ -20,6 +20,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
>   CONFIG_SPL_BSS_START_ADDR=0x80c80000
>   CONFIG_SPL_BSS_MAX_SIZE=0x80000
>   CONFIG_SPL_STACK_R=y
> +CONFIG_HAS_SPL_SIZE_LIMIT=y
How much of this massive config file patching can be done using some 
"select" in Kconfig file ?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 3/5] Image size checks: Use consistent help texts
  2025-09-03 10:56 ` [PATCH v3 3/5] Image size checks: Use consistent help texts Philip Oberfichtner
@ 2025-09-03 12:54   ` Marek Vasut
  2025-09-04  8:20     ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-03 12:54 UTC (permalink / raw)
  To: Philip Oberfichtner, u-boot
  Cc: Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> The multiple XXX_SIZE_LIMIT options use slightly varying help texts.
> Their similarities and differences should become more clear if we use
> consistent help texts.
> 
> Signed-off-by: Philip Oberfichtner <pro@denx.de>
> ---
>   Kconfig | 20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/Kconfig b/Kconfig
> index e73dd91a408..aa00669ba20 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -538,7 +538,7 @@ config BUILD_TARGET
>   menu "Image size limits"
>   
>   config HAS_BOARD_SIZE_LIMIT
> -	bool "Define a maximum size for the U-Boot image"
> +	bool "Enable size limit check for the U-Boot image"
>   	depends on !COMPILE_TEST
>   	default y if RCAR_32 || RCAR_64
>   	help
> @@ -562,11 +562,11 @@ config HAS_VPL_SIZE_LIMIT
>   	depends on VPL
>   
>   config VPL_SIZE_LIMIT
> -	hex "Maximum size of VPL image"
> +	hex "Maximum size of VPL image in bytes"
>   	depends on HAS_VPL_SIZE_LIMIT
>   	help
> -	  Specifies the maximum length of the U-Boot VPL image.
> -	  If this value is zero, it is ignored.
> +	  Maximum size of the VPL image. When defined, the build system checks

The "when defined ..." part should be in HAS_VPL_SIZE_LIMIT , which 
gates access to VPL_SIZE_LIMIT . If HAS_VPL_SIZE_LIMIT is set, then this 
is always defined.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-03 10:56 ` [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic Philip Oberfichtner
  2025-09-03 12:08   ` Heinrich Schuchardt
@ 2025-09-03 12:59   ` Marek Vasut
  2025-09-04  8:23     ` Philip Oberfichtner
  1 sibling, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-03 12:59 UTC (permalink / raw)
  To: Philip Oberfichtner, u-boot
  Cc: Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.
> 
> Signed-off-by: Philip Oberfichtner <pro@denx.de>
> ---
>   Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Kconfig b/Kconfig
> index aa00669ba20..343299eed50 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
>   config SPL_SIZE_LIMIT
>   	hex "Maximum size of SPL image in bytes"
>   	depends on HAS_SPL_SIZE_LIMIT
> -	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
>   	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> +	default 0x11000 if ARCH_MX6
This makes it less obvious what the other case (!256 kiB SRAM SoCs) 
covers, why is that an improvement ?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 4/5] Image size checks: Deduplicate Makefile
  2025-09-03 10:56 ` [PATCH v3 4/5] Image size checks: Deduplicate Makefile Philip Oberfichtner
@ 2025-09-03 13:02   ` Marek Vasut
  2025-09-04  8:30     ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-03 13:02 UTC (permalink / raw)
  To: Philip Oberfichtner, u-boot
  Cc: Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> Deduplicate some redundancies within the SIZE_CHECK code in the toplevel
> Makefile. No functional changes.
> 
> Note: To make this work for the special case of SPL, spl_size_limit.c
> has to print an empty string "" instead of zero when there is no size
> limit in place.
> 
> Signed-off-by: Philip Oberfichtner <pro@denx.de>
> ---
>   Makefile               | 45 +++++++++++-------------------------------
>   tools/spl_size_limit.c |  4 ++--
>   2 files changed, 13 insertions(+), 36 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index a17d8b57196..b6f01591ee9 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -428,8 +428,9 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
>   # Check ths size of a binary:
>   # Args:
>   #   $1: File to check
> -#   #2: Size limit in bytes (decimal or 0xhex)
> +#   #2: Size limit in bytes (decimal or 0xhex), always return OK if undefined

You should be able to use the HAS_ variables to correctly test for and 
handle the undefined case .

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-03 12:50   ` Marek Vasut
@ 2025-09-04  8:12     ` Philip Oberfichtner
  2025-09-04 13:54       ` Marek Vasut
  0 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-04  8:12 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On Wed, Sep 03, 2025 at 02:50:49PM +0200, Marek Vasut wrote:
> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > How image size limiting works in U-Boot should be easier to grasp if we
> > have all related options in one place.
> > 
> > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > ---
> >   Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
> >   common/spl/Kconfig     | 38 ---------------------------
> >   common/spl/Kconfig.tpl |  7 -----
> >   common/spl/Kconfig.vpl |  7 -----
> >   4 files changed, 59 insertions(+), 52 deletions(-)
> > 
> > diff --git a/Kconfig b/Kconfig
> > index 70125c4e5a6..f1a6be299e8 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -535,6 +535,8 @@ config BUILD_TARGET
> >   	  special image will be automatically built upon calling
> >   	  make / buildman.
> > +menu "Image size limits"
> > +
> >   config HAS_BOARD_SIZE_LIMIT
> >   	bool "Define a maximum size for the U-Boot image"
> >   	depends on !COMPILE_TEST
> > @@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
> >   	  include SPL nor TPL, on platforms that use that functionality, they
> >   	  have separate options to restrict size.
> > +config VPL_SIZE_LIMIT
> > +	depends on VPL
> > +	hex "Maximum size of VPL image"
> > +	default 0x0
> > +	help
> > +	  Specifies the maximum length of the U-Boot VPL image.
> > +	  If this value is zero, it is ignored.
> > +
> > +config TPL_SIZE_LIMIT
> > +	depends on TPL
> > +	hex "Maximum size of TPL image"
> > +	default 0x0
> > +	help
> > +	  Specifies the maximum length of the U-Boot TPL image.
> > +	  If this value is zero, it is ignored.
> The point of separate common/spl/Kconfig.tpl and common/spl/Kconfig.vpl
> files is to group SPL / TPL / VPL symbols in those files .

There is "config TPL_" definitions literally all over the place. I think
there might actually even be more of them outside Kconfig.tpl than
inside.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-03 12:51   ` Marek Vasut
@ 2025-09-04  8:19     ` Philip Oberfichtner
  2025-09-04 13:56       ` Marek Vasut
  0 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-04  8:19 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On Wed, Sep 03, 2025 at 02:51:44PM +0200, Marek Vasut wrote:
> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> 
> > diff --git a/configs/am62x_beagleplay_a53_defconfig b/configs/am62x_beagleplay_a53_defconfig
> > index 05853317fea..dfac96379ce 100644
> > --- a/configs/am62x_beagleplay_a53_defconfig
> > +++ b/configs/am62x_beagleplay_a53_defconfig
> > @@ -20,6 +20,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
> >   CONFIG_SPL_BSS_START_ADDR=0x80c80000
> >   CONFIG_SPL_BSS_MAX_SIZE=0x80000
> >   CONFIG_SPL_STACK_R=y
> > +CONFIG_HAS_SPL_SIZE_LIMIT=y
> How much of this massive config file patching can be done using some
> "select" in Kconfig file ?

I'm not following you here. I'm only adding CONFIG_HAS_XXX_SIZE_LIMIT
wherever there already was an explicit CONFIG_XXX_SIZE_LIMIT in the
defconfig before. I'm not changing anything here. Can you please
elaborate on what it is that your asking for?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 3/5] Image size checks: Use consistent help texts
  2025-09-03 12:54   ` Marek Vasut
@ 2025-09-04  8:20     ` Philip Oberfichtner
  0 siblings, 0 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-04  8:20 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On Wed, Sep 03, 2025 at 02:54:23PM +0200, Marek Vasut wrote:
> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > The multiple XXX_SIZE_LIMIT options use slightly varying help texts.
> > Their similarities and differences should become more clear if we use
> > consistent help texts.
> > 
> > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > ---
> >   Kconfig | 20 ++++++++++----------
> >   1 file changed, 10 insertions(+), 10 deletions(-)
> > 
> > diff --git a/Kconfig b/Kconfig
> > index e73dd91a408..aa00669ba20 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -538,7 +538,7 @@ config BUILD_TARGET
> >   menu "Image size limits"
> >   config HAS_BOARD_SIZE_LIMIT
> > -	bool "Define a maximum size for the U-Boot image"
> > +	bool "Enable size limit check for the U-Boot image"
> >   	depends on !COMPILE_TEST
> >   	default y if RCAR_32 || RCAR_64
> >   	help
> > @@ -562,11 +562,11 @@ config HAS_VPL_SIZE_LIMIT
> >   	depends on VPL
> >   config VPL_SIZE_LIMIT
> > -	hex "Maximum size of VPL image"
> > +	hex "Maximum size of VPL image in bytes"
> >   	depends on HAS_VPL_SIZE_LIMIT
> >   	help
> > -	  Specifies the maximum length of the U-Boot VPL image.
> > -	  If this value is zero, it is ignored.
> > +	  Maximum size of the VPL image. When defined, the build system checks
> 
> The "when defined ..." part should be in HAS_VPL_SIZE_LIMIT , which gates
> access to VPL_SIZE_LIMIT . If HAS_VPL_SIZE_LIMIT is set, then this is always
> defined.

Yep, you're right. Good point.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-03 12:59   ` Marek Vasut
@ 2025-09-04  8:23     ` Philip Oberfichtner
  2025-09-04  8:30       ` Heinrich Schuchardt
  2025-09-04 15:02       ` Marek Vasut
  0 siblings, 2 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-04  8:23 UTC (permalink / raw)
  To: Marek Vasut, Heinrich Schuchardt
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On Wed, Sep 03, 2025 at 02:59:01PM +0200, Marek Vasut wrote:
> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.
> > 
> > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > ---
> >   Kconfig | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/Kconfig b/Kconfig
> > index aa00669ba20..343299eed50 100644
> > --- a/Kconfig
> > +++ b/Kconfig
> > @@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
> >   config SPL_SIZE_LIMIT
> >   	hex "Maximum size of SPL image in bytes"
> >   	depends on HAS_SPL_SIZE_LIMIT
> > -	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> >   	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> > +	default 0x11000 if ARCH_MX6
> This makes it less obvious what the other case (!256 kiB SRAM SoCs) covers,
> why is that an improvement ?

This was originally Heinrich's idea. I personally find it better this
way, but I won't argue about it. Can you please find a consensus the two
of you?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-04  8:23     ` Philip Oberfichtner
@ 2025-09-04  8:30       ` Heinrich Schuchardt
  2025-09-04 15:02       ` Marek Vasut
  1 sibling, 0 replies; 34+ messages in thread
From: Heinrich Schuchardt @ 2025-09-04  8:30 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li, Marek Vasut

On 9/4/25 10:23, Philip Oberfichtner wrote:
> On Wed, Sep 03, 2025 at 02:59:01PM +0200, Marek Vasut wrote:
>> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
>>> Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.
>>>
>>> Signed-off-by: Philip Oberfichtner <pro@denx.de>
>>> ---
>>>    Kconfig | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/Kconfig b/Kconfig
>>> index aa00669ba20..343299eed50 100644
>>> --- a/Kconfig
>>> +++ b/Kconfig
>>> @@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
>>>    config SPL_SIZE_LIMIT
>>>    	hex "Maximum size of SPL image in bytes"
>>>    	depends on HAS_SPL_SIZE_LIMIT
>>> -	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
>>>    	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
>>> +	default 0x11000 if ARCH_MX6
>> This makes it less obvious what the other case (!256 kiB SRAM SoCs) covers,
>> why is that an improvement ?
> 
> This was originally Heinrich's idea. I personally find it better this
> way, but I won't argue about it. Can you please find a consensus the two
> of you?

We can drop the patch.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 4/5] Image size checks: Deduplicate Makefile
  2025-09-03 13:02   ` Marek Vasut
@ 2025-09-04  8:30     ` Philip Oberfichtner
  2025-09-04 15:03       ` Marek Vasut
  0 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-04  8:30 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On Wed, Sep 03, 2025 at 03:02:20PM +0200, Marek Vasut wrote:
> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > Deduplicate some redundancies within the SIZE_CHECK code in the toplevel
> > Makefile. No functional changes.
> > 
> > Note: To make this work for the special case of SPL, spl_size_limit.c
> > has to print an empty string "" instead of zero when there is no size
> > limit in place.
> > 
> > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > ---
> >   Makefile               | 45 +++++++++++-------------------------------
> >   tools/spl_size_limit.c |  4 ++--
> >   2 files changed, 13 insertions(+), 36 deletions(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index a17d8b57196..b6f01591ee9 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -428,8 +428,9 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
> >   # Check ths size of a binary:
> >   # Args:
> >   #   $1: File to check
> > -#   #2: Size limit in bytes (decimal or 0xhex)
> > +#   #2: Size limit in bytes (decimal or 0xhex), always return OK if undefined
> 
> You should be able to use the HAS_ variables to correctly test for and
> handle the undefined case .

In general, I agree. But this would mean to reintroduce the multiply
duplicated Makefile bloat à la:

	ifeq ($(CONFIG_HAS_BOARD_SIZE_LIMIT),y)
	BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
	else
	BOARD_SIZE_CHECK =
	endif


That's why after all I preferred my "test -z" solution. Is there maybe
a third way I am missing out on?

What do you think about giving size_check another argument, i.e. 
call size_check,$@,$(CONFIG_HAS_BOARD_SIZE_LIMIT),$(CONFIG_BOARD_SIZE_LIMIT)

Any other suggestions?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-04  8:12     ` Philip Oberfichtner
@ 2025-09-04 13:54       ` Marek Vasut
  2025-09-05  8:13         ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-04 13:54 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/4/25 10:12 AM, Philip Oberfichtner wrote:
> On Wed, Sep 03, 2025 at 02:50:49PM +0200, Marek Vasut wrote:
>> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
>>> How image size limiting works in U-Boot should be easier to grasp if we
>>> have all related options in one place.
>>>
>>> Signed-off-by: Philip Oberfichtner <pro@denx.de>
>>> ---
>>>    Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
>>>    common/spl/Kconfig     | 38 ---------------------------
>>>    common/spl/Kconfig.tpl |  7 -----
>>>    common/spl/Kconfig.vpl |  7 -----
>>>    4 files changed, 59 insertions(+), 52 deletions(-)
>>>
>>> diff --git a/Kconfig b/Kconfig
>>> index 70125c4e5a6..f1a6be299e8 100644
>>> --- a/Kconfig
>>> +++ b/Kconfig
>>> @@ -535,6 +535,8 @@ config BUILD_TARGET
>>>    	  special image will be automatically built upon calling
>>>    	  make / buildman.
>>> +menu "Image size limits"
>>> +
>>>    config HAS_BOARD_SIZE_LIMIT
>>>    	bool "Define a maximum size for the U-Boot image"
>>>    	depends on !COMPILE_TEST
>>> @@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
>>>    	  include SPL nor TPL, on platforms that use that functionality, they
>>>    	  have separate options to restrict size.
>>> +config VPL_SIZE_LIMIT
>>> +	depends on VPL
>>> +	hex "Maximum size of VPL image"
>>> +	default 0x0
>>> +	help
>>> +	  Specifies the maximum length of the U-Boot VPL image.
>>> +	  If this value is zero, it is ignored.
>>> +
>>> +config TPL_SIZE_LIMIT
>>> +	depends on TPL
>>> +	hex "Maximum size of TPL image"
>>> +	default 0x0
>>> +	help
>>> +	  Specifies the maximum length of the U-Boot TPL image.
>>> +	  If this value is zero, it is ignored.
>> The point of separate common/spl/Kconfig.tpl and common/spl/Kconfig.vpl
>> files is to group SPL / TPL / VPL symbols in those files .
> 
> There is "config TPL_" definitions literally all over the place. I think
> there might actually even be more of them outside Kconfig.tpl than
> inside.

That does not make it OK to make that situation worse.

This config TPL... should be in common/spl/Kconfig.tpl .

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-04  8:19     ` Philip Oberfichtner
@ 2025-09-04 13:56       ` Marek Vasut
  2025-09-05  8:15         ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-04 13:56 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/4/25 10:19 AM, Philip Oberfichtner wrote:
> On Wed, Sep 03, 2025 at 02:51:44PM +0200, Marek Vasut wrote:
>> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
>>
>>> diff --git a/configs/am62x_beagleplay_a53_defconfig b/configs/am62x_beagleplay_a53_defconfig
>>> index 05853317fea..dfac96379ce 100644
>>> --- a/configs/am62x_beagleplay_a53_defconfig
>>> +++ b/configs/am62x_beagleplay_a53_defconfig
>>> @@ -20,6 +20,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
>>>    CONFIG_SPL_BSS_START_ADDR=0x80c80000
>>>    CONFIG_SPL_BSS_MAX_SIZE=0x80000
>>>    CONFIG_SPL_STACK_R=y
>>> +CONFIG_HAS_SPL_SIZE_LIMIT=y
>> How much of this massive config file patching can be done using some
>> "select" in Kconfig file ?
> 
> I'm not following you here. I'm only adding CONFIG_HAS_XXX_SIZE_LIMIT
> wherever there already was an explicit CONFIG_XXX_SIZE_LIMIT in the
> defconfig before. I'm not changing anything here. Can you please
> elaborate on what it is that your asking for?

Can this massive configs/ update be avoided by using a default value / 
select / imply in some Kconfig file ?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-04  8:23     ` Philip Oberfichtner
  2025-09-04  8:30       ` Heinrich Schuchardt
@ 2025-09-04 15:02       ` Marek Vasut
  2025-09-05  8:19         ` Philip Oberfichtner
  1 sibling, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-04 15:02 UTC (permalink / raw)
  To: Philip Oberfichtner, Heinrich Schuchardt
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/4/25 10:23 AM, Philip Oberfichtner wrote:
> On Wed, Sep 03, 2025 at 02:59:01PM +0200, Marek Vasut wrote:
>> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
>>> Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.
>>>
>>> Signed-off-by: Philip Oberfichtner <pro@denx.de>
>>> ---
>>>    Kconfig | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/Kconfig b/Kconfig
>>> index aa00669ba20..343299eed50 100644
>>> --- a/Kconfig
>>> +++ b/Kconfig
>>> @@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
>>>    config SPL_SIZE_LIMIT
>>>    	hex "Maximum size of SPL image in bytes"
>>>    	depends on HAS_SPL_SIZE_LIMIT
>>> -	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
>>>    	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
>>> +	default 0x11000 if ARCH_MX6
>> This makes it less obvious what the other case (!256 kiB SRAM SoCs) covers,
>> why is that an improvement ?
> 
> This was originally Heinrich's idea. I personally find it better this
> way, but I won't argue about it.

Why do you send a patch which you cannot even argue is correct ?

> Can you please find a consensus the two of you?

No, you should be able to clarify why this patch should be applied, do 
not shift this onus to other participants.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 4/5] Image size checks: Deduplicate Makefile
  2025-09-04  8:30     ` Philip Oberfichtner
@ 2025-09-04 15:03       ` Marek Vasut
  2025-09-05  8:22         ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Marek Vasut @ 2025-09-04 15:03 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker, Peng Fan,
	Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On 9/4/25 10:30 AM, Philip Oberfichtner wrote:
> On Wed, Sep 03, 2025 at 03:02:20PM +0200, Marek Vasut wrote:
>> On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
>>> Deduplicate some redundancies within the SIZE_CHECK code in the toplevel
>>> Makefile. No functional changes.
>>>
>>> Note: To make this work for the special case of SPL, spl_size_limit.c
>>> has to print an empty string "" instead of zero when there is no size
>>> limit in place.
>>>
>>> Signed-off-by: Philip Oberfichtner <pro@denx.de>
>>> ---
>>>    Makefile               | 45 +++++++++++-------------------------------
>>>    tools/spl_size_limit.c |  4 ++--
>>>    2 files changed, 13 insertions(+), 36 deletions(-)
>>>
>>> diff --git a/Makefile b/Makefile
>>> index a17d8b57196..b6f01591ee9 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -428,8 +428,9 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
>>>    # Check ths size of a binary:
>>>    # Args:
>>>    #   $1: File to check
>>> -#   #2: Size limit in bytes (decimal or 0xhex)
>>> +#   #2: Size limit in bytes (decimal or 0xhex), always return OK if undefined
>>
>> You should be able to use the HAS_ variables to correctly test for and
>> handle the undefined case .
> 
> In general, I agree. But this would mean to reintroduce the multiply
> duplicated Makefile bloat à la:
> 
> 	ifeq ($(CONFIG_HAS_BOARD_SIZE_LIMIT),y)
> 	BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
> 	else
> 	BOARD_SIZE_CHECK =
> 	endif
> 
> 
> That's why after all I preferred my "test -z" solution. Is there maybe
> a third way I am missing out on?
> 
> What do you think about giving size_check another argument, i.e.
> call size_check,$@,$(CONFIG_HAS_BOARD_SIZE_LIMIT),$(CONFIG_BOARD_SIZE_LIMIT)
This could be an option , yes .

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-04 13:54       ` Marek Vasut
@ 2025-09-05  8:13         ` Philip Oberfichtner
  2025-09-05 14:22           ` Tom Rini
  0 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-05  8:13 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

On Thu, Sep 04, 2025 at 03:54:54PM +0200, Marek Vasut wrote:
> On 9/4/25 10:12 AM, Philip Oberfichtner wrote:
> > On Wed, Sep 03, 2025 at 02:50:49PM +0200, Marek Vasut wrote:
> > > On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > > > How image size limiting works in U-Boot should be easier to grasp if we
> > > > have all related options in one place.
> > > > 
> > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > > ---
> > > >    Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
> > > >    common/spl/Kconfig     | 38 ---------------------------
> > > >    common/spl/Kconfig.tpl |  7 -----
> > > >    common/spl/Kconfig.vpl |  7 -----
> > > >    4 files changed, 59 insertions(+), 52 deletions(-)
> > > > 
> > > > diff --git a/Kconfig b/Kconfig
> > > > index 70125c4e5a6..f1a6be299e8 100644
> > > > --- a/Kconfig
> > > > +++ b/Kconfig
> > > > @@ -535,6 +535,8 @@ config BUILD_TARGET
> > > >    	  special image will be automatically built upon calling
> > > >    	  make / buildman.
> > > > +menu "Image size limits"
> > > > +
> > > >    config HAS_BOARD_SIZE_LIMIT
> > > >    	bool "Define a maximum size for the U-Boot image"
> > > >    	depends on !COMPILE_TEST
> > > > @@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
> > > >    	  include SPL nor TPL, on platforms that use that functionality, they
> > > >    	  have separate options to restrict size.
> > > > +config VPL_SIZE_LIMIT
> > > > +	depends on VPL
> > > > +	hex "Maximum size of VPL image"
> > > > +	default 0x0
> > > > +	help
> > > > +	  Specifies the maximum length of the U-Boot VPL image.
> > > > +	  If this value is zero, it is ignored.
> > > > +
> > > > +config TPL_SIZE_LIMIT
> > > > +	depends on TPL
> > > > +	hex "Maximum size of TPL image"
> > > > +	default 0x0
> > > > +	help
> > > > +	  Specifies the maximum length of the U-Boot TPL image.
> > > > +	  If this value is zero, it is ignored.
> > > The point of separate common/spl/Kconfig.tpl and common/spl/Kconfig.vpl
> > > files is to group SPL / TPL / VPL symbols in those files .
> > 
> > There is "config TPL_" definitions literally all over the place. I think
> > there might actually even be more of them outside Kconfig.tpl than
> > inside.
> 
> That does not make it OK to make that situation worse.

It doesn't. Someone who stumbles over BOARD_SIZE_LIMIT might be asking
himself, if there's an analogous option for SPL, too. It'll jump right
into his eyes, after this patch of mine.

And apparently there were other contributers before me who found it
reasonable to group strongly related options together within one menu,
instead of spreading them out over many different places. Let me give
you a few examples (and this list is by far not exhaustive):


	Kconfig:
		config SYS_MALLOC_F
		config SPL_SYS_MALLOC_F
		config TPL_SYS_MALLOC_F
		config VPL_SYS_MALLOC_F

	arch/Kconfig 
		menu "Skipping low level initialization functions"
		config SKIP_LOWLEVEL_INIT
		config SPL_SKIP_LOWLEVEL_INIT
		config TPL_SKIP_LOWLEVEL_INIT

	boot/Kconfig
		menuconfig FIT
		config SPL_FIT
		config VPL_FIT
		config TPL_FIT


	common/Kconfig
		menu "Logging"
		config LOG
		config SPL_LOG
		config TPL_LOG
		config VPL_LOG

	dts/Kconfig
		menu "Device Tree Control"
		config OF_CONTROL
		config SPL_OF_CONTROL
		config TPL_OF_CONTROL
		config VPL_OF_CONTROL

	lib/Kconfig
		menu "Compression Support"
		config LZ4
		config SPL_LZ4
		config TPL_LZ4
		config VPL_LZ4


So how do these and many other cases differ from the SIZE_LIMIT case
discussed here? Or would it be better to tear all those menus apart?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-04 13:56       ` Marek Vasut
@ 2025-09-05  8:15         ` Philip Oberfichtner
  0 siblings, 0 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-05  8:15 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

On Thu, Sep 04, 2025 at 03:56:26PM +0200, Marek Vasut wrote:
> On 9/4/25 10:19 AM, Philip Oberfichtner wrote:
> > On Wed, Sep 03, 2025 at 02:51:44PM +0200, Marek Vasut wrote:
> > > On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > > 
> > > > diff --git a/configs/am62x_beagleplay_a53_defconfig b/configs/am62x_beagleplay_a53_defconfig
> > > > index 05853317fea..dfac96379ce 100644
> > > > --- a/configs/am62x_beagleplay_a53_defconfig
> > > > +++ b/configs/am62x_beagleplay_a53_defconfig
> > > > @@ -20,6 +20,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
> > > >    CONFIG_SPL_BSS_START_ADDR=0x80c80000
> > > >    CONFIG_SPL_BSS_MAX_SIZE=0x80000
> > > >    CONFIG_SPL_STACK_R=y
> > > > +CONFIG_HAS_SPL_SIZE_LIMIT=y
> > > How much of this massive config file patching can be done using some
> > > "select" in Kconfig file ?
> > 
> > I'm not following you here. I'm only adding CONFIG_HAS_XXX_SIZE_LIMIT
> > wherever there already was an explicit CONFIG_XXX_SIZE_LIMIT in the
> > defconfig before. I'm not changing anything here. Can you please
> > elaborate on what it is that your asking for?
> 
> Can this massive configs/ update be avoided by using a default value /
> select / imply in some Kconfig file ?

No, I'm afraid it cannot ...

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic
  2025-09-04 15:02       ` Marek Vasut
@ 2025-09-05  8:19         ` Philip Oberfichtner
  0 siblings, 0 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-05  8:19 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Heinrich Schuchardt, u-boot, Andre Przywara, Anshul Dalal,
	Dario Binacchi, Greg Malysa, Heinrich Schuchardt,
	Ilias Apalodimas, Jerome Forissier, Nathan Barrett-Morrison,
	Peng Fan, Simon Glass, Tom Rini, Trevor Woerner, Ye Li

On Thu, Sep 04, 2025 at 05:02:30PM +0200, Marek Vasut wrote:
> On 9/4/25 10:23 AM, Philip Oberfichtner wrote:
> > On Wed, Sep 03, 2025 at 02:59:01PM +0200, Marek Vasut wrote:
> > > On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > > > Simplify the depends-on logic for SPL_SIZE_LIMIT. No functional change.
> > > > 
> > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > > ---
> > > >    Kconfig | 2 +-
> > > >    1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/Kconfig b/Kconfig
> > > > index aa00669ba20..343299eed50 100644
> > > > --- a/Kconfig
> > > > +++ b/Kconfig
> > > > @@ -588,8 +588,8 @@ config HAS_SPL_SIZE_LIMIT
> > > >    config SPL_SIZE_LIMIT
> > > >    	hex "Maximum size of SPL image in bytes"
> > > >    	depends on HAS_SPL_SIZE_LIMIT
> > > > -	default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> > > >    	default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> > > > +	default 0x11000 if ARCH_MX6
> > > This makes it less obvious what the other case (!256 kiB SRAM SoCs) covers,
> > > why is that an improvement ?
> > 
> > This was originally Heinrich's idea. I personally find it better this
> > way, but I won't argue about it.
> 
> Why do you send a patch which you cannot even argue is correct ?
> 
> > Can you please find a consensus the two of you?
> 
> No, you should be able to clarify why this patch should be applied, do not
> shift this onus to other participants.

I prefer conciseness over verbosity. That's all. But I'm okay to step
back on this one. There may be different view points.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 4/5] Image size checks: Deduplicate Makefile
  2025-09-04 15:03       ` Marek Vasut
@ 2025-09-05  8:22         ` Philip Oberfichtner
  0 siblings, 0 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-05  8:22 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Nathan Barrett-Morrison, Peng Fan, Simon Glass, Tom Rini,
	Trevor Woerner, Ye Li

On Thu, Sep 04, 2025 at 05:03:24PM +0200, Marek Vasut wrote:
> On 9/4/25 10:30 AM, Philip Oberfichtner wrote:
> > On Wed, Sep 03, 2025 at 03:02:20PM +0200, Marek Vasut wrote:
> > > On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > > > Deduplicate some redundancies within the SIZE_CHECK code in the toplevel
> > > > Makefile. No functional changes.
> > > > 
> > > > Note: To make this work for the special case of SPL, spl_size_limit.c
> > > > has to print an empty string "" instead of zero when there is no size
> > > > limit in place.
> > > > 
> > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > > ---
> > > >    Makefile               | 45 +++++++++++-------------------------------
> > > >    tools/spl_size_limit.c |  4 ++--
> > > >    2 files changed, 13 insertions(+), 36 deletions(-)
> > > > 
> > > > diff --git a/Makefile b/Makefile
> > > > index a17d8b57196..b6f01591ee9 100644
> > > > --- a/Makefile
> > > > +++ b/Makefile
> > > > @@ -428,8 +428,9 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
> > > >    # Check ths size of a binary:
> > > >    # Args:
> > > >    #   $1: File to check
> > > > -#   #2: Size limit in bytes (decimal or 0xhex)
> > > > +#   #2: Size limit in bytes (decimal or 0xhex), always return OK if undefined
> > > 
> > > You should be able to use the HAS_ variables to correctly test for and
> > > handle the undefined case .
> > 
> > In general, I agree. But this would mean to reintroduce the multiply
> > duplicated Makefile bloat à la:
> > 
> > 	ifeq ($(CONFIG_HAS_BOARD_SIZE_LIMIT),y)
> > 	BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT))
> > 	else
> > 	BOARD_SIZE_CHECK =
> > 	endif
> > 
> > 
> > That's why after all I preferred my "test -z" solution. Is there maybe
> > a third way I am missing out on?
> > 
> > What do you think about giving size_check another argument, i.e.
> > call size_check,$@,$(CONFIG_HAS_BOARD_SIZE_LIMIT),$(CONFIG_BOARD_SIZE_LIMIT)
> This could be an option , yes .

Okay, I'll try it this way in v4.

Unfortunately I'm on leave the upcoming three weeks. I won't be able to
pick up this patch again before the end of this month.

Best regards,
Philip

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-03 10:56 ` [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently Philip Oberfichtner
  2025-09-03 12:51   ` Marek Vasut
@ 2025-09-05 14:19   ` Tom Rini
  2025-09-30  8:33     ` Philip Oberfichtner
  1 sibling, 1 reply; 34+ messages in thread
From: Tom Rini @ 2025-09-05 14:19 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Marek Vasut, Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker,
	Peng Fan, Simon Glass, Trevor Woerner, Ye Li

[-- Attachment #1: Type: text/plain, Size: 2738 bytes --]

On Wed, Sep 03, 2025 at 12:56:50PM +0200, Philip Oberfichtner wrote:

> Use a consistent logic for image size checks. No functional change.
> 
> Before this commit, there were two concurrent approaches of how image
> size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
> dedicated Kconfig symbol to achieve this, all the other size checks were
> disabled by assigning them a limit of zero bytes.
> 
> By this commit we achieve a consistent logic for size limiting, by
> introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
> have it yet.
> 
> Signed-off-by: Philip Oberfichtner <pro@denx.de>
[snip]
> diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
> index f2e959b5662..d4d46100736 100644
> --- a/arch/arm/mach-socfpga/Kconfig
> +++ b/arch/arm/mach-socfpga/Kconfig
> @@ -22,8 +22,11 @@ config SOCFPGA_SECURE_VAB_AUTH_ALLOW_NON_FIT_IMAGE
>  	bool "Allow non-FIT VAB signed images"
>  	depends on SOCFPGA_SECURE_VAB_AUTH
>  
> +config HAS_SPL_SIZE_LIMIT
> +	default y if TARGET_SOCFPGA_GEN5
> +
>  config SPL_SIZE_LIMIT
> -	default 0x10000 if TARGET_SOCFPGA_GEN5
> +	default 0x10000 if TARGET_SOCFPGA_GEN5 && HAS_SPL_SIZE_LIMIT
>  
>  config SPL_SIZE_LIMIT_PROVIDE_STACK
>  	default 0x200 if TARGET_SOCFPGA_GEN5
> diff --git a/arch/mips/mach-mtmips/Kconfig b/arch/mips/mach-mtmips/Kconfig
> index 3fcd0b8465b..d2a1652954c 100644
> --- a/arch/mips/mach-mtmips/Kconfig
> +++ b/arch/mips/mach-mtmips/Kconfig
> @@ -36,8 +36,11 @@ config SPL_TEXT_BASE
>  	default 0x9c000000 if !SOC_MT7621
>  	default 0x80100000 if SOC_MT7621
>  
> +config HAS_SPL_SIZE_LIMIT
> +	default y if SOC_MT7621
> +
>  config SPL_SIZE_LIMIT
> -	default 0x30000 if SOC_MT7621
> +	default 0x30000 if SOC_MT7621 && HAS_SPL_SIZE_LIMIT
>  
>  config TPL_TEXT_BASE
>  	default 0xbfc00000 if SOC_MT7621
> diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
> index 5dd866ffcfe..d70e8def36f 100644
> --- a/arch/x86/cpu/apollolake/Kconfig
> +++ b/arch/x86/cpu/apollolake/Kconfig
> @@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
>  	hex
>  	default 0xe0000000
>  
> +config HAS_TPL_SIZE_LIMIT
> +	default y
> +
>  config TPL_SIZE_LIMIT
> -	default 0x7800
> +	default 0x7800 if HAS_TPL_SIZE_LIMIT
>  
>  config CPU_ADDR_BITS
>  	default 39

These should be "default y if .." in the main Kconfig entry for the
option.

> diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig

The reset of these, to Marek's point, show that we need to also add
"default y if .." for a number of other platforms too. At least the ones
where today we have default limits provided in Kconfig today.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-05  8:13         ` Philip Oberfichtner
@ 2025-09-05 14:22           ` Tom Rini
  2025-10-10 14:19             ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Rini @ 2025-09-05 14:22 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: Marek Vasut, u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Nathan Barrett-Morrison, Peng Fan, Simon Glass,
	Trevor Woerner, Ye Li

[-- Attachment #1: Type: text/plain, Size: 4332 bytes --]

On Fri, Sep 05, 2025 at 10:13:36AM +0200, Philip Oberfichtner wrote:
> On Thu, Sep 04, 2025 at 03:54:54PM +0200, Marek Vasut wrote:
> > On 9/4/25 10:12 AM, Philip Oberfichtner wrote:
> > > On Wed, Sep 03, 2025 at 02:50:49PM +0200, Marek Vasut wrote:
> > > > On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > > > > How image size limiting works in U-Boot should be easier to grasp if we
> > > > > have all related options in one place.
> > > > > 
> > > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > > > ---
> > > > >    Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
> > > > >    common/spl/Kconfig     | 38 ---------------------------
> > > > >    common/spl/Kconfig.tpl |  7 -----
> > > > >    common/spl/Kconfig.vpl |  7 -----
> > > > >    4 files changed, 59 insertions(+), 52 deletions(-)
> > > > > 
> > > > > diff --git a/Kconfig b/Kconfig
> > > > > index 70125c4e5a6..f1a6be299e8 100644
> > > > > --- a/Kconfig
> > > > > +++ b/Kconfig
> > > > > @@ -535,6 +535,8 @@ config BUILD_TARGET
> > > > >    	  special image will be automatically built upon calling
> > > > >    	  make / buildman.
> > > > > +menu "Image size limits"
> > > > > +
> > > > >    config HAS_BOARD_SIZE_LIMIT
> > > > >    	bool "Define a maximum size for the U-Boot image"
> > > > >    	depends on !COMPILE_TEST
> > > > > @@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
> > > > >    	  include SPL nor TPL, on platforms that use that functionality, they
> > > > >    	  have separate options to restrict size.
> > > > > +config VPL_SIZE_LIMIT
> > > > > +	depends on VPL
> > > > > +	hex "Maximum size of VPL image"
> > > > > +	default 0x0
> > > > > +	help
> > > > > +	  Specifies the maximum length of the U-Boot VPL image.
> > > > > +	  If this value is zero, it is ignored.
> > > > > +
> > > > > +config TPL_SIZE_LIMIT
> > > > > +	depends on TPL
> > > > > +	hex "Maximum size of TPL image"
> > > > > +	default 0x0
> > > > > +	help
> > > > > +	  Specifies the maximum length of the U-Boot TPL image.
> > > > > +	  If this value is zero, it is ignored.
> > > > The point of separate common/spl/Kconfig.tpl and common/spl/Kconfig.vpl
> > > > files is to group SPL / TPL / VPL symbols in those files .
> > > 
> > > There is "config TPL_" definitions literally all over the place. I think
> > > there might actually even be more of them outside Kconfig.tpl than
> > > inside.
> > 
> > That does not make it OK to make that situation worse.
> 
> It doesn't. Someone who stumbles over BOARD_SIZE_LIMIT might be asking
> himself, if there's an analogous option for SPL, too. It'll jump right
> into his eyes, after this patch of mine.
> 
> And apparently there were other contributers before me who found it
> reasonable to group strongly related options together within one menu,
> instead of spreading them out over many different places. Let me give
> you a few examples (and this list is by far not exhaustive):
> 
> 
> 	Kconfig:
> 		config SYS_MALLOC_F
> 		config SPL_SYS_MALLOC_F
> 		config TPL_SYS_MALLOC_F
> 		config VPL_SYS_MALLOC_F
> 
> 	arch/Kconfig 
> 		menu "Skipping low level initialization functions"
> 		config SKIP_LOWLEVEL_INIT
> 		config SPL_SKIP_LOWLEVEL_INIT
> 		config TPL_SKIP_LOWLEVEL_INIT
> 
> 	boot/Kconfig
> 		menuconfig FIT
> 		config SPL_FIT
> 		config VPL_FIT
> 		config TPL_FIT
> 
> 
> 	common/Kconfig
> 		menu "Logging"
> 		config LOG
> 		config SPL_LOG
> 		config TPL_LOG
> 		config VPL_LOG
> 
> 	dts/Kconfig
> 		menu "Device Tree Control"
> 		config OF_CONTROL
> 		config SPL_OF_CONTROL
> 		config TPL_OF_CONTROL
> 		config VPL_OF_CONTROL
> 
> 	lib/Kconfig
> 		menu "Compression Support"
> 		config LZ4
> 		config SPL_LZ4
> 		config TPL_LZ4
> 		config VPL_LZ4
> 
> 
> So how do these and many other cases differ from the SIZE_LIMIT case
> discussed here? Or would it be better to tear all those menus apart?

We are not consistent about this, and it really becomes a stylistic
argument. Roughly speaking, common/spl/Kconfig.* is for things core to a
given phase (SPL, TPL, VPL) which is why often but not always, say
compression algorithms are with the compression algorithms. In this
case, limits are a core part of the phase so I think Marek's point is
valid here.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-05 14:19   ` Tom Rini
@ 2025-09-30  8:33     ` Philip Oberfichtner
  2025-09-30 14:45       ` Tom Rini
  0 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-09-30  8:33 UTC (permalink / raw)
  To: Tom Rini
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Marek Vasut, Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker,
	Peng Fan, Simon Glass, Trevor Woerner, Ye Li

On Fri, Sep 05, 2025 at 08:19:59AM -0600, Tom Rini wrote:
> On Wed, Sep 03, 2025 at 12:56:50PM +0200, Philip Oberfichtner wrote:
> 
> > Use a consistent logic for image size checks. No functional change.
> > 
> > Before this commit, there were two concurrent approaches of how image
> > size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
> > dedicated Kconfig symbol to achieve this, all the other size checks were
> > disabled by assigning them a limit of zero bytes.
> > 
> > By this commit we achieve a consistent logic for size limiting, by
> > introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
> > have it yet.
> > 
> > Signed-off-by: Philip Oberfichtner <pro@denx.de>
<...>
> > diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
> > index 5dd866ffcfe..d70e8def36f 100644
> > --- a/arch/x86/cpu/apollolake/Kconfig
> > +++ b/arch/x86/cpu/apollolake/Kconfig
> > @@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
> >  	hex
> >  	default 0xe0000000
> >  
> > +config HAS_TPL_SIZE_LIMIT
> > +	default y
> > +
> >  config TPL_SIZE_LIMIT
> > -	default 0x7800
> > +	default 0x7800 if HAS_TPL_SIZE_LIMIT
> >  
> >  config CPU_ADDR_BITS
> >  	default 39
> 
> These should be "default y if .." in the main Kconfig entry for the
> option.

Not sure if I'm following you here. So you mean both of the defaults
should be moved to common/spl/Kconfig.tpl? - like

	config HAS_TPL_SIZE_LIMIT
		[...]
		default y if INTEL_APOLLOLAKE


	config TPL_SIZE_LIMIT
		[...]
		default 0x7800 if INTEL_APOLLOLAKE

> 
> > diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig
> 
> The reset of these, to Marek's point, show that we need to also add
> "default y if .." for a number of other platforms too.

Which platforms exactly?

> At least the ones
> where today we have default limits provided in Kconfig today.

Besides the ones handled above, i.e.
	arch/arm/mach-socfpga/Kconfig,
	arch/mips/mach-mtmips/Kconfig and
	arch/x86/cpu/apollolake/Kconfig,

there aren't any.

I myself am not very fond of changing that many defconfigs, but I still
don't see a way of avoiding it. I guess it would become more clear if
you concretely name a few examples.

Best regards,
Philip

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-30  8:33     ` Philip Oberfichtner
@ 2025-09-30 14:45       ` Tom Rini
  2025-10-02  8:55         ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Rini @ 2025-09-30 14:45 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Marek Vasut, Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker,
	Peng Fan, Simon Glass, Trevor Woerner, Ye Li

[-- Attachment #1: Type: text/plain, Size: 3787 bytes --]

On Tue, Sep 30, 2025 at 10:33:13AM +0200, Philip Oberfichtner wrote:
> On Fri, Sep 05, 2025 at 08:19:59AM -0600, Tom Rini wrote:
> > On Wed, Sep 03, 2025 at 12:56:50PM +0200, Philip Oberfichtner wrote:
> > 
> > > Use a consistent logic for image size checks. No functional change.
> > > 
> > > Before this commit, there were two concurrent approaches of how image
> > > size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
> > > dedicated Kconfig symbol to achieve this, all the other size checks were
> > > disabled by assigning them a limit of zero bytes.
> > > 
> > > By this commit we achieve a consistent logic for size limiting, by
> > > introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
> > > have it yet.
> > > 
> > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> <...>
> > > diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
> > > index 5dd866ffcfe..d70e8def36f 100644
> > > --- a/arch/x86/cpu/apollolake/Kconfig
> > > +++ b/arch/x86/cpu/apollolake/Kconfig
> > > @@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
> > >  	hex
> > >  	default 0xe0000000
> > >  
> > > +config HAS_TPL_SIZE_LIMIT
> > > +	default y
> > > +
> > >  config TPL_SIZE_LIMIT
> > > -	default 0x7800
> > > +	default 0x7800 if HAS_TPL_SIZE_LIMIT
> > >  
> > >  config CPU_ADDR_BITS
> > >  	default 39
> > 
> > These should be "default y if .." in the main Kconfig entry for the
> > option.
> 
> Not sure if I'm following you here. So you mean both of the defaults
> should be moved to common/spl/Kconfig.tpl? - like
> 
> 	config HAS_TPL_SIZE_LIMIT
> 		[...]
> 		default y if INTEL_APOLLOLAKE
> 
> 
> 	config TPL_SIZE_LIMIT
> 		[...]
> 		default 0x7800 if INTEL_APOLLOLAKE

Yes, like that.

> > > diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig
> > 
> > The reset of these, to Marek's point, show that we need to also add
> > "default y if .." for a number of other platforms too.
> 
> Which platforms exactly?

So the platforms today which have a default ..size.. if SOC should also
be listed as default y if SOC, is that I was I believe getting at.

> > At least the ones
> > where today we have default limits provided in Kconfig today.
> 
> Besides the ones handled above, i.e.
> 	arch/arm/mach-socfpga/Kconfig,
> 	arch/mips/mach-mtmips/Kconfig and
> 	arch/x86/cpu/apollolake/Kconfig,
> 
> there aren't any.
> 
> I myself am not very fond of changing that many defconfigs, but I still
> don't see a way of avoiding it. I guess it would become more clear if
> you concretely name a few examples.

So, part of the pattern is that we should take this from
common/spl/Kconfig:
config SPL_SIZE_LIMIT
        hex "Maximum size of SPL image"
        default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
        default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
        default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
        default 0x0
        help
	  ...
And it becomes:

config HAS_SPL_SIZE_LIMIT
	bool "Enforce a maximum size of the SPL image
	default y if ARCH_MX6 || (ARCH_MVEBU && ARMADA_32BIT) || \
		ARCH_K3
	help
	  .. What we had talked about in earlier threads to be clear about what
	  .. is / isn't checked by this option.

config SPL_SIZE_LIMIT
        hex "Maximum size of SPL image"
	depends on HAS_SPL_SIZE_LIMIT
        default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
        default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
        default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
	help
	  ..

And note that I've added ARCH_K3 to the list here because from a quick grep, TI
K3 platforms also set SPL_SIZE_LIMIT and so with this, you won't have to change
all of those defconfigs as well.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-09-30 14:45       ` Tom Rini
@ 2025-10-02  8:55         ` Philip Oberfichtner
  2025-10-02 21:19           ` Tom Rini
  0 siblings, 1 reply; 34+ messages in thread
From: Philip Oberfichtner @ 2025-10-02  8:55 UTC (permalink / raw)
  To: Tom Rini
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Marek Vasut, Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker,
	Peng Fan, Simon Glass, Trevor Woerner, Ye Li

Hi Tom,

Thank you for the clarification.

On Tue, Sep 30, 2025 at 08:45:36AM -0600, Tom Rini wrote:
> On Tue, Sep 30, 2025 at 10:33:13AM +0200, Philip Oberfichtner wrote:
> > On Fri, Sep 05, 2025 at 08:19:59AM -0600, Tom Rini wrote:
> > > On Wed, Sep 03, 2025 at 12:56:50PM +0200, Philip Oberfichtner wrote:
> > > 
> > > > Use a consistent logic for image size checks. No functional change.
> > > > 
> > > > Before this commit, there were two concurrent approaches of how image
> > > > size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
> > > > dedicated Kconfig symbol to achieve this, all the other size checks were
> > > > disabled by assigning them a limit of zero bytes.
> > > > 
> > > > By this commit we achieve a consistent logic for size limiting, by
> > > > introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
> > > > have it yet.
> > > > 
> > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > <...>
> > > > diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
> > > > index 5dd866ffcfe..d70e8def36f 100644
> > > > --- a/arch/x86/cpu/apollolake/Kconfig
> > > > +++ b/arch/x86/cpu/apollolake/Kconfig
> > > > @@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
> > > >  	hex
> > > >  	default 0xe0000000
> > > >  
> > > > +config HAS_TPL_SIZE_LIMIT
> > > > +	default y
> > > > +
> > > >  config TPL_SIZE_LIMIT
> > > > -	default 0x7800
> > > > +	default 0x7800 if HAS_TPL_SIZE_LIMIT
> > > >  
> > > >  config CPU_ADDR_BITS
> > > >  	default 39
> > > 
> > > These should be "default y if .." in the main Kconfig entry for the
> > > option.
> > 
> > Not sure if I'm following you here. So you mean both of the defaults
> > should be moved to common/spl/Kconfig.tpl? - like
> > 
> > 	config HAS_TPL_SIZE_LIMIT
> > 		[...]
> > 		default y if INTEL_APOLLOLAKE
> > 
> > 
> > 	config TPL_SIZE_LIMIT
> > 		[...]
> > 		default 0x7800 if INTEL_APOLLOLAKE
> 
> Yes, like that.

Ok.

> 
> > > > diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig
> > > 
> > > The reset of these, to Marek's point, show that we need to also add
> > > "default y if .." for a number of other platforms too.
> > 
> > Which platforms exactly?
> 
> So the platforms today which have a default ..size.. if SOC should also
> be listed as default y if SOC, is that I was I believe getting at.

Yes, this part is already included as of now.

> 
> > > At least the ones
> > > where today we have default limits provided in Kconfig today.
> > 
> > Besides the ones handled above, i.e.
> > 	arch/arm/mach-socfpga/Kconfig,
> > 	arch/mips/mach-mtmips/Kconfig and
> > 	arch/x86/cpu/apollolake/Kconfig,
> > 
> > there aren't any.
> > 
> > I myself am not very fond of changing that many defconfigs, but I still
> > don't see a way of avoiding it. I guess it would become more clear if
> > you concretely name a few examples.
> 
> So, part of the pattern is that we should take this from
> common/spl/Kconfig:
> config SPL_SIZE_LIMIT
>         hex "Maximum size of SPL image"
>         default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
>         default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
>         default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
>         default 0x0
>         help
> 	  ...
> And it becomes:
> 
> config HAS_SPL_SIZE_LIMIT
> 	bool "Enforce a maximum size of the SPL image
> 	default y if ARCH_MX6 || (ARCH_MVEBU && ARMADA_32BIT) || \
> 		ARCH_K3
> 	help
> 	  .. What we had talked about in earlier threads to be clear about what
> 	  .. is / isn't checked by this option.
> 
> config SPL_SIZE_LIMIT
>         hex "Maximum size of SPL image"
> 	depends on HAS_SPL_SIZE_LIMIT
>         default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
>         default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
>         default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> 	help
> 	  ..
> 

Ok, I agree until here, but ...


> And note that I've added ARCH_K3 to the list here because from a quick grep, TI
> K3 platforms also set SPL_SIZE_LIMIT and so with this, you won't have to change
> all of those defconfigs as well.

concerning ARCH_K3 I do not yet agree:

	git grep -l ARCH_K3=y configs | wc -l

gives me 54 ARCH_K3 platforms. But only 24 of them use SPL_SIZE_LIMITs:

	git grep -l ARCH_K3=y configs | xargs grep -l SIZE_LIMIT | wc -l


So if I'm not mistaken, we cannot set default HAS_SPL_SIZE_LIMIT for
ARCH_K3.


Best regards,
Philip

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-10-02  8:55         ` Philip Oberfichtner
@ 2025-10-02 21:19           ` Tom Rini
  2025-10-10 14:28             ` Philip Oberfichtner
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Rini @ 2025-10-02 21:19 UTC (permalink / raw)
  To: Philip Oberfichtner
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Marek Vasut, Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker,
	Peng Fan, Simon Glass, Trevor Woerner, Ye Li

[-- Attachment #1: Type: text/plain, Size: 5055 bytes --]

On Thu, Oct 02, 2025 at 10:55:19AM +0200, Philip Oberfichtner wrote:
> Hi Tom,
> 
> Thank you for the clarification.
> 
> On Tue, Sep 30, 2025 at 08:45:36AM -0600, Tom Rini wrote:
> > On Tue, Sep 30, 2025 at 10:33:13AM +0200, Philip Oberfichtner wrote:
> > > On Fri, Sep 05, 2025 at 08:19:59AM -0600, Tom Rini wrote:
> > > > On Wed, Sep 03, 2025 at 12:56:50PM +0200, Philip Oberfichtner wrote:
> > > > 
> > > > > Use a consistent logic for image size checks. No functional change.
> > > > > 
> > > > > Before this commit, there were two concurrent approaches of how image
> > > > > size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
> > > > > dedicated Kconfig symbol to achieve this, all the other size checks were
> > > > > disabled by assigning them a limit of zero bytes.
> > > > > 
> > > > > By this commit we achieve a consistent logic for size limiting, by
> > > > > introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
> > > > > have it yet.
> > > > > 
> > > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > <...>
> > > > > diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
> > > > > index 5dd866ffcfe..d70e8def36f 100644
> > > > > --- a/arch/x86/cpu/apollolake/Kconfig
> > > > > +++ b/arch/x86/cpu/apollolake/Kconfig
> > > > > @@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
> > > > >  	hex
> > > > >  	default 0xe0000000
> > > > >  
> > > > > +config HAS_TPL_SIZE_LIMIT
> > > > > +	default y
> > > > > +
> > > > >  config TPL_SIZE_LIMIT
> > > > > -	default 0x7800
> > > > > +	default 0x7800 if HAS_TPL_SIZE_LIMIT
> > > > >  
> > > > >  config CPU_ADDR_BITS
> > > > >  	default 39
> > > > 
> > > > These should be "default y if .." in the main Kconfig entry for the
> > > > option.
> > > 
> > > Not sure if I'm following you here. So you mean both of the defaults
> > > should be moved to common/spl/Kconfig.tpl? - like
> > > 
> > > 	config HAS_TPL_SIZE_LIMIT
> > > 		[...]
> > > 		default y if INTEL_APOLLOLAKE
> > > 
> > > 
> > > 	config TPL_SIZE_LIMIT
> > > 		[...]
> > > 		default 0x7800 if INTEL_APOLLOLAKE
> > 
> > Yes, like that.
> 
> Ok.
> 
> > 
> > > > > diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig
> > > > 
> > > > The reset of these, to Marek's point, show that we need to also add
> > > > "default y if .." for a number of other platforms too.
> > > 
> > > Which platforms exactly?
> > 
> > So the platforms today which have a default ..size.. if SOC should also
> > be listed as default y if SOC, is that I was I believe getting at.
> 
> Yes, this part is already included as of now.
> 
> > 
> > > > At least the ones
> > > > where today we have default limits provided in Kconfig today.
> > > 
> > > Besides the ones handled above, i.e.
> > > 	arch/arm/mach-socfpga/Kconfig,
> > > 	arch/mips/mach-mtmips/Kconfig and
> > > 	arch/x86/cpu/apollolake/Kconfig,
> > > 
> > > there aren't any.
> > > 
> > > I myself am not very fond of changing that many defconfigs, but I still
> > > don't see a way of avoiding it. I guess it would become more clear if
> > > you concretely name a few examples.
> > 
> > So, part of the pattern is that we should take this from
> > common/spl/Kconfig:
> > config SPL_SIZE_LIMIT
> >         hex "Maximum size of SPL image"
> >         default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> >         default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> >         default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> >         default 0x0
> >         help
> > 	  ...
> > And it becomes:
> > 
> > config HAS_SPL_SIZE_LIMIT
> > 	bool "Enforce a maximum size of the SPL image
> > 	default y if ARCH_MX6 || (ARCH_MVEBU && ARMADA_32BIT) || \
> > 		ARCH_K3
> > 	help
> > 	  .. What we had talked about in earlier threads to be clear about what
> > 	  .. is / isn't checked by this option.
> > 
> > config SPL_SIZE_LIMIT
> >         hex "Maximum size of SPL image"
> > 	depends on HAS_SPL_SIZE_LIMIT
> >         default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> >         default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> >         default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> > 	help
> > 	  ..
> > 
> 
> Ok, I agree until here, but ...
> 
> 
> > And note that I've added ARCH_K3 to the list here because from a quick grep, TI
> > K3 platforms also set SPL_SIZE_LIMIT and so with this, you won't have to change
> > all of those defconfigs as well.
> 
> concerning ARCH_K3 I do not yet agree:
> 
> 	git grep -l ARCH_K3=y configs | wc -l
> 
> gives me 54 ARCH_K3 platforms. But only 24 of them use SPL_SIZE_LIMITs:
> 
> 	git grep -l ARCH_K3=y configs | xargs grep -l SIZE_LIMIT | wc -l
> 
> 
> So if I'm not mistaken, we cannot set default HAS_SPL_SIZE_LIMIT for
> ARCH_K3.

Some of them use different limits.
$ ./tools/qconfig.py -b
... wait
$ ./tools/qconfig.py -f ~SPL_SIZE_LIMIT ARCH_K3
0 matches

So no platforms set ARCH_K3 and do not set SPL_SIZE_LIMIT.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 1/5] Image size checks: Move all configs in one place
  2025-09-05 14:22           ` Tom Rini
@ 2025-10-10 14:19             ` Philip Oberfichtner
  0 siblings, 0 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-10-10 14:19 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marek Vasut, u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi,
	Greg Malysa, Heinrich Schuchardt, Ilias Apalodimas,
	Jerome Forissier, Nathan Barrett-Morrison, Peng Fan, Simon Glass,
	Trevor Woerner, Ye Li

On Fri, Sep 05, 2025 at 08:22:35AM -0600, Tom Rini wrote:
> On Fri, Sep 05, 2025 at 10:13:36AM +0200, Philip Oberfichtner wrote:
> > On Thu, Sep 04, 2025 at 03:54:54PM +0200, Marek Vasut wrote:
> > > On 9/4/25 10:12 AM, Philip Oberfichtner wrote:
> > > > On Wed, Sep 03, 2025 at 02:50:49PM +0200, Marek Vasut wrote:
> > > > > On 9/3/25 12:56 PM, Philip Oberfichtner wrote:
> > > > > > How image size limiting works in U-Boot should be easier to grasp if we
> > > > > > have all related options in one place.
> > > > > > 
> > > > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > > > > ---
> > > > > >    Kconfig                | 59 ++++++++++++++++++++++++++++++++++++++++++
> > > > > >    common/spl/Kconfig     | 38 ---------------------------
> > > > > >    common/spl/Kconfig.tpl |  7 -----
> > > > > >    common/spl/Kconfig.vpl |  7 -----
> > > > > >    4 files changed, 59 insertions(+), 52 deletions(-)
> > > > > > 
> > > > > > diff --git a/Kconfig b/Kconfig
> > > > > > index 70125c4e5a6..f1a6be299e8 100644
> > > > > > --- a/Kconfig
> > > > > > +++ b/Kconfig
> > > > > > @@ -535,6 +535,8 @@ config BUILD_TARGET
> > > > > >    	  special image will be automatically built upon calling
> > > > > >    	  make / buildman.
> > > > > > +menu "Image size limits"
> > > > > > +
> > > > > >    config HAS_BOARD_SIZE_LIMIT
> > > > > >    	bool "Define a maximum size for the U-Boot image"
> > > > > >    	depends on !COMPILE_TEST
> > > > > > @@ -554,6 +556,63 @@ config BOARD_SIZE_LIMIT
> > > > > >    	  include SPL nor TPL, on platforms that use that functionality, they
> > > > > >    	  have separate options to restrict size.
> > > > > > +config VPL_SIZE_LIMIT
> > > > > > +	depends on VPL
> > > > > > +	hex "Maximum size of VPL image"
> > > > > > +	default 0x0
> > > > > > +	help
> > > > > > +	  Specifies the maximum length of the U-Boot VPL image.
> > > > > > +	  If this value is zero, it is ignored.
> > > > > > +
> > > > > > +config TPL_SIZE_LIMIT
> > > > > > +	depends on TPL
> > > > > > +	hex "Maximum size of TPL image"
> > > > > > +	default 0x0
> > > > > > +	help
> > > > > > +	  Specifies the maximum length of the U-Boot TPL image.
> > > > > > +	  If this value is zero, it is ignored.
> > > > > The point of separate common/spl/Kconfig.tpl and common/spl/Kconfig.vpl
> > > > > files is to group SPL / TPL / VPL symbols in those files .
> > > > 
> > > > There is "config TPL_" definitions literally all over the place. I think
> > > > there might actually even be more of them outside Kconfig.tpl than
> > > > inside.
> > > 
> > > That does not make it OK to make that situation worse.
> > 
> > It doesn't. Someone who stumbles over BOARD_SIZE_LIMIT might be asking
> > himself, if there's an analogous option for SPL, too. It'll jump right
> > into his eyes, after this patch of mine.
> > 
> > And apparently there were other contributers before me who found it
> > reasonable to group strongly related options together within one menu,
> > instead of spreading them out over many different places. Let me give
> > you a few examples (and this list is by far not exhaustive):
> > 
> > 
> > 	Kconfig:
> > 		config SYS_MALLOC_F
> > 		config SPL_SYS_MALLOC_F
> > 		config TPL_SYS_MALLOC_F
> > 		config VPL_SYS_MALLOC_F
> > 
> > 	arch/Kconfig 
> > 		menu "Skipping low level initialization functions"
> > 		config SKIP_LOWLEVEL_INIT
> > 		config SPL_SKIP_LOWLEVEL_INIT
> > 		config TPL_SKIP_LOWLEVEL_INIT
> > 
> > 	boot/Kconfig
> > 		menuconfig FIT
> > 		config SPL_FIT
> > 		config VPL_FIT
> > 		config TPL_FIT
> > 
> > 
> > 	common/Kconfig
> > 		menu "Logging"
> > 		config LOG
> > 		config SPL_LOG
> > 		config TPL_LOG
> > 		config VPL_LOG
> > 
> > 	dts/Kconfig
> > 		menu "Device Tree Control"
> > 		config OF_CONTROL
> > 		config SPL_OF_CONTROL
> > 		config TPL_OF_CONTROL
> > 		config VPL_OF_CONTROL
> > 
> > 	lib/Kconfig
> > 		menu "Compression Support"
> > 		config LZ4
> > 		config SPL_LZ4
> > 		config TPL_LZ4
> > 		config VPL_LZ4
> > 
> > 
> > So how do these and many other cases differ from the SIZE_LIMIT case
> > discussed here? Or would it be better to tear all those menus apart?
> 
> We are not consistent about this, and it really becomes a stylistic
> argument. Roughly speaking, common/spl/Kconfig.* is for things core to a
> given phase (SPL, TPL, VPL) which is why often but not always, say
> compression algorithms are with the compression algorithms. In this
> case, limits are a core part of the phase so I think Marek's point is
> valid here.

Okay. Thanks for the clarification. 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently
  2025-10-02 21:19           ` Tom Rini
@ 2025-10-10 14:28             ` Philip Oberfichtner
  0 siblings, 0 replies; 34+ messages in thread
From: Philip Oberfichtner @ 2025-10-10 14:28 UTC (permalink / raw)
  To: Tom Rini
  Cc: u-boot, Andre Przywara, Anshul Dalal, Dario Binacchi, Greg Malysa,
	Heinrich Schuchardt, Ilias Apalodimas, Jerome Forissier,
	Marek Vasut, Nathan Barrett-Morrison, Oliver Gaskell, Paul Barker,
	Peng Fan, Simon Glass, Trevor Woerner, Ye Li

On Thu, Oct 02, 2025 at 03:19:10PM -0600, Tom Rini wrote:
> On Thu, Oct 02, 2025 at 10:55:19AM +0200, Philip Oberfichtner wrote:
> > Hi Tom,
> > 
> > Thank you for the clarification.
> > 
> > On Tue, Sep 30, 2025 at 08:45:36AM -0600, Tom Rini wrote:
> > > On Tue, Sep 30, 2025 at 10:33:13AM +0200, Philip Oberfichtner wrote:
> > > > On Fri, Sep 05, 2025 at 08:19:59AM -0600, Tom Rini wrote:
> > > > > On Wed, Sep 03, 2025 at 12:56:50PM +0200, Philip Oberfichtner wrote:
> > > > > 
> > > > > > Use a consistent logic for image size checks. No functional change.
> > > > > > 
> > > > > > Before this commit, there were two concurrent approaches of how image
> > > > > > size checks are disabled: Whereas BOARD_SIZE_LIMIT was gated through a
> > > > > > dedicated Kconfig symbol to achieve this, all the other size checks were
> > > > > > disabled by assigning them a limit of zero bytes.
> > > > > > 
> > > > > > By this commit we achieve a consistent logic for size limiting, by
> > > > > > introducing CONFIG_HAS_XXX_SIZE_LIMIT for all those options that don't
> > > > > > have it yet.
> > > > > > 
> > > > > > Signed-off-by: Philip Oberfichtner <pro@denx.de>
> > > > <...>
> > > > > > diff --git a/arch/x86/cpu/apollolake/Kconfig b/arch/x86/cpu/apollolake/Kconfig
> > > > > > index 5dd866ffcfe..d70e8def36f 100644
> > > > > > --- a/arch/x86/cpu/apollolake/Kconfig
> > > > > > +++ b/arch/x86/cpu/apollolake/Kconfig
> > > > > > @@ -78,8 +78,11 @@ config MMCONF_BASE_ADDRESS
> > > > > >  	hex
> > > > > >  	default 0xe0000000
> > > > > >  
> > > > > > +config HAS_TPL_SIZE_LIMIT
> > > > > > +	default y
> > > > > > +
> > > > > >  config TPL_SIZE_LIMIT
> > > > > > -	default 0x7800
> > > > > > +	default 0x7800 if HAS_TPL_SIZE_LIMIT
> > > > > >  
> > > > > >  config CPU_ADDR_BITS
> > > > > >  	default 39
> > > > > 
> > > > > These should be "default y if .." in the main Kconfig entry for the
> > > > > option.
> > > > 
> > > > Not sure if I'm following you here. So you mean both of the defaults
> > > > should be moved to common/spl/Kconfig.tpl? - like
> > > > 
> > > > 	config HAS_TPL_SIZE_LIMIT
> > > > 		[...]
> > > > 		default y if INTEL_APOLLOLAKE
> > > > 
> > > > 
> > > > 	config TPL_SIZE_LIMIT
> > > > 		[...]
> > > > 		default 0x7800 if INTEL_APOLLOLAKE
> > > 
> > > Yes, like that.
> > 
> > Ok.
> > 
> > > 
> > > > > > diff --git a/configs/am62ax_evm_r5_defconfig b/configs/am62ax_evm_r5_defconfig
> > > > > 
> > > > > The reset of these, to Marek's point, show that we need to also add
> > > > > "default y if .." for a number of other platforms too.
> > > > 
> > > > Which platforms exactly?
> > > 
> > > So the platforms today which have a default ..size.. if SOC should also
> > > be listed as default y if SOC, is that I was I believe getting at.
> > 
> > Yes, this part is already included as of now.
> > 
> > > 
> > > > > At least the ones
> > > > > where today we have default limits provided in Kconfig today.
> > > > 
> > > > Besides the ones handled above, i.e.
> > > > 	arch/arm/mach-socfpga/Kconfig,
> > > > 	arch/mips/mach-mtmips/Kconfig and
> > > > 	arch/x86/cpu/apollolake/Kconfig,
> > > > 
> > > > there aren't any.
> > > > 
> > > > I myself am not very fond of changing that many defconfigs, but I still
> > > > don't see a way of avoiding it. I guess it would become more clear if
> > > > you concretely name a few examples.
> > > 
> > > So, part of the pattern is that we should take this from
> > > common/spl/Kconfig:
> > > config SPL_SIZE_LIMIT
> > >         hex "Maximum size of SPL image"
> > >         default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> > >         default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> > >         default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> > >         default 0x0
> > >         help
> > > 	  ...
> > > And it becomes:
> > > 
> > > config HAS_SPL_SIZE_LIMIT
> > > 	bool "Enforce a maximum size of the SPL image
> > > 	default y if ARCH_MX6 || (ARCH_MVEBU && ARMADA_32BIT) || \
> > > 		ARCH_K3
> > > 	help
> > > 	  .. What we had talked about in earlier threads to be clear about what
> > > 	  .. is / isn't checked by this option.
> > > 
> > > config SPL_SIZE_LIMIT
> > >         hex "Maximum size of SPL image"
> > > 	depends on HAS_SPL_SIZE_LIMIT
> > >         default 0x11000 if ARCH_MX6 && !MX6_OCRAM_256KB
> > >         default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
> > >         default 0x30000 if ARCH_MVEBU && ARMADA_32BIT
> > > 	help
> > > 	  ..
> > > 
> > 
> > Ok, I agree until here, but ...
> > 
> > 
> > > And note that I've added ARCH_K3 to the list here because from a quick grep, TI
> > > K3 platforms also set SPL_SIZE_LIMIT and so with this, you won't have to change
> > > all of those defconfigs as well.
> > 
> > concerning ARCH_K3 I do not yet agree:
> > 
> > 	git grep -l ARCH_K3=y configs | wc -l
> > 
> > gives me 54 ARCH_K3 platforms. But only 24 of them use SPL_SIZE_LIMITs:
> > 
> > 	git grep -l ARCH_K3=y configs | xargs grep -l SIZE_LIMIT | wc -l
> > 
> > 
> > So if I'm not mistaken, we cannot set default HAS_SPL_SIZE_LIMIT for
> > ARCH_K3.
> 
> Some of them use different limits.
> $ ./tools/qconfig.py -b
> ... wait
> $ ./tools/qconfig.py -f ~SPL_SIZE_LIMIT ARCH_K3
> 0 matches
> 
> So no platforms set ARCH_K3 and do not set SPL_SIZE_LIMIT.

I wasn't aware of the qconfig tool. Thanks for the hint. However,
SPL_SIZE_LIMIT is always defined:

	./tools/qconfig.py ARCH_K3 SPL_SIZE_LIMIT=0x0
	23 matches

Tells us there are 23 boards not using SPL_SIZE_LIMITs.

Nevertheless I'll go ahead and try if "qconfig.py -i" gives us something
else which might work instead.

Best regards,
Philip

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2025-10-10 14:28 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 10:56 [PATCH v3 0/5] Simplify image size checks Philip Oberfichtner
2025-09-03 10:56 ` [PATCH v3 1/5] Image size checks: Move all configs in one place Philip Oberfichtner
2025-09-03 12:50   ` Marek Vasut
2025-09-04  8:12     ` Philip Oberfichtner
2025-09-04 13:54       ` Marek Vasut
2025-09-05  8:13         ` Philip Oberfichtner
2025-09-05 14:22           ` Tom Rini
2025-10-10 14:19             ` Philip Oberfichtner
2025-09-03 10:56 ` [PATCH v3 2/5] Image size checks: Use HAS_SIZE_LIMIT consistently Philip Oberfichtner
2025-09-03 12:51   ` Marek Vasut
2025-09-04  8:19     ` Philip Oberfichtner
2025-09-04 13:56       ` Marek Vasut
2025-09-05  8:15         ` Philip Oberfichtner
2025-09-05 14:19   ` Tom Rini
2025-09-30  8:33     ` Philip Oberfichtner
2025-09-30 14:45       ` Tom Rini
2025-10-02  8:55         ` Philip Oberfichtner
2025-10-02 21:19           ` Tom Rini
2025-10-10 14:28             ` Philip Oberfichtner
2025-09-03 10:56 ` [PATCH v3 3/5] Image size checks: Use consistent help texts Philip Oberfichtner
2025-09-03 12:54   ` Marek Vasut
2025-09-04  8:20     ` Philip Oberfichtner
2025-09-03 10:56 ` [PATCH v3 4/5] Image size checks: Deduplicate Makefile Philip Oberfichtner
2025-09-03 13:02   ` Marek Vasut
2025-09-04  8:30     ` Philip Oberfichtner
2025-09-04 15:03       ` Marek Vasut
2025-09-05  8:22         ` Philip Oberfichtner
2025-09-03 10:56 ` [PATCH v3 5/5] Image size checks: Simplify SPL_SIZE_LIMIT logic Philip Oberfichtner
2025-09-03 12:08   ` Heinrich Schuchardt
2025-09-03 12:59   ` Marek Vasut
2025-09-04  8:23     ` Philip Oberfichtner
2025-09-04  8:30       ` Heinrich Schuchardt
2025-09-04 15:02       ` Marek Vasut
2025-09-05  8:19         ` Philip Oberfichtner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.