Commit d7c3f8cee81f4548de0513403b74131aee655576

Authored by Christoph Lameter
Committed by Linus Torvalds
1 parent 76597cd314

percpu: Omit segment prefix in the UP case for cmpxchg_double

Omit the segment prefix in the UP case. GS is not used then
and we will generate segfaults if cmpxchg16b is used otherwise.

Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 16 additions and 8 deletions Side-by-side Diff

arch/x86/include/asm/percpu.h
... ... @@ -45,7 +45,7 @@
45 45 #include <linux/stringify.h>
46 46  
47 47 #ifdef CONFIG_SMP
48   -#define __percpu_arg(x) "%%"__stringify(__percpu_seg)":%P" #x
  48 +#define __percpu_prefix "%%"__stringify(__percpu_seg)":"
49 49 #define __my_cpu_offset percpu_read(this_cpu_off)
50 50  
51 51 /*
52 52  
... ... @@ -62,9 +62,11 @@
62 62 (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \
63 63 })
64 64 #else
65   -#define __percpu_arg(x) "%P" #x
  65 +#define __percpu_prefix ""
66 66 #endif
67 67  
  68 +#define __percpu_arg(x) __percpu_prefix "%P" #x
  69 +
68 70 /*
69 71 * Initialized pointers to per-cpu variables needed for the boot
70 72 * processor need to use these macros to get the proper address
71 73  
... ... @@ -516,11 +518,11 @@
516 518 typeof(o2) __n2 = n2; \
517 519 typeof(o2) __dummy; \
518 520 alternative_io("call this_cpu_cmpxchg16b_emu\n\t" P6_NOP4, \
519   - "cmpxchg16b %%gs:(%%rsi)\n\tsetz %0\n\t", \
  521 + "cmpxchg16b " __percpu_prefix "(%%rsi)\n\tsetz %0\n\t", \
520 522 X86_FEATURE_CX16, \
521 523 ASM_OUTPUT2("=a"(__ret), "=d"(__dummy)), \
522 524 "S" (&pcp1), "b"(__n1), "c"(__n2), \
523   - "a"(__o1), "d"(__o2)); \
  525 + "a"(__o1), "d"(__o2) : "memory"); \
524 526 __ret; \
525 527 })
526 528  
arch/x86/lib/cmpxchg16b_emu.S
... ... @@ -10,6 +10,12 @@
10 10 #include <asm/frame.h>
11 11 #include <asm/dwarf2.h>
12 12  
  13 +#ifdef CONFIG_SMP
  14 +#define SEG_PREFIX %gs:
  15 +#else
  16 +#define SEG_PREFIX
  17 +#endif
  18 +
13 19 .text
14 20  
15 21 /*
16 22  
17 23  
... ... @@ -37,13 +43,13 @@
37 43 pushf
38 44 cli
39 45  
40   - cmpq %gs:(%rsi), %rax
  46 + cmpq SEG_PREFIX(%rsi), %rax
41 47 jne not_same
42   - cmpq %gs:8(%rsi), %rdx
  48 + cmpq SEG_PREFIX 8(%rsi), %rdx
43 49 jne not_same
44 50  
45   - movq %rbx, %gs:(%rsi)
46   - movq %rcx, %gs:8(%rsi)
  51 + movq %rbx, SEG_PREFIX(%rsi)
  52 + movq %rcx, SEG_PREFIX 8(%rsi)
47 53  
48 54 popf
49 55 mov $1, %al