Patchwork Update compilation flags with core specific options

login
register
mail settings
Submitter Catalin Udma
Date July 2, 2013, 11:20 a.m.
Message ID <1372764004-18896-1-git-send-email-catalin.udma@freescale.com>
Download mbox | patch
Permalink /patch/256091/
State Superseded
Delegated to: Scott Wood
Headers show

Comments

Catalin Udma - July 2, 2013, 11:20 a.m.
If CONFIG_E500 is enabled, the compilation flags are updated
specifying the target core -mcpu=e5500/e500mc/8540
Also remove -Wa,-me500, being incompatible with -mcpu=e5500/e6500
The assembler option is redundant if the -mcpu= flag is set.
The patch fixes the kernel compilation problem for e5500/e6500
when using gcc option -mcpu=e5500/e6500.

Signed-off-by: Catalin Udma <catalin.udma@freescale.com>
---
 arch/powerpc/Makefile |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
Scott Wood - July 9, 2013, 11:48 p.m.
On 07/02/2013 06:20:04 AM, Catalin Udma wrote:
> If CONFIG_E500 is enabled, the compilation flags are updated
> specifying the target core -mcpu=e5500/e500mc/8540
> Also remove -Wa,-me500, being incompatible with -mcpu=e5500/e6500
> The assembler option is redundant if the -mcpu= flag is set.
> The patch fixes the kernel compilation problem for e5500/e6500
> when using gcc option -mcpu=e5500/e6500.

Another reason to do this is that currently, the assembler is replacing  
lwsync with sync on 64-bit kernels (it doesn't happen on 32-bit because  
we generate the lwsync at runtime) due to the -Wa,-me500.

-Scott
Udma Catalin-Dan-B32721 - July 24, 2013, 4:25 p.m.
> This breaks the vdso for e500v1/v2 (userspace dies with SIGILL), since
> KBUILD_CFLAGS doesn't get used when building asm files, and the vdso
> uses mftbu/mftbl which are not being assembled to the form that
> e500v1/v2 support.
> 
> We should be setting -mcpu=whatever and -msoft-float in both CFLAGS and
> AFLAGS, since we don't call "as" directly, and target selection should
> not differ based on whether we're building a C file or an asm file.
> 
> -Scott
[CU] Thank you, Scott. I'll update also AFLAGS.

I have some questions about how you reproduce the SIGILL issue.
I tried to reproduce the issue looking to gettimeofday.S, that uses
mftbu/mftbl. In my tests, I obtained the same output when compiling this file
for p1021rdb before and after this patch, and also after adding -mcpu to
AFLAGS: "objdump -d arch/powerpc/kernel/vdso32/gettimeofday.o" looks the same
for the cases mentioned above:
   "mftbu r3" from .S file is decoded to "mfspr   r3,269" in "objdump -d" output

Indeed, for -mcpu=601/power3, the "objdump -d" output is "mftbu r3" and according to
powerISA this instruction would cause Illegal Instruction error handler to be invoked
and permits the sw to emulate the instruction.

Regards,
Catalin

Patch

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 0624909..82808b5 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -140,6 +140,18 @@  ifeq ($(CONFIG_6xx),y)
 KBUILD_CFLAGS		+= -mcpu=powerpc
 endif
 
+ifeq ($(CONFIG_E500),y)
+ifeq ($(CONFIG_64BIT),y)
+KBUILD_CFLAGS		+= -mcpu=e5500
+else
+ifeq ($(CONFIG_PPC_E500MC),y)
+KBUILD_CFLAGS		+= -mcpu=e500mc
+else
+KBUILD_CFLAGS		+= -mcpu=8540
+endif
+endif
+endif
+
 # Work around a gcc code-gen bug with -fno-omit-frame-pointer.
 ifeq ($(CONFIG_FUNCTION_TRACER),y)
 KBUILD_CFLAGS		+= -mno-sched-epilog
@@ -147,7 +159,6 @@  endif
 
 cpu-as-$(CONFIG_4xx)		+= -Wa,-m405
 cpu-as-$(CONFIG_ALTIVEC)	+= -Wa,-maltivec
-cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
 KBUILD_AFLAGS += $(cpu-as-y)