Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
compat.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Tilera Corporation. All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation, version 2.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11  * NON INFRINGEMENT. See the GNU General Public License for
12  * more details.
13  */
14 
15 #ifndef _ASM_TILE_COMPAT_H
16 #define _ASM_TILE_COMPAT_H
17 
18 /*
19  * Architecture specific compatibility types
20  */
21 #include <linux/types.h>
22 #include <linux/sched.h>
23 
24 #define COMPAT_USER_HZ 100
25 
26 /* "long" and pointer-based types are different. */
31 typedef s32 compat_off_t;
34 typedef u32 compat_ino_t;
37 
38 /* Many types are "int" or otherwise the same. */
52 typedef int compat_int_t;
53 typedef s64 compat_s64;
55 typedef u64 compat_u64;
56 
57 /* We use the same register dump format in 32-bit images. */
58 typedef unsigned long compat_elf_greg_t;
59 #define COMPAT_ELF_NGREG (sizeof(struct pt_regs) / sizeof(compat_elf_greg_t))
61 
62 struct compat_timespec {
64  s32 tv_nsec;
65 };
66 
67 struct compat_timeval {
69  s32 tv_usec;
70 };
71 
72 #define compat_stat stat
73 #define compat_statfs statfs
74 
75 struct compat_sysctl {
76  unsigned int name;
77  int nlen;
78  unsigned int oldval;
79  unsigned int oldlenp;
80  unsigned int newval;
81  unsigned int newlen;
82  unsigned int __unused[4];
83 };
84 
85 
86 struct compat_flock {
87  short l_type;
88  short l_whence;
92 };
93 
94 #define F_GETLK64 12 /* using 'struct flock64' */
95 #define F_SETLK64 13
96 #define F_SETLKW64 14
97 
98 struct compat_flock64 {
99  short l_type;
100  short l_whence;
104 };
105 
106 #define COMPAT_RLIM_INFINITY 0xffffffff
107 
108 #define _COMPAT_NSIG 64
109 #define _COMPAT_NSIG_BPW 32
110 
112 
113 typedef union compat_sigval {
117 
118 #define COMPAT_SI_PAD_SIZE (128/sizeof(int) - 3)
119 
120 typedef struct compat_siginfo {
121  int si_signo;
122  int si_errno;
123  int si_code;
124 
125  union {
127 
128  /* kill() */
129  struct {
130  unsigned int _pid; /* sender's pid */
131  unsigned int _uid; /* sender's uid */
132  } _kill;
133 
134  /* POSIX.1b timers */
135  struct {
136  compat_timer_t _tid; /* timer id */
137  int _overrun; /* overrun count */
138  compat_sigval_t _sigval; /* same as below */
139  int _sys_private; /* not to be passed to user */
140  int _overrun_incr; /* amount to add to overrun */
141  } _timer;
142 
143  /* POSIX.1b signals */
144  struct {
145  unsigned int _pid; /* sender's pid */
146  unsigned int _uid; /* sender's uid */
148  } _rt;
149 
150  /* SIGCHLD */
151  struct {
152  unsigned int _pid; /* which child */
153  unsigned int _uid; /* sender's uid */
154  int _status; /* exit code */
157  } _sigchld;
158 
159  /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
160  struct {
161  unsigned int _addr; /* faulting insn/memory ref. */
162 #ifdef __ARCH_SI_TRAPNO
163  int _trapno; /* TRAP # which caused the signal */
164 #endif
165  } _sigfault;
166 
167  /* SIGPOLL */
168  struct {
169  int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
170  int _fd;
171  } _sigpoll;
172  } _sifields;
174 
175 #define COMPAT_OFF_T_MAX 0x7fffffff
176 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
177 
178 struct compat_ipc64_perm {
184  unsigned short mode;
185  unsigned short __pad1;
186  unsigned short seq;
187  unsigned short __pad2;
190 };
191 
192 struct compat_semid64_ds {
193  struct compat_ipc64_perm sem_perm;
201 };
202 
203 struct compat_msqid64_ds {
204  struct compat_ipc64_perm msg_perm;
218 };
219 
220 struct compat_shmid64_ds {
234 };
235 
236 /*
237  * A pointer passed in from user mode. This should not
238  * be used for syscall parameters, just declare them
239  * as pointers because the syscall entry code will have
240  * appropriately converted them already.
241  */
242 
243 static inline void __user *compat_ptr(compat_uptr_t uptr)
244 {
245  return (void __user *)(long)(s32)uptr;
246 }
247 
248 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
249 {
250  return (u32)(unsigned long)uptr;
251 }
252 
253 /* Sign-extend when storing a kernel pointer to a user's ptregs. */
254 static inline unsigned long ptr_to_compat_reg(void __user *uptr)
255 {
256  return (long)(int)(long __force)uptr;
257 }
258 
259 static inline void __user *arch_compat_alloc_user_space(long len)
260 {
261  struct pt_regs *regs = task_pt_regs(current);
262  return (void __user *)regs->sp - len;
263 }
264 
265 static inline int is_compat_task(void)
266 {
267  return current_thread_info()->status & TS_COMPAT;
268 }
269 
270 extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka,
271  siginfo_t *info, sigset_t *set,
272  struct pt_regs *regs);
273 
274 /* Compat syscalls. */
275 struct compat_sigaction;
276 struct compat_siginfo;
277 struct compat_sigaltstack;
278 long compat_sys_execve(const char __user *path,
279  compat_uptr_t __user *argv,
280  compat_uptr_t __user *envp, struct pt_regs *);
281 long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
282  struct compat_sigaction __user *oact,
283  size_t sigsetsize);
284 long compat_sys_rt_sigqueueinfo(int pid, int sig,
285  struct compat_siginfo __user *uinfo);
286 long compat_sys_rt_sigreturn(struct pt_regs *);
287 long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
288  struct compat_sigaltstack __user *uoss_ptr,
289  struct pt_regs *);
290 long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
291 long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
292 long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
293  u32 dummy, u32 low, u32 high);
294 long compat_sys_pwrite64(unsigned int fd, char __user *ubuf, size_t count,
295  u32 dummy, u32 low, u32 high);
296 long compat_sys_lookup_dcookie(u32 low, u32 high, char __user *buf, size_t len);
297 long compat_sys_sync_file_range2(int fd, unsigned int flags,
298  u32 offset_lo, u32 offset_hi,
299  u32 nbytes_lo, u32 nbytes_hi);
300 long compat_sys_fallocate(int fd, int mode,
301  u32 offset_lo, u32 offset_hi,
302  u32 len_lo, u32 len_hi);
304  struct compat_timespec __user *interval);
305 
306 /* These are the intvec_64.S trampolines. */
307 long _compat_sys_execve(const char __user *path,
308  const compat_uptr_t __user *argv,
309  const compat_uptr_t __user *envp);
310 long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
311  struct compat_sigaltstack __user *uoss_ptr);
312 long _compat_sys_rt_sigreturn(void);
313 
314 #endif /* _ASM_TILE_COMPAT_H */