[U-Boot] [PATCH] arm926ejs: 16-byte align stack to avoid LDRD/STRD problems
Andrew Dyer
amdyer at gmail.com
Mon Oct 5 16:30:54 CEST 2009
On Mon, Oct 5, 2009 at 8:23 AM, Simon Kagstrom
<simon.kagstrom at netinsight.net> wrote:
> U-boot for Marvell Kirkwood boards no longer work after the EABI changes
> introduced in commit f772acf8a584067033eff1e231fcd1fb3a00d3d9. This
> turns out to be caused by a stack alignment issue. The armv5te
> instructions ldrd/strd instructions require 8-byte alignment to work
> properly (otherwise undefined behavior), and start.S gave the stack a
> 12-byte alignment.
>
> Tested on an OpenRD base board, where both printouts and ubifs stuff now
> works.
>
> Signed-off-by: Simon Kagstrom <simon.kagstrom at netinsight.net>
> ---
> cpu/arm926ejs/start.S | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/cpu/arm926ejs/start.S b/cpu/arm926ejs/start.S
> index 8043322..ca520eb 100644
> --- a/cpu/arm926ejs/start.S
> +++ b/cpu/arm926ejs/start.S
> @@ -171,7 +171,8 @@ stack_setup:
> #ifdef CONFIG_USE_IRQ
> sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
> #endif
> - sub sp, r0, #12 /* leave 3 words for abort-stack */
> + sub sp, r0, #16 /* leave 3 words for abort-stack and */
> + /* align stack for ldrd/strd */
This doesn't guarantee an alignment. Right above this code is a
series of subtractions by constants, any one of which could throw the
alignment out of whack and be difficult to figure out.
IMHO it's much safer to do the subtraction to R0, then mask the bottom
address bits out to guarantee alignment, then stuff the results into
sp.
More information about the U-Boot
mailing list