Re: [2/3] powerpc: allow compilation on cross-endian toolchain

2017-03-07 Thread Michael Ellerman
On Sun, 2016-11-27 at 02:46:20 UTC, Nicholas Piggin wrote:
> Subject: [PATCH] powerpc: allow compilation on cross-endian toolchain
> 
> GCC can compile with either endian, but the ABI version always
> defaults to the default endian. Alan Modra says:
> 
>   you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc
>   generate powerpc64 code
> 
> The opposite is true for powerpc64 when generating -mlittle it
> requires -mabi=elfv2 to generate v2 ABI. This change adds ABI
> annotations together with endianness. The kernel with ELFv2 ABI
> also uses -mcall-aixdesc, but boot/ does not.
> 
> Signed-off-by: Nicholas Piggin 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/4dc831aa88132f835cefe876aa0206

cheers


Re: [PATCH 2/3] powerpc: allow compilation on cross-endian toolchain

2017-02-02 Thread Naveen N. Rao
On 2016/11/27 01:46PM, Nicholas Piggin wrote:
> On Sat, 26 Nov 2016 18:30:15 +1100
> Michael Ellerman  wrote:
> 
> > Nicholas Piggin  writes:
> > > On Thu, 24 Nov 2016 00:02:08 +1100
> > > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> > > index 617dece..8828807 100644
> > > --- a/arch/powerpc/Makefile
> > > +++ b/arch/powerpc/Makefile
> > > @@ -73,13 +73,18 @@ MULTIPLEWORD  := -mmultiple
> > >  endif
> > >  
> > >  cflags-$(CONFIG_CPU_BIG_ENDIAN)  += $(call 
> > > cc-option,-mbig-endian)
> > > +cflags-$(CONFIG_CPU_BIG_ENDIAN)  += $(call cc-option,-mabi=elfv1)
> > > +cflags-$(CONFIG_CPU_BIG_ENDIAN)  += $(call 
> > > cc-option,-mcall-aixdesc)  
> > 
> > This blew up the world:
> > 
> >   
> > http://kisskb.ellerman.id.au/kisskb/head/1ba4cb3d67e181bdc9a911d7be81f64e3d7597d2/
> > 
> >   Successful:   24% 63/258
> > 
> > I suspect you need to make -mcall-aixdesc 64-bit only.
> 
> Yes, I forgot 32-bit will pick those up. 3rd time's a charm, this compiles
> 64 bit be/le and 32-bit now.
> 
> --
> 
> Subject: [PATCH] powerpc: allow compilation on cross-endian toolchain
> 
> GCC can compile with either endian, but the ABI version always
> defaults to the default endian. Alan Modra says:
> 
>   you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc
>   generate powerpc64 code
> 
> The opposite is true for powerpc64 when generating -mlittle it
> requires -mabi=elfv2 to generate v2 ABI. This change adds ABI
> annotations together with endianness. The kernel with ELFv2 ABI
> also uses -mcall-aixdesc, but boot/ does not.
> 
> Signed-off-by: Nicholas Piggin 

FWIW, this fixes the issue with vmx build when doing a BE build with LE 
toolchain:
/tmp/ccR5lr0U.s: Error: .size expression for aes_p8_set_encrypt_key 
does not evaluate to a constant
/tmp/ccR5lr0U.s: Error: .size expression for .aes_p8_set_encrypt_key 
does not evaluate to a constant
/tmp/ccR5lr0U.s: Error: .size expression for aes_p8_set_decrypt_key 
does not evaluate to a constant
/tmp/ccR5lr0U.s: Error: .size expression for .aes_p8_set_decrypt_key 
does not evaluate to a constant
/tmp/ccR5lr0U.s: Error: .size expression for aes_p8_encrypt does not 
evaluate to a constant
/tmp/ccR5lr0U.s: Error: .size expression for .aes_p8_encrypt does not 
evaluate to a constant

Tested-by: Naveen N. Rao 

Thanks,
Naveen



Re: [PATCH 2/3] powerpc: allow compilation on cross-endian toolchain

2016-11-26 Thread Nicholas Piggin
On Sat, 26 Nov 2016 18:30:15 +1100
Michael Ellerman  wrote:

> Nicholas Piggin  writes:
> > On Thu, 24 Nov 2016 00:02:08 +1100
> > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> > index 617dece..8828807 100644
> > --- a/arch/powerpc/Makefile
> > +++ b/arch/powerpc/Makefile
> > @@ -73,13 +73,18 @@ MULTIPLEWORD:= -mmultiple
> >  endif
> >  
> >  cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
> > cc-option,-mbig-endian)
> > +cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
> > +cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
> > cc-option,-mcall-aixdesc)  
> 
> This blew up the world:
> 
>   
> http://kisskb.ellerman.id.au/kisskb/head/1ba4cb3d67e181bdc9a911d7be81f64e3d7597d2/
> 
>   Successful: 24% 63/258
> 
> I suspect you need to make -mcall-aixdesc 64-bit only.

Yes, I forgot 32-bit will pick those up. 3rd time's a charm, this compiles
64 bit be/le and 32-bit now.

--

Subject: [PATCH] powerpc: allow compilation on cross-endian toolchain

GCC can compile with either endian, but the ABI version always
defaults to the default endian. Alan Modra says:

  you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc
  generate powerpc64 code

The opposite is true for powerpc64 when generating -mlittle it
requires -mabi=elfv2 to generate v2 ABI. This change adds ABI
annotations together with endianness. The kernel with ELFv2 ABI
also uses -mcall-aixdesc, but boot/ does not.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/Makefile  | 11 ++-
 arch/powerpc/boot/Makefile |  4 +++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 617dece..a60c9c6 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -72,8 +72,15 @@ GNUTARGET:= powerpc
 MULTIPLEWORD   := -mmultiple
 endif
 
-cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+ifdef CONFIG_PPC64
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mcall-aixdesc)
+aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
+aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
+endif
+
 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
 ifneq ($(cc-name),clang)
   cflags-$(CONFIG_CPU_LITTLE_ENDIAN)   += -mno-strict-align
 endif
@@ -113,7 +120,9 @@ ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call 
cc-option,-mcall-aixdesc))
 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
 else
+CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
+AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index eae2dc8..7c46cf3 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -28,14 +28,16 @@ BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes 
-Wno-trigraphs \
 -isystem $(shell $(CROSS32CC) -print-file-name=include) \
 -D$(compress-y)
 
+# PPC64_BOOT_WRAPPER is little-endian specific.
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTCFLAGS += -m64
+BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
 endif
+
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS += -mbig-endian
 else
 BOOTCFLAGS += -mlittle-endian
-BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
 endif
 
 BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
-- 
2.10.2



Re: [PATCH 2/3] powerpc: allow compilation on cross-endian toolchain

2016-11-25 Thread Michael Ellerman
Nicholas Piggin  writes:
> On Thu, 24 Nov 2016 00:02:08 +1100
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 617dece..8828807 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -73,13 +73,18 @@ MULTIPLEWORD  := -mmultiple
>  endif
>  
>  cflags-$(CONFIG_CPU_BIG_ENDIAN)  += $(call 
> cc-option,-mbig-endian)
> +cflags-$(CONFIG_CPU_BIG_ENDIAN)  += $(call cc-option,-mabi=elfv1)
> +cflags-$(CONFIG_CPU_BIG_ENDIAN)  += $(call 
> cc-option,-mcall-aixdesc)

This blew up the world:

  
http://kisskb.ellerman.id.au/kisskb/head/1ba4cb3d67e181bdc9a911d7be81f64e3d7597d2/

  Successful:   24% 63/258

I suspect you need to make -mcall-aixdesc 64-bit only.

cheers


Re: [PATCH 2/3] powerpc: allow compilation on cross-endian toolchain

2016-11-25 Thread Nicholas Piggin
On Thu, 24 Nov 2016 20:04:23 +1100
Nicholas Piggin  wrote:

> On Thu, 24 Nov 2016 00:02:08 +1100
> Nicholas Piggin  wrote:
> 
> > GCC can compile with either endian, but the ABI version always
> > defaults to the default endian. Alan Modra says:  
> 
> Okay I was missing mcall-aixdesc, thanks again to Alan for pointing
> it out.

Final patch here which just slightly changes how the boot code flags
are set (don't introduce unnecessary setting of elfv1 on 32-bit builds).
--

GCC can compile with either endian, but the ABI version always
defaults to the default endian. Alan Modra says:

  you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc
  generate powerpc64 code

The opposite is true for powerpc64 when generating -mlittle it
requires -mabi=elfv2 to generate v2 ABI. This change adds ABI
annotations together with endianness. The kernel with ELFv2 ABI
also uses -mcall-aixdesc, but boot/ does not.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/Makefile  | 7 +++
 arch/powerpc/boot/Makefile | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 617dece..8828807 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -73,13 +73,18 @@ MULTIPLEWORD:= -mmultiple
 endif
 
 cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mcall-aixdesc)
 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
 ifneq ($(cc-name),clang)
   cflags-$(CONFIG_CPU_LITTLE_ENDIAN)   += -mno-strict-align
 endif
 
 aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
 
 ifeq ($(HAS_BIARCH),y)
 override AS+= -a$(BITS)
@@ -113,7 +118,9 @@ ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call 
cc-option,-mcall-aixdesc))
 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
 else
+CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
+AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index eae2dc8..7c46cf3 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -28,14 +28,16 @@ BOOTCFLAGS:= -Wall -Wundef -Wstrict-prototypes 
-Wno-trigraphs \
 -isystem $(shell $(CROSS32CC) -print-file-name=include) \
 -D$(compress-y)
 
+# PPC64_BOOT_WRAPPER is little-endian specific.
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTCFLAGS += -m64
+BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
 endif
+
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS += -mbig-endian
 else
 BOOTCFLAGS += -mlittle-endian
-BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
 endif
 
 BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
-- 
2.10.2



Re: [PATCH 2/3] powerpc: allow compilation on cross-endian toolchain

2016-11-24 Thread Nicholas Piggin
On Thu, 24 Nov 2016 00:02:08 +1100
Nicholas Piggin  wrote:

> GCC can compile with either endian, but the ABI version always
> defaults to the default endian. Alan Modra says:

Okay I was missing mcall-aixdesc, thanks again to Alan for pointing
it out.

This updated patch seems to do better, and it builds BE kernel with
powerpc64le-gcc, and LE with powerpc64-gcc here (I did see a link
failure but then couldn't reproduce it so it might have been a stale
file hanging around somewhere).


From: Nicholas Piggin 
Date: Wed, 23 Nov 2016 17:27:39 +1100
Subject: [PATCH] powerpc: allow compilation on cross-endian toolchain

GCC can compile with either endian, but the ABI version always
defaults to the default endian. Alan Modra says:

  you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc
  generate powerpc64 code

The opposite is true for powerpc64 when generating -mlittle it
requires -mabi=elfv2 to generate v2 ABI. This change adds ABI
annotations together with endianness. The kernel with ELFv2 ABI
also uses -mcall-aixdesc, but boot/ does not.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/Makefile  | 7 +++
 arch/powerpc/boot/Makefile | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 617dece..8828807 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -73,13 +73,18 @@ MULTIPLEWORD:= -mmultiple
 endif
 
 cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mcall-aixdesc)
 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
 ifneq ($(cc-name),clang)
   cflags-$(CONFIG_CPU_LITTLE_ENDIAN)   += -mno-strict-align
 endif
 
 aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
 
 ifeq ($(HAS_BIARCH),y)
 override AS+= -a$(BITS)
@@ -113,7 +118,9 @@ ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call 
cc-option,-mcall-aixdesc))
 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
 else
+CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
+AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index eae2dc8..1d50d41 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -33,6 +33,7 @@ BOOTCFLAGS+= -m64
 endif
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS += -mbig-endian
+BOOTCFLAGS += $(call cc-option,-mabi=elfv1)
 else
 BOOTCFLAGS += -mlittle-endian
 BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
-- 
2.10.2




[PATCH 2/3] powerpc: allow compilation on cross-endian toolchain

2016-11-23 Thread Nicholas Piggin
GCC can compile with either endian, but the ABI version always
defaults to the default endian. Alan Modra says:

  you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc
  generate powerpc64 code

The opposite is true for powerpc64 when generating -mlittle it
requires -mabi=elfv2 to generate v2 ABI. This change adds abi
annotations together with endianness.

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/Makefile  | 6 ++
 arch/powerpc/boot/Makefile | 1 +
 2 files changed, 7 insertions(+)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 617dece..902da6e 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -73,13 +73,17 @@ MULTIPLEWORD:= -mmultiple
 endif
 
 cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+cflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
 ifneq ($(cc-name),clang)
   cflags-$(CONFIG_CPU_LITTLE_ENDIAN)   += -mno-strict-align
 endif
 
 aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call 
cc-option,-mbig-endian)
+aflags-$(CONFIG_CPU_BIG_ENDIAN)+= $(call cc-option,-mabi=elfv1)
 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
+aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
 
 ifeq ($(HAS_BIARCH),y)
 override AS+= -a$(BITS)
@@ -114,6 +118,8 @@ CFLAGS-$(CONFIG_PPC64)  += $(call 
cc-option,-mabi=elfv2,$(call cc-option,-mcall-a
 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
 else
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
+CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
+AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
 endif
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call 
cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index eae2dc8..1d50d41 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -33,6 +33,7 @@ BOOTCFLAGS+= -m64
 endif
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS += -mbig-endian
+BOOTCFLAGS += $(call cc-option,-mabi=elfv1)
 else
 BOOTCFLAGS += -mlittle-endian
 BOOTCFLAGS += $(call cc-option,-mabi=elfv2)
-- 
2.10.2