blob: 0d53ab4f79c5c3763772eba06adbfe7ec9e24220 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _LINUX_COMPAT_H
2#define _LINUX_COMPAT_H
3/*
4 * These are the type definitions for the architecture specific
5 * syscall compatibility layer.
6 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
8#ifdef CONFIG_COMPAT
9
10#include <linux/stat.h>
11#include <linux/param.h> /* for HZ */
12#include <linux/sem.h>
Arnd Bergmann2dceba12009-11-06 08:09:03 +000013#include <linux/socket.h>
14#include <linux/if.h>
Chris Metcalfbe84cb42011-05-09 13:12:30 -040015#include <linux/fs.h>
Stephen Rothwell45e96832011-05-24 13:28:54 +100016#include <linux/aio_abi.h> /* for aio_context_t */
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18#include <asm/compat.h>
19#include <asm/siginfo.h>
David Howells3f2e05e2006-10-02 14:12:31 +010020#include <asm/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
H. J. Lu45e87782012-02-10 14:04:27 -080022#ifndef COMPAT_USE_64BIT_TIME
23#define COMPAT_USE_64BIT_TIME 0
24#endif
25
Al Viro46836612012-11-23 09:12:59 -050026#ifndef __SC_DELOUSE
27#define __SC_DELOUSE(t,v) ((t)(unsigned long)(v))
28#endif
29
30#define __SC_CCAST1(t1, a1) __SC_DELOUSE(t1,a1)
31#define __SC_CCAST2(t2, a2, ...) __SC_DELOUSE(t2,a2), __SC_CCAST1(__VA_ARGS__)
32#define __SC_CCAST3(t3, a3, ...) __SC_DELOUSE(t3,a3), __SC_CCAST2(__VA_ARGS__)
33#define __SC_CCAST4(t4, a4, ...) __SC_DELOUSE(t4,a4), __SC_CCAST3(__VA_ARGS__)
34#define __SC_CCAST5(t5, a5, ...) __SC_DELOUSE(t5,a5), __SC_CCAST4(__VA_ARGS__)
35#define __SC_CCAST6(t6, a6, ...) __SC_DELOUSE(t6,a6), __SC_CCAST5(__VA_ARGS__)
36#define COMPAT_SYSCALL_DEFINE1(name, ...) \
37 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
38#define COMPAT_SYSCALL_DEFINE2(name, ...) \
39 COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
40#define COMPAT_SYSCALL_DEFINE3(name, ...) \
41 COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
42#define COMPAT_SYSCALL_DEFINE4(name, ...) \
43 COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
44#define COMPAT_SYSCALL_DEFINE5(name, ...) \
45 COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
46#define COMPAT_SYSCALL_DEFINE6(name, ...) \
47 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
48
49#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
50
51#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
52 asmlinkage long compat_sys##name(__SC_DECL##x(__VA_ARGS__)); \
53 static inline long C_SYSC##name(__SC_DECL##x(__VA_ARGS__)); \
54 asmlinkage long compat_SyS##name(__SC_LONG##x(__VA_ARGS__)) \
55 { \
56 return (long) C_SYSC##name(__SC_CCAST##x(__VA_ARGS__)); \
57 } \
58 SYSCALL_ALIAS(compat_sys##name, compat_SyS##name); \
59 static inline long C_SYSC##name(__SC_DECL##x(__VA_ARGS__))
60
61#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
62
63#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
64 asmlinkage long compat_sys##name(__SC_DECL##x(__VA_ARGS__))
65
66#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
67
Al Viro9b064fc2012-12-14 13:49:35 -050068#ifndef compat_user_stack_pointer
69#define compat_user_stack_pointer() current_user_stack_pointer()
70#endif
Al Viro90268432012-12-14 14:47:53 -050071#ifdef CONFIG_GENERIC_SIGALTSTACK
72#ifndef compat_sigaltstack /* we'll need that for MIPS */
73typedef struct compat_sigaltstack {
74 compat_uptr_t ss_sp;
75 int ss_flags;
76 compat_size_t ss_size;
77} compat_stack_t;
78#endif
79#endif
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#define compat_jiffies_to_clock_t(x) \
82 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
83
Stephen Rothwell202e5972005-09-06 15:16:40 -070084typedef __compat_uid32_t compat_uid_t;
85typedef __compat_gid32_t compat_gid_t;
86
Christoph Hellwig5d0e5282010-03-10 15:21:13 -080087struct compat_sel_arg_struct;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088struct rusage;
89
Chris Metcalf4800a5b2011-05-17 14:41:06 -040090struct compat_itimerspec {
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 struct compat_timespec it_interval;
92 struct compat_timespec it_value;
93};
94
95struct compat_utimbuf {
96 compat_time_t actime;
97 compat_time_t modtime;
98};
99
100struct compat_itimerval {
101 struct compat_timeval it_interval;
102 struct compat_timeval it_value;
103};
104
105struct compat_tms {
106 compat_clock_t tms_utime;
107 compat_clock_t tms_stime;
108 compat_clock_t tms_cutime;
109 compat_clock_t tms_cstime;
110};
111
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800112struct compat_timex {
113 compat_uint_t modes;
114 compat_long_t offset;
115 compat_long_t freq;
116 compat_long_t maxerror;
117 compat_long_t esterror;
118 compat_int_t status;
119 compat_long_t constant;
120 compat_long_t precision;
121 compat_long_t tolerance;
122 struct compat_timeval time;
123 compat_long_t tick;
124 compat_long_t ppsfreq;
125 compat_long_t jitter;
126 compat_int_t shift;
127 compat_long_t stabil;
128 compat_long_t jitcnt;
129 compat_long_t calcnt;
130 compat_long_t errcnt;
131 compat_long_t stbcnt;
Roman Zippel153b5d02008-05-01 04:34:37 -0700132 compat_int_t tai;
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800133
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400134 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
135 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
136 compat_int_t:32; compat_int_t:32; compat_int_t:32;
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800137};
138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
140
141typedef struct {
142 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
143} compat_sigset_t;
144
Al Viro08d32fe2012-12-25 18:38:15 -0500145#ifdef CONFIG_GENERIC_COMPAT_RT_SIGACTION
146struct compat_sigaction {
147#ifndef __ARCH_HAS_ODD_SIGACTION
148 compat_uptr_t sa_handler;
149 compat_ulong_t sa_flags;
150#else
151 compat_ulong_t sa_flags;
152 compat_uptr_t sa_handler;
153#endif
154#ifdef __ARCH_HAS_SA_RESTORER
155 compat_uptr_t sa_restorer;
156#endif
157 compat_sigset_t sa_mask __packed;
158};
159#endif
160
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800161/*
162 * These functions operate strictly on struct compat_time*
163 */
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400164extern int get_compat_timespec(struct timespec *,
165 const struct compat_timespec __user *);
166extern int put_compat_timespec(const struct timespec *,
167 struct compat_timespec __user *);
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800168extern int get_compat_timeval(struct timeval *,
169 const struct compat_timeval __user *);
170extern int put_compat_timeval(const struct timeval *,
171 struct compat_timeval __user *);
172/*
173 * These functions operate on 32- or 64-bit specs depending on
174 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments and the
175 * naming as compat_get/put_ rather than get/put_compat_.
176 */
177extern int compat_get_timespec(struct timespec *, const void __user *);
178extern int compat_put_timespec(const struct timespec *, void __user *);
179extern int compat_get_timeval(struct timeval *, const void __user *);
180extern int compat_put_timeval(const struct timeval *, void __user *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
182struct compat_iovec {
183 compat_uptr_t iov_base;
184 compat_size_t iov_len;
185};
186
187struct compat_rlimit {
188 compat_ulong_t rlim_cur;
189 compat_ulong_t rlim_max;
190};
191
192struct compat_rusage {
193 struct compat_timeval ru_utime;
194 struct compat_timeval ru_stime;
195 compat_long_t ru_maxrss;
196 compat_long_t ru_ixrss;
197 compat_long_t ru_idrss;
198 compat_long_t ru_isrss;
199 compat_long_t ru_minflt;
200 compat_long_t ru_majflt;
201 compat_long_t ru_nswap;
202 compat_long_t ru_inblock;
203 compat_long_t ru_oublock;
204 compat_long_t ru_msgsnd;
205 compat_long_t ru_msgrcv;
206 compat_long_t ru_nsignals;
207 compat_long_t ru_nvcsw;
208 compat_long_t ru_nivcsw;
209};
210
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400211extern int put_compat_rusage(const struct rusage *,
212 struct compat_rusage __user *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214struct compat_siginfo;
215
216extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
217 struct compat_siginfo __user *, int,
218 struct compat_rusage __user *);
219
220struct compat_dirent {
221 u32 d_ino;
222 compat_off_t d_off;
223 u16 d_reclen;
224 char d_name[256];
225};
226
Christoph Hellwig2b1c6bd2008-11-28 10:09:09 +0100227struct compat_ustat {
228 compat_daddr_t f_tfree;
229 compat_ino_t f_tinode;
230 char f_fname[6];
231 char f_fpack[6];
232};
233
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234#define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
235
236typedef struct compat_sigevent {
237 compat_sigval_t sigev_value;
238 compat_int_t sigev_signo;
239 compat_int_t sigev_notify;
240 union {
241 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
242 compat_int_t _tid;
243
244 struct {
245 compat_uptr_t _function;
246 compat_uptr_t _attribute;
247 } _sigev_thread;
248 } _sigev_un;
249} compat_sigevent_t;
250
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000251struct compat_ifmap {
252 compat_ulong_t mem_start;
253 compat_ulong_t mem_end;
254 unsigned short base_addr;
255 unsigned char irq;
256 unsigned char dma;
257 unsigned char port;
258};
259
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400260struct compat_if_settings {
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800261 unsigned int type; /* Type of physical device or protocol */
262 unsigned int size; /* Size of the data allocated by the caller */
263 compat_uptr_t ifs_ifsu; /* union of pointers */
264};
265
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000266struct compat_ifreq {
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800267 union {
268 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
269 } ifr_ifrn;
270 union {
271 struct sockaddr ifru_addr;
272 struct sockaddr ifru_dstaddr;
273 struct sockaddr ifru_broadaddr;
274 struct sockaddr ifru_netmask;
275 struct sockaddr ifru_hwaddr;
276 short ifru_flags;
277 compat_int_t ifru_ivalue;
278 compat_int_t ifru_mtu;
279 struct compat_ifmap ifru_map;
280 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000281 char ifru_newname[IFNAMSIZ];
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800282 compat_caddr_t ifru_data;
283 struct compat_if_settings ifru_settings;
284 } ifr_ifru;
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000285};
286
287struct compat_ifconf {
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400288 compat_int_t ifc_len; /* size of buffer */
289 compat_caddr_t ifcbuf;
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000290};
291
Ingo Molnar34f192c2006-03-27 01:16:24 -0800292struct compat_robust_list {
293 compat_uptr_t next;
294};
295
296struct compat_robust_list_head {
297 struct compat_robust_list list;
298 compat_long_t futex_offset;
299 compat_uptr_t list_op_pending;
300};
301
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400302struct compat_statfs;
303struct compat_statfs64;
304struct compat_old_linux_dirent;
305struct compat_linux_dirent;
306struct linux_dirent64;
307struct compat_msghdr;
308struct compat_mmsghdr;
309struct compat_sysinfo;
310struct compat_sysctl_args;
311struct compat_kexec_segment;
312struct compat_mq_attr;
Chris Metcalf48b25c42012-03-15 13:13:38 -0400313struct compat_msgbuf;
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400314
Ingo Molnar34f192c2006-03-27 01:16:24 -0800315extern void compat_exit_robust_list(struct task_struct *curr);
316
317asmlinkage long
318compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
319 compat_size_t len);
320asmlinkage long
Al Viroba46df92006-10-10 22:46:07 +0100321compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
Ingo Molnar34f192c2006-03-27 01:16:24 -0800322 compat_size_t __user *len_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
Chris Metcalf48b25c42012-03-15 13:13:38 -0400324#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325long compat_sys_semctl(int first, int second, int third, void __user *uptr);
326long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
327long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
328 int version, void __user *uptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
330 void __user *uptr);
Chris Metcalf48b25c42012-03-15 13:13:38 -0400331#else
332long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
333long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
Will Deacon05ba3f12012-07-30 14:42:43 -0700334 compat_ssize_t msgsz, int msgflg);
Chris Metcalf48b25c42012-03-15 13:13:38 -0400335long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
Will Deacon05ba3f12012-07-30 14:42:43 -0700336 compat_ssize_t msgsz, long msgtyp, int msgflg);
Chris Metcalf48b25c42012-03-15 13:13:38 -0400337long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
338#endif
339long compat_sys_msgctl(int first, int second, void __user *uptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340long compat_sys_shmctl(int first, int second, void __user *uptr);
341long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
342 unsigned nsems, const struct compat_timespec __user *timeout);
343asmlinkage long compat_sys_keyctl(u32 option,
344 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
Christoph Hellwig2b1c6bd2008-11-28 10:09:09 +0100345asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347asmlinkage ssize_t compat_sys_readv(unsigned long fd,
348 const struct compat_iovec __user *vec, unsigned long vlen);
349asmlinkage ssize_t compat_sys_writev(unsigned long fd,
350 const struct compat_iovec __user *vec, unsigned long vlen);
Gerd Hoffmannf3554f42009-04-02 16:59:23 -0700351asmlinkage ssize_t compat_sys_preadv(unsigned long fd,
352 const struct compat_iovec __user *vec,
Linus Torvalds601cc11d2009-04-03 08:03:22 -0700353 unsigned long vlen, u32 pos_low, u32 pos_high);
Gerd Hoffmannf3554f42009-04-02 16:59:23 -0700354asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
355 const struct compat_iovec __user *vec,
Linus Torvalds601cc11d2009-04-03 08:03:22 -0700356 unsigned long vlen, u32 pos_low, u32 pos_high);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
Al Viro38b983b2012-09-30 13:38:55 -0400358asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
359 const compat_uptr_t __user *envp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360
361asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
362 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
363 struct compat_timeval __user *tvp);
364
Christoph Hellwig5d0e5282010-03-10 15:21:13 -0800365asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
366
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100367asmlinkage long compat_sys_wait4(compat_pid_t pid,
Al Viro7d61c452008-03-29 03:09:28 +0000368 compat_uint_t __user *stat_addr, int options,
369 struct compat_rusage __user *ru);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
372
373#define BITS_TO_COMPAT_LONGS(bits) \
374 (((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
375
Stephen Rothwell5fa38392006-10-28 10:38:46 -0700376long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 unsigned long bitmap_size);
378long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
379 unsigned long bitmap_size);
380int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
381int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
382int get_compat_sigevent(struct sigevent *event,
383 const struct compat_sigevent __user *u_event);
Thomas Gleixner62ab4502009-04-04 21:01:06 +0000384long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
385 struct compat_siginfo __user *uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386
Andrew Morton643a6542006-02-11 17:55:52 -0800387static inline int compat_timeval_compare(struct compat_timeval *lhs,
388 struct compat_timeval *rhs)
389{
390 if (lhs->tv_sec < rhs->tv_sec)
391 return -1;
392 if (lhs->tv_sec > rhs->tv_sec)
393 return 1;
394 return lhs->tv_usec - rhs->tv_usec;
395}
396
397static inline int compat_timespec_compare(struct compat_timespec *lhs,
398 struct compat_timespec *rhs)
399{
400 if (lhs->tv_sec < rhs->tv_sec)
401 return -1;
402 if (lhs->tv_sec > rhs->tv_sec)
403 return 1;
404 return lhs->tv_nsec - rhs->tv_nsec;
405}
406
Davide Libenzi83f5d122007-05-10 22:23:18 -0700407extern int get_compat_itimerspec(struct itimerspec *dst,
408 const struct compat_itimerspec __user *src);
409extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
410 const struct itimerspec *src);
411
Christoph Hellwigb418da12008-10-15 22:02:06 -0700412asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
413 struct timezone __user *tz);
414asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
415 struct timezone __user *tz);
416
Stephen Rothwell3158e942006-03-26 01:37:29 -0800417asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
418
Andi Kleenbebfa102006-06-26 13:56:52 +0200419extern int compat_printk(const char *fmt, ...);
Al Viro322a56c2012-12-25 13:32:58 -0500420extern void sigset_from_compat(sigset_t *set, const compat_sigset_t *compat);
421extern void sigset_to_compat(compat_sigset_t *compat, const sigset_t *set);
Andi Kleenbebfa102006-06-26 13:56:52 +0200422
Stephen Rothwell3fd59392006-11-02 22:07:24 -0800423asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
424 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
425 const compat_ulong_t __user *new_nodes);
426
Roland McGrath032d82d2008-01-30 13:31:47 +0100427extern int compat_ptrace_request(struct task_struct *child,
428 compat_long_t request,
429 compat_ulong_t addr, compat_ulong_t data);
430
Roland McGrathc269f192008-01-30 13:31:48 +0100431extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
432 compat_ulong_t addr, compat_ulong_t data);
433asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
434 compat_long_t addr, compat_long_t data);
Roland McGrathc269f192008-01-30 13:31:48 +0100435
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800436/*
437 * epoll (fs/eventpoll.c) compat bits follow ...
438 */
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800439struct epoll_event;
440#define compat_epoll_event epoll_event
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800441asmlinkage long compat_sys_epoll_pwait(int epfd,
442 struct compat_epoll_event __user *events,
443 int maxevents, int timeout,
444 const compat_sigset_t __user *sigmask,
445 compat_size_t sigsetsize);
446
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400447asmlinkage long compat_sys_utime(const char __user *filename,
448 struct compat_utimbuf __user *t);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400449asmlinkage long compat_sys_utimensat(unsigned int dfd,
450 const char __user *filename,
451 struct compat_timespec __user *t,
452 int flags);
Stephen Rothwell97416ce2007-05-09 02:32:35 -0700453
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400454asmlinkage long compat_sys_time(compat_time_t __user *tloc);
455asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
Stephen Rothwell140ff8b2007-05-14 13:47:47 +1000456asmlinkage long compat_sys_signalfd(int ufd,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400457 const compat_sigset_t __user *sigmask,
458 compat_size_t sigsetsize);
Davide Libenzi4d672e72008-02-04 22:27:26 -0800459asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
460 const struct compat_itimerspec __user *utmr,
461 struct compat_itimerspec __user *otmr);
462asmlinkage long compat_sys_timerfd_gettime(int ufd,
463 struct compat_itimerspec __user *otmr);
Stephen Rothwell140ff8b2007-05-14 13:47:47 +1000464
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100465asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
466 __u32 __user *pages,
467 const int __user *nodes,
468 int __user *status,
469 int flags);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400470asmlinkage long compat_sys_futimesat(unsigned int dfd,
471 const char __user *filename,
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100472 struct compat_timeval __user *t);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400473asmlinkage long compat_sys_utimes(const char __user *filename,
474 struct compat_timeval __user *t);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400475asmlinkage long compat_sys_newstat(const char __user *filename,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400476 struct compat_stat __user *statbuf);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400477asmlinkage long compat_sys_newlstat(const char __user *filename,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400478 struct compat_stat __user *statbuf);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400479asmlinkage long compat_sys_newfstatat(unsigned int dfd,
480 const char __user *filename,
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100481 struct compat_stat __user *statbuf,
482 int flag);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400483asmlinkage long compat_sys_newfstat(unsigned int fd,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400484 struct compat_stat __user *statbuf);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400485asmlinkage long compat_sys_statfs(const char __user *pathname,
486 struct compat_statfs __user *buf);
487asmlinkage long compat_sys_fstatfs(unsigned int fd,
488 struct compat_statfs __user *buf);
489asmlinkage long compat_sys_statfs64(const char __user *pathname,
490 compat_size_t sz,
491 struct compat_statfs64 __user *buf);
492asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
493 struct compat_statfs64 __user *buf);
494asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
495 unsigned long arg);
496asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
497 unsigned long arg);
498asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
499asmlinkage long compat_sys_io_getevents(aio_context_t ctx_id,
500 unsigned long min_nr,
501 unsigned long nr,
502 struct io_event __user *events,
503 struct compat_timespec __user *timeout);
504asmlinkage long compat_sys_io_submit(aio_context_t ctx_id, int nr,
505 u32 __user *iocb);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400506asmlinkage long compat_sys_mount(const char __user *dev_name,
507 const char __user *dir_name,
508 const char __user *type, unsigned long flags,
509 const void __user *data);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400510asmlinkage long compat_sys_old_readdir(unsigned int fd,
511 struct compat_old_linux_dirent __user *,
512 unsigned int count);
513asmlinkage long compat_sys_getdents(unsigned int fd,
514 struct compat_linux_dirent __user *dirent,
515 unsigned int count);
516asmlinkage long compat_sys_getdents64(unsigned int fd,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400517 struct linux_dirent64 __user *dirent,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400518 unsigned int count);
519asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
520 unsigned int nr_segs, unsigned int flags);
521asmlinkage long compat_sys_open(const char __user *filename, int flags,
Al Viroa218d0f2011-11-21 14:59:34 -0500522 umode_t mode);
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100523asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
Al Viroa218d0f2011-11-21 14:59:34 -0500524 int flags, umode_t mode);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400525asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
526 struct file_handle __user *handle,
527 int flags);
528asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
529 compat_ulong_t __user *outp,
530 compat_ulong_t __user *exp,
531 struct compat_timespec __user *tsp,
532 void __user *sig);
533asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
534 unsigned int nfds,
535 struct compat_timespec __user *tsp,
536 const compat_sigset_t __user *sigmask,
537 compat_size_t sigsetsize);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400538asmlinkage long compat_sys_signalfd4(int ufd,
539 const compat_sigset_t __user *sigmask,
540 compat_size_t sigsetsize, int flags);
541asmlinkage long compat_sys_get_mempolicy(int __user *policy,
542 compat_ulong_t __user *nmask,
543 compat_ulong_t maxnode,
544 compat_ulong_t addr,
545 compat_ulong_t flags);
546asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
547 compat_ulong_t maxnode);
548asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
549 compat_ulong_t mode,
550 compat_ulong_t __user *nmask,
551 compat_ulong_t maxnode, compat_ulong_t flags);
552
553asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
554 char __user *optval, unsigned int optlen);
555asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
556 unsigned flags);
Chris Metcalf507c5f12011-06-27 16:18:07 -0700557asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
558 unsigned vlen, unsigned int flags);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400559asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
560 unsigned int flags);
561asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len,
562 unsigned flags);
563asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
564 unsigned flags, struct sockaddr __user *addr,
565 int __user *addrlen);
566asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
567 unsigned vlen, unsigned int flags,
568 struct compat_timespec __user *timeout);
569asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
570 struct compat_timespec __user *rmtp);
571asmlinkage long compat_sys_getitimer(int which,
572 struct compat_itimerval __user *it);
573asmlinkage long compat_sys_setitimer(int which,
574 struct compat_itimerval __user *in,
575 struct compat_itimerval __user *out);
576asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
577asmlinkage long compat_sys_setrlimit(unsigned int resource,
578 struct compat_rlimit __user *rlim);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400579asmlinkage long compat_sys_getrlimit(unsigned int resource,
580 struct compat_rlimit __user *rlim);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400581asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
582asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
583 unsigned int len,
584 compat_ulong_t __user *user_mask_ptr);
585asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
586 unsigned int len,
587 compat_ulong_t __user *user_mask_ptr);
588asmlinkage long compat_sys_timer_create(clockid_t which_clock,
589 struct compat_sigevent __user *timer_event_spec,
590 timer_t __user *created_timer_id);
591asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
592 struct compat_itimerspec __user *new,
593 struct compat_itimerspec __user *old);
594asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
595 struct compat_itimerspec __user *setting);
596asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
597 struct compat_timespec __user *tp);
598asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
599 struct compat_timespec __user *tp);
600asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
601 struct compat_timex __user *tp);
602asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
603 struct compat_timespec __user *tp);
604asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
605 struct compat_timespec __user *rqtp,
606 struct compat_timespec __user *rmtp);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400607asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400608 struct compat_siginfo __user *uinfo,
609 struct compat_timespec __user *uts, compat_size_t sigsetsize);
610asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
611 compat_size_t sigsetsize);
Al Viro322a56c2012-12-25 13:32:58 -0500612#ifdef CONFIG_GENERIC_COMPAT_RT_SIGPROCMASK
613asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set,
614 compat_sigset_t __user *oset,
615 compat_size_t sigsetsize);
616#endif
Al Virofe9c1db2012-12-25 14:31:38 -0500617#ifdef CONFIG_GENERIC_COMPAT_RT_SIGPENDING
618asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
619 compat_size_t sigsetsize);
620#endif
Al Viro08d32fe2012-12-25 18:38:15 -0500621#ifndef CONFIG_ODD_RT_SIGACTION
622#ifdef CONFIG_GENERIC_COMPAT_RT_SIGACTION
623asmlinkage long compat_sys_rt_sigaction(int,
624 const struct compat_sigaction __user *,
625 struct compat_sigaction __user *,
626 compat_size_t);
627#endif
628#endif
Al Viro75907d42012-12-25 15:19:12 -0500629#ifdef CONFIG_GENERIC_COMPAT_RT_SIGQUEUEINFO
630asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
631 struct compat_siginfo __user *uinfo);
632#endif
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400633asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
634asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
635 unsigned long arg);
636asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
637 struct compat_timespec __user *utime, u32 __user *uaddr2,
638 u32 val3);
639asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
640 char __user *optval, int __user *optlen);
641asmlinkage long compat_sys_kexec_load(unsigned long entry,
642 unsigned long nr_segments,
643 struct compat_kexec_segment __user *,
644 unsigned long flags);
645asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
646 const struct compat_mq_attr __user *u_mqstat,
647 struct compat_mq_attr __user *u_omqstat);
648asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
649 const struct compat_sigevent __user *u_notification);
650asmlinkage long compat_sys_mq_open(const char __user *u_name,
651 int oflag, compat_mode_t mode,
652 struct compat_mq_attr __user *u_attr);
653asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
654 const char __user *u_msg_ptr,
655 size_t msg_len, unsigned int msg_prio,
656 const struct compat_timespec __user *u_abs_timeout);
657asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
658 char __user *u_msg_ptr,
659 size_t msg_len, unsigned int __user *u_msg_prio,
660 const struct compat_timespec __user *u_abs_timeout);
661asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
662asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100663
Jeff Moyerb8373362010-05-26 14:44:25 -0700664extern ssize_t compat_rw_copy_check_uvector(int type,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400665 const struct compat_iovec __user *uvector,
666 unsigned long nr_segs,
Jeff Moyerb8373362010-05-26 14:44:25 -0700667 unsigned long fast_segs, struct iovec *fast_pointer,
Christopher Yeohac34ebb2012-05-31 16:26:42 -0700668 struct iovec **ret_pointer);
H. Peter Anvinc41d68a2010-09-07 16:16:18 -0700669
670extern void __user *compat_alloc_user_space(unsigned long len);
671
Chris Metcalfa67ba432011-12-01 12:54:31 -0500672asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid,
673 const struct compat_iovec __user *lvec,
674 unsigned long liovcnt, const struct compat_iovec __user *rvec,
675 unsigned long riovcnt, unsigned long flags);
676asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
677 const struct compat_iovec __user *lvec,
678 unsigned long liovcnt, const struct compat_iovec __user *rvec,
679 unsigned long riovcnt, unsigned long flags);
680
Catalin Marinas8f9c0112012-09-19 12:01:52 +0100681asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
682 compat_off_t __user *offset, compat_size_t count);
Al Viro90268432012-12-14 14:47:53 -0500683#ifdef CONFIG_GENERIC_SIGALTSTACK
684asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
685 compat_stack_t __user *uoss_ptr);
686
687int compat_restore_altstack(const compat_stack_t __user *uss);
Al Viroc40702c2012-11-20 14:24:26 -0500688int __compat_save_altstack(compat_stack_t __user *, unsigned long);
Al Viro90268432012-12-14 14:47:53 -0500689#endif
Catalin Marinas8f9c0112012-09-19 12:01:52 +0100690
Catalin Marinas0ad50c32012-12-17 16:01:45 -0800691asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
692 struct compat_timespec __user *interval);
693
Linus Torvalds3c761ea2012-02-26 09:44:55 -0800694#else
695
696#define is_compat_task() (0)
697
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698#endif /* CONFIG_COMPAT */
699#endif /* _LINUX_COMPAT_H */