Commit 3234282f33b29d349bcada40204fc7c8fda7fe72
Committed by
H. Peter Anvin
1 parent
d0ed0c3266
Exists in
master
and in
41 other branches
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>
Showing 7 changed files with 56 additions and 79 deletions Side-by-side Diff
Kbuild
| ... | ... | @@ -53,7 +53,7 @@ |
| 53 | 53 | # Default sed regexp - multiline due to syntax constraints |
| 54 | 54 | define sed-y |
| 55 | 55 | "/^->/{s:->#\(.*\):/* \1 */:; \ |
| 56 | - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* */:; \ | |
| 56 | + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 (\2) /* */:; \ | |
| 57 | 57 | s:->::; p;}" |
| 58 | 58 | endef |
| 59 | 59 |
arch/x86/include/asm/calling.h
| ... | ... | @@ -48,36 +48,38 @@ |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | /* |
| 51 | - * 64-bit system call stack frame layout defines and helpers, | |
| 52 | - * for assembly code: | |
| 51 | + * 64-bit system call stack frame layout defines and helpers, for | |
| 52 | + * assembly code (note that the seemingly unnecessary parentheses | |
| 53 | + * are to prevent cpp from inserting spaces in expressions that get | |
| 54 | + * passed to macros): | |
| 53 | 55 | */ |
| 54 | 56 | |
| 55 | -#define R15 0 | |
| 56 | -#define R14 8 | |
| 57 | -#define R13 16 | |
| 58 | -#define R12 24 | |
| 59 | -#define RBP 32 | |
| 60 | -#define RBX 40 | |
| 57 | +#define R15 (0) | |
| 58 | +#define R14 (8) | |
| 59 | +#define R13 (16) | |
| 60 | +#define R12 (24) | |
| 61 | +#define RBP (32) | |
| 62 | +#define RBX (40) | |
| 61 | 63 | |
| 62 | 64 | /* arguments: interrupts/non tracing syscalls only save up to here: */ |
| 63 | -#define R11 48 | |
| 64 | -#define R10 56 | |
| 65 | -#define R9 64 | |
| 66 | -#define R8 72 | |
| 67 | -#define RAX 80 | |
| 68 | -#define RCX 88 | |
| 69 | -#define RDX 96 | |
| 70 | -#define RSI 104 | |
| 71 | -#define RDI 112 | |
| 72 | -#define ORIG_RAX 120 /* + error_code */ | |
| 65 | +#define R11 (48) | |
| 66 | +#define R10 (56) | |
| 67 | +#define R9 (64) | |
| 68 | +#define R8 (72) | |
| 69 | +#define RAX (80) | |
| 70 | +#define RCX (88) | |
| 71 | +#define RDX (96) | |
| 72 | +#define RSI (104) | |
| 73 | +#define RDI (112) | |
| 74 | +#define ORIG_RAX (120) /* + error_code */ | |
| 73 | 75 | /* end of arguments */ |
| 74 | 76 | |
| 75 | 77 | /* cpu exception frame or undefined in case of fast syscall: */ |
| 76 | -#define RIP 128 | |
| 77 | -#define CS 136 | |
| 78 | -#define EFLAGS 144 | |
| 79 | -#define RSP 152 | |
| 80 | -#define SS 160 | |
| 78 | +#define RIP (128) | |
| 79 | +#define CS (136) | |
| 80 | +#define EFLAGS (144) | |
| 81 | +#define RSP (152) | |
| 82 | +#define SS (160) | |
| 81 | 83 | |
| 82 | 84 | #define ARGOFFSET R11 |
| 83 | 85 | #define SWFRAME ORIG_RAX |
| ... | ... | @@ -111,7 +113,7 @@ |
| 111 | 113 | .endif |
| 112 | 114 | .endm |
| 113 | 115 | |
| 114 | -#define ARG_SKIP 9*8 | |
| 116 | +#define ARG_SKIP (9*8) | |
| 115 | 117 | |
| 116 | 118 | .macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \ |
| 117 | 119 | skipr8910=0, skiprdx=0 |
| ... | ... | @@ -169,7 +171,7 @@ |
| 169 | 171 | .endif |
| 170 | 172 | .endm |
| 171 | 173 | |
| 172 | -#define REST_SKIP 6*8 | |
| 174 | +#define REST_SKIP (6*8) | |
| 173 | 175 | |
| 174 | 176 | .macro SAVE_REST |
| 175 | 177 | subq $REST_SKIP, %rsp |
arch/x86/include/asm/entry_arch.h
| ... | ... | @@ -16,22 +16,11 @@ |
| 16 | 16 | BUILD_INTERRUPT(irq_move_cleanup_interrupt,IRQ_MOVE_CLEANUP_VECTOR) |
| 17 | 17 | BUILD_INTERRUPT(reboot_interrupt,REBOOT_VECTOR) |
| 18 | 18 | |
| 19 | -BUILD_INTERRUPT3(invalidate_interrupt0,INVALIDATE_TLB_VECTOR_START+0, | |
| 19 | +.irpc idx, "01234567" | |
| 20 | +BUILD_INTERRUPT3(invalidate_interrupt\idx, | |
| 21 | + (INVALIDATE_TLB_VECTOR_START)+\idx, | |
| 20 | 22 | smp_invalidate_interrupt) |
| 21 | -BUILD_INTERRUPT3(invalidate_interrupt1,INVALIDATE_TLB_VECTOR_START+1, | |
| 22 | - smp_invalidate_interrupt) | |
| 23 | -BUILD_INTERRUPT3(invalidate_interrupt2,INVALIDATE_TLB_VECTOR_START+2, | |
| 24 | - smp_invalidate_interrupt) | |
| 25 | -BUILD_INTERRUPT3(invalidate_interrupt3,INVALIDATE_TLB_VECTOR_START+3, | |
| 26 | - smp_invalidate_interrupt) | |
| 27 | -BUILD_INTERRUPT3(invalidate_interrupt4,INVALIDATE_TLB_VECTOR_START+4, | |
| 28 | - smp_invalidate_interrupt) | |
| 29 | -BUILD_INTERRUPT3(invalidate_interrupt5,INVALIDATE_TLB_VECTOR_START+5, | |
| 30 | - smp_invalidate_interrupt) | |
| 31 | -BUILD_INTERRUPT3(invalidate_interrupt6,INVALIDATE_TLB_VECTOR_START+6, | |
| 32 | - smp_invalidate_interrupt) | |
| 33 | -BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7, | |
| 34 | - smp_invalidate_interrupt) | |
| 23 | +.endr | |
| 35 | 24 | #endif |
| 36 | 25 | |
| 37 | 26 | BUILD_INTERRUPT(x86_platform_ipi, X86_PLATFORM_IPI_VECTOR) |
arch/x86/include/asm/segment.h
| ... | ... | @@ -73,31 +73,31 @@ |
| 73 | 73 | |
| 74 | 74 | #define GDT_ENTRY_DEFAULT_USER_DS 15 |
| 75 | 75 | |
| 76 | -#define GDT_ENTRY_KERNEL_BASE 12 | |
| 76 | +#define GDT_ENTRY_KERNEL_BASE (12) | |
| 77 | 77 | |
| 78 | -#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0) | |
| 78 | +#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0) | |
| 79 | 79 | |
| 80 | -#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1) | |
| 80 | +#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1) | |
| 81 | 81 | |
| 82 | -#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4) | |
| 83 | -#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5) | |
| 82 | +#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4) | |
| 83 | +#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE+5) | |
| 84 | 84 | |
| 85 | -#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6) | |
| 86 | -#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11) | |
| 85 | +#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE+6) | |
| 86 | +#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE+11) | |
| 87 | 87 | |
| 88 | -#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14) | |
| 89 | -#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8) | |
| 88 | +#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE+14) | |
| 89 | +#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS*8) | |
| 90 | 90 | |
| 91 | -#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15) | |
| 91 | +#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE+15) | |
| 92 | 92 | #ifdef CONFIG_SMP |
| 93 | 93 | #define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8) |
| 94 | 94 | #else |
| 95 | 95 | #define __KERNEL_PERCPU 0 |
| 96 | 96 | #endif |
| 97 | 97 | |
| 98 | -#define GDT_ENTRY_STACK_CANARY (GDT_ENTRY_KERNEL_BASE + 16) | |
| 98 | +#define GDT_ENTRY_STACK_CANARY (GDT_ENTRY_KERNEL_BASE+16) | |
| 99 | 99 | #ifdef CONFIG_CC_STACKPROTECTOR |
| 100 | -#define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY * 8) | |
| 100 | +#define __KERNEL_STACK_CANARY (GDT_ENTRY_STACK_CANARY*8) | |
| 101 | 101 | #else |
| 102 | 102 | #define __KERNEL_STACK_CANARY 0 |
| 103 | 103 | #endif |
| ... | ... | @@ -182,10 +182,10 @@ |
| 182 | 182 | |
| 183 | 183 | #endif |
| 184 | 184 | |
| 185 | -#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8) | |
| 186 | -#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8) | |
| 187 | -#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS* 8 + 3) | |
| 188 | -#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS* 8 + 3) | |
| 185 | +#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8) | |
| 186 | +#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8) | |
| 187 | +#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3) | |
| 188 | +#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3) | |
| 189 | 189 | #ifndef CONFIG_PARAVIRT |
| 190 | 190 | #define get_kernel_rpl() 0 |
| 191 | 191 | #endif |
arch/x86/kernel/asm-offsets_32.c
| ... | ... | @@ -99,9 +99,7 @@ |
| 99 | 99 | |
| 100 | 100 | DEFINE(PAGE_SIZE_asm, PAGE_SIZE); |
| 101 | 101 | DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT); |
| 102 | - DEFINE(PTRS_PER_PTE, PTRS_PER_PTE); | |
| 103 | - DEFINE(PTRS_PER_PMD, PTRS_PER_PMD); | |
| 104 | - DEFINE(PTRS_PER_PGD, PTRS_PER_PGD); | |
| 102 | + DEFINE(THREAD_SIZE_asm, THREAD_SIZE); | |
| 105 | 103 | |
| 106 | 104 | OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); |
| 107 | 105 |
arch/x86/kernel/entry_32.S
| ... | ... | @@ -382,20 +382,20 @@ |
| 382 | 382 | * enough kernel state to call TRACE_IRQS_OFF can be called - but |
| 383 | 383 | * we immediately enable interrupts at that point anyway. |
| 384 | 384 | */ |
| 385 | - pushl_cfi $(__USER_DS) | |
| 385 | + pushl_cfi $__USER_DS | |
| 386 | 386 | /*CFI_REL_OFFSET ss, 0*/ |
| 387 | 387 | pushl_cfi %ebp |
| 388 | 388 | CFI_REL_OFFSET esp, 0 |
| 389 | 389 | pushfl_cfi |
| 390 | 390 | orl $X86_EFLAGS_IF, (%esp) |
| 391 | - pushl_cfi $(__USER_CS) | |
| 391 | + pushl_cfi $__USER_CS | |
| 392 | 392 | /*CFI_REL_OFFSET cs, 0*/ |
| 393 | 393 | /* |
| 394 | 394 | * Push current_thread_info()->sysenter_return to the stack. |
| 395 | 395 | * A tiny bit of offset fixup is necessary - 4*4 means the 4 words |
| 396 | 396 | * pushed above; +8 corresponds to copy_thread's esp0 setting. |
| 397 | 397 | */ |
| 398 | - pushl_cfi (TI_sysenter_return-THREAD_SIZE+8+4*4)(%esp) | |
| 398 | + pushl_cfi TI_sysenter_return-THREAD_SIZE_asm+8+4*4(%esp) | |
| 399 | 399 | CFI_REL_OFFSET eip, 0 |
| 400 | 400 | |
| 401 | 401 | pushl_cfi %eax |
arch/x86/kernel/entry_64.S
| ... | ... | @@ -963,22 +963,10 @@ |
| 963 | 963 | x86_platform_ipi smp_x86_platform_ipi |
| 964 | 964 | |
| 965 | 965 | #ifdef CONFIG_SMP |
| 966 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+0 \ | |
| 967 | - invalidate_interrupt0 smp_invalidate_interrupt | |
| 968 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+1 \ | |
| 969 | - invalidate_interrupt1 smp_invalidate_interrupt | |
| 970 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+2 \ | |
| 971 | - invalidate_interrupt2 smp_invalidate_interrupt | |
| 972 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+3 \ | |
| 973 | - invalidate_interrupt3 smp_invalidate_interrupt | |
| 974 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+4 \ | |
| 975 | - invalidate_interrupt4 smp_invalidate_interrupt | |
| 976 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+5 \ | |
| 977 | - invalidate_interrupt5 smp_invalidate_interrupt | |
| 978 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+6 \ | |
| 979 | - invalidate_interrupt6 smp_invalidate_interrupt | |
| 980 | -apicinterrupt INVALIDATE_TLB_VECTOR_START+7 \ | |
| 981 | - invalidate_interrupt7 smp_invalidate_interrupt | |
| 966 | +.irpc idx, "01234567" | |
| 967 | +apicinterrupt (INVALIDATE_TLB_VECTOR_START)+\idx \ | |
| 968 | + invalidate_interrupt\idx smp_invalidate_interrupt | |
| 969 | +.endr | |
| 982 | 970 | #endif |
| 983 | 971 | |
| 984 | 972 | apicinterrupt THRESHOLD_APIC_VECTOR \ |