]> git.sur5r.net Git - u-boot/commitdiff
ARM: Align stack to 8 bytes
authorVitaly Kuzmichev <vkuzmichev@mvista.com>
Tue, 15 Jun 2010 18:18:11 +0000 (22:18 +0400)
committerWolfgang Denk <wd@denx.de>
Tue, 22 Jun 2010 20:15:07 +0000 (22:15 +0200)
The ARM ABI requires that the stack be aligned to 8 bytes as it is noted
in Procedure Call Standard for the ARM Architecture:
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/index.html

Unaligned SP also causes the problem with variable-length arrays
allocation when VLA address becomes less than stack pointer during
aligning of this address, so the next 'push' in the stack overwrites
first 4 bytes of VLA.

Signed-off-by: Vitaly Kuzmichev <vkuzmichev@mvista.com>
Tested on tx25(mx25), imx27lite(mx27), qong(mx31) and trab(s3c2400)
Tested-by: Wolfgang Denk <wd@denx.de>
14 files changed:
arch/arm/cpu/arm1136/start.S
arch/arm/cpu/arm1176/start.S
arch/arm/cpu/arm720t/start.S
arch/arm/cpu/arm920t/start.S
arch/arm/cpu/arm925t/start.S
arch/arm/cpu/arm926ejs/start.S
arch/arm/cpu/arm946es/start.S
arch/arm/cpu/arm_cortexa8/start.S
arch/arm/cpu/arm_intcm/start.S
arch/arm/cpu/ixp/start.S
arch/arm/cpu/lh7a40x/start.S
arch/arm/cpu/pxa/start.S
arch/arm/cpu/s3c44b0/start.S
arch/arm/cpu/sa1100/start.S

index 922d01cb70080cd1605a801626b5a439796ee9f8..41eb82dae246b9509545f051daac605a02b7db05 100644 (file)
@@ -185,6 +185,7 @@ stack_setup:
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
 #endif /* CONFIG_PRELOADER */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index a540edbfbf807bc008b4bd8b576510692b524d98..f98a7aa35528e979f2456f2a3301138440e628a8 100644 (file)
@@ -276,6 +276,7 @@ stack_setup:
        sub     r0, r0, #CONFIG_SYS_MALLOC_LEN  /* malloc area                      */
        sub     r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo                        */
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 022b873e35c4e8a45e8a2e5048b5c95234f5f89c..d6f2c165c729cd70e064674e3b71fb684e87c502 100644 (file)
@@ -172,6 +172,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 779f192e519ef000fef340722aabffe30382417c..e532f55bfcba4ba4cdf92af000cfa1c57d3d9530 100644 (file)
@@ -204,6 +204,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 567e80479e2f68fdd5f75cf1052bd1aa57121e9f..346615e4b4ddf13e4cd2ca2670582532752fc420 100644 (file)
@@ -196,6 +196,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 3b81151f49cecaa0b42875ed031b8e3f313cc1c6..cf40ce12928359c5238d02a32ed361ccc153c101 100644 (file)
@@ -196,7 +196,7 @@ stack_setup:
 #endif
 #endif /* CONFIG_PRELOADER */
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
-       bic     sp, r0, #7              /* 8-byte align stack for ABI compliance */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 627e3cb94db5beb2ea736bf0cc3e714803857961..8844d4438b5f1c9735134e9fe05ddecf629579fe 100644 (file)
@@ -163,6 +163,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 29dae2f2823ef1ab679619d9de746800d17245b7..1e0a1504bfc28a2ec413935c9464e63be1852ff5 100644 (file)
@@ -164,7 +164,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             @ leave 3 words for abort-stack
-       and     sp, sp, #~7             @ 8 byte alinged for (ldr/str)d
+       bic     sp, sp, #7              @ 8-byte alignment for ABI compliance
 
        /* Clear BSS (if any). Is below tx (watch load addr - need space) */
 clear_bss:
index bb1f003592a6322a012cf40cc2cb839e332d16b6..328bae0274181948e33ee4a3be2c469385be6c97 100644 (file)
@@ -161,6 +161,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 5ebce5338cb41bf1b1416e5aacec7d223fe8fb59..6efe333f1a1eb171119b654a8b91f496420d0ac5 100644 (file)
@@ -289,6 +289,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index a1321b1d740fbc4afb15a65ab6bcf0fa3c48b137..14a1fbe121f68ec44c94718c3e8e8d870aa4dc2a 100644 (file)
@@ -178,6 +178,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index 3989fa61bc797e34b3a647f8bb76d1b714c8bdbb..e07c8c2e0e70744c45152c1649cef65f87825708 100644 (file)
@@ -140,10 +140,8 @@ stack_setup:
 #ifdef CONFIG_USE_IRQ
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif /* CONFIG_USE_IRQ */
-       sub     r0, r0, #12             /* leave 3 words for abort-stack    */
-       bic     sp, r0, #7              /* NOTE: stack MUST be aligned to   */
-                                       /* 8 bytes in case we want to use   */
-                                       /* 64bit datatypes (eg. VSPRINTF64) */
+       sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */
index f5a3d3ac386ceabe492e91c8ba6bab56a6938cec..0063063f45d436914c06c40c71f3766ffff653d6 100644 (file)
@@ -163,6 +163,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
        ldr     pc, _start_armboot
 
index 278c5008fb84079362a4145f078b9fb74a9af1fd..deb4745e216d064f99e97b6b7f0068c204dd802d 100644 (file)
@@ -153,6 +153,7 @@ stack_setup:
        sub     r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
 #endif
        sub     sp, r0, #12             /* leave 3 words for abort-stack    */
+       bic     sp, sp, #7              /* 8-byte alignment for ABI compliance */
 
 clear_bss:
        ldr     r0, _bss_start          /* find start of bss segment        */