linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: fix CFI macro invocations to deal with shortcomings in gas
@ 2010-10-19 13:52 Jan Beulich
  2010-10-19 21:03 ` Alexander van Heukelum
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Jan Beulich @ 2010-10-19 13:52 UTC (permalink / raw)
  To: mingo, tglx, akpm, hpa; +Cc: heukelum, linux-kbuild, linux-kernel

gas prior to (perhaps) 2.16.90 has problems with passing non-
parenthesized expressions containing spaces to macros. Spaces, however,
get inserted by cpp between any macro expanding to a number and a
subsequent + or -. For the +, current x86 gas then removes the space
again (future gas may not do so), but for the - the space gets retained
and is then considered a separator between macro arguments.

Fix the respective definitions for both the - and + cases, so that they
neither contain spaces nor make cpp insert any (the latter by adding
seemingly redundant parentheses).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Alexander van Heukelum <heukelum@fastmail.fm>

---
 Kbuild                            |    2 -
 arch/x86/include/asm/calling.h    |   52 +++++++++++++++++++-------------------
 arch/x86/include/asm/entry_arch.h |   19 ++-----------
 arch/x86/include/asm/segment.h    |   32 +++++++++++------------
 arch/x86/kernel/asm-offsets_32.c  |    4 --
 arch/x86/kernel/entry_32.S        |    6 ++--
 arch/x86/kernel/entry_64.S        |   20 ++------------
 7 files changed, 56 insertions(+), 79 deletions(-)

--- 2.6.36-rc8-x86-cfi.orig/Kbuild
+++ 2.6.36-rc8-x86-cfi/Kbuild
@@ -53,7 +53,7 @@ targets += arch/$(SRCARCH)/kernel/asm-of
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* \3 */:; \
 	s:->::; p;}"
 endef
 
--- 2.6.36-rc8-x86-cfi.orig/arch/x86/include/asm/calling.h
+++ 2.6.36-rc8-x86-cfi/arch/x86/include/asm/calling.h
@@ -48,36 +48,38 @@ For 32-bit we have the following convent
 
 
 /*
- * 64-bit system call stack frame layout defines and helpers,
- * for assembly code:
+ * 64-bit system call stack frame layout defines and helpers, for
+ * assembly code (note that the seemingly unnecessary parentheses
+ * are to prevent cpp from inserting spaces in expressions that get
+ * passed to macros):
  */
 
-#define R15		  0
-#define R14		  8
-#define R13		 16
-#define R12		 24
-#define RBP		 32
-#define RBX		 40
+#define R15		  (0)
+#define R14		  (8)
+#define R13		 (16)
+#define R12		 (24)
+#define RBP		 (32)
+#define RBX		 (40)
 
 /* arguments: interrupts/non tracing syscalls only save up to here: */
-#define R11		 48
-#define R10		 56
-#define R9		 64
-#define R8		 72
-#define RAX		 80
-#define RCX		 88
-#define RDX		 96
-#define RSI		104
-#define RDI		112
-#define ORIG_RAX	120       /* + error_code */
+#define R11		 (48)
+#define R10		 (56)
+#define R9		 (64)
+#define R8		 (72)
+#define RAX		 (80)
+#define RCX		 (88)
+#define RDX		 (96)
+#define RSI		(104)
+#define RDI		(112)
+#define ORIG_RAX	(120)       /* + error_code */
 /* end of arguments */
 
 /* cpu exception frame or undefined in case of fast syscall: */
-#define RIP		128
-#define CS		136
-#define EFLAGS		144
-#define RSP		152
-#define SS		160
+#define RIP		(128)
+#define CS		(136)
+#define EFLAGS		(144)
+#define RSP		(152)
+#define SS		(160)
 
 #define ARGOFFSET	R11
 #define SWFRAME		ORIG_RAX
@@ -111,7 +113,7 @@ For 32-bit we have the following convent
 	.endif
 	.endm
 
-#define ARG_SKIP	9*8
+#define ARG_SKIP	(9*8)
 
 	.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
 			    skipr8910=0, skiprdx=0
@@ -169,7 +171,7 @@ For 32-bit we have the following convent
 	.endif
 	.endm
 
-#define REST_SKIP	6*8
+#define REST_SKIP	(6*8)
 
 	.macro SAVE_REST
 	subq $REST_SKIP, %rsp
--- 2.6.36-rc8-x86-cfi.orig/arch/x86/include/asm/entry_arch.h
+++ 2.6.36-rc8-x86-cfi/arch/x86/include/asm/entry_arch.h
@@ -16,22 +16,11 @@ BUILD_INTERRUPT(call_function_single_int
 BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR)
 BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR)
 
-BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt2,INVALIDATE_TLB_VECTOR_START+2,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt3,INVALIDATE_TLB_VECTOR_START+3,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt4,INVALIDATE_TLB_VECTOR_START+4,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt5,INVALIDATE_TLB_VECTOR_START+5,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt6,INVALIDATE_TLB_VECTOR_START+6,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7,
+.irpc idx, "01234567"
+BUILD_INTERRUPT3(invalidate_interrupt\idx,
+		 (INVALIDATE_TLB_VECTOR_START)+\idx,
 		 smp_invalidate_interrupt)
+.endr
 #endif
 
 BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
--- 2.6.36-rc8-x86-cfi.orig/arch/x86/include/asm/segment.h
+++ 2.6.36-rc8-x86-cfi/arch/x86/include/asm/segment.h
@@ -73,31 +73,31 @@
 
 #define GDT_ENTRY_DEFAULT_USER_DS	15
 
-#define GDT_ENTRY_KERNEL_BASE	12
+#define GDT_ENTRY_KERNEL_BASE		(12)
 
-#define GDT_ENTRY_KERNEL_CS		(GDT_ENTRY_KERNEL_BASE + 0)
+#define GDT_ENTRY_KERNEL_CS		(GDT_ENTRY_KERNEL_BASE+0)
 
-#define GDT_ENTRY_KERNEL_DS		(GDT_ENTRY_KERNEL_BASE + 1)
+#define GDT_ENTRY_KERNEL_DS		(GDT_ENTRY_KERNEL_BASE+1)
 
-#define GDT_ENTRY_TSS			(GDT_ENTRY_KERNEL_BASE + 4)
-#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE + 5)
+#define GDT_ENTRY_TSS			(GDT_ENTRY_KERNEL_BASE+4)
+#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE+5)
 
-#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 6)
-#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 11)
+#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE+6)
+#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE+11)
 
-#define GDT_ENTRY_ESPFIX_SS		(GDT_ENTRY_KERNEL_BASE + 14)
-#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
+#define GDT_ENTRY_ESPFIX_SS		(GDT_ENTRY_KERNEL_BASE+14)
+#define __ESPFIX_SS			(GDT_ENTRY_ESPFIX_SS*8)
 
-#define GDT_ENTRY_PERCPU			(GDT_ENTRY_KERNEL_BASE + 15)
+#define GDT_ENTRY_PERCPU		(GDT_ENTRY_KERNEL_BASE+15)
 #ifdef CONFIG_SMP
 #define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
 #else
 #define __KERNEL_PERCPU 0
 #endif
 
-#define GDT_ENTRY_STACK_CANARY		(GDT_ENTRY_KERNEL_BASE + 16)
+#define GDT_ENTRY_STACK_CANARY		(GDT_ENTRY_KERNEL_BASE+16)
 #ifdef CONFIG_CC_STACKPROTECTOR
-#define __KERNEL_STACK_CANARY		(GDT_ENTRY_STACK_CANARY * 8)
+#define __KERNEL_STACK_CANARY		(GDT_ENTRY_STACK_CANARY*8)
 #else
 #define __KERNEL_STACK_CANARY		0
 #endif
@@ -182,10 +182,10 @@
 
 #endif
 
-#define __KERNEL_CS	(GDT_ENTRY_KERNEL_CS * 8)
-#define __KERNEL_DS	(GDT_ENTRY_KERNEL_DS * 8)
-#define __USER_DS     (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3)
-#define __USER_CS     (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3)
+#define __KERNEL_CS	(GDT_ENTRY_KERNEL_CS*8)
+#define __KERNEL_DS	(GDT_ENTRY_KERNEL_DS*8)
+#define __USER_DS	(GDT_ENTRY_DEFAULT_USER_DS*8+3)
+#define __USER_CS	(GDT_ENTRY_DEFAULT_USER_CS*8+3)
 #ifndef CONFIG_PARAVIRT
 #define get_kernel_rpl()  0
 #endif
--- 2.6.36-rc8-x86-cfi.orig/arch/x86/kernel/asm-offsets_32.c
+++ 2.6.36-rc8-x86-cfi/arch/x86/kernel/asm-offsets_32.c
@@ -99,9 +99,7 @@ void foo(void)
 
 	DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
 	DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
-	DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
-	DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
-	DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
+	DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
 
 	OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
 
--- 2.6.36-rc8-x86-cfi.orig/arch/x86/kernel/entry_32.S
+++ 2.6.36-rc8-x86-cfi/arch/x86/kernel/entry_32.S
@@ -382,20 +382,20 @@ sysenter_past_esp:
 	 * enough kernel state to call TRACE_IRQS_OFF can be called - but
 	 * we immediately enable interrupts at that point anyway.
 	 */
-	pushl_cfi $(__USER_DS)
+	pushl_cfi $__USER_DS
 	/*CFI_REL_OFFSET ss, 0*/
 	pushl_cfi %ebp
 	CFI_REL_OFFSET esp, 0
 	pushfl_cfi
 	orl $X86_EFLAGS_IF, (%esp)
-	pushl_cfi $(__USER_CS)
+	pushl_cfi $__USER_CS
 	/*CFI_REL_OFFSET cs, 0*/
 	/*
 	 * Push current_thread_info()->sysenter_return to the stack.
 	 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
 	 * pushed above; +8 corresponds to copy_thread's esp0 setting.
 	 */
-	pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
+	pushl_cfi TI_sysenter_return-THREAD_SIZE_asm+8+4*4(%esp)
 	CFI_REL_OFFSET eip, 0
 
 	pushl_cfi %eax
--- 2.6.36-rc8-x86-cfi.orig/arch/x86/kernel/entry_64.S
+++ 2.6.36-rc8-x86-cfi/arch/x86/kernel/entry_64.S
@@ -964,22 +964,10 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
 	x86_platform_ipi smp_x86_platform_ipi
 
 #ifdef CONFIG_SMP
-apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \
-	invalidate_interrupt0 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \
-	invalidate_interrupt1 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \
-	invalidate_interrupt2 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \
-	invalidate_interrupt3 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \
-	invalidate_interrupt4 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \
-	invalidate_interrupt5 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \
-	invalidate_interrupt6 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \
-	invalidate_interrupt7 smp_invalidate_interrupt
+.irpc idx, "01234567"
+apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \
+	invalidate_interrupt\idx smp_invalidate_interrupt
+.endr
 #endif
 
 apicinterrupt THRESHOLD_APIC_VECTOR \



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

* Re: [PATCH] x86: fix CFI macro invocations to deal with  shortcomings in gas
  2010-10-19 13:52 [PATCH] x86: fix CFI macro invocations to deal with shortcomings in gas Jan Beulich
@ 2010-10-19 21:03 ` Alexander van Heukelum
  2010-10-20  6:43   ` Jan Beulich
  2010-10-19 21:14 ` H. Peter Anvin
  2010-10-20  0:55 ` [tip:x86/debug] x86, asm: Fix " tip-bot for Jan Beulich
  2 siblings, 1 reply; 10+ messages in thread
From: Alexander van Heukelum @ 2010-10-19 21:03 UTC (permalink / raw)
  To: Jan Beulich, Ingo Molnar, Thomas Gleixner, Andrew Morton, H. Peter Anvin
  Cc: linux-kbuild, linux-kernel

Hallo Jan Beulich,

I checked the patch on i386 using an old Ubuntu image.

On Tue, 19 Oct 2010 14:52 +0100, "Jan Beulich" <JBeulich@novell.com> wrote:
> gas prior to (perhaps) 2.16.90 has problems with passing non-
> parenthesized expressions containing spaces to macros. Spaces, however,
> get inserted by cpp between any macro expanding to a number and a
> subsequent + or -. For the +, current x86 gas then removes the space
> again (future gas may not do so), but for the - the space gets retained
> and is then considered a separator between macro arguments.
> 
> Fix the respective definitions for both the - and + cases, so that they
> neither contain spaces nor make cpp insert any (the latter by adding
> seemingly redundant parentheses).
> 
> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> Cc: Alexander van Heukelum <heukelum@fastmail.fm>
> 
> ---
>  Kbuild                            |    2 -
>  arch/x86/include/asm/calling.h    |   52
>  +++++++++++++++++++-------------------
>  arch/x86/include/asm/entry_arch.h |   19 ++-----------
>  arch/x86/include/asm/segment.h    |   32 +++++++++++------------
>  arch/x86/kernel/asm-offsets_32.c  |    4 --
>  arch/x86/kernel/entry_32.S        |    6 ++--
>  arch/x86/kernel/entry_64.S        |   20 ++------------
>  7 files changed, 56 insertions(+), 79 deletions(-)
> 
> --- 2.6.36-rc8-x86-cfi.orig/Kbuild
> +++ 2.6.36-rc8-x86-cfi/Kbuild
> @@ -53,7 +53,7 @@ targets += arch/$(SRCARCH)/kernel/asm-of
>  # Default sed regexp - multiline due to syntax constraints
>  define sed-y
>  	"/^->/{s:->#\(.*\):/* \1 */:; \
> -       s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
> +       s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* \3 */:;
> \
>  	s:->::; p;}"
>  endef
>  
> --- 2.6.36-rc8-x86-cfi.orig/arch/x86/include/asm/calling.h
> +++ 2.6.36-rc8-x86-cfi/arch/x86/include/asm/calling.h
> @@ -48,36 +48,38 @@ For 32-bit we have the following convent
>  
>  
>  /*
> - * 64-bit system call stack frame layout defines and helpers,
> - * for assembly code:
> + * 64-bit system call stack frame layout defines and helpers, for
> + * assembly code (note that the seemingly unnecessary parentheses
> + * are to prevent cpp from inserting spaces in expressions that get
> + * passed to macros):
>   */
>  
> -#define R15              0
> -#define R14              8
> -#define R13             16
> -#define R12             24
> -#define RBP             32
> -#define RBX             40
> +#define R15              (0)
> +#define R14              (8)
> +#define R13             (16)
> +#define R12             (24)
> +#define RBP             (32)
> +#define RBX             (40)
>  
>  /* arguments: interrupts/non tracing syscalls only save up to here: */
> -#define R11             48
> -#define R10             56
> -#define R9              64
> -#define R8              72
> -#define RAX             80
> -#define RCX             88
> -#define RDX             96
> -#define RSI            104
> -#define RDI            112
> -#define ORIG_RAX       120       /* + error_code */
> +#define R11             (48)
> +#define R10             (56)
> +#define R9              (64)
> +#define R8              (72)
> +#define RAX             (80)
> +#define RCX             (88)
> +#define RDX             (96)
> +#define RSI            (104)
> +#define RDI            (112)
> +#define ORIG_RAX       (120)       /* + error_code */
>  /* end of arguments */
>  
>  /* cpu exception frame or undefined in case of fast syscall: */
> -#define RIP            128
> -#define CS             136
> -#define EFLAGS         144
> -#define RSP            152
> -#define SS             160
> +#define RIP            (128)
> +#define CS             (136)
> +#define EFLAGS         (144)
> +#define RSP            (152)
> +#define SS             (160)
>  
>  #define ARGOFFSET       R11
>  #define SWFRAME         ORIG_RAX
> @@ -111,7 +113,7 @@ For 32-bit we have the following convent
>  	.endif
>  	.endm
>  
> -#define ARG_SKIP       9*8
> +#define ARG_SKIP       (9*8)
>  
>  	.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
>  			    skipr8910=0, skiprdx=0
> @@ -169,7 +171,7 @@ For 32-bit we have the following convent
>  	.endif
>  	.endm
>  
> -#define REST_SKIP      6*8
> +#define REST_SKIP      (6*8)
>  
>  	.macro SAVE_REST
>  	subq $REST_SKIP, %rsp
> --- 2.6.36-rc8-x86-cfi.orig/arch/x86/include/asm/entry_arch.h
> +++ 2.6.36-rc8-x86-cfi/arch/x86/include/asm/entry_arch.h
> @@ -16,22 +16,11 @@ BUILD_INTERRUPT(call_function_single_int
>  BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR)
>  BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR)
>  
> -BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt2,INVALIDATE_TLB_VECTOR_START+2,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt3,INVALIDATE_TLB_VECTOR_START+3,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt4,INVALIDATE_TLB_VECTOR_START+4,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt5,INVALIDATE_TLB_VECTOR_START+5,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt6,INVALIDATE_TLB_VECTOR_START+6,
> -                smp_invalidate_interrupt)
> -BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7,
> +.irpc idx, "01234567"
> +BUILD_INTERRUPT3(invalidate_interrupt\idx,
> +                (INVALIDATE_TLB_VECTOR_START)+\idx,
>  		 smp_invalidate_interrupt)
> +.endr
>  #endif
>  
>  BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
> --- 2.6.36-rc8-x86-cfi.orig/arch/x86/include/asm/segment.h
> +++ 2.6.36-rc8-x86-cfi/arch/x86/include/asm/segment.h
> @@ -73,31 +73,31 @@
>  
>  #define GDT_ENTRY_DEFAULT_USER_DS       15
>  
> -#define GDT_ENTRY_KERNEL_BASE  12
> +#define GDT_ENTRY_KERNEL_BASE          (12)
>  
> -#define GDT_ENTRY_KERNEL_CS            (GDT_ENTRY_KERNEL_BASE + 0)
> +#define GDT_ENTRY_KERNEL_CS            (GDT_ENTRY_KERNEL_BASE+0)
>  
> -#define GDT_ENTRY_KERNEL_DS            (GDT_ENTRY_KERNEL_BASE + 1)
> +#define GDT_ENTRY_KERNEL_DS            (GDT_ENTRY_KERNEL_BASE+1)
>  
> -#define GDT_ENTRY_TSS                  (GDT_ENTRY_KERNEL_BASE + 4)
> -#define GDT_ENTRY_LDT                  (GDT_ENTRY_KERNEL_BASE + 5)
> +#define GDT_ENTRY_TSS                  (GDT_ENTRY_KERNEL_BASE+4)
> +#define GDT_ENTRY_LDT                  (GDT_ENTRY_KERNEL_BASE+5)
>  
> -#define GDT_ENTRY_PNPBIOS_BASE         (GDT_ENTRY_KERNEL_BASE + 6)
> -#define GDT_ENTRY_APMBIOS_BASE         (GDT_ENTRY_KERNEL_BASE + 11)
> +#define GDT_ENTRY_PNPBIOS_BASE         (GDT_ENTRY_KERNEL_BASE+6)
> +#define GDT_ENTRY_APMBIOS_BASE         (GDT_ENTRY_KERNEL_BASE+11)
>  
> -#define GDT_ENTRY_ESPFIX_SS            (GDT_ENTRY_KERNEL_BASE + 14)
> -#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
> +#define GDT_ENTRY_ESPFIX_SS            (GDT_ENTRY_KERNEL_BASE+14)
> +#define __ESPFIX_SS                    (GDT_ENTRY_ESPFIX_SS*8)
>  
> -#define GDT_ENTRY_PERCPU                       (GDT_ENTRY_KERNEL_BASE +
> 15)
> +#define GDT_ENTRY_PERCPU               (GDT_ENTRY_KERNEL_BASE+15)
>  #ifdef CONFIG_SMP
>  #define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
>  #else
>  #define __KERNEL_PERCPU 0
>  #endif
>  
> -#define GDT_ENTRY_STACK_CANARY         (GDT_ENTRY_KERNEL_BASE + 16)
> +#define GDT_ENTRY_STACK_CANARY         (GDT_ENTRY_KERNEL_BASE+16)
>  #ifdef CONFIG_CC_STACKPROTECTOR
> -#define __KERNEL_STACK_CANARY          (GDT_ENTRY_STACK_CANARY * 8)
> +#define __KERNEL_STACK_CANARY          (GDT_ENTRY_STACK_CANARY*8)
>  #else
>  #define __KERNEL_STACK_CANARY           0
>  #endif
> @@ -182,10 +182,10 @@
>  
>  #endif
>  
> -#define __KERNEL_CS    (GDT_ENTRY_KERNEL_CS * 8)
> -#define __KERNEL_DS    (GDT_ENTRY_KERNEL_DS * 8)
> -#define __USER_DS     (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3)
> -#define __USER_CS     (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3)
> +#define __KERNEL_CS    (GDT_ENTRY_KERNEL_CS*8)
> +#define __KERNEL_DS    (GDT_ENTRY_KERNEL_DS*8)
> +#define __USER_DS      (GDT_ENTRY_DEFAULT_USER_DS*8+3)
> +#define __USER_CS      (GDT_ENTRY_DEFAULT_USER_CS*8+3)
>  #ifndef CONFIG_PARAVIRT
>  #define get_kernel_rpl()  0
>  #endif
> --- 2.6.36-rc8-x86-cfi.orig/arch/x86/kernel/asm-offsets_32.c
> +++ 2.6.36-rc8-x86-cfi/arch/x86/kernel/asm-offsets_32.c
> @@ -99,9 +99,7 @@ void foo(void)
>  
>  	DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
>  	DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
> -       DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
> -       DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
> -       DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
> +       DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
>  
>  	OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
>  
> --- 2.6.36-rc8-x86-cfi.orig/arch/x86/kernel/entry_32.S
> +++ 2.6.36-rc8-x86-cfi/arch/x86/kernel/entry_32.S
> @@ -382,20 +382,20 @@ sysenter_past_esp:
>  	 * enough kernel state to call TRACE_IRQS_OFF can be called - but
>  	 * we immediately enable interrupts at that point anyway.
>  	 */
> -       pushl_cfi $(__USER_DS)
> +       pushl_cfi $__USER_DS
>  	/*CFI_REL_OFFSET ss, 0*/
>  	pushl_cfi %ebp
>  	CFI_REL_OFFSET esp, 0
>  	pushfl_cfi
>  	orl $X86_EFLAGS_IF, (%esp)
> -       pushl_cfi $(__USER_CS)
> +       pushl_cfi $__USER_CS
>  	/*CFI_REL_OFFSET cs, 0*/
>  	/*
>  	 * Push current_thread_info()->sysenter_return to the stack.
>  	 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
>  	 * pushed above; +8 corresponds to copy_thread's esp0 setting.
>  	 */
> -       pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
> +       pushl_cfi TI_sysenter_return-THREAD_SIZE_asm+8+4*4(%esp)

This expands to:
    pushl_cfi (60)-(8192)+8+4*4(%esp)

I'm sorry to say that Ubuntu 6.06's gas (2.16.91 20060118) still chokes
with "too many positional arguments" on this line.

The other ones have disappeared.

Greetings,
    Alexander van Heukelum

>  	CFI_REL_OFFSET eip, 0
>  
>  	pushl_cfi %eax
> --- 2.6.36-rc8-x86-cfi.orig/arch/x86/kernel/entry_64.S
> +++ 2.6.36-rc8-x86-cfi/arch/x86/kernel/entry_64.S
> @@ -964,22 +964,10 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
>  	x86_platform_ipi smp_x86_platform_ipi
>  
>  #ifdef CONFIG_SMP
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \
> -       invalidate_interrupt0 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \
> -       invalidate_interrupt1 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \
> -       invalidate_interrupt2 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \
> -       invalidate_interrupt3 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \
> -       invalidate_interrupt4 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \
> -       invalidate_interrupt5 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \
> -       invalidate_interrupt6 smp_invalidate_interrupt
> -apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \
> -       invalidate_interrupt7 smp_invalidate_interrupt
> +.irpc idx, "01234567"
> +apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \
> +       invalidate_interrupt\idx smp_invalidate_interrupt
> +.endr
>  #endif
>  
>  apicinterrupt THRESHOLD_APIC_VECTOR \
> 
> 

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

* Re: [PATCH] x86: fix CFI macro invocations to deal with  shortcomings in gas
  2010-10-19 13:52 [PATCH] x86: fix CFI macro invocations to deal with shortcomings in gas Jan Beulich
  2010-10-19 21:03 ` Alexander van Heukelum
@ 2010-10-19 21:14 ` H. Peter Anvin
  2010-10-20  0:55 ` [tip:x86/debug] x86, asm: Fix " tip-bot for Jan Beulich
  2 siblings, 0 replies; 10+ messages in thread
From: H. Peter Anvin @ 2010-10-19 21:14 UTC (permalink / raw)
  To: Jan Beulich; +Cc: mingo, tglx, akpm, heukelum, linux-kbuild, linux-kernel

On 10/19/2010 06:52 AM, Jan Beulich wrote:
> gas prior to (perhaps) 2.16.90 has problems with passing non-
> parenthesized expressions containing spaces to macros. Spaces, however,
> get inserted by cpp between any macro expanding to a number and a
> subsequent + or -. For the +, current x86 gas then removes the space
> again (future gas may not do so), but for the - the space gets retained
> and is then considered a separator between macro arguments.
> 
> Fix the respective definitions for both the - and + cases, so that they
> neither contain spaces nor make cpp insert any (the latter by adding
> seemingly redundant parentheses).
> 
> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> Cc: Alexander van Heukelum <heukelum@fastmail.fm>
> 

It's ugly -- very ugly -- and will almost certainly bitrot and break
again, but it's a lot less ugly than any other alternative I can think
of.  Unfortunately these versions of gas are not old enough that we can
just kill them off, I don't think.

	-hpa

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

* [tip:x86/debug] x86, asm: Fix CFI macro invocations to deal with shortcomings in gas
  2010-10-19 13:52 [PATCH] x86: fix CFI macro invocations to deal with shortcomings in gas Jan Beulich
  2010-10-19 21:03 ` Alexander van Heukelum
  2010-10-19 21:14 ` H. Peter Anvin
@ 2010-10-20  0:55 ` tip-bot for Jan Beulich
  2010-10-21 10:16   ` Ingo Molnar
  2 siblings, 1 reply; 10+ messages in thread
From: tip-bot for Jan Beulich @ 2010-10-20  0:55 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, jbeulich, heukelum, JBeulich, tglx, hpa

Commit-ID:  3234282f33b29d349bcada40204fc7c8fda7fe72
Gitweb:     http://git.kernel.org/tip/3234282f33b29d349bcada40204fc7c8fda7fe72
Author:     Jan Beulich <JBeulich@novell.com>
AuthorDate: Tue, 19 Oct 2010 14:52:26 +0100
Committer:  H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Tue, 19 Oct 2010 14:28:02 -0700

x86, asm: Fix CFI macro invocations to deal with shortcomings in gas

gas prior to (perhaps) 2.16.90 has problems with passing non-
parenthesized expressions containing spaces to macros. Spaces, however,
get inserted by cpp between any macro expanding to a number and a
subsequent + or -. For the +, current x86 gas then removes the space
again (future gas may not do so), but for the - the space gets retained
and is then considered a separator between macro arguments.

Fix the respective definitions for both the - and + cases, so that they
neither contain spaces nor make cpp insert any (the latter by adding
seemingly redundant parentheses).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
LKML-Reference: <4CBDBEBA020000780001E05A@vpn.id2.novell.com>
Cc: Alexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
 Kbuild                            |    2 +-
 arch/x86/include/asm/calling.h    |   52 +++++++++++++++++++-----------------
 arch/x86/include/asm/entry_arch.h |   19 +++----------
 arch/x86/include/asm/segment.h    |   32 +++++++++++-----------
 arch/x86/kernel/asm-offsets_32.c  |    4 +--
 arch/x86/kernel/entry_32.S        |    6 ++--
 arch/x86/kernel/entry_64.S        |   20 +++-----------
 7 files changed, 56 insertions(+), 79 deletions(-)

diff --git a/Kbuild b/Kbuild
index e3737ad..3995939 100644
--- a/Kbuild
+++ b/Kbuild
@@ -53,7 +53,7 @@ targets += arch/$(SRCARCH)/kernel/asm-offsets.s
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* \3 */:; \
 	s:->::; p;}"
 endef
 
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
index 0e63c9a..30af5a8 100644
--- a/arch/x86/include/asm/calling.h
+++ b/arch/x86/include/asm/calling.h
@@ -48,36 +48,38 @@ For 32-bit we have the following conventions - kernel is built with
 
 
 /*
- * 64-bit system call stack frame layout defines and helpers,
- * for assembly code:
+ * 64-bit system call stack frame layout defines and helpers, for
+ * assembly code (note that the seemingly unnecessary parentheses
+ * are to prevent cpp from inserting spaces in expressions that get
+ * passed to macros):
  */
 
-#define R15		  0
-#define R14		  8
-#define R13		 16
-#define R12		 24
-#define RBP		 32
-#define RBX		 40
+#define R15		  (0)
+#define R14		  (8)
+#define R13		 (16)
+#define R12		 (24)
+#define RBP		 (32)
+#define RBX		 (40)
 
 /* arguments: interrupts/non tracing syscalls only save up to here: */
-#define R11		 48
-#define R10		 56
-#define R9		 64
-#define R8		 72
-#define RAX		 80
-#define RCX		 88
-#define RDX		 96
-#define RSI		104
-#define RDI		112
-#define ORIG_RAX	120       /* + error_code */
+#define R11		 (48)
+#define R10		 (56)
+#define R9		 (64)
+#define R8		 (72)
+#define RAX		 (80)
+#define RCX		 (88)
+#define RDX		 (96)
+#define RSI		(104)
+#define RDI		(112)
+#define ORIG_RAX	(120)       /* + error_code */
 /* end of arguments */
 
 /* cpu exception frame or undefined in case of fast syscall: */
-#define RIP		128
-#define CS		136
-#define EFLAGS		144
-#define RSP		152
-#define SS		160
+#define RIP		(128)
+#define CS		(136)
+#define EFLAGS		(144)
+#define RSP		(152)
+#define SS		(160)
 
 #define ARGOFFSET	R11
 #define SWFRAME		ORIG_RAX
@@ -111,7 +113,7 @@ For 32-bit we have the following conventions - kernel is built with
 	.endif
 	.endm
 
-#define ARG_SKIP	9*8
+#define ARG_SKIP	(9*8)
 
 	.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
 			    skipr8910=0, skiprdx=0
@@ -169,7 +171,7 @@ For 32-bit we have the following conventions - kernel is built with
 	.endif
 	.endm
 
-#define REST_SKIP	6*8
+#define REST_SKIP	(6*8)
 
 	.macro SAVE_REST
 	subq $REST_SKIP, %rsp
diff --git a/arch/x86/include/asm/entry_arch.h b/arch/x86/include/asm/entry_arch.h
index 8e8ec66..4d2966e 100644
--- a/arch/x86/include/asm/entry_arch.h
+++ b/arch/x86/include/asm/entry_arch.h
@@ -16,22 +16,11 @@ BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR)
 BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR)
 BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR)
 
-BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt2,INVALIDATE_TLB_VECTOR_START+2,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt3,INVALIDATE_TLB_VECTOR_START+3,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt4,INVALIDATE_TLB_VECTOR_START+4,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt5,INVALIDATE_TLB_VECTOR_START+5,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt6,INVALIDATE_TLB_VECTOR_START+6,
-		 smp_invalidate_interrupt)
-BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7,
+.irpc idx, "01234567"
+BUILD_INTERRUPT3(invalidate_interrupt\idx,
+		 (INVALIDATE_TLB_VECTOR_START)+\idx,
 		 smp_invalidate_interrupt)
+.endr
 #endif
 
 BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 14e0ed8..231f1c1 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -73,31 +73,31 @@
 
 #define GDT_ENTRY_DEFAULT_USER_DS	15
 
-#define GDT_ENTRY_KERNEL_BASE	12
+#define GDT_ENTRY_KERNEL_BASE		(12)
 
-#define GDT_ENTRY_KERNEL_CS		(GDT_ENTRY_KERNEL_BASE + 0)
+#define GDT_ENTRY_KERNEL_CS		(GDT_ENTRY_KERNEL_BASE+0)
 
-#define GDT_ENTRY_KERNEL_DS		(GDT_ENTRY_KERNEL_BASE + 1)
+#define GDT_ENTRY_KERNEL_DS		(GDT_ENTRY_KERNEL_BASE+1)
 
-#define GDT_ENTRY_TSS			(GDT_ENTRY_KERNEL_BASE + 4)
-#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE + 5)
+#define GDT_ENTRY_TSS			(GDT_ENTRY_KERNEL_BASE+4)
+#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE+5)
 
-#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 6)
-#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 11)
+#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE+6)
+#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE+11)
 
-#define GDT_ENTRY_ESPFIX_SS		(GDT_ENTRY_KERNEL_BASE + 14)
-#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
+#define GDT_ENTRY_ESPFIX_SS		(GDT_ENTRY_KERNEL_BASE+14)
+#define __ESPFIX_SS			(GDT_ENTRY_ESPFIX_SS*8)
 
-#define GDT_ENTRY_PERCPU			(GDT_ENTRY_KERNEL_BASE + 15)
+#define GDT_ENTRY_PERCPU		(GDT_ENTRY_KERNEL_BASE+15)
 #ifdef CONFIG_SMP
 #define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
 #else
 #define __KERNEL_PERCPU 0
 #endif
 
-#define GDT_ENTRY_STACK_CANARY		(GDT_ENTRY_KERNEL_BASE + 16)
+#define GDT_ENTRY_STACK_CANARY		(GDT_ENTRY_KERNEL_BASE+16)
 #ifdef CONFIG_CC_STACKPROTECTOR
-#define __KERNEL_STACK_CANARY		(GDT_ENTRY_STACK_CANARY * 8)
+#define __KERNEL_STACK_CANARY		(GDT_ENTRY_STACK_CANARY*8)
 #else
 #define __KERNEL_STACK_CANARY		0
 #endif
@@ -182,10 +182,10 @@
 
 #endif
 
-#define __KERNEL_CS	(GDT_ENTRY_KERNEL_CS * 8)
-#define __KERNEL_DS	(GDT_ENTRY_KERNEL_DS * 8)
-#define __USER_DS     (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3)
-#define __USER_CS     (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3)
+#define __KERNEL_CS	(GDT_ENTRY_KERNEL_CS*8)
+#define __KERNEL_DS	(GDT_ENTRY_KERNEL_DS*8)
+#define __USER_DS	(GDT_ENTRY_DEFAULT_USER_DS*8+3)
+#define __USER_CS	(GDT_ENTRY_DEFAULT_USER_CS*8+3)
 #ifndef CONFIG_PARAVIRT
 #define get_kernel_rpl()  0
 #endif
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index dfdbf64..1a4088d 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -99,9 +99,7 @@ void foo(void)
 
 	DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
 	DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
-	DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
-	DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
-	DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
+	DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
 
 	OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
 
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 9fb188d..f73a4b8 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -382,20 +382,20 @@ sysenter_past_esp:
 	 * enough kernel state to call TRACE_IRQS_OFF can be called - but
 	 * we immediately enable interrupts at that point anyway.
 	 */
-	pushl_cfi $(__USER_DS)
+	pushl_cfi $__USER_DS
 	/*CFI_REL_OFFSET ss, 0*/
 	pushl_cfi %ebp
 	CFI_REL_OFFSET esp, 0
 	pushfl_cfi
 	orl $X86_EFLAGS_IF, (%esp)
-	pushl_cfi $(__USER_CS)
+	pushl_cfi $__USER_CS
 	/*CFI_REL_OFFSET cs, 0*/
 	/*
 	 * Push current_thread_info()->sysenter_return to the stack.
 	 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
 	 * pushed above; +8 corresponds to copy_thread's esp0 setting.
 	 */
-	pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
+	pushl_cfi TI_sysenter_return-THREAD_SIZE_asm+8+4*4(%esp)
 	CFI_REL_OFFSET eip, 0
 
 	pushl_cfi %eax
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8851a2b..9cc9a71 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -963,22 +963,10 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
 	x86_platform_ipi smp_x86_platform_ipi
 
 #ifdef CONFIG_SMP
-apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \
-	invalidate_interrupt0 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \
-	invalidate_interrupt1 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \
-	invalidate_interrupt2 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \
-	invalidate_interrupt3 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \
-	invalidate_interrupt4 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \
-	invalidate_interrupt5 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \
-	invalidate_interrupt6 smp_invalidate_interrupt
-apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \
-	invalidate_interrupt7 smp_invalidate_interrupt
+.irpc idx, "01234567"
+apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \
+	invalidate_interrupt\idx smp_invalidate_interrupt
+.endr
 #endif
 
 apicinterrupt THRESHOLD_APIC_VECTOR \

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

* Re: [PATCH] x86: fix CFI macro invocations to deal with shortcomings in gas
  2010-10-19 21:03 ` Alexander van Heukelum
@ 2010-10-20  6:43   ` Jan Beulich
  2010-10-20 18:11     ` Alexander van Heukelum
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Beulich @ 2010-10-20  6:43 UTC (permalink / raw)
  To: Alexander van Heukelum
  Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel,
	H. Peter Anvin

>>> On 19.10.10 at 23:03, "Alexander van Heukelum" <heukelum@fastmail.fm> wrote:
>> -       pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
>> +       pushl_cfi TI_sysenter_return-THREAD_SIZE_asm+8+4*4(%esp)
> 
> This expands to:
>     pushl_cfi (60)-(8192)+8+4*4(%esp)
> 
> I'm sorry to say that Ubuntu 6.06's gas (2.16.91 20060118) still chokes
> with "too many positional arguments" on this line.

It escapes me where it would split the obviously single argument, and
I know I checked all official versions from 2.15 onwards. Could you
try whether that specific gas would be okay with

     pushl_cfi ((60)-(8192)+8+4*4)(%esp)

I had intentionally removed the surrounding parentheses since
those are considered by newer gas when determining arguments,
and thus I could expose eventual problems with older gas even
on newer versions.

Further, could you experiment (or ideally debug) where is splits
the argument. Something like

.macro m arg1 arg2=0
	.long	\arg1, \arg2
.endm

.data
_start:
	m	(60)-(8192)+8+4*4

might be handy - assembling with -alm=<filename> should allow
you to inspect where the argument got split.

Thanks, Jan


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

* Re: [PATCH] x86: fix CFI macro invocations to deal with  shortcomings in gas
  2010-10-20  6:43   ` Jan Beulich
@ 2010-10-20 18:11     ` Alexander van Heukelum
  0 siblings, 0 replies; 10+ messages in thread
From: Alexander van Heukelum @ 2010-10-20 18:11 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel,
	H. Peter Anvin

Hello Jan and all,

On Wed, 20 Oct 2010 07:43 +0100, "Jan Beulich" <JBeulich@novell.com> wrote:
> >>> On 19.10.10 at 23:03, "Alexander van Heukelum" <heukelum@fastmail.fm> wrote:
> >> -       pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp)
> >> +       pushl_cfi TI_sysenter_return-THREAD_SIZE_asm+8+4*4(%esp)
> > 
> > This expands to:
> >     pushl_cfi (60)-(8192)+8+4*4(%esp)
> > 
> > I'm sorry to say that Ubuntu 6.06's gas (2.16.91 20060118) still chokes
> > with "too many positional arguments" on this line.
> 
> It escapes me where it would split the obviously single argument, and
> I know I checked all official versions from 2.15 onwards. Could you
> try whether that specific gas would be okay with
> 
>      pushl_cfi ((60)-(8192)+8+4*4)(%esp)

Yes, this works! Adding the parentheses to the patch makes things go
on Ubuntu 6.06 (i386). I hope we can get rid of the old gas, but feel free
to add an Acked-by: Alexander van Heukelum <heukelum@fastmail.fm>.

> I had intentionally removed the surrounding parentheses since
> those are considered by newer gas when determining arguments,
> and thus I could expose eventual problems with older gas even
> on newer versions.
> 
> Further, could you experiment (or ideally debug) where is splits
> the argument. Something like
> 
> .macro m arg1 arg2=0
> 	.long	\arg1, \arg2
> .endm
> 
> .data
> _start:
> 	m	(60)-(8192)+8+4*4

Contents of section .data:
 0000 3c000000 18e0ffff

So it splits at the minus sign, even though there is no space.

Greetings,
    Alexander

> might be handy - assembling with -alm=<filename> should allow
> you to inspect where the argument got split.
> 
> Thanks, Jan
> 

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

* Re: [tip:x86/debug] x86, asm: Fix CFI macro invocations to deal with shortcomings in gas
  2010-10-20  0:55 ` [tip:x86/debug] x86, asm: Fix " tip-bot for Jan Beulich
@ 2010-10-21 10:16   ` Ingo Molnar
  2010-10-21 21:30     ` Alexander van Heukelum
  0 siblings, 1 reply; 10+ messages in thread
From: Ingo Molnar @ 2010-10-21 10:16 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, jbeulich, heukelum, tglx, hpa; +Cc: linux-tip-commits


* tip-bot for Jan Beulich <JBeulich@novell.com> wrote:

> Commit-ID:  3234282f33b29d349bcada40204fc7c8fda7fe72
> Gitweb:     http://git.kernel.org/tip/3234282f33b29d349bcada40204fc7c8fda7fe72
> Author:     Jan Beulich <JBeulich@novell.com>
> AuthorDate: Tue, 19 Oct 2010 14:52:26 +0100
> Committer:  H. Peter Anvin <hpa@linux.intel.com>
> CommitDate: Tue, 19 Oct 2010 14:28:02 -0700
> 
> x86, asm: Fix CFI macro invocations to deal with shortcomings in gas

This commit broke the UML build (see the full error log below).

	Ingo

/home/mingo/tip/arch/um/os-Linux/irq.c: In function ‘os_waiting_for_events’:
/home/mingo/tip/arch/um/os-Linux/irq.c:35: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/irq.c: In function ‘os_free_irq_by_cb’:
/home/mingo/tip/arch/um/os-Linux/irq.c:94: error: expected ‘)’ before string constant
make[2]: *** [arch/um/os-Linux/irq.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘do_aio’:
/home/mingo/tip/arch/um/os-Linux/aio.c:93: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘aio_thread’:
/home/mingo/tip/arch/um/os-Linux/aio.c:116: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c:126: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘do_not_aio’:
/home/mingo/tip/arch/um/os-Linux/aio.c:156: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘not_aio_thread’:
/home/mingo/tip/arch/um/os-Linux/aio.c:183: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c:188: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c:199: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘init_aio_24’:
/home/mingo/tip/arch/um/os-Linux/aio.c:239: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘init_aio_26’:
/home/mingo/tip/arch/um/os-Linux/aio.c:252: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c:264: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘submit_aio_26’:
/home/mingo/tip/arch/um/os-Linux/aio.c:281: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/aio.c: In function ‘init_aio’:
/home/mingo/tip/arch/um/os-Linux/aio.c:332: error: expected ‘)’ before string constant
make[2]: *** [arch/um/os-Linux/aio.o] Error 1
/home/mingo/tip/arch/um/os-Linux/helper.c: In function ‘run_helper’:
/home/mingo/tip/arch/um/os-Linux/helper.c:57: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c:64: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c:79: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c:97: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c: In function ‘run_helper_thread’:
/home/mingo/tip/arch/um/os-Linux/helper.c:129: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c:137: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c:142: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c: In function ‘helper_wait’:
/home/mingo/tip/arch/um/os-Linux/helper.c:157: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/helper.c:161: error: expected ‘)’ before string constant
make[2]: *** [arch/um/os-Linux/helper.o] Error 1
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_file_size’:
/home/mingo/tip/arch/um/os-Linux/file.c:278: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c:290: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c:296: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_file_modtime’:
/home/mingo/tip/arch/um/os-Linux/file.c:316: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_pipe’:
/home/mingo/tip/arch/um/os-Linux/file.c:358: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_set_fd_async’:
/home/mingo/tip/arch/um/os-Linux/file.c:376: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c:384: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_rcv_fd’:
/home/mingo/tip/arch/um/os-Linux/file.c:492: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c:498: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_create_unix_socket’:
/home/mingo/tip/arch/um/os-Linux/file.c:518: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/os-Linux/file.c: In function ‘os_lock_file’:
/home/mingo/tip/arch/um/os-Linux/file.c:558: error: expected ‘)’ before string constant
make[2]: *** [arch/um/os-Linux/file.o] Error 1
/home/mingo/tip/arch/um/kernel/exec.c: In function ‘um_execve’:
/home/mingo/tip/arch/um/kernel/exec.c:69: warning: passing argument 2 of ‘execve1’ from incompatible pointer type
/home/mingo/tip/arch/um/kernel/exec.c:47: note: expected ‘const char * const*’ but argument is of type ‘char **’
/home/mingo/tip/arch/um/kernel/exec.c:69: warning: passing argument 3 of ‘execve1’ from incompatible pointer type
/home/mingo/tip/arch/um/kernel/exec.c:47: note: expected ‘const char * const*’ but argument is of type ‘char **’
/home/mingo/tip/arch/um/kernel/exec.c: In function ‘sys_execve’:
/home/mingo/tip/arch/um/kernel/exec.c:85: warning: passing argument 2 of ‘execve1’ from incompatible pointer type
/home/mingo/tip/arch/um/kernel/exec.c:47: note: expected ‘const char * const*’ but argument is of type ‘char **’
/home/mingo/tip/arch/um/kernel/exec.c:85: warning: passing argument 3 of ‘execve1’ from incompatible pointer type
/home/mingo/tip/arch/um/kernel/exec.c:47: note: expected ‘const char * const*’ but argument is of type ‘char **’
make[1]: *** [arch/um/os-Linux] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/mingo/tip/arch/um/drivers/fd.c: In function ‘fd_init’:
/home/mingo/tip/arch/um/drivers/fd.c:31: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/drivers/fd.c:38: error: expected ‘)’ before string constant
/home/mingo/tip/arch/um/drivers/fd.c: In function ‘fd_close’:
/home/mingo/tip/arch/um/drivers/fd.c:81: error: expected ‘)’ before string constant
make[2]: *** [arch/um/drivers/fd.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [arch/um/drivers] Error 2
/home/mingo/tip/kernel/irq/handle.c:432:3: warning: #warning __do_IRQ is deprecated. Please convert to proper flow handlers
make: *** [sub-make] Error 2

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

* Re: [tip:x86/debug] x86, asm: Fix CFI macro invocations to deal with shortcomings in gas
  2010-10-21 10:16   ` Ingo Molnar
@ 2010-10-21 21:30     ` Alexander van Heukelum
  2010-10-22  7:08       ` Jan Beulich
  2010-10-22  9:55       ` [tip:x86/debug] x86, asm: Fix ancient-GAS workaround tip-bot for Alexander van Heukelum
  0 siblings, 2 replies; 10+ messages in thread
From: Alexander van Heukelum @ 2010-10-21 21:30 UTC (permalink / raw)
  To: Ingo Molnar, mingo, H. Peter Anvin, linux-kernel, Jan Beulich,
	Thomas Gleixner, hpa
  Cc: linux-tip-commits

[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]

On Thu, 21 Oct 2010 12:16 +0200, "Ingo Molnar" <mingo@elte.hu> wrote:
> 
> * tip-bot for Jan Beulich <JBeulich@novell.com> wrote:
> 
> > Commit-ID:  3234282f33b29d349bcada40204fc7c8fda7fe72
> > Gitweb:     http://git.kernel.org/tip/3234282f33b29d349bcada40204fc7c8fda7fe72
> > Author:     Jan Beulich <JBeulich@novell.com>
> > AuthorDate: Tue, 19 Oct 2010 14:52:26 +0100
> > Committer:  H. Peter Anvin <hpa@linux.intel.com>
> > CommitDate: Tue, 19 Oct 2010 14:28:02 -0700
> > 
> > x86, asm: Fix CFI macro invocations to deal with shortcomings in gas
> 
> This commit broke the UML build (see the full error log below).
> 
> 	Ingo
> 
> /home/mingo/tip/arch/um/os-Linux/irq.c: In function
> ‘os_waiting_for_events’:
> /home/mingo/tip/arch/um/os-Linux/irq.c:35: error: expected ‘)’ before
> string constant
> /home/mingo/tip/arch/um/os-Linux/irq.c: In function ‘os_free_irq_by_cb’:
> /home/mingo/tip/arch/um/os-Linux/irq.c:94: error: expected ‘)’ before
> string constant

Hi all,

It turns out to generate something like this:
    printk ( ("<3>") "something");
The extra parentheses here break the compile.

Change the sed-program to add the parentheses only for numbers.

Greetings,
    Alexander

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sedpatch.patch --]
[-- Type: text/x-patch; name="sedpatch.patch", Size: 829 bytes --]

Fix for "x86, asm: Fix CFI macro invocations to deal with shortcomings in gas"

It turns out to generate something like this:
    printk ( ("<3>") "something");
The extra parentheses here break the compile.

Change the sed-program to add the parentheses only for numbers.


Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>

diff --git a/Kbuild b/Kbuild
index 3995939..431f7ca 100644
--- a/Kbuild
+++ b/Kbuild
@@ -53,7 +53,8 @@ targets += arch/$(SRCARCH)/kernel/asm-offsets.s
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 (\2) /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:->::; p;}"
 endef
 

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

* Re: [tip:x86/debug] x86, asm: Fix CFI macro invocations to deal with shortcomings in gas
  2010-10-21 21:30     ` Alexander van Heukelum
@ 2010-10-22  7:08       ` Jan Beulich
  2010-10-22  9:55       ` [tip:x86/debug] x86, asm: Fix ancient-GAS workaround tip-bot for Alexander van Heukelum
  1 sibling, 0 replies; 10+ messages in thread
From: Jan Beulich @ 2010-10-22  7:08 UTC (permalink / raw)
  To: Alexander van Heukelum
  Cc: Ingo Molnar, Thomas Gleixner, hpa, mingo, linux-kernel,
	linux-tip-commits, H. Peter Anvin

>>> On 21.10.10 at 23:30, "Alexander van Heukelum" <heukelum@fastmail.fm> wrote:
> It turns out to generate something like this:
>     printk ( ("<3>") "something");
> The extra parentheses here break the compile.
> 
> Change the sed-program to add the parentheses only for numbers.

Thanks!

Acked-by: Jan Beulich <jbeulich@novell.com>


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

* [tip:x86/debug] x86, asm: Fix ancient-GAS workaround
  2010-10-21 21:30     ` Alexander van Heukelum
  2010-10-22  7:08       ` Jan Beulich
@ 2010-10-22  9:55       ` tip-bot for Alexander van Heukelum
  1 sibling, 0 replies; 10+ messages in thread
From: tip-bot for Alexander van Heukelum @ 2010-10-22  9:55 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, jbeulich, heukelum, tglx, mingo

Commit-ID:  a22dcdb0032c78c6b443f6897d7ac432a3b5a272
Gitweb:     http://git.kernel.org/tip/a22dcdb0032c78c6b443f6897d7ac432a3b5a272
Author:     Alexander van Heukelum <heukelum@fastmail.fm>
AuthorDate: Thu, 21 Oct 2010 23:30:49 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 22 Oct 2010 10:45:02 +0200

x86, asm: Fix ancient-GAS workaround

It turns out to generate something like this:

    printk ( ("<3>") "something");

The extra parentheses here break the UML compile.

Change the sed-program to add the parentheses only for numbers.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Acked-by: Jan Beulich <jbeulich@novell.com>
LKML-Reference: <1287696649.20421.1401306095@webmail.messagingengine.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 Kbuild |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Kbuild b/Kbuild
index 3995939..431f7ca 100644
--- a/Kbuild
+++ b/Kbuild
@@ -53,7 +53,8 @@ targets += arch/$(SRCARCH)/kernel/asm-offsets.s
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 (\2) /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:->::; p;}"
 endef
 

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

end of thread, other threads:[~2010-10-22  9:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-19 13:52 [PATCH] x86: fix CFI macro invocations to deal with shortcomings in gas Jan Beulich
2010-10-19 21:03 ` Alexander van Heukelum
2010-10-20  6:43   ` Jan Beulich
2010-10-20 18:11     ` Alexander van Heukelum
2010-10-19 21:14 ` H. Peter Anvin
2010-10-20  0:55 ` [tip:x86/debug] x86, asm: Fix " tip-bot for Jan Beulich
2010-10-21 10:16   ` Ingo Molnar
2010-10-21 21:30     ` Alexander van Heukelum
2010-10-22  7:08       ` Jan Beulich
2010-10-22  9:55       ` [tip:x86/debug] x86, asm: Fix ancient-GAS workaround tip-bot for Alexander van Heukelum

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).