Patchwork [U-Boot,v4,1/4] ARM: fix CONFIG_SPL_MAX_SIZE semantics

login
register
mail settings
Submitter Albert ARIBAUD
Date April 12, 2013, 3:14 p.m.
Message ID <1365779673-17354-2-git-send-email-albert.u.boot@aribaud.net>
Download mbox | patch
Permalink /patch/236128/
State Accepted
Delegated to: Albert ARIBAUD
Headers show

Comments

Albert ARIBAUD - April 12, 2013, 3:14 p.m.
Remove SPL-related ASSERT() in arch/arm/cpu/u-boot.lds
as this file is never used for SPL builds.

Rewrite the ASSERT() in arch/arm/cpu/u-boot-spl.lds
to separately test image (text,data,rodata...) size,
BSS size, and full footprint each against its own max,
and make Tegra boards check full footprint.

Also, output section mmutable is not used in SPL builds.
Remove it.

Finally, update README regarding the (now homogeneous)
semantics of CONFIG_SPL_[BSS_]MAX_SIZE and add the new
CONFIG_SPL_MAX_FOOTPRINT macro.

Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
Reported-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
---
Changes in v4:
- rewrote README entries

Changes in v3:
- introduced CONFIG_SPL_MAX_FOOTPRINT
- fixed typo in BSS size test

Changes in v2:
- removed mmutable in SPL linker file

 README                         |   18 ++++++++++++++++--
 arch/arm/cpu/u-boot-spl.lds    |   24 +++++++++++++-----------
 arch/arm/cpu/u-boot.lds        |    4 ----
 include/configs/tegra-common.h |    2 +-
 4 files changed, 30 insertions(+), 18 deletions(-)
Tom Rini - April 12, 2013, 3:30 p.m.
On Fri, Apr 12, 2013 at 05:14:30PM +0200, Albert ARIBAUD wrote:

> +		CONFIG_SPL_MAX_FOOTPRINT
> +		Maximum size in memory allocated to the SPL, BSS included.
> +		When defined, the linker checks that the actual memory
> +		used by SPL from _start to __bss_end does not exceed it.
> +		CONFIG_MAX_FOOTPRINT and CONFIG_MAX_BSS_SIZE should not

must not, not should not.  And CONFIG_SPL_... for both.  You can just
fix that up when commiting, assuming no other comments require change :)
Albert ARIBAUD - April 12, 2013, 4:22 p.m.
Hi Tom,

On Fri, 12 Apr 2013 11:30:32 -0400, Tom Rini <trini@ti.com> wrote:

> On Fri, Apr 12, 2013 at 05:14:30PM +0200, Albert ARIBAUD wrote:
> 
> > +		CONFIG_SPL_MAX_FOOTPRINT
> > +		Maximum size in memory allocated to the SPL, BSS included.
> > +		When defined, the linker checks that the actual memory
> > +		used by SPL from _start to __bss_end does not exceed it.
> > +		CONFIG_MAX_FOOTPRINT and CONFIG_MAX_BSS_SIZE should not
> 
> must not, not should not.  And CONFIG_SPL_... for both.  You can just
> fix that up when commiting, assuming no other comments require change :)

Will do; I'll just wait for 24 hours, to make sure no other change is
requested.

Amicalement,

Patch

diff --git a/README b/README
index 6272853..f544c88 100644
--- a/README
+++ b/README
@@ -2775,8 +2775,18 @@  FIT uImage format:
 		CONFIG_SPL_LDSCRIPT
 		LDSCRIPT for linking the SPL binary.
 
+		CONFIG_SPL_MAX_FOOTPRINT
+		Maximum size in memory allocated to the SPL, BSS included.
+		When defined, the linker checks that the actual memory
+		used by SPL from _start to __bss_end does not exceed it.
+		CONFIG_MAX_FOOTPRINT and CONFIG_MAX_BSS_SIZE should not
+		be both defined at the same time.
+
 		CONFIG_SPL_MAX_SIZE
-		Maximum binary size (text, data and rodata) of the SPL binary.
+		Maximum size of the SPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size does
+		not exceed it.
 
 		CONFIG_SPL_TEXT_BASE
 		TEXT_BASE for linking the SPL binary.
@@ -2789,7 +2799,11 @@  FIT uImage format:
 		Link address for the BSS within the SPL binary.
 
 		CONFIG_SPL_BSS_MAX_SIZE
-		Maximum binary size of the BSS section of the SPL binary.
+		Maximum size in memory allocated to the SPL BSS.
+		When defined, the linker checks that the actual memory used
+		by SPL from __bss_start to __bss_end does not exceed it.
+		CONFIG_MAX_FOOTPRINT and CONFIG_MAX_BSS_SIZE should not
+		be both defined at the same time.
 
 		CONFIG_SPL_STACK
 		Adress of the start of the stack SPL will use
diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds
index 3c0d99c..1408f03 100644
--- a/arch/arm/cpu/u-boot-spl.lds
+++ b/arch/arm/cpu/u-boot-spl.lds
@@ -65,15 +65,6 @@  SECTIONS
 
 	_end = .;
 
-	/*
-	 * Deprecated: this MMU section is used by pxa at present but
-	 * should not be used by new boards/CPUs.
-	 */
-	. = ALIGN(4096);
-	.mmutable : {
-		*(.mmutable)
-	}
-
 	.bss __rel_dyn_start (OVERLAY) : {
 		__bss_start = .;
 		*(.bss*)
@@ -88,6 +79,17 @@  SECTIONS
 	/DISCARD/ : { *(.gnu*) }
 }
 
-#if defined(CONFIG_SPL_TEXT_BASE) && defined(CONFIG_SPL_MAX_SIZE)
-ASSERT(__bss_end < (CONFIG_SPL_TEXT_BASE + CONFIG_SPL_MAX_SIZE), "SPL image too big");
+#if defined(CONFIG_SPL_MAX_SIZE)
+ASSERT(__image_copy_end - __image_copy_start < (CONFIG_SPL_MAX_SIZE), \
+	"SPL image too big");
+#endif
+
+#if defined(CONFIG_SPL_BSS_MAX_SIZE)
+ASSERT(__bss_end - __bss_start < (CONFIG_SPL_BSS_MAX_SIZE), \
+	"SPL image BSS too big");
+#endif
+
+#if defined(CONFIG_SPL_MAX_FOOTPRINT)
+ASSERT(__bss_end - _start < (CONFIG_SPL_MAX_FOOTPRINT), \
+	"SPL image plus BSS too big");
 #endif
diff --git a/arch/arm/cpu/u-boot.lds b/arch/arm/cpu/u-boot.lds
index 3a1083d..7bbc4f5 100644
--- a/arch/arm/cpu/u-boot.lds
+++ b/arch/arm/cpu/u-boot.lds
@@ -101,7 +101,3 @@  SECTIONS
 	/DISCARD/ : { *(.interp*) }
 	/DISCARD/ : { *(.gnu*) }
 }
-
-#if defined(CONFIG_SPL_TEXT_BASE) && defined(CONFIG_SPL_MAX_SIZE)
-ASSERT(__bss_end < (CONFIG_SPL_TEXT_BASE + CONFIG_SPL_MAX_SIZE), "SPL image too big");
-#endif
diff --git a/include/configs/tegra-common.h b/include/configs/tegra-common.h
index 036ded0..e9241b8 100644
--- a/include/configs/tegra-common.h
+++ b/include/configs/tegra-common.h
@@ -158,7 +158,7 @@ 
 #define CONFIG_SPL_RAM_DEVICE
 #define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_NAND_SIMPLE
-#define CONFIG_SPL_MAX_SIZE		(CONFIG_SYS_TEXT_BASE - \
+#define CONFIG_SPL_MAX_FOOTPRINT	(CONFIG_SYS_TEXT_BASE - \
 						CONFIG_SPL_TEXT_BASE)
 #define CONFIG_SYS_SPL_MALLOC_SIZE	0x00010000