[U-Boot-Users] [Patch 05/17] U-Boot-V2:ARM: Introduce capability to have different stack/malloc area

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 3 10:08:11 CEST 2008


On Wed, May 21, 2008 at 11:26:25AM -0500, Menon, Nishanth wrote:
> The default setup of ARM memory allocation is as follows:
>  ----
> Stack Area
>  ----
> Heap Area
> ---
> _u_boot_start
> Rest of U-Boot..
> 
> This is an excellent strategy to catch stack overflow and memory buffer overflow issues. However, in conditions where:
> a) U-Boot is automatically loaded by h/w in the default location without a writable memory area above it, this will crash,
> b) Multiple non-contiguous memory areas available in system (e.g. SRAM and SDRAM), but the area where U-Boot is loaded is restricted in size and cannot fit the required heap and stack areas.
> In these cases, we need to have ability to move the Heap and stack to the area of our choice. This patch introduces CONFIG_MALLOC_START for machine configurations which require this.
> This would need to be enabled only if MACH_CAN_MODIFY_MALLOC_START is defined by the machine configurations that desire it. I have clubbed both heap and stack area to still catch some of those overflow issues.

This patch rises an issue we currently have in U-Boot-v2: We have as
many stack/memory strategies as we have architectures :(

Instead of modifying this for one architecture I would prefer something
like this (currently no implementation, only kconfig).
Would this solve your issues?

regards,
 Sascha

diff --git a/common/Kconfig b/common/Kconfig
index 79a3684..d764482 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -19,13 +19,66 @@ menu "General Settings              "
 config BOARDINFO
 	string
 
+menu "memory layout                 "
+
 config TEXT_BASE
+	depends on HAVE_CONFIGURABLE_TEXT_BASE
 	prompt "TEXT_BASE"
 	hex
 	default ARCH_TEXT_BASE
 	help
 	  The Address U-Boot gets linked at.
 
+choice
+	prompt "select stack base policy"
+	depends on HAVE_CONFIGURABLE_STACK
+	default STACK_BASE_FIXED
+
+config STACK_BASE_DEFAULT
+	bool "place stack before malloc space"
+
+config STACK_BASE_FIXED
+	bool "manually assign a stack base"
+
+endchoice
+
+config STACK_BASE
+	depends on STACK_BASE_FIXED
+	hex
+	prompt "STACK_BASE"
+
+config STACK_SIZE
+	hex
+	depends on HAVE_CONFIGURABLE_STACK
+	default 0x8000
+	prompt "Stack size"
+
+choice
+	prompt "select stack base policy"
+	depends on HAVE_CONFIGURABLE_MALLOC
+
+config MALLOC_BASE_DEFAULT
+	bool
+	prompt "place stack before U-Boot"
+
+config MALLOC_BASE_FIXED
+	bool
+	prompt "manually assign a malloc base"
+
+endchoice
+
+config MALLOC_BASE
+	depends on MALLOC_BASE_FIXED
+	hex
+	prompt "MALLOC_BASE"
+
+config MALLOC_SIZE
+	hex
+	depends on HAVE_CONFIGURABLE_MALLOC
+	default 0x400000
+	prompt "malloc area size"
+endmenu
+
 config BROKEN
 	bool
 	prompt "Prompt for broken or incomplete code"


-- 
Pengutronix e.K. - Linux Solutions for Science and Industry
-----------------------------------------------------------
Kontakt-Informationen finden Sie im Header dieser Mail oder
auf der Webseite -> http://www.pengutronix.de/impressum/ <-




More information about the U-Boot mailing list