mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									d0ed0c3266
								
							
						
					
					
						commit
						3234282f33
					
				
					 7 changed files with 56 additions and 79 deletions
				
			
		
							
								
								
									
										2
									
								
								Kbuild
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Kbuild
									
									
									
									
									
								
							| 
						 | 
					@ -53,7 +53,7 @@ targets += arch/$(SRCARCH)/kernel/asm-offsets.s
 | 
				
			||||||
# Default sed regexp - multiline due to syntax constraints
 | 
					# Default sed regexp - multiline due to syntax constraints
 | 
				
			||||||
define sed-y
 | 
					define sed-y
 | 
				
			||||||
	"/^->/{s:->#\(.*\):/* \1 */:; \
 | 
						"/^->/{s:->#\(.*\):/* \1 */:; \
 | 
				
			||||||
	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 | 
						s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* \3 */:; \
 | 
				
			||||||
	s:->::; p;}"
 | 
						s:->::; p;}"
 | 
				
			||||||
endef
 | 
					endef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,
 | 
					 * 64-bit system call stack frame layout defines and helpers, for
 | 
				
			||||||
 * for assembly code:
 | 
					 * 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 R15		  (0)
 | 
				
			||||||
#define R14		  8
 | 
					#define R14		  (8)
 | 
				
			||||||
#define R13		 16
 | 
					#define R13		 (16)
 | 
				
			||||||
#define R12		 24
 | 
					#define R12		 (24)
 | 
				
			||||||
#define RBP		 32
 | 
					#define RBP		 (32)
 | 
				
			||||||
#define RBX		 40
 | 
					#define RBX		 (40)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* arguments: interrupts/non tracing syscalls only save up to here: */
 | 
					/* arguments: interrupts/non tracing syscalls only save up to here: */
 | 
				
			||||||
#define R11		 48
 | 
					#define R11		 (48)
 | 
				
			||||||
#define R10		 56
 | 
					#define R10		 (56)
 | 
				
			||||||
#define R9		 64
 | 
					#define R9		 (64)
 | 
				
			||||||
#define R8		 72
 | 
					#define R8		 (72)
 | 
				
			||||||
#define RAX		 80
 | 
					#define RAX		 (80)
 | 
				
			||||||
#define RCX		 88
 | 
					#define RCX		 (88)
 | 
				
			||||||
#define RDX		 96
 | 
					#define RDX		 (96)
 | 
				
			||||||
#define RSI		104
 | 
					#define RSI		(104)
 | 
				
			||||||
#define RDI		112
 | 
					#define RDI		(112)
 | 
				
			||||||
#define ORIG_RAX	120       /* + error_code */
 | 
					#define ORIG_RAX	(120)       /* + error_code */
 | 
				
			||||||
/* end of arguments */
 | 
					/* end of arguments */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* cpu exception frame or undefined in case of fast syscall: */
 | 
					/* cpu exception frame or undefined in case of fast syscall: */
 | 
				
			||||||
#define RIP		128
 | 
					#define RIP		(128)
 | 
				
			||||||
#define CS		136
 | 
					#define CS		(136)
 | 
				
			||||||
#define EFLAGS		144
 | 
					#define EFLAGS		(144)
 | 
				
			||||||
#define RSP		152
 | 
					#define RSP		(152)
 | 
				
			||||||
#define SS		160
 | 
					#define SS		(160)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define ARGOFFSET	R11
 | 
					#define ARGOFFSET	R11
 | 
				
			||||||
#define SWFRAME		ORIG_RAX
 | 
					#define SWFRAME		ORIG_RAX
 | 
				
			||||||
| 
						 | 
					@ -111,7 +113,7 @@ For 32-bit we have the following conventions - kernel is built with
 | 
				
			||||||
	.endif
 | 
						.endif
 | 
				
			||||||
	.endm
 | 
						.endm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define ARG_SKIP	9*8
 | 
					#define ARG_SKIP	(9*8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
 | 
						.macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
 | 
				
			||||||
			    skipr8910=0, skiprdx=0
 | 
								    skipr8910=0, skiprdx=0
 | 
				
			||||||
| 
						 | 
					@ -169,7 +171,7 @@ For 32-bit we have the following conventions - kernel is built with
 | 
				
			||||||
	.endif
 | 
						.endif
 | 
				
			||||||
	.endm
 | 
						.endm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define REST_SKIP	6*8
 | 
					#define REST_SKIP	(6*8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	.macro SAVE_REST
 | 
						.macro SAVE_REST
 | 
				
			||||||
	subq $REST_SKIP, %rsp
 | 
						subq $REST_SKIP, %rsp
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR)
 | 
				
			||||||
BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR)
 | 
					BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0,
 | 
					.irpc idx, "01234567"
 | 
				
			||||||
		 smp_invalidate_interrupt)
 | 
					BUILD_INTERRUPT3(invalidate_interrupt\idx,
 | 
				
			||||||
BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1,
 | 
							 (INVALIDATE_TLB_VECTOR_START)+\idx,
 | 
				
			||||||
		 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,
 | 
					 | 
				
			||||||
		 smp_invalidate_interrupt)
 | 
							 smp_invalidate_interrupt)
 | 
				
			||||||
 | 
					.endr
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
 | 
					BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,31 +73,31 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GDT_ENTRY_DEFAULT_USER_DS	15
 | 
					#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_TSS			(GDT_ENTRY_KERNEL_BASE+4)
 | 
				
			||||||
#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE + 5)
 | 
					#define GDT_ENTRY_LDT			(GDT_ENTRY_KERNEL_BASE+5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 6)
 | 
					#define GDT_ENTRY_PNPBIOS_BASE		(GDT_ENTRY_KERNEL_BASE+6)
 | 
				
			||||||
#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE + 11)
 | 
					#define GDT_ENTRY_APMBIOS_BASE		(GDT_ENTRY_KERNEL_BASE+11)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define GDT_ENTRY_ESPFIX_SS		(GDT_ENTRY_KERNEL_BASE + 14)
 | 
					#define GDT_ENTRY_ESPFIX_SS		(GDT_ENTRY_KERNEL_BASE+14)
 | 
				
			||||||
#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
 | 
					#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
 | 
					#ifdef CONFIG_SMP
 | 
				
			||||||
#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
 | 
					#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define __KERNEL_PERCPU 0
 | 
					#define __KERNEL_PERCPU 0
 | 
				
			||||||
#endif
 | 
					#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
 | 
					#ifdef CONFIG_CC_STACKPROTECTOR
 | 
				
			||||||
#define __KERNEL_STACK_CANARY		(GDT_ENTRY_STACK_CANARY * 8)
 | 
					#define __KERNEL_STACK_CANARY		(GDT_ENTRY_STACK_CANARY*8)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define __KERNEL_STACK_CANARY		0
 | 
					#define __KERNEL_STACK_CANARY		0
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -182,10 +182,10 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define __KERNEL_CS	(GDT_ENTRY_KERNEL_CS * 8)
 | 
					#define __KERNEL_CS	(GDT_ENTRY_KERNEL_CS*8)
 | 
				
			||||||
#define __KERNEL_DS	(GDT_ENTRY_KERNEL_DS * 8)
 | 
					#define __KERNEL_DS	(GDT_ENTRY_KERNEL_DS*8)
 | 
				
			||||||
#define __USER_DS     (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3)
 | 
					#define __USER_DS	(GDT_ENTRY_DEFAULT_USER_DS*8+3)
 | 
				
			||||||
#define __USER_CS     (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3)
 | 
					#define __USER_CS	(GDT_ENTRY_DEFAULT_USER_CS*8+3)
 | 
				
			||||||
#ifndef CONFIG_PARAVIRT
 | 
					#ifndef CONFIG_PARAVIRT
 | 
				
			||||||
#define get_kernel_rpl()  0
 | 
					#define get_kernel_rpl()  0
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -99,9 +99,7 @@ void foo(void)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
 | 
						DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
 | 
				
			||||||
	DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
 | 
						DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
 | 
				
			||||||
	DEFINE(PTRS_PER_PTE, PTRS_PER_PTE);
 | 
						DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
 | 
				
			||||||
	DEFINE(PTRS_PER_PMD, PTRS_PER_PMD);
 | 
					 | 
				
			||||||
	DEFINE(PTRS_PER_PGD, PTRS_PER_PGD);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
 | 
						OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -382,20 +382,20 @@ sysenter_past_esp:
 | 
				
			||||||
	 * enough kernel state to call TRACE_IRQS_OFF can be called - but
 | 
						 * enough kernel state to call TRACE_IRQS_OFF can be called - but
 | 
				
			||||||
	 * we immediately enable interrupts at that point anyway.
 | 
						 * we immediately enable interrupts at that point anyway.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	pushl_cfi $(__USER_DS)
 | 
						pushl_cfi $__USER_DS
 | 
				
			||||||
	/*CFI_REL_OFFSET ss, 0*/
 | 
						/*CFI_REL_OFFSET ss, 0*/
 | 
				
			||||||
	pushl_cfi %ebp
 | 
						pushl_cfi %ebp
 | 
				
			||||||
	CFI_REL_OFFSET esp, 0
 | 
						CFI_REL_OFFSET esp, 0
 | 
				
			||||||
	pushfl_cfi
 | 
						pushfl_cfi
 | 
				
			||||||
	orl $X86_EFLAGS_IF, (%esp)
 | 
						orl $X86_EFLAGS_IF, (%esp)
 | 
				
			||||||
	pushl_cfi $(__USER_CS)
 | 
						pushl_cfi $__USER_CS
 | 
				
			||||||
	/*CFI_REL_OFFSET cs, 0*/
 | 
						/*CFI_REL_OFFSET cs, 0*/
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Push current_thread_info()->sysenter_return to the stack.
 | 
						 * Push current_thread_info()->sysenter_return to the stack.
 | 
				
			||||||
	 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
 | 
						 * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
 | 
				
			||||||
	 * pushed above; +8 corresponds to copy_thread's esp0 setting.
 | 
						 * 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
 | 
						CFI_REL_OFFSET eip, 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pushl_cfi %eax
 | 
						pushl_cfi %eax
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -963,22 +963,10 @@ apicinterrupt X86_PLATFORM_IPI_VECTOR \
 | 
				
			||||||
	x86_platform_ipi smp_x86_platform_ipi
 | 
						x86_platform_ipi smp_x86_platform_ipi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_SMP
 | 
					#ifdef CONFIG_SMP
 | 
				
			||||||
apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \
 | 
					.irpc idx, "01234567"
 | 
				
			||||||
	invalidate_interrupt0 smp_invalidate_interrupt
 | 
					apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \
 | 
				
			||||||
apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \
 | 
						invalidate_interrupt\idx smp_invalidate_interrupt
 | 
				
			||||||
	invalidate_interrupt1 smp_invalidate_interrupt
 | 
					.endr
 | 
				
			||||||
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
 | 
					 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
apicinterrupt THRESHOLD_APIC_VECTOR \
 | 
					apicinterrupt THRESHOLD_APIC_VECTOR \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue