diff mbox

[U-Boot] arm: Fix setjmp (again)

Message ID 1467743837-185762-1-git-send-email-agraf@suse.de
State Accepted
Commit 0de02de76833cf3adcc0ba2e43cff52e6e18b63f
Delegated to: Tom Rini
Headers show

Commit Message

Alexander Graf July 5, 2016, 6:37 p.m. UTC
Commit e677724 (arm: Fix setjmp) added code to fix compilation of the setjmp
code path with thumv1. Unfortunately it missed a constraint that the adr
instruction can only refer to 4 byte aligned offsets.

So this patch adds the required alignment hooks to make compilation
work again even when setjmp doesn't happen to be 4 byte aligned.

Signed-off-by: Alexander Graf <agraf@suse.de>
Tested-by: Tom Rini <trini@konsulko.com>
---
 arch/arm/include/asm/setjmp.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Karsten Merker July 9, 2016, 11:09 a.m. UTC | #1
On Tue, Jul 05, 2016 at 08:37:17PM +0200, Alexander Graf wrote:

> Commit e677724 (arm: Fix setjmp) added code to fix compilation of the setjmp
> code path with thumv1. Unfortunately it missed a constraint that the adr
> instruction can only refer to 4 byte aligned offsets.
> 
> So this patch adds the required alignment hooks to make compilation
> work again even when setjmp doesn't happen to be 4 byte aligned.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Tested-by: Tom Rini <trini@konsulko.com>
> ---
>  arch/arm/include/asm/setjmp.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
> index ae738b2..f7b97ef 100644
> --- a/arch/arm/include/asm/setjmp.h
> +++ b/arch/arm/include/asm/setjmp.h
> @@ -43,6 +43,7 @@ static inline int setjmp(jmp_buf jmp)
>  #else
>  	asm volatile(
>  #ifdef CONFIG_SYS_THUMB_BUILD
> +		".align 2\n"
>  		"adr r0, jmp_target\n"
>  		"add r0, r0, $1\n"
>  #else
> @@ -52,7 +53,8 @@ static inline int setjmp(jmp_buf jmp)
>  		"mov r2, sp\n"
>  		"stm r1!, {r0, r2, r4, r5, r6, r7}\n"
>  		"b 2f\n"
> -		"jmp_target: "
> +		".align 2\n"
> +		"jmp_target: \n"
>  		"mov %0, #1\n"
>  		"2:\n"
>  		: "+l" (r)

Hello,

this patch (https://patchwork.ozlabs.org/patch/644968/) hasn't
yet found its way into u-boot master, but it should go in before
the v2016.07 release which is due in two days, as without the
patch u-boot fails to build on a number of platforms (cf.
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/266777).

Regards,
Karsten
Tom Rini July 9, 2016, 1:22 p.m. UTC | #2
On Sat, Jul 09, 2016 at 01:09:29PM +0200, Karsten Merker wrote:
> On Tue, Jul 05, 2016 at 08:37:17PM +0200, Alexander Graf wrote:
> 
> > Commit e677724 (arm: Fix setjmp) added code to fix compilation of the setjmp
> > code path with thumv1. Unfortunately it missed a constraint that the adr
> > instruction can only refer to 4 byte aligned offsets.
> > 
> > So this patch adds the required alignment hooks to make compilation
> > work again even when setjmp doesn't happen to be 4 byte aligned.
> > 
> > Signed-off-by: Alexander Graf <agraf@suse.de>
> > Tested-by: Tom Rini <trini@konsulko.com>
> > ---
> >  arch/arm/include/asm/setjmp.h | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
> > index ae738b2..f7b97ef 100644
> > --- a/arch/arm/include/asm/setjmp.h
> > +++ b/arch/arm/include/asm/setjmp.h
> > @@ -43,6 +43,7 @@ static inline int setjmp(jmp_buf jmp)
> >  #else
> >  	asm volatile(
> >  #ifdef CONFIG_SYS_THUMB_BUILD
> > +		".align 2\n"
> >  		"adr r0, jmp_target\n"
> >  		"add r0, r0, $1\n"
> >  #else
> > @@ -52,7 +53,8 @@ static inline int setjmp(jmp_buf jmp)
> >  		"mov r2, sp\n"
> >  		"stm r1!, {r0, r2, r4, r5, r6, r7}\n"
> >  		"b 2f\n"
> > -		"jmp_target: "
> > +		".align 2\n"
> > +		"jmp_target: \n"
> >  		"mov %0, #1\n"
> >  		"2:\n"
> >  		: "+l" (r)
> 
> Hello,
> 
> this patch (https://patchwork.ozlabs.org/patch/644968/) hasn't
> yet found its way into u-boot master, but it should go in before
> the v2016.07 release which is due in two days, as without the
> patch u-boot fails to build on a number of platforms (cf.
> http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/266777).

Yes.  This is part of a small number that I was testing yesterday.
Tom Rini July 9, 2016, 1:24 p.m. UTC | #3
On Tue, Jul 05, 2016 at 08:37:17PM +0200, Alexander Graf wrote:

> Commit e677724 (arm: Fix setjmp) added code to fix compilation of the setjmp
> code path with thumv1. Unfortunately it missed a constraint that the adr
> instruction can only refer to 4 byte aligned offsets.
> 
> So this patch adds the required alignment hooks to make compilation
> work again even when setjmp doesn't happen to be 4 byte aligned.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Tested-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
index ae738b2..f7b97ef 100644
--- a/arch/arm/include/asm/setjmp.h
+++ b/arch/arm/include/asm/setjmp.h
@@ -43,6 +43,7 @@  static inline int setjmp(jmp_buf jmp)
 #else
 	asm volatile(
 #ifdef CONFIG_SYS_THUMB_BUILD
+		".align 2\n"
 		"adr r0, jmp_target\n"
 		"add r0, r0, $1\n"
 #else
@@ -52,7 +53,8 @@  static inline int setjmp(jmp_buf jmp)
 		"mov r2, sp\n"
 		"stm r1!, {r0, r2, r4, r5, r6, r7}\n"
 		"b 2f\n"
-		"jmp_target: "
+		".align 2\n"
+		"jmp_target: \n"
 		"mov %0, #1\n"
 		"2:\n"
 		: "+l" (r)