linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* x86-64 build problem with tip
@ 2008-05-14  9:54 Jeremy Fitzhardinge
  2008-05-16 12:48 ` [PATCH] Fix immediate asm constraint for gcc 3 x86_64 Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-14  9:54 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: Ingo Molnar, Linux Kernel Mailing List

I'm getting this when I build for x86-64 with

jeremy@cosworth:~/hg/xen/paravirt/linux-x86_64$ gcc -v
Reading specs from /usr/lib/gcc/x86_64-linux/3.4.4/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --disable-werror x86_64-linux
Thread model: posix
gcc version 3.4.4 20050314 (prerelease) (Debian 3.4.3-13)


  CC      kernel/sched.o
/home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h: In function `wait_task_inactive':
/home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h:5: warning: asm operand 1 probably doesn't match constraints
/home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h:5: error: impossible constraint in `asm'
/home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h:5: warning: 'value' might be used uninitialized in this function
/home/jeremy/hg/xen/paravirt/linux/kernel/sched.c: At top level:
/home/jeremy/hg/xen/paravirt/linux/kernel/sched_fair.c:1167: warning: 'wakeup_preempt_entity' defined but not used
make[3]: *** [kernel/sched.o] Error 1


Turning CONFIG_MARKER off avoids the problem.

    J

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] Fix immediate asm constraint for gcc 3 x86_64
  2008-05-14  9:54 x86-64 build problem with tip Jeremy Fitzhardinge
@ 2008-05-16 12:48 ` Mathieu Desnoyers
  2008-05-16 21:32   ` H. Peter Anvin
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-16 12:48 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Ingo Molnar, Linux Kernel Mailing List, H. Peter Anvin

* Jeremy Fitzhardinge (jeremy@goop.org) wrote:
> I'm getting this when I build for x86-64 with
>
> jeremy@cosworth:~/hg/xen/paravirt/linux-x86_64$ gcc -v
> Reading specs from /usr/lib/gcc/x86_64-linux/3.4.4/specs
> Configured with: ../src/configure -v 
> --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr 
> --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 
> --enable-shared --with-system-zlib --enable-nls --without-included-gettext 
> --program-suffix=-3.4 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt 
> --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm 
> --enable-java-awt=gtk --disable-werror x86_64-linux
> Thread model: posix
> gcc version 3.4.4 20050314 (prerelease) (Debian 3.4.3-13)
>
>
>  CC      kernel/sched.o
> /home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h: In function 
> `wait_task_inactive':
> /home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h:5: warning: asm 
> operand 1 probably doesn't match constraints
> /home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h:5: error: 
> impossible constraint in `asm'
> /home/jeremy/hg/xen/paravirt/linux/kernel/sched_trace.h:5: warning: 'value' 
> might be used uninitialized in this function
> /home/jeremy/hg/xen/paravirt/linux/kernel/sched.c: At top level:
> /home/jeremy/hg/xen/paravirt/linux/kernel/sched_fair.c:1167: warning: 
> 'wakeup_preempt_entity' defined but not used
> make[3]: *** [kernel/sched.o] Error 1
>
>

It seems that include/asm-x86/immediate.h in sched-devel.git causes
this. gcc-3.4 does not seem to like the "i" (&name##__imv) constraint. I
have seen no such problem with gcc-4.1. This is weird. It seems that
relaxing the constraint helps fixing this, but it's not clear whether
fixing the code or gcc-3.4 is the correct solution... here is the fix :

Fix immediate asm constraint for gcc 3 x86_64

make CC=gcc-3.4 HOSTCC=gcc-3.4 causes this problem with immediate values on
x86_64 :

kernel/sched_trace.h: In function `wait_task_inactive':
kernel/sched_trace.h:5: warning: asm operand 1 probably doesn't match constraints
kernel/sched_trace.h:5: error: impossible constraint in `asm'
kernel/sched_trace.h:5: warning: 'value' might be used uninitialized in this function
make[1]: *** [kernel/sched.o] Error 1
make: *** [kernel/] Error 2

gcc-4.1 does not have this problem.

Fix this by changing the "i" (&name##__imv) for a "g" (&name##__imv) constraint.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Jeremy Fitzhardinge <jeremy@goop.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: "H. Peter Anvin" <hpa@zytor.com>
---
 include/asm-x86/immediate.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6-sched-devel/include/asm-x86/immediate.h
===================================================================
--- linux-2.6-sched-devel.orig/include/asm-x86/immediate.h	2008-05-16 05:07:55.000000000 -0400
+++ linux-2.6-sched-devel/include/asm-x86/immediate.h	2008-05-16 05:08:29.000000000 -0400
@@ -63,7 +63,7 @@
 				"mov $0,%0\n\t"				\
 				"3:\n\t"				\
 				: "=q" (value)				\
-				: "i" (&name##__imv),			\
+				: "g" (&name##__imv),			\
 				  "i" (sizeof(value)));			\
 			break;						\
 		case 2:							\
@@ -81,7 +81,7 @@
 				"mov $0,%0\n\t"				\
 				"3:\n\t"				\
 				: "=r" (value)				\
-				: "i" (&name##__imv),			\
+				: "g" (&name##__imv),			\
 				  "i" (sizeof(value)));			\
 			break;						\
 		case 8:							\
@@ -102,7 +102,7 @@
 				"mov $0xFEFEFEFE01010101,%0\n\t" 	\
 				"3:\n\t"				\
 				: "=r" (value)				\
-				: "i" (&name##__imv),			\
+				: "g" (&name##__imv),			\
 				  "i" (sizeof(value)));			\
 			break;						\
 		};							\
@@ -143,7 +143,7 @@
 			"mov $0,%0\n\t"					\
 			"3:\n\t"					\
 			: "=a" (value)					\
-			: "i" (&name##__imv),				\
+			: "g" (&name##__imv),				\
 			  "i" (sizeof(value)),				\
 			  "i" (sizeof(__typeof__(name##__imv))));	\
 		value;							\




> Turning CONFIG_MARKER off avoids the problem.
>
>    J

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix immediate asm constraint for gcc 3 x86_64
  2008-05-16 12:48 ` [PATCH] Fix immediate asm constraint for gcc 3 x86_64 Mathieu Desnoyers
@ 2008-05-16 21:32   ` H. Peter Anvin
  2008-05-21 13:31     ` Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: H. Peter Anvin @ 2008-05-16 21:32 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: Jeremy Fitzhardinge, Ingo Molnar, Linux Kernel Mailing List

Mathieu Desnoyers wrote:

> 
> It seems that include/asm-x86/immediate.h in sched-devel.git causes
> this. gcc-3.4 does not seem to like the "i" (&name##__imv) constraint. I
> have seen no such problem with gcc-4.1. This is weird. It seems that
> relaxing the constraint helps fixing this, but it's not clear whether
> fixing the code or gcc-3.4 is the correct solution... here is the fix :
> 
> Fix immediate asm constraint for gcc 3 x86_64
> 

It might make it compile, but it's completely *wrong* for the purpose 
intended.

It permits gcc to present the address in a register, for example, so 
there is no guarantee that you end up with an immediate.

	-hpa

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix immediate asm constraint for gcc 3 x86_64
  2008-05-16 21:32   ` H. Peter Anvin
@ 2008-05-21 13:31     ` Mathieu Desnoyers
       [not found]       ` <48344239.9070003@zytor.com>
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-21 13:31 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Jeremy Fitzhardinge, Ingo Molnar, Linux Kernel Mailing List

* H. Peter Anvin (hpa@zytor.com) wrote:
> Mathieu Desnoyers wrote:
>
>> It seems that include/asm-x86/immediate.h in sched-devel.git causes
>> this. gcc-3.4 does not seem to like the "i" (&name##__imv) constraint. I
>> have seen no such problem with gcc-4.1. This is weird. It seems that
>> relaxing the constraint helps fixing this, but it's not clear whether
>> fixing the code or gcc-3.4 is the correct solution... here is the fix :
>> Fix immediate asm constraint for gcc 3 x86_64
>
> It might make it compile, but it's completely *wrong* for the purpose 
> intended.
>
> It permits gcc to present the address in a register, for example, so there 
> is no guarantee that you end up with an immediate.
>
> 	-hpa

Hrm, you are right. Let's see a simple toy case which generates the
problem :

struct test_struct {
  int a;
  int b;
  int c;
};

static struct test_struct testa;

int main()
{
        asm (
             ".quad %c0\n\t"
                :
                : "i" (&testa.c));
        return 0;
}

gcc 4.1 generates :  .quad testa+8

and doesn't complain. However, gcc-3.4 stops with :
compudj@amd64:~/test$ gcc-3.4 -S -o oldgcc.S oldgcc.c
oldgcc.c: In function `main':
oldgcc.c:11: warning: asm operand 0 probably doesn't match constraints
oldgcc.c:11: error: impossible constraint in `asm'

It's understandable given that changing the "i" for a "g" constraint
changes the assembly result for :

        movl    $testa, %eax
        addq    $8, %rax
#APP
        .quad %rax

#NO_APP

Is there any way we could get a symbol assigned to &testa.c to make gcc
3 happy ?

Mathieu

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] Fix Immediate Values x86_64 support old gcc
       [not found]         ` <20080521160217.GA26974@Krystal>
@ 2008-05-21 17:01           ` Mathieu Desnoyers
  2008-05-21 20:37             ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-21 17:01 UTC (permalink / raw)
  To: H. Peter Anvin, Sam Ravnborg
  Cc: linux-kernel, Jeremy Fitzhardinge, Ingo Molnar

Does this fix make more sense ?

GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
asm statements. Fallback on generic immediate values if this compiler is
detected.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
---
 arch/x86/Makefile           |    3 +++
 arch/x86/kernel/Makefile    |    4 +++-
 include/asm-x86/immediate.h |    5 +++++
 include/linux/immediate.h   |    4 +++-
 kernel/Makefile             |    4 +++-
 5 files changed, 17 insertions(+), 3 deletions(-)

Index: linux-2.6-sched-devel/arch/x86/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 09:04:52.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 09:22:05.000000000 -0400
@@ -78,6 +78,9 @@
                 "$(CC)" -fstack-protector-all )
 
         KBUILD_CFLAGS += $(stackp-y)
+
+	export GCC_BROKEN_IMMEDIATE
+	GCC_BROKEN_IMMEDIATE := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Index: linux-2.6-sched-devel/include/asm-x86/immediate.h
===================================================================
--- linux-2.6-sched-devel.orig/include/asm-x86/immediate.h	2008-05-21 09:10:59.000000000 -0400
+++ linux-2.6-sched-devel/include/asm-x86/immediate.h	2008-05-21 09:15:43.000000000 -0400
@@ -12,6 +12,10 @@
 
 #include <asm/asm.h>
 
+#if (defined(CONFIG_X86_64) && __GNUC__ < 4)	/* Detect broken x86_64 gcc */
+#undef CONFIG_IMMEDIATE
+#else
+
 struct __imv {
 	unsigned long var;	/* Pointer to the identifier variable of the
 				 * immediate value
@@ -166,4 +170,5 @@
 
 extern int arch_imv_update(struct __imv *imv, int early);
 
+#endif
 #endif /* _ASM_X86_IMMEDIATE_H */
Index: linux-2.6-sched-devel/include/linux/immediate.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 09:12:22.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 09:12:59.000000000 -0400
@@ -11,8 +11,10 @@
  */
 
 #ifdef CONFIG_IMMEDIATE
+#include <asm/immediate.h>	/* May undef CONFIG_IMMEDIATE */
+#endif
 
-#include <asm/immediate.h>
+#ifdef CONFIG_IMMEDIATE
 
 /**
  * imv_set - set immediate variable (with locking)
Index: linux-2.6-sched-devel/arch/x86/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/Makefile	2008-05-21 09:20:49.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/Makefile	2008-05-21 09:21:22.000000000 -0400
@@ -75,7 +75,9 @@
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 obj-$(CONFIG_MODULES)		+= module_$(BITS).o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat_32.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+ifneq ($(GCC_BROKEN_IMMEDIATE),y)
+	obj-$(CONFIG_IMMEDIATE)	+= immediate.o
+endif
 obj-$(CONFIG_EFI) 		+= efi.o efi_$(BITS).o efi_stub_$(BITS).o
 obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault_32.o
 obj-$(CONFIG_KGDB)		+= kgdb.o
Index: linux-2.6-sched-devel/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/kernel/Makefile	2008-05-21 09:21:28.000000000 -0400
+++ linux-2.6-sched-devel/kernel/Makefile	2008-05-21 09:21:44.000000000 -0400
@@ -75,7 +75,9 @@
 obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
-obj-$(CONFIG_IMMEDIATE) += immediate.o
+ifneq ($(GCC_BROKEN_IMMEDIATE),y)
+	obj-$(CONFIG_IMMEDIATE) += immediate.o
+endif
 obj-$(CONFIG_MARKERS) += marker.o
 obj-$(CONFIG_LATENCYTOP) += latencytop.o
 obj-$(CONFIG_FTRACE) += trace/

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc
  2008-05-21 17:01           ` [PATCH] Fix Immediate Values x86_64 support old gcc Mathieu Desnoyers
@ 2008-05-21 20:37             ` Sam Ravnborg
  2008-05-21 21:28               ` Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2008-05-21 20:37 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar

Hi Mathieu
> Does this fix make more sense ?
> 
> GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
> asm statements. Fallback on generic immediate values if this compiler is
> detected.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> ---
>  arch/x86/Makefile           |    3 +++
>  arch/x86/kernel/Makefile    |    4 +++-
>  include/asm-x86/immediate.h |    5 +++++
>  include/linux/immediate.h   |    4 +++-
>  kernel/Makefile             |    4 +++-
>  5 files changed, 17 insertions(+), 3 deletions(-)
> 
> Index: linux-2.6-sched-devel/arch/x86/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 09:04:52.000000000 -0400
> +++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 09:22:05.000000000 -0400
> @@ -78,6 +78,9 @@
>                  "$(CC)" -fstack-protector-all )
>  
>          KBUILD_CFLAGS += $(stackp-y)
> +
> +	export GCC_BROKEN_IMMEDIATE
> +	GCC_BROKEN_IMMEDIATE := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)

So here we introduce a global environment variable that tells
us that gcc has "BROKEN_IMMEDIATE".
I have absolutely no clue what "BROKEN_IMMEDIATE" is so I guess others
are in the same boat. Comment please!

Consider something like this (note: no negative logic involved):
export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))

Then the MAkefile fragment can be simplified as:
> -obj-$(CONFIG_IMMEDIATE)              += immediate.o
> +obj-$(USE_IMMEDIATE)                 += immediate.o

(Or find a better name than "USE_IMMEDIATE".


>  endif
>  
>  # Stackpointer is addressed different for 32 bit and 64 bit x86
> Index: linux-2.6-sched-devel/include/asm-x86/immediate.h
> ===================================================================
> --- linux-2.6-sched-devel.orig/include/asm-x86/immediate.h	2008-05-21 09:10:59.000000000 -0400
> +++ linux-2.6-sched-devel/include/asm-x86/immediate.h	2008-05-21 09:15:43.000000000 -0400
> @@ -12,6 +12,10 @@
>  
>  #include <asm/asm.h>
>  
> +#if (defined(CONFIG_X86_64) && __GNUC__ < 4)	/* Detect broken x86_64 gcc */
> +#undef CONFIG_IMMEDIATE
> +#else

And now in the source we use a direct check of the GNUC version. So this is a duplicate
of GCC_BROKEN_IMMEDIATE and not sensible comments.
"I ask myself in what way is gcc broken?"
And you DO NOT fiddle with the CONFIG_* variables - this is just plain wrong.

> --- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 09:12:22.000000000 -0400
> +++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 09:12:59.000000000 -0400
> @@ -11,8 +11,10 @@
>   */
>  
>  #ifdef CONFIG_IMMEDIATE
> +#include <asm/immediate.h>	/* May undef CONFIG_IMMEDIATE */
> +#endif

So you need to find a better way for this.


>  
> -#include <asm/immediate.h>
> +#ifdef CONFIG_IMMEDIATE
>  
>  /**
>   * imv_set - set immediate variable (with locking)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc
  2008-05-21 20:37             ` Sam Ravnborg
@ 2008-05-21 21:28               ` Mathieu Desnoyers
  2008-05-21 21:46                 ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-21 21:28 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar

* Sam Ravnborg (sam@ravnborg.org) wrote:
> Hi Mathieu
> > Does this fix make more sense ?
> > 
> > GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
> > asm statements. Fallback on generic immediate values if this compiler is
> > detected.
> > 
> > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > ---
> >  arch/x86/Makefile           |    3 +++
> >  arch/x86/kernel/Makefile    |    4 +++-
> >  include/asm-x86/immediate.h |    5 +++++
> >  include/linux/immediate.h   |    4 +++-
> >  kernel/Makefile             |    4 +++-
> >  5 files changed, 17 insertions(+), 3 deletions(-)
> > 
> > Index: linux-2.6-sched-devel/arch/x86/Makefile
> > ===================================================================
> > --- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 09:04:52.000000000 -0400
> > +++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 09:22:05.000000000 -0400
> > @@ -78,6 +78,9 @@
> >                  "$(CC)" -fstack-protector-all )
> >  
> >          KBUILD_CFLAGS += $(stackp-y)
> > +
> > +	export GCC_BROKEN_IMMEDIATE
> > +	GCC_BROKEN_IMMEDIATE := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)
> 
> So here we introduce a global environment variable that tells
> us that gcc has "BROKEN_IMMEDIATE".
> I have absolutely no clue what "BROKEN_IMMEDIATE" is so I guess others
> are in the same boat. Comment please!
> 

Yes, I guess this worth being commented, you are right. I'll write
something along the lines written in the patch header.

> Consider something like this (note: no negative logic involved):
> export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
> 

Hrm, if I do that, I would have to add USE_IMMEDIATE to each
architecture's makefiles for which immediate values are supported, e.g.:

export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)

The "BROKEN_IMMEDIATE" (negative) approach only needs to be defined on
x86_64 where gcc 3.x does not support symbol+offset correctly.

> Then the MAkefile fragment can be simplified as:
> > -obj-$(CONFIG_IMMEDIATE)              += immediate.o
> > +obj-$(USE_IMMEDIATE)                 += immediate.o
> 
> (Or find a better name than "USE_IMMEDIATE".
> 
> 
> >  endif
> >  
> >  # Stackpointer is addressed different for 32 bit and 64 bit x86
> > Index: linux-2.6-sched-devel/include/asm-x86/immediate.h
> > ===================================================================
> > --- linux-2.6-sched-devel.orig/include/asm-x86/immediate.h	2008-05-21 09:10:59.000000000 -0400
> > +++ linux-2.6-sched-devel/include/asm-x86/immediate.h	2008-05-21 09:15:43.000000000 -0400
> > @@ -12,6 +12,10 @@
> >  
> >  #include <asm/asm.h>
> >  
> > +#if (defined(CONFIG_X86_64) && __GNUC__ < 4)	/* Detect broken x86_64 gcc */
> > +#undef CONFIG_IMMEDIATE
> > +#else
> 
> And now in the source we use a direct check of the GNUC version. So this is a duplicate
> of GCC_BROKEN_IMMEDIATE and not sensible comments.
> "I ask myself in what way is gcc broken?"
> And you DO NOT fiddle with the CONFIG_* variables - this is just plain wrong.
> 

I could pass the USE_IMMEDIATE as a -D to the compiler flags. That would
be cleaner.

> > --- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 09:12:22.000000000 -0400
> > +++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 09:12:59.000000000 -0400
> > @@ -11,8 +11,10 @@
> >   */
> >  
> >  #ifdef CONFIG_IMMEDIATE
> > +#include <asm/immediate.h>	/* May undef CONFIG_IMMEDIATE */
> > +#endif
> 
> So you need to find a better way for this.
> 

I think USE_IMMEDIATE is the way to go then.

Thanks,

Mathieu

> 
> >  
> > -#include <asm/immediate.h>
> > +#ifdef CONFIG_IMMEDIATE
> >  
> >  /**
> >   * imv_set - set immediate variable (with locking)
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc
  2008-05-21 21:28               ` Mathieu Desnoyers
@ 2008-05-21 21:46                 ` Sam Ravnborg
  2008-05-21 21:57                   ` [PATCH] Fix Immediate Values x86_64 support old gcc (v2) Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2008-05-21 21:46 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar

On Wed, May 21, 2008 at 05:28:09PM -0400, Mathieu Desnoyers wrote:
> * Sam Ravnborg (sam@ravnborg.org) wrote:
> > Hi Mathieu
> > > Does this fix make more sense ?
> > > 
> > > GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
> > > asm statements. Fallback on generic immediate values if this compiler is
> > > detected.
> > > 
> > > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> > > ---
> > >  arch/x86/Makefile           |    3 +++
> > >  arch/x86/kernel/Makefile    |    4 +++-
> > >  include/asm-x86/immediate.h |    5 +++++
> > >  include/linux/immediate.h   |    4 +++-
> > >  kernel/Makefile             |    4 +++-
> > >  5 files changed, 17 insertions(+), 3 deletions(-)
> > > 
> > > Index: linux-2.6-sched-devel/arch/x86/Makefile
> > > ===================================================================
> > > --- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 09:04:52.000000000 -0400
> > > +++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 09:22:05.000000000 -0400
> > > @@ -78,6 +78,9 @@
> > >                  "$(CC)" -fstack-protector-all )
> > >  
> > >          KBUILD_CFLAGS += $(stackp-y)
> > > +
> > > +	export GCC_BROKEN_IMMEDIATE
> > > +	GCC_BROKEN_IMMEDIATE := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)
> > 
> > So here we introduce a global environment variable that tells
> > us that gcc has "BROKEN_IMMEDIATE".
> > I have absolutely no clue what "BROKEN_IMMEDIATE" is so I guess others
> > are in the same boat. Comment please!
> > 
> 
> Yes, I guess this worth being commented, you are right. I'll write
> something along the lines written in the patch header.
> 
> > Consider something like this (note: no negative logic involved):
> > export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
> > 
> 
> Hrm, if I do that, I would have to add USE_IMMEDIATE to each
> architecture's makefiles for which immediate values are supported, e.g.:
> 
> export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
> 
> The "BROKEN_IMMEDIATE" (negative) approach only needs to be defined on
> x86_64 where gcc 3.x does not support symbol+offset correctly.
Same with USE_IMMEDIATE - as USE_IMMEDIATE is only used in a x86 Makefile.
Or did I miss sothing?

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc (v2)
  2008-05-21 21:46                 ` Sam Ravnborg
@ 2008-05-21 21:57                   ` Mathieu Desnoyers
  2008-05-21 22:38                     ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-21 21:57 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar,
	David Miller, PaulMackerraspaulus

* Sam Ravnborg (sam@ravnborg.org) wrote:

> Same with USE_IMMEDIATE - as USE_IMMEDIATE is only used in a x86 Makefile.
> Or did I miss sothing?
> 

Given that I want to change every use of CONFIG_IMMEDIATE into
USE_IMMEDIATE, both in architecture specific and independant C files and
also in arch spec. and indep. Makefiles, I will have to define
USE_IMMEDIATE on other arch too.

Here is the updated patch. It applies on top of the sched-devel.git
tree.

Fix Immediate Values x86_64 support old gcc

GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
asm statements. Fallback on generic immediate values if this compiler is
detected.

Changelog :
- USE_IMMEDIATE must now be used in lieue of CONFIG_IMMEDIATE in Makefiles and
  in C code.
- Every architecture implementing immediate values must declare USE_IMMEDIATE
  in their Makefile.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Sam Ravnborg <sam@ravnborg.org>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Jeremy Fitzhardinge <jeremy@goop.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: David Miller <davem@davemloft.net>
CC: Paul Mackerras paulus@samba.org
---
 Makefile                     |    5 +++++
 arch/powerpc/Makefile        |    2 ++
 arch/powerpc/kernel/Makefile |    2 +-
 arch/x86/Makefile            |    5 +++++
 arch/x86/kernel/Makefile     |    2 +-
 arch/x86/kernel/traps_32.c   |    4 ++--
 include/linux/immediate.h    |    2 +-
 include/linux/module.h       |    4 ++--
 kernel/Makefile              |    2 +-
 kernel/module.c              |    8 ++++----
 10 files changed, 24 insertions(+), 12 deletions(-)

Index: linux-2.6-sched-devel/arch/x86/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 09:04:52.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 14:18:16.000000000 -0400
@@ -43,6 +43,7 @@
 
         # temporary until string.h is fixed
         KBUILD_CFLAGS += -ffreestanding
+	export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
 else
         BITS := 64
         UTS_MACHINE := x86_64
@@ -78,6 +79,10 @@
                 "$(CC)" -fstack-protector-all )
 
         KBUILD_CFLAGS += $(stackp-y)
+
+	# x86_64 gcc 3.x has problems with passing symbol+offset in
+	# asm "i" constraint.
+	export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Index: linux-2.6-sched-devel/include/linux/immediate.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 09:12:22.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 14:12:05.000000000 -0400
@@ -10,7 +10,7 @@
  * See the file COPYING for more details.
  */
 
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 
 #include <asm/immediate.h>
 
Index: linux-2.6-sched-devel/arch/x86/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/Makefile	2008-05-21 09:20:49.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/Makefile	2008-05-21 14:11:10.000000000 -0400
@@ -75,7 +75,7 @@
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 obj-$(CONFIG_MODULES)		+= module_$(BITS).o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat_32.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+obj-$(USE_IMMEDIATE)		+= immediate.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_$(BITS).o efi_stub_$(BITS).o
 obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault_32.o
 obj-$(CONFIG_KGDB)		+= kgdb.o
Index: linux-2.6-sched-devel/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/kernel/Makefile	2008-05-21 09:21:28.000000000 -0400
+++ linux-2.6-sched-devel/kernel/Makefile	2008-05-21 14:10:51.000000000 -0400
@@ -75,7 +75,7 @@
 obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
-obj-$(CONFIG_IMMEDIATE) += immediate.o
+obj-$(USE_IMMEDIATE) += immediate.o
 obj-$(CONFIG_MARKERS) += marker.o
 obj-$(CONFIG_LATENCYTOP) += latencytop.o
 obj-$(CONFIG_FTRACE) += trace/
Index: linux-2.6-sched-devel/arch/powerpc/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/powerpc/Makefile	2008-05-21 14:00:23.000000000 -0400
+++ linux-2.6-sched-devel/arch/powerpc/Makefile	2008-05-21 14:08:15.000000000 -0400
@@ -98,6 +98,8 @@
 endif
 endif
 
+export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
+
 ifeq ($(CONFIG_TUNE_CELL),y)
 	KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
 endif
Index: linux-2.6-sched-devel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/Makefile	2008-05-21 14:09:41.000000000 -0400
+++ linux-2.6-sched-devel/Makefile	2008-05-21 14:16:44.000000000 -0400
@@ -532,6 +532,11 @@
 KBUILD_CFLAGS	+= -pg
 endif
 
+# arch Makefile detects if the compiler permits use of immediate values
+ifdef USE_IMMEDIATE
+KBUILD_CFLAGS	+= -DUSE_IMMEDIATE
+endif
+
 # We trigger additional mismatches with less inlining
 ifdef CONFIG_DEBUG_SECTION_MISMATCH
 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
Index: linux-2.6-sched-devel/arch/powerpc/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/powerpc/kernel/Makefile	2008-05-21 14:11:25.000000000 -0400
+++ linux-2.6-sched-devel/arch/powerpc/kernel/Makefile	2008-05-21 14:11:36.000000000 -0400
@@ -45,7 +45,7 @@
 obj64-$(CONFIG_HIBERNATION)	+= swsusp_asm64.o
 obj-$(CONFIG_MODULES)		+= module_$(CONFIG_WORD_SIZE).o
 obj-$(CONFIG_44x)		+= cpu_setup_44x.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+obj-$(USE_IMMEDIATE)		+= immediate.o
 
 ifeq ($(CONFIG_PPC_MERGE),y)
 
Index: linux-2.6-sched-devel/kernel/module.c
===================================================================
--- linux-2.6-sched-devel.orig/kernel/module.c	2008-05-21 14:13:01.000000000 -0400
+++ linux-2.6-sched-devel/kernel/module.c	2008-05-21 14:13:18.000000000 -0400
@@ -2013,7 +2013,7 @@
 	mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr;
 	if (gplfuturecrcindex)
 		mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr;
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	mod->immediate = (void *)sechdrs[immediateindex].sh_addr;
 	mod->num_immediate =
 		sechdrs[immediateindex].sh_size / sizeof(*mod->immediate);
@@ -2097,7 +2097,7 @@
 		marker_update_probe_range(mod->markers,
 			mod->markers + mod->num_markers);
 #endif
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 		/* Immediate values must be updated after markers */
 		imv_update_range(mod->immediate,
 			mod->immediate + mod->num_immediate);
@@ -2258,7 +2258,7 @@
 	/* Drop initial reference. */
 	module_put(mod);
 	unwind_remove_table(mod->unwind_info, 1);
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	imv_unref(mod->immediate, mod->immediate + mod->num_immediate,
 		mod->module_init, mod->init_size);
 #endif
@@ -2657,7 +2657,7 @@
 }
 #endif
 
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 /**
  * _module_imv_update - update all immediate values in the kernel
  *
Index: linux-2.6-sched-devel/include/linux/module.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/module.h	2008-05-21 14:13:30.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/module.h	2008-05-21 14:13:47.000000000 -0400
@@ -339,7 +339,7 @@
 	/* The command line arguments (may be mangled).  People like
 	   keeping pointers to this stuff */
 	char *args;
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	struct __imv *immediate;
 	unsigned int num_immediate;
 	unsigned long *immediate_cond_end;
@@ -563,7 +563,7 @@
 
 #endif /* CONFIG_MODULES */
 
-#if defined(CONFIG_MODULES) && defined(CONFIG_IMMEDIATE)
+#if defined(CONFIG_MODULES) && defined(USE_IMMEDIATE)
 extern void _module_imv_update(void);
 extern void module_imv_update(void);
 extern int is_imv_cond_end_module(unsigned long addr1, unsigned long addr2);
Index: linux-2.6-sched-devel/arch/x86/kernel/traps_32.c
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/traps_32.c	2008-05-21 14:14:13.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/traps_32.c	2008-05-21 14:14:32.000000000 -0400
@@ -595,7 +595,7 @@
 }
 
 DO_VM86_ERROR_INFO(0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->ip)
-#if !defined(CONFIG_KPROBES) && !defined(CONFIG_IMMEDIATE)
+#if !defined(CONFIG_KPROBES) && !defined(USE_IMMEDIATE)
 DO_VM86_ERROR(3, SIGTRAP, "int3", int3)
 #endif
 DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
@@ -860,7 +860,7 @@
 	acpi_nmi_enable();
 }
 
-#if defined(CONFIG_KPROBES) || defined(CONFIG_IMMEDIATE)
+#if defined(CONFIG_KPROBES) || defined(USE_IMMEDIATE)
 void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
 	trace_hardirqs_fixup();

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc (v2)
  2008-05-21 21:57                   ` [PATCH] Fix Immediate Values x86_64 support old gcc (v2) Mathieu Desnoyers
@ 2008-05-21 22:38                     ` Sam Ravnborg
  2008-05-21 23:24                       ` [PATCH] Fix Immediate Values x86_64 support old gcc (v3) Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2008-05-21 22:38 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar,
	David Miller, PaulMackerraspaulus

On Wed, May 21, 2008 at 05:57:56PM -0400, Mathieu Desnoyers wrote:
> * Sam Ravnborg (sam@ravnborg.org) wrote:
> 
> > Same with USE_IMMEDIATE - as USE_IMMEDIATE is only used in a x86 Makefile.
> > Or did I miss sothing?
> > 
> 
> Given that I want to change every use of CONFIG_IMMEDIATE into
> USE_IMMEDIATE, both in architecture specific and independant C files and
> also in arch spec. and indep. Makefiles, I will have to define
> USE_IMMEDIATE on other arch too.
> 
> Here is the updated patch. It applies on top of the sched-devel.git
> tree.
> 
> Fix Immediate Values x86_64 support old gcc
> 
> GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
> asm statements. Fallback on generic immediate values if this compiler is
> detected.
> 
> Changelog :
> - USE_IMMEDIATE must now be used in lieue of CONFIG_IMMEDIATE in Makefiles and
>   in C code.
> - Every architecture implementing immediate values must declare USE_IMMEDIATE
>   in their Makefile.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> CC: Sam Ravnborg <sam@ravnborg.org>
> CC: "H. Peter Anvin" <hpa@zytor.com>
> CC: Jeremy Fitzhardinge <jeremy@goop.org>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: David Miller <davem@davemloft.net>
> CC: Paul Mackerras paulus@samba.org
> ---
>  Makefile                     |    5 +++++
>  arch/powerpc/Makefile        |    2 ++
>  arch/powerpc/kernel/Makefile |    2 +-
>  arch/x86/Makefile            |    5 +++++
>  arch/x86/kernel/Makefile     |    2 +-
>  arch/x86/kernel/traps_32.c   |    4 ++--
>  include/linux/immediate.h    |    2 +-
>  include/linux/module.h       |    4 ++--
>  kernel/Makefile              |    2 +-
>  kernel/module.c              |    8 ++++----
>  10 files changed, 24 insertions(+), 12 deletions(-)
> 
> Index: linux-2.6-sched-devel/arch/x86/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 09:04:52.000000000 -0400
> +++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 14:18:16.000000000 -0400
> @@ -43,6 +43,7 @@
>  
>          # temporary until string.h is fixed
>          KBUILD_CFLAGS += -ffreestanding
> +	export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
tabs has a special sematic purpose in makefiles so do not
use tabs for indent.

>  else
>          BITS := 64
>          UTS_MACHINE := x86_64
> @@ -78,6 +79,10 @@
>                  "$(CC)" -fstack-protector-all )
>  
>          KBUILD_CFLAGS += $(stackp-y)
> +
> +	# x86_64 gcc 3.x has problems with passing symbol+offset in
> +	# asm "i" constraint.
> +	export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
tabs -> spaces again.

Other than that I like this patch much better.

Thanks,
	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc (v3)
  2008-05-21 22:38                     ` Sam Ravnborg
@ 2008-05-21 23:24                       ` Mathieu Desnoyers
  2008-05-22  2:03                         ` Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-21 23:24 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar,
	David Miller, Paul Mackerras

GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
asm statements. Fallback on generic immediate values if this compiler is
detected.

Changelog :
- USE_IMMEDIATE must now be used in lieue of CONFIG_IMMEDIATE in Makefiles and
  in C code.
- Every architecture implementing immediate values must declare USE_IMMEDIATE
  in their Makefile.
- Tab -> spaces in Makefiles.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Sam Ravnborg <sam@ravnborg.org>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Jeremy Fitzhardinge <jeremy@goop.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: David Miller <davem@davemloft.net>
CC: Paul Mackerras <paulus@samba.org>
---
 Makefile                     |    5 +++++
 arch/powerpc/Makefile        |    2 ++
 arch/powerpc/kernel/Makefile |    2 +-
 arch/x86/Makefile            |    5 +++++
 arch/x86/kernel/Makefile     |    2 +-
 arch/x86/kernel/traps_32.c   |    4 ++--
 include/linux/immediate.h    |    2 +-
 include/linux/module.h       |    4 ++--
 kernel/Makefile              |    2 +-
 kernel/module.c              |    8 ++++----
 10 files changed, 24 insertions(+), 12 deletions(-)

Index: linux-2.6-sched-devel/arch/x86/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 15:53:00.000000000 -0400
@@ -43,6 +43,7 @@
 
         # temporary until string.h is fixed
         KBUILD_CFLAGS += -ffreestanding
+        export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
 else
         BITS := 64
         UTS_MACHINE := x86_64
@@ -78,6 +79,10 @@
                 "$(CC)" -fstack-protector-all )
 
         KBUILD_CFLAGS += $(stackp-y)
+
+        # x86_64 gcc 3.x has problems with passing symbol+offset in
+        # asm "i" constraint.
+        export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Index: linux-2.6-sched-devel/include/linux/immediate.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 15:16:59.000000000 -0400
@@ -10,7 +10,7 @@
  * See the file COPYING for more details.
  */
 
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 
 #include <asm/immediate.h>
 
Index: linux-2.6-sched-devel/arch/x86/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/Makefile	2008-05-21 15:16:51.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -75,7 +75,7 @@
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 obj-$(CONFIG_MODULES)		+= module_$(BITS).o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat_32.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+obj-$(USE_IMMEDIATE)		+= immediate.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_$(BITS).o efi_stub_$(BITS).o
 obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault_32.o
 obj-$(CONFIG_KGDB)		+= kgdb.o
Index: linux-2.6-sched-devel/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/kernel/Makefile	2008-05-21 15:16:52.000000000 -0400
+++ linux-2.6-sched-devel/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -75,7 +75,7 @@
 obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
-obj-$(CONFIG_IMMEDIATE) += immediate.o
+obj-$(USE_IMMEDIATE) += immediate.o
 obj-$(CONFIG_MARKERS) += marker.o
 obj-$(CONFIG_LATENCYTOP) += latencytop.o
 obj-$(CONFIG_FTRACE) += trace/
Index: linux-2.6-sched-devel/arch/powerpc/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/powerpc/Makefile	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/powerpc/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -98,6 +98,8 @@
 endif
 endif
 
+export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
+
 ifeq ($(CONFIG_TUNE_CELL),y)
 	KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
 endif
Index: linux-2.6-sched-devel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/Makefile	2008-05-21 15:16:51.000000000 -0400
+++ linux-2.6-sched-devel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -532,6 +532,11 @@
 KBUILD_CFLAGS	+= -pg
 endif
 
+# arch Makefile detects if the compiler permits use of immediate values
+ifdef USE_IMMEDIATE
+KBUILD_CFLAGS	+= -DUSE_IMMEDIATE
+endif
+
 # We trigger additional mismatches with less inlining
 ifdef CONFIG_DEBUG_SECTION_MISMATCH
 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
Index: linux-2.6-sched-devel/arch/powerpc/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/powerpc/kernel/Makefile	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/powerpc/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -45,7 +45,7 @@
 obj64-$(CONFIG_HIBERNATION)	+= swsusp_asm64.o
 obj-$(CONFIG_MODULES)		+= module_$(CONFIG_WORD_SIZE).o
 obj-$(CONFIG_44x)		+= cpu_setup_44x.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+obj-$(USE_IMMEDIATE)		+= immediate.o
 
 ifeq ($(CONFIG_PPC_MERGE),y)
 
Index: linux-2.6-sched-devel/kernel/module.c
===================================================================
--- linux-2.6-sched-devel.orig/kernel/module.c	2008-05-21 15:16:52.000000000 -0400
+++ linux-2.6-sched-devel/kernel/module.c	2008-05-21 15:16:59.000000000 -0400
@@ -2013,7 +2013,7 @@
 	mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr;
 	if (gplfuturecrcindex)
 		mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr;
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	mod->immediate = (void *)sechdrs[immediateindex].sh_addr;
 	mod->num_immediate =
 		sechdrs[immediateindex].sh_size / sizeof(*mod->immediate);
@@ -2097,7 +2097,7 @@
 		marker_update_probe_range(mod->markers,
 			mod->markers + mod->num_markers);
 #endif
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 		/* Immediate values must be updated after markers */
 		imv_update_range(mod->immediate,
 			mod->immediate + mod->num_immediate);
@@ -2258,7 +2258,7 @@
 	/* Drop initial reference. */
 	module_put(mod);
 	unwind_remove_table(mod->unwind_info, 1);
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	imv_unref(mod->immediate, mod->immediate + mod->num_immediate,
 		mod->module_init, mod->init_size);
 #endif
@@ -2657,7 +2657,7 @@
 }
 #endif
 
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 /**
  * _module_imv_update - update all immediate values in the kernel
  *
Index: linux-2.6-sched-devel/include/linux/module.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/module.h	2008-05-21 15:16:52.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/module.h	2008-05-21 15:16:59.000000000 -0400
@@ -339,7 +339,7 @@
 	/* The command line arguments (may be mangled).  People like
 	   keeping pointers to this stuff */
 	char *args;
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	struct __imv *immediate;
 	unsigned int num_immediate;
 	unsigned long *immediate_cond_end;
@@ -563,7 +563,7 @@
 
 #endif /* CONFIG_MODULES */
 
-#if defined(CONFIG_MODULES) && defined(CONFIG_IMMEDIATE)
+#if defined(CONFIG_MODULES) && defined(USE_IMMEDIATE)
 extern void _module_imv_update(void);
 extern void module_imv_update(void);
 extern int is_imv_cond_end_module(unsigned long addr1, unsigned long addr2);
Index: linux-2.6-sched-devel/arch/x86/kernel/traps_32.c
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/traps_32.c	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/traps_32.c	2008-05-21 15:16:59.000000000 -0400
@@ -595,7 +595,7 @@
 }
 
 DO_VM86_ERROR_INFO(0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->ip)
-#if !defined(CONFIG_KPROBES) && !defined(CONFIG_IMMEDIATE)
+#if !defined(CONFIG_KPROBES) && !defined(USE_IMMEDIATE)
 DO_VM86_ERROR(3, SIGTRAP, "int3", int3)
 #endif
 DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
@@ -860,7 +860,7 @@
 	acpi_nmi_enable();
 }
 
-#if defined(CONFIG_KPROBES) || defined(CONFIG_IMMEDIATE)
+#if defined(CONFIG_KPROBES) || defined(USE_IMMEDIATE)
 void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
 	trace_hardirqs_fixup();

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc (v3)
  2008-05-21 23:24                       ` [PATCH] Fix Immediate Values x86_64 support old gcc (v3) Mathieu Desnoyers
@ 2008-05-22  2:03                         ` Mathieu Desnoyers
  2008-05-25  7:21                           ` Sam Ravnborg
  0 siblings, 1 reply; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-22  2:03 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar,
	David Miller, Paul Mackerras

* Mathieu Desnoyers (compudj@krystal.dyndns.org) wrote:
> GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
> asm statements. Fallback on generic immediate values if this compiler is
> detected.
> 

Please replace the previous paragraph in the changelog by :

GCC < 4, on x86_64, does not accept symbol+offset operands for "i"
constraints asm statements. Fallback on a memory read in lieue of
immediate value if this compiler is detected.

As Peter pointed out, talking of "generic immediate value" is rather
confusing.

Mathieu

> Changelog :
> - USE_IMMEDIATE must now be used in lieue of CONFIG_IMMEDIATE in Makefiles and
>   in C code.
> - Every architecture implementing immediate values must declare USE_IMMEDIATE
>   in their Makefile.
> - Tab -> spaces in Makefiles.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
> CC: Sam Ravnborg <sam@ravnborg.org>
> CC: "H. Peter Anvin" <hpa@zytor.com>
> CC: Jeremy Fitzhardinge <jeremy@goop.org>
> CC: Ingo Molnar <mingo@elte.hu>
> CC: David Miller <davem@davemloft.net>
> CC: Paul Mackerras <paulus@samba.org>
> ---
>  Makefile                     |    5 +++++
>  arch/powerpc/Makefile        |    2 ++
>  arch/powerpc/kernel/Makefile |    2 +-
>  arch/x86/Makefile            |    5 +++++
>  arch/x86/kernel/Makefile     |    2 +-
>  arch/x86/kernel/traps_32.c   |    4 ++--
>  include/linux/immediate.h    |    2 +-
>  include/linux/module.h       |    4 ++--
>  kernel/Makefile              |    2 +-
>  kernel/module.c              |    8 ++++----
>  10 files changed, 24 insertions(+), 12 deletions(-)
> 
> Index: linux-2.6-sched-devel/arch/x86/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 15:16:06.000000000 -0400
> +++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 15:53:00.000000000 -0400
> @@ -43,6 +43,7 @@
>  
>          # temporary until string.h is fixed
>          KBUILD_CFLAGS += -ffreestanding
> +        export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
>  else
>          BITS := 64
>          UTS_MACHINE := x86_64
> @@ -78,6 +79,10 @@
>                  "$(CC)" -fstack-protector-all )
>  
>          KBUILD_CFLAGS += $(stackp-y)
> +
> +        # x86_64 gcc 3.x has problems with passing symbol+offset in
> +        # asm "i" constraint.
> +        export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
>  endif
>  
>  # Stackpointer is addressed different for 32 bit and 64 bit x86
> Index: linux-2.6-sched-devel/include/linux/immediate.h
> ===================================================================
> --- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 15:16:06.000000000 -0400
> +++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 15:16:59.000000000 -0400
> @@ -10,7 +10,7 @@
>   * See the file COPYING for more details.
>   */
>  
> -#ifdef CONFIG_IMMEDIATE
> +#ifdef USE_IMMEDIATE
>  
>  #include <asm/immediate.h>
>  
> Index: linux-2.6-sched-devel/arch/x86/kernel/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/x86/kernel/Makefile	2008-05-21 15:16:51.000000000 -0400
> +++ linux-2.6-sched-devel/arch/x86/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
> @@ -75,7 +75,7 @@
>  obj-$(CONFIG_KPROBES)		+= kprobes.o
>  obj-$(CONFIG_MODULES)		+= module_$(BITS).o
>  obj-$(CONFIG_ACPI_SRAT) 	+= srat_32.o
> -obj-$(CONFIG_IMMEDIATE)		+= immediate.o
> +obj-$(USE_IMMEDIATE)		+= immediate.o
>  obj-$(CONFIG_EFI) 		+= efi.o efi_$(BITS).o efi_stub_$(BITS).o
>  obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault_32.o
>  obj-$(CONFIG_KGDB)		+= kgdb.o
> Index: linux-2.6-sched-devel/kernel/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/kernel/Makefile	2008-05-21 15:16:52.000000000 -0400
> +++ linux-2.6-sched-devel/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
> @@ -75,7 +75,7 @@
>  obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
>  obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
>  obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
> -obj-$(CONFIG_IMMEDIATE) += immediate.o
> +obj-$(USE_IMMEDIATE) += immediate.o
>  obj-$(CONFIG_MARKERS) += marker.o
>  obj-$(CONFIG_LATENCYTOP) += latencytop.o
>  obj-$(CONFIG_FTRACE) += trace/
> Index: linux-2.6-sched-devel/arch/powerpc/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/powerpc/Makefile	2008-05-21 15:16:06.000000000 -0400
> +++ linux-2.6-sched-devel/arch/powerpc/Makefile	2008-05-21 15:16:59.000000000 -0400
> @@ -98,6 +98,8 @@
>  endif
>  endif
>  
> +export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
> +
>  ifeq ($(CONFIG_TUNE_CELL),y)
>  	KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
>  endif
> Index: linux-2.6-sched-devel/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/Makefile	2008-05-21 15:16:51.000000000 -0400
> +++ linux-2.6-sched-devel/Makefile	2008-05-21 15:16:59.000000000 -0400
> @@ -532,6 +532,11 @@
>  KBUILD_CFLAGS	+= -pg
>  endif
>  
> +# arch Makefile detects if the compiler permits use of immediate values
> +ifdef USE_IMMEDIATE
> +KBUILD_CFLAGS	+= -DUSE_IMMEDIATE
> +endif
> +
>  # We trigger additional mismatches with less inlining
>  ifdef CONFIG_DEBUG_SECTION_MISMATCH
>  KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
> Index: linux-2.6-sched-devel/arch/powerpc/kernel/Makefile
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/powerpc/kernel/Makefile	2008-05-21 15:16:06.000000000 -0400
> +++ linux-2.6-sched-devel/arch/powerpc/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
> @@ -45,7 +45,7 @@
>  obj64-$(CONFIG_HIBERNATION)	+= swsusp_asm64.o
>  obj-$(CONFIG_MODULES)		+= module_$(CONFIG_WORD_SIZE).o
>  obj-$(CONFIG_44x)		+= cpu_setup_44x.o
> -obj-$(CONFIG_IMMEDIATE)		+= immediate.o
> +obj-$(USE_IMMEDIATE)		+= immediate.o
>  
>  ifeq ($(CONFIG_PPC_MERGE),y)
>  
> Index: linux-2.6-sched-devel/kernel/module.c
> ===================================================================
> --- linux-2.6-sched-devel.orig/kernel/module.c	2008-05-21 15:16:52.000000000 -0400
> +++ linux-2.6-sched-devel/kernel/module.c	2008-05-21 15:16:59.000000000 -0400
> @@ -2013,7 +2013,7 @@
>  	mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr;
>  	if (gplfuturecrcindex)
>  		mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr;
> -#ifdef CONFIG_IMMEDIATE
> +#ifdef USE_IMMEDIATE
>  	mod->immediate = (void *)sechdrs[immediateindex].sh_addr;
>  	mod->num_immediate =
>  		sechdrs[immediateindex].sh_size / sizeof(*mod->immediate);
> @@ -2097,7 +2097,7 @@
>  		marker_update_probe_range(mod->markers,
>  			mod->markers + mod->num_markers);
>  #endif
> -#ifdef CONFIG_IMMEDIATE
> +#ifdef USE_IMMEDIATE
>  		/* Immediate values must be updated after markers */
>  		imv_update_range(mod->immediate,
>  			mod->immediate + mod->num_immediate);
> @@ -2258,7 +2258,7 @@
>  	/* Drop initial reference. */
>  	module_put(mod);
>  	unwind_remove_table(mod->unwind_info, 1);
> -#ifdef CONFIG_IMMEDIATE
> +#ifdef USE_IMMEDIATE
>  	imv_unref(mod->immediate, mod->immediate + mod->num_immediate,
>  		mod->module_init, mod->init_size);
>  #endif
> @@ -2657,7 +2657,7 @@
>  }
>  #endif
>  
> -#ifdef CONFIG_IMMEDIATE
> +#ifdef USE_IMMEDIATE
>  /**
>   * _module_imv_update - update all immediate values in the kernel
>   *
> Index: linux-2.6-sched-devel/include/linux/module.h
> ===================================================================
> --- linux-2.6-sched-devel.orig/include/linux/module.h	2008-05-21 15:16:52.000000000 -0400
> +++ linux-2.6-sched-devel/include/linux/module.h	2008-05-21 15:16:59.000000000 -0400
> @@ -339,7 +339,7 @@
>  	/* The command line arguments (may be mangled).  People like
>  	   keeping pointers to this stuff */
>  	char *args;
> -#ifdef CONFIG_IMMEDIATE
> +#ifdef USE_IMMEDIATE
>  	struct __imv *immediate;
>  	unsigned int num_immediate;
>  	unsigned long *immediate_cond_end;
> @@ -563,7 +563,7 @@
>  
>  #endif /* CONFIG_MODULES */
>  
> -#if defined(CONFIG_MODULES) && defined(CONFIG_IMMEDIATE)
> +#if defined(CONFIG_MODULES) && defined(USE_IMMEDIATE)
>  extern void _module_imv_update(void);
>  extern void module_imv_update(void);
>  extern int is_imv_cond_end_module(unsigned long addr1, unsigned long addr2);
> Index: linux-2.6-sched-devel/arch/x86/kernel/traps_32.c
> ===================================================================
> --- linux-2.6-sched-devel.orig/arch/x86/kernel/traps_32.c	2008-05-21 15:16:06.000000000 -0400
> +++ linux-2.6-sched-devel/arch/x86/kernel/traps_32.c	2008-05-21 15:16:59.000000000 -0400
> @@ -595,7 +595,7 @@
>  }
>  
>  DO_VM86_ERROR_INFO(0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->ip)
> -#if !defined(CONFIG_KPROBES) && !defined(CONFIG_IMMEDIATE)
> +#if !defined(CONFIG_KPROBES) && !defined(USE_IMMEDIATE)
>  DO_VM86_ERROR(3, SIGTRAP, "int3", int3)
>  #endif
>  DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
> @@ -860,7 +860,7 @@
>  	acpi_nmi_enable();
>  }
>  
> -#if defined(CONFIG_KPROBES) || defined(CONFIG_IMMEDIATE)
> +#if defined(CONFIG_KPROBES) || defined(USE_IMMEDIATE)
>  void __kprobes do_int3(struct pt_regs *regs, long error_code)
>  {
>  	trace_hardirqs_fixup();
> 
> -- 
> Mathieu Desnoyers
> OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] Fix Immediate Values x86_64 support old gcc (v3)
  2008-05-22  2:03                         ` Mathieu Desnoyers
@ 2008-05-25  7:21                           ` Sam Ravnborg
  2008-05-27 13:12                             ` [PATCH ftrace.git sched-fixes.git] " Mathieu Desnoyers
  0 siblings, 1 reply; 14+ messages in thread
From: Sam Ravnborg @ 2008-05-25  7:21 UTC (permalink / raw)
  To: Mathieu Desnoyers
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, Ingo Molnar,
	David Miller, Paul Mackerras

On Wed, May 21, 2008 at 10:03:09PM -0400, Mathieu Desnoyers wrote:
> * Mathieu Desnoyers (compudj@krystal.dyndns.org) wrote:
> > GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
> > asm statements. Fallback on generic immediate values if this compiler is
> > detected.
> > 
> 
> Please replace the previous paragraph in the changelog by :
> 
> GCC < 4, on x86_64, does not accept symbol+offset operands for "i"
> constraints asm statements. Fallback on a memory read in lieue of
> immediate value if this compiler is detected.
> 
> As Peter pointed out, talking of "generic immediate value" is rather
> confusing.

Hi Mathieu

As this is not kbuild related (except fom some minor details)
I do not plan to take this in kbuild.git.
I suggest to push it via Andrew.

You may add an Acked-by: from me though.

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH ftrace.git sched-fixes.git] Fix Immediate Values x86_64 support old gcc (v3)
  2008-05-25  7:21                           ` Sam Ravnborg
@ 2008-05-27 13:12                             ` Mathieu Desnoyers
  0 siblings, 0 replies; 14+ messages in thread
From: Mathieu Desnoyers @ 2008-05-27 13:12 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: H. Peter Anvin, linux-kernel, Jeremy Fitzhardinge, David Miller,
	Paul Mackerras, Sam Ravnborg

GCC < 4, on x86_64, does not accept symbol+offset operands for "i" constraints
asm statements. Fallback on a memory read in lieue of immediate value if this
compiler is detected.

Changelog :
- USE_IMMEDIATE must now be used in lieue of CONFIG_IMMEDIATE in Makefiles and
  in C code.
- Every architecture implementing immediate values must declare USE_IMMEDIATE
  in their Makefile.
- Tab -> spaces in Makefiles.

It should be pulled in
linux-2.6-ftrace.git
and
linux-2.6-sched-fixes.git,
which are the two trees which seem to have immediate values support.

Note to David Miller : the sparc64 patch you proposed will have to be
updated to follow these changes.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Jeremy Fitzhardinge <jeremy@goop.org>
CC: Ingo Molnar <mingo@elte.hu>
CC: David Miller <davem@davemloft.net>
CC: Paul Mackerras <paulus@samba.org>
---
 Makefile                     |    5 +++++
 arch/powerpc/Makefile        |    2 ++
 arch/powerpc/kernel/Makefile |    2 +-
 arch/x86/Makefile            |    5 +++++
 arch/x86/kernel/Makefile     |    2 +-
 arch/x86/kernel/traps_32.c   |    4 ++--
 include/linux/immediate.h    |    2 +-
 include/linux/module.h       |    4 ++--
 kernel/Makefile              |    2 +-
 kernel/module.c              |    8 ++++----
 10 files changed, 24 insertions(+), 12 deletions(-)

Index: linux-2.6-sched-devel/arch/x86/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/Makefile	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/Makefile	2008-05-21 15:53:00.000000000 -0400
@@ -43,6 +43,7 @@
 
         # temporary until string.h is fixed
         KBUILD_CFLAGS += -ffreestanding
+        export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
 else
         BITS := 64
         UTS_MACHINE := x86_64
@@ -78,6 +79,10 @@
                 "$(CC)" -fstack-protector-all )
 
         KBUILD_CFLAGS += $(stackp-y)
+
+        # x86_64 gcc 3.x has problems with passing symbol+offset in
+        # asm "i" constraint.
+        export USE_IMMEDIATE := $(call cc-ifversion, -ge, 0400, $(CONFIG_IMMEDIATE))
 endif
 
 # Stackpointer is addressed different for 32 bit and 64 bit x86
Index: linux-2.6-sched-devel/include/linux/immediate.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/immediate.h	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/immediate.h	2008-05-21 15:16:59.000000000 -0400
@@ -10,7 +10,7 @@
  * See the file COPYING for more details.
  */
 
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 
 #include <asm/immediate.h>
 
Index: linux-2.6-sched-devel/arch/x86/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/Makefile	2008-05-21 15:16:51.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -75,7 +75,7 @@
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 obj-$(CONFIG_MODULES)		+= module_$(BITS).o
 obj-$(CONFIG_ACPI_SRAT) 	+= srat_32.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+obj-$(USE_IMMEDIATE)		+= immediate.o
 obj-$(CONFIG_EFI) 		+= efi.o efi_$(BITS).o efi_stub_$(BITS).o
 obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault_32.o
 obj-$(CONFIG_KGDB)		+= kgdb.o
Index: linux-2.6-sched-devel/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/kernel/Makefile	2008-05-21 15:16:52.000000000 -0400
+++ linux-2.6-sched-devel/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -75,7 +75,7 @@
 obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
 obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
 obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
-obj-$(CONFIG_IMMEDIATE) += immediate.o
+obj-$(USE_IMMEDIATE) += immediate.o
 obj-$(CONFIG_MARKERS) += marker.o
 obj-$(CONFIG_LATENCYTOP) += latencytop.o
 obj-$(CONFIG_FTRACE) += trace/
Index: linux-2.6-sched-devel/arch/powerpc/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/powerpc/Makefile	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/powerpc/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -98,6 +98,8 @@
 endif
 endif
 
+export USE_IMMEDIATE := $(CONFIG_IMMEDIATE)
+
 ifeq ($(CONFIG_TUNE_CELL),y)
 	KBUILD_CFLAGS += $(call cc-option,-mtune=cell)
 endif
Index: linux-2.6-sched-devel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/Makefile	2008-05-21 15:16:51.000000000 -0400
+++ linux-2.6-sched-devel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -532,6 +532,11 @@
 KBUILD_CFLAGS	+= -pg
 endif
 
+# arch Makefile detects if the compiler permits use of immediate values
+ifdef USE_IMMEDIATE
+KBUILD_CFLAGS	+= -DUSE_IMMEDIATE
+endif
+
 # We trigger additional mismatches with less inlining
 ifdef CONFIG_DEBUG_SECTION_MISMATCH
 KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
Index: linux-2.6-sched-devel/arch/powerpc/kernel/Makefile
===================================================================
--- linux-2.6-sched-devel.orig/arch/powerpc/kernel/Makefile	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/powerpc/kernel/Makefile	2008-05-21 15:16:59.000000000 -0400
@@ -45,7 +45,7 @@
 obj64-$(CONFIG_HIBERNATION)	+= swsusp_asm64.o
 obj-$(CONFIG_MODULES)		+= module_$(CONFIG_WORD_SIZE).o
 obj-$(CONFIG_44x)		+= cpu_setup_44x.o
-obj-$(CONFIG_IMMEDIATE)		+= immediate.o
+obj-$(USE_IMMEDIATE)		+= immediate.o
 
 ifeq ($(CONFIG_PPC_MERGE),y)
 
Index: linux-2.6-sched-devel/kernel/module.c
===================================================================
--- linux-2.6-sched-devel.orig/kernel/module.c	2008-05-21 15:16:52.000000000 -0400
+++ linux-2.6-sched-devel/kernel/module.c	2008-05-21 15:16:59.000000000 -0400
@@ -2013,7 +2013,7 @@
 	mod->gpl_future_syms = (void *)sechdrs[gplfutureindex].sh_addr;
 	if (gplfuturecrcindex)
 		mod->gpl_future_crcs = (void *)sechdrs[gplfuturecrcindex].sh_addr;
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	mod->immediate = (void *)sechdrs[immediateindex].sh_addr;
 	mod->num_immediate =
 		sechdrs[immediateindex].sh_size / sizeof(*mod->immediate);
@@ -2097,7 +2097,7 @@
 		marker_update_probe_range(mod->markers,
 			mod->markers + mod->num_markers);
 #endif
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 		/* Immediate values must be updated after markers */
 		imv_update_range(mod->immediate,
 			mod->immediate + mod->num_immediate);
@@ -2258,7 +2258,7 @@
 	/* Drop initial reference. */
 	module_put(mod);
 	unwind_remove_table(mod->unwind_info, 1);
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	imv_unref(mod->immediate, mod->immediate + mod->num_immediate,
 		mod->module_init, mod->init_size);
 #endif
@@ -2657,7 +2657,7 @@
 }
 #endif
 
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 /**
  * _module_imv_update - update all immediate values in the kernel
  *
Index: linux-2.6-sched-devel/include/linux/module.h
===================================================================
--- linux-2.6-sched-devel.orig/include/linux/module.h	2008-05-21 15:16:52.000000000 -0400
+++ linux-2.6-sched-devel/include/linux/module.h	2008-05-21 15:16:59.000000000 -0400
@@ -339,7 +339,7 @@
 	/* The command line arguments (may be mangled).  People like
 	   keeping pointers to this stuff */
 	char *args;
-#ifdef CONFIG_IMMEDIATE
+#ifdef USE_IMMEDIATE
 	struct __imv *immediate;
 	unsigned int num_immediate;
 	unsigned long *immediate_cond_end;
@@ -563,7 +563,7 @@
 
 #endif /* CONFIG_MODULES */
 
-#if defined(CONFIG_MODULES) && defined(CONFIG_IMMEDIATE)
+#if defined(CONFIG_MODULES) && defined(USE_IMMEDIATE)
 extern void _module_imv_update(void);
 extern void module_imv_update(void);
 extern int is_imv_cond_end_module(unsigned long addr1, unsigned long addr2);
Index: linux-2.6-sched-devel/arch/x86/kernel/traps_32.c
===================================================================
--- linux-2.6-sched-devel.orig/arch/x86/kernel/traps_32.c	2008-05-21 15:16:06.000000000 -0400
+++ linux-2.6-sched-devel/arch/x86/kernel/traps_32.c	2008-05-21 15:16:59.000000000 -0400
@@ -595,7 +595,7 @@
 }
 
 DO_VM86_ERROR_INFO(0, SIGFPE,  "divide error", divide_error, FPE_INTDIV, regs->ip)
-#if !defined(CONFIG_KPROBES) && !defined(CONFIG_IMMEDIATE)
+#if !defined(CONFIG_KPROBES) && !defined(USE_IMMEDIATE)
 DO_VM86_ERROR(3, SIGTRAP, "int3", int3)
 #endif
 DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
@@ -860,7 +860,7 @@
 	acpi_nmi_enable();
 }
 
-#if defined(CONFIG_KPROBES) || defined(CONFIG_IMMEDIATE)
+#if defined(CONFIG_KPROBES) || defined(USE_IMMEDIATE)
 void __kprobes do_int3(struct pt_regs *regs, long error_code)
 {
 	trace_hardirqs_fixup();

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2008-05-27 13:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-14  9:54 x86-64 build problem with tip Jeremy Fitzhardinge
2008-05-16 12:48 ` [PATCH] Fix immediate asm constraint for gcc 3 x86_64 Mathieu Desnoyers
2008-05-16 21:32   ` H. Peter Anvin
2008-05-21 13:31     ` Mathieu Desnoyers
     [not found]       ` <48344239.9070003@zytor.com>
     [not found]         ` <20080521160217.GA26974@Krystal>
2008-05-21 17:01           ` [PATCH] Fix Immediate Values x86_64 support old gcc Mathieu Desnoyers
2008-05-21 20:37             ` Sam Ravnborg
2008-05-21 21:28               ` Mathieu Desnoyers
2008-05-21 21:46                 ` Sam Ravnborg
2008-05-21 21:57                   ` [PATCH] Fix Immediate Values x86_64 support old gcc (v2) Mathieu Desnoyers
2008-05-21 22:38                     ` Sam Ravnborg
2008-05-21 23:24                       ` [PATCH] Fix Immediate Values x86_64 support old gcc (v3) Mathieu Desnoyers
2008-05-22  2:03                         ` Mathieu Desnoyers
2008-05-25  7:21                           ` Sam Ravnborg
2008-05-27 13:12                             ` [PATCH ftrace.git sched-fixes.git] " Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).