1
2
3
4
5
6 #ifndef _ASM_X86_SYSCALL_WRAPPER_H
7 #define _ASM_X86_SYSCALL_WRAPPER_H
8
9 struct pt_regs;
10
11
12 #define SC_X86_64_REGS_TO_ARGS(x, ...) \
13 __MAP(x,__SC_ARGS \
14 ,,regs->di,,regs->si,,regs->dx \
15 ,,regs->r10,,regs->r8,,regs->r9) \
16
17
18 #define SC_IA32_REGS_TO_ARGS(x, ...) \
19 __MAP(x,__SC_ARGS \
20 ,,(unsigned int)regs->bx,,(unsigned int)regs->cx \
21 ,,(unsigned int)regs->dx,,(unsigned int)regs->si \
22 ,,(unsigned int)regs->di,,(unsigned int)regs->bp)
23
24 #ifdef CONFIG_IA32_EMULATION
25
26
27
28
29
30
31
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
41 #define __IA32_COMPAT_SYS_STUBx(x, name, ...) \
42 asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs);\
43 ALLOW_ERROR_INJECTION(__ia32_compat_sys##name, ERRNO); \
44 asmlinkage long __ia32_compat_sys##name(const struct pt_regs *regs)\
45 { \
46 return __se_compat_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
47 }
48
49 #define __IA32_SYS_STUBx(x, name, ...) \
50 asmlinkage long __ia32_sys##name(const struct pt_regs *regs); \
51 ALLOW_ERROR_INJECTION(__ia32_sys##name, ERRNO); \
52 asmlinkage long __ia32_sys##name(const struct pt_regs *regs) \
53 { \
54 return __se_sys##name(SC_IA32_REGS_TO_ARGS(x,__VA_ARGS__));\
55 }
56
57
58
59
60
61
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 }
78
79 #define SYS_NI(name) \
80 SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \
81 SYSCALL_ALIAS(__ia32_sys_##name, sys_ni_posix_timers)
82
83 #else
84 #define __IA32_COMPAT_SYS_STUBx(x, name, ...)
85 #define __IA32_SYS_STUBx(x, fullname, name, ...)
86 #endif
87
88
89 #ifdef CONFIG_X86_X32
90
91
92
93
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
103 #define __X32_COMPAT_SYS_STUBx(x, name, ...) \
104 asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs);\
105 ALLOW_ERROR_INJECTION(__x32_compat_sys##name, ERRNO); \
106 asmlinkage long __x32_compat_sys##name(const struct pt_regs *regs)\
107 { \
108 return __se_compat_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
109 }
110
111 #else
112 #define __X32_COMPAT_SYS_STUB0(x, name)
113 #define __X32_COMPAT_SYS_STUBx(x, name, ...)
114 #endif
115
116
117 #ifdef CONFIG_COMPAT
118
119
120
121
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
134 #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
135 static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
136 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
137 __IA32_COMPAT_SYS_STUBx(x, name, __VA_ARGS__) \
138 __X32_COMPAT_SYS_STUBx(x, name, __VA_ARGS__) \
139 static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
140 { \
141 return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
142 } \
143 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
144
145
146
147
148
149
150 #define COND_SYSCALL_COMPAT(name) \
151 cond_syscall(__ia32_compat_sys_##name); \
152 cond_syscall(__x32_compat_sys_##name)
153
154 #define COMPAT_SYS_NI(name) \
155 SYSCALL_ALIAS(__ia32_compat_sys_##name, sys_ni_posix_timers); \
156 SYSCALL_ALIAS(__x32_compat_sys_##name, sys_ni_posix_timers)
157
158 #endif
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194 #define __SYSCALL_DEFINEx(x, name, ...) \
195 asmlinkage long __x64_sys##name(const struct pt_regs *regs); \
196 ALLOW_ERROR_INJECTION(__x64_sys##name, ERRNO); \
197 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
198 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
199 asmlinkage long __x64_sys##name(const struct pt_regs *regs) \
200 { \
201 return __se_sys##name(SC_X86_64_REGS_TO_ARGS(x,__VA_ARGS__));\
202 } \
203 __IA32_SYS_STUBx(x, name, __VA_ARGS__) \
204 static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
205 { \
206 long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
207 __MAP(x,__SC_TEST,__VA_ARGS__); \
208 __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \
209 return ret; \
210 } \
211 static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
212
213
214
215
216
217
218
219
220 #ifndef SYSCALL_DEFINE0
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)
226 #endif
227
228 #ifndef COND_SYSCALL
229 #define COND_SYSCALL(name) \
230 asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \
231 { \
232 return sys_ni_syscall(); \
233 }
234 #endif
235
236 #ifndef SYS_NI
237 #define SYS_NI(name) SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers);
238 #endif
239
240
241
242
243
244
245 asmlinkage long __x64_sys_getcpu(const struct pt_regs *regs);
246 asmlinkage long __x64_sys_gettimeofday(const struct pt_regs *regs);
247 asmlinkage long __x64_sys_time(const struct pt_regs *regs);
248
249 #endif