[PATCH] ARM: Enable unaligned accesses on armv6 and later

Eric Bénard eric at eukrea.com
Thu Jul 12 05:43:52 EDT 2012


Hi Sascha,

Le Mon,  9 Jul 2012 09:09:39 +0200,
Sascha Hauer <s.hauer at pengutronix.de> a écrit :

> We have the following in the tree:
> 
> |commit af42feb9d255bc3ea3b514180f265479ea8834f9
> |Author: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
> |Date:   Mon Jan 2 11:49:17 2012 +0100
> |
> |    ARM: set SCTRL[A] only when architecture does not support unaligned access
> |
> |    Recent gcc generates code with unaligned access when architecture
> |    supports it. Setting A bit unconditionally causes data-aborts on such
> |    code rendering barebox unusable.
> |
> |    Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
> |    Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> 
> What the patch tried is correct: We should set the A bit only when the architecture
> does not support unaligned accesses. To figure out whether the architecture supports
> unaligned accesses the patch tested for the U bit which is wrong. The U bit may be
> 0 after a reset, so instead of testing for the U bit we have to set it. This can
> be done on armv6 and later. All others have the A bit set to trap unaligned accesses.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
> 
> Enrico, can you confirm this is correct?
> 
> Thanks
>  Sascha
> 
>  arch/arm/cpu/start.c |   12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
> index 3c282ee..523179d 100644
> --- a/arch/arm/cpu/start.c
> +++ b/arch/arm/cpu/start.c
> @@ -81,13 +81,11 @@ void __naked __bare_init reset(void)
>  	r &= ~(CR_M | CR_C | CR_B | CR_S | CR_R | CR_V);
>  	r |= CR_I;
>  
> -	if (!(r & CR_U))
> -		/* catch unaligned access on architectures which do not
> -		 * support unaligned access */
> -		r |= CR_A;
> -	else
> -		r &= ~CR_A;
> -
> +#if __LINUX_ARM_ARCH__ >= 6
> +	r |= CR_U;
> +#else
> +	r |= CR_A;
> +#endif
>  
>  #ifdef __ARMEB__
>  	r |= CR_B;

Tested-by: Eric Bénard <eric at eukrea.com>

this patch fix the crash we had in show_progress.

Eric



More information about the barebox mailing list