|
6 | 6 | #ifndef _ASM_X86_SYSCALL_WRAPPER_H
|
7 | 7 | #define _ASM_X86_SYSCALL_WRAPPER_H
|
8 | 8 |
|
| 9 | +struct pt_regs; |
| 10 | + |
9 | 11 | /* Mapping of registers to parameters for syscalls on x86-64 and x32 */
|
10 | 12 | #define SC_X86_64_REGS_TO_ARGS(x, ...) \
|
11 | 13 | __MAP(x,__SC_ARGS \
|
|
28 | 30 | * kernel/sys_ni.c and SYS_NI in kernel/time/posix-stubs.c to cover this
|
29 | 31 | * case as well.
|
30 | 32 | */
|
| 33 | +#define __IA32_COMPAT_SYS_STUB0(x, name) \ |
| 34 | + asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs);\ |
| 35 | + ALLOW_ERROR_INJECTION(__ia32_compat_sys_##name, ERRNO); \ |
| 36 | + asmlinkage long __ia32_compat_sys_##name(const struct pt_regs *regs)\ |
| 37 | + { \ |
| 38 | + return __se_compat_sys_##name(); \ |
| 39 | + } |
| 40 | + |
31 | 41 | #define __IA32_COMPAT_SYS_STUBx(x, name, ...) \
|
32 | 42 | asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs);\
|
33 | 43 | ALLOW_ERROR_INJECTION(__ia32_compat_sys##name, ERRNO); \
|
34 | 44 | asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs)\
|
35 | 45 | { \
|
36 | 46 | return __se_compat_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
|
37 |
| - } \ |
| 47 | + } |
38 | 48 |
|
39 | 49 | #define __IA32_SYS_STUBx(x, name, ...) \
|
40 | 50 | asmlinkage long __ia32_sys##name(const struct pt_regs *regs); \
|
|
48 | 58 | * To keep the naming coherent, re-define SYSCALL_DEFINE0 to create an alias
|
49 | 59 | * named __ia32_sys_*()
|
50 | 60 | */
|
51 |
| -#define SYSCALL_DEFINE0(sname) \ |
52 |
| - SYSCALL_METADATA(_##sname, 0); \ |
53 |
| - asmlinkage long __x64_sys_##sname(void); \ |
54 |
| - ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ |
55 |
| - SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \ |
56 |
| - asmlinkage long __x64_sys_##sname(void) |
57 | 61 |
|
58 |
| -#define COND_SYSCALL(name) \ |
59 |
| - cond_syscall(__x64_sys_##name); \ |
60 |
| - cond_syscall(__ia32_sys_##name) |
| 62 | +#define SYSCALL_DEFINE0(sname) \ |
| 63 | + SYSCALL_METADATA(_##sname, 0); \ |
| 64 | + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\ |
| 65 | + ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ |
| 66 | + SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \ |
| 67 | + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused) |
| 68 | + |
| 69 | +#define COND_SYSCALL(name) \ |
| 70 | + asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ |
| 71 | + { \ |
| 72 | + return sys_ni_syscall(); \ |
| 73 | + } \ |
| 74 | + asmlinkage __weak long __ia32_sys_##name(const struct pt_regs *__unused)\ |
| 75 | + { \ |
| 76 | + return sys_ni_syscall(); \ |
| 77 | + } |
61 | 78 |
|
62 | 79 | #define SYS_NI(name) \
|
63 | 80 | SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \
|
|
75 | 92 | * of the x86-64-style parameter ordering of x32 syscalls. The syscalls common
|
76 | 93 | * with x86_64 obviously do not need such care.
|
77 | 94 | */
|
| 95 | +#define __X32_COMPAT_SYS_STUB0(x, name, ...) \ |
| 96 | + asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs);\ |
| 97 | + ALLOW_ERROR_INJECTION(__x32_compat_sys_##name, ERRNO); \ |
| 98 | + asmlinkage long __x32_compat_sys_##name(const struct pt_regs *regs)\ |
| 99 | + { \ |
| 100 | + return __se_compat_sys_##name();\ |
| 101 | + } |
| 102 | + |
78 | 103 | #define __X32_COMPAT_SYS_STUBx(x, name, ...) \
|
79 | 104 | asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs);\
|
80 | 105 | ALLOW_ERROR_INJECTION(__x32_compat_sys##name, ERRNO); \
|
81 | 106 | asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs)\
|
82 | 107 | { \
|
83 | 108 | return __se_compat_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
|
84 |
| - } \ |
| 109 | + } |
85 | 110 |
|
86 | 111 | #else /* CONFIG_X86_X32 */
|
| 112 | +#define __X32_COMPAT_SYS_STUB0(x, name) |
87 | 113 | #define __X32_COMPAT_SYS_STUBx(x, name, ...)
|
88 | 114 | #endif /* CONFIG_X86_X32 */
|
89 | 115 |
|
|
94 | 120 | * mapping of registers to parameters, we need to generate stubs for each
|
95 | 121 | * of them.
|
96 | 122 | */
|
| 123 | +#define COMPAT_SYSCALL_DEFINE0(name) \ |
| 124 | + static long __se_compat_sys_##name(void); \ |
| 125 | + static inline long __do_compat_sys_##name(void); \ |
| 126 | + __IA32_COMPAT_SYS_STUB0(x, name) \ |
| 127 | + __X32_COMPAT_SYS_STUB0(x, name) \ |
| 128 | + static long __se_compat_sys_##name(void) \ |
| 129 | + { \ |
| 130 | + return __do_compat_sys_##name(); \ |
| 131 | + } \ |
| 132 | + static inline long __do_compat_sys_##name(void) |
| 133 | + |
97 | 134 | #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
|
98 | 135 | static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
|
99 | 136 | static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
|
|
181 | 218 | * macros to work correctly.
|
182 | 219 | */
|
183 | 220 | #ifndef SYSCALL_DEFINE0
|
184 |
| -#define SYSCALL_DEFINE0(sname) \ |
185 |
| - SYSCALL_METADATA(_##sname, 0); \ |
186 |
| - asmlinkage long __x64_sys_##sname(void); \ |
187 |
| - ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ |
188 |
| - asmlinkage long __x64_sys_##sname(void) |
| 221 | +#define SYSCALL_DEFINE0(sname) \ |
| 222 | + SYSCALL_METADATA(_##sname, 0); \ |
| 223 | + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused);\ |
| 224 | + ALLOW_ERROR_INJECTION(__x64_sys_##sname, ERRNO); \ |
| 225 | + asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused) |
189 | 226 | #endif
|
190 | 227 |
|
191 | 228 | #ifndef COND_SYSCALL
|
192 |
| -#define COND_SYSCALL(name) cond_syscall(__x64_sys_##name) |
| 229 | +#define COND_SYSCALL(name) \ |
| 230 | + asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ |
| 231 | + { \ |
| 232 | + return sys_ni_syscall(); \ |
| 233 | + } |
193 | 234 | #endif
|
194 | 235 |
|
195 | 236 | #ifndef SYS_NI
|
|
201 | 242 | * For VSYSCALLS, we need to declare these three syscalls with the new
|
202 | 243 | * pt_regs-based calling convention for in-kernel use.
|
203 | 244 | */
|
204 |
| -struct pt_regs; |
205 | 245 | asmlinkage long __x64_sys_getcpu(const struct pt_regs *regs);
|
206 | 246 | asmlinkage long __x64_sys_gettimeofday(const struct pt_regs *regs);
|
207 | 247 | asmlinkage long __x64_sys_time(const struct pt_regs *regs);
|
|
0 commit comments