|
59 | 59 | #define __force_percpu_prefix "%%"__stringify(__percpu_seg)":"
|
60 | 60 | #define __my_cpu_offset this_cpu_read(this_cpu_off)
|
61 | 61 |
|
62 |
| -#ifdef CONFIG_USE_X86_SEG_SUPPORT |
63 |
| -/* |
64 |
| - * Efficient implementation for cases in which the compiler supports |
65 |
| - * named address spaces. Allows the compiler to perform additional |
66 |
| - * optimizations that can save more instructions. |
67 |
| - */ |
68 |
| -#define arch_raw_cpu_ptr(ptr) \ |
69 |
| -({ \ |
70 |
| - unsigned long tcp_ptr__; \ |
71 |
| - tcp_ptr__ = __raw_cpu_read(, this_cpu_off); \ |
72 |
| - \ |
73 |
| - tcp_ptr__ += (unsigned long)(ptr); \ |
74 |
| - (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \ |
75 |
| -}) |
76 |
| -#else /* CONFIG_USE_X86_SEG_SUPPORT */ |
| 62 | +#ifdef CONFIG_X86_64 |
| 63 | +#define __raw_my_cpu_offset raw_cpu_read_8(this_cpu_off); |
| 64 | +#else |
| 65 | +#define __raw_my_cpu_offset raw_cpu_read_4(this_cpu_off); |
| 66 | +#endif |
| 67 | + |
77 | 68 | /*
|
78 | 69 | * Compared to the generic __my_cpu_offset version, the following
|
79 | 70 | * saves one instruction and avoids clobbering a temp register.
|
| 71 | + * |
| 72 | + * arch_raw_cpu_ptr should not be used in 32-bit VDSO for a 64-bit |
| 73 | + * kernel, because games are played with CONFIG_X86_64 there and |
| 74 | + * sizeof(this_cpu_off) becames 4. |
80 | 75 | */
|
81 |
| -#define arch_raw_cpu_ptr(ptr) \ |
| 76 | +#ifndef BUILD_VDSO32_64 |
| 77 | +#define arch_raw_cpu_ptr(_ptr) \ |
82 | 78 | ({ \
|
83 |
| - unsigned long tcp_ptr__; \ |
84 |
| - asm ("mov " __percpu_arg(1) ", %0" \ |
85 |
| - : "=r" (tcp_ptr__) \ |
86 |
| - : "m" (__my_cpu_var(this_cpu_off))); \ |
87 |
| - \ |
88 |
| - tcp_ptr__ += (unsigned long)(ptr); \ |
89 |
| - (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \ |
| 79 | + unsigned long tcp_ptr__ = __raw_my_cpu_offset; \ |
| 80 | + tcp_ptr__ += (unsigned long)(_ptr); \ |
| 81 | + (typeof(*(_ptr)) __kernel __force *)tcp_ptr__; \ |
90 | 82 | })
|
91 |
| -#endif /* CONFIG_USE_X86_SEG_SUPPORT */ |
| 83 | +#else |
| 84 | +#define arch_raw_cpu_ptr(_ptr) ({ BUILD_BUG(); (typeof(_ptr))0; }) |
| 85 | +#endif |
92 | 86 |
|
93 | 87 | #define PER_CPU_VAR(var) %__percpu_seg:(var)__percpu_rel
|
94 | 88 |
|
|
0 commit comments