import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm64 / include / asm / compat.h
CommitLineData
3dd681d9
WD
1/*
2 * Copyright (C) 2012 ARM Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#ifndef __ASM_COMPAT_H
17#define __ASM_COMPAT_H
18#ifdef __KERNEL__
19#ifdef CONFIG_COMPAT
20
21/*
22 * Architecture specific compatibility types
23 */
24#include <linux/types.h>
25#include <linux/sched.h>
7ae42c96 26#include <linux/ptrace.h>
3dd681d9
WD
27
28#define COMPAT_USER_HZ 100
29#define COMPAT_UTS_MACHINE "armv8l\0\0"
30
31typedef u32 compat_size_t;
32typedef s32 compat_ssize_t;
33typedef s32 compat_time_t;
34typedef s32 compat_clock_t;
35typedef s32 compat_pid_t;
36typedef u32 __compat_uid_t;
37typedef u32 __compat_gid_t;
f15a2a12
CM
38typedef u16 __compat_uid16_t;
39typedef u16 __compat_gid16_t;
3dd681d9
WD
40typedef u32 __compat_uid32_t;
41typedef u32 __compat_gid32_t;
f15a2a12 42typedef u16 compat_mode_t;
3dd681d9
WD
43typedef u32 compat_ino_t;
44typedef u32 compat_dev_t;
45typedef s32 compat_off_t;
46typedef s64 compat_loff_t;
f15a2a12 47typedef s32 compat_nlink_t;
3dd681d9
WD
48typedef u16 compat_ipc_pid_t;
49typedef s32 compat_daddr_t;
50typedef u32 compat_caddr_t;
51typedef __kernel_fsid_t compat_fsid_t;
52typedef s32 compat_key_t;
53typedef s32 compat_timer_t;
54
f15a2a12 55typedef s16 compat_short_t;
3dd681d9
WD
56typedef s32 compat_int_t;
57typedef s32 compat_long_t;
58typedef s64 compat_s64;
f15a2a12 59typedef u16 compat_ushort_t;
3dd681d9
WD
60typedef u32 compat_uint_t;
61typedef u32 compat_ulong_t;
62typedef u64 compat_u64;
751f409d 63typedef u32 compat_uptr_t;
3dd681d9
WD
64
65struct compat_timespec {
66 compat_time_t tv_sec;
67 s32 tv_nsec;
68};
69
70struct compat_timeval {
71 compat_time_t tv_sec;
72 s32 tv_usec;
73};
74
75struct compat_stat {
76 compat_dev_t st_dev;
77 compat_ino_t st_ino;
78 compat_mode_t st_mode;
f15a2a12
CM
79 compat_ushort_t st_nlink;
80 __compat_uid16_t st_uid;
81 __compat_gid16_t st_gid;
3dd681d9
WD
82 compat_dev_t st_rdev;
83 compat_off_t st_size;
84 compat_off_t st_blksize;
85 compat_off_t st_blocks;
86 compat_time_t st_atime;
f15a2a12 87 compat_ulong_t st_atime_nsec;
3dd681d9 88 compat_time_t st_mtime;
f15a2a12 89 compat_ulong_t st_mtime_nsec;
3dd681d9 90 compat_time_t st_ctime;
f15a2a12
CM
91 compat_ulong_t st_ctime_nsec;
92 compat_ulong_t __unused4[2];
3dd681d9
WD
93};
94
95struct compat_flock {
96 short l_type;
97 short l_whence;
98 compat_off_t l_start;
99 compat_off_t l_len;
100 compat_pid_t l_pid;
101};
102
103#define F_GETLK64 12 /* using 'struct flock64' */
104#define F_SETLK64 13
105#define F_SETLKW64 14
106
107struct compat_flock64 {
108 short l_type;
109 short l_whence;
110 compat_loff_t l_start;
111 compat_loff_t l_len;
112 compat_pid_t l_pid;
113};
114
115struct compat_statfs {
116 int f_type;
117 int f_bsize;
118 int f_blocks;
119 int f_bfree;
120 int f_bavail;
121 int f_files;
122 int f_ffree;
123 compat_fsid_t f_fsid;
124 int f_namelen; /* SunOS ignores this field. */
125 int f_frsize;
126 int f_flags;
127 int f_spare[4];
128};
129
130#define COMPAT_RLIM_INFINITY 0xffffffff
131
132typedef u32 compat_old_sigset_t;
133
134#define _COMPAT_NSIG 64
135#define _COMPAT_NSIG_BPW 32
136
137typedef u32 compat_sigset_word;
138
751f409d
DV
139typedef union compat_sigval {
140 compat_int_t sival_int;
141 compat_uptr_t sival_ptr;
142} compat_sigval_t;
143
144typedef struct compat_siginfo {
145 int si_signo;
146 int si_errno;
147 int si_code;
148
149 union {
150 /* The padding is the same size as AArch64. */
151 int _pad[128/sizeof(int) - 3];
152
153 /* kill() */
154 struct {
155 compat_pid_t _pid; /* sender's pid */
156 __compat_uid32_t _uid; /* sender's uid */
157 } _kill;
158
159 /* POSIX.1b timers */
160 struct {
161 compat_timer_t _tid; /* timer id */
162 int _overrun; /* overrun count */
163 compat_sigval_t _sigval; /* same as below */
164 int _sys_private; /* not to be passed to user */
165 } _timer;
166
167 /* POSIX.1b signals */
168 struct {
169 compat_pid_t _pid; /* sender's pid */
170 __compat_uid32_t _uid; /* sender's uid */
171 compat_sigval_t _sigval;
172 } _rt;
173
174 /* SIGCHLD */
175 struct {
176 compat_pid_t _pid; /* which child */
177 __compat_uid32_t _uid; /* sender's uid */
178 int _status; /* exit code */
179 compat_clock_t _utime;
180 compat_clock_t _stime;
181 } _sigchld;
182
183 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
184 struct {
185 compat_uptr_t _addr; /* faulting insn/memory ref. */
186 short _addr_lsb; /* LSB of the reported address */
187 } _sigfault;
188
189 /* SIGPOLL */
190 struct {
191 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
192 int _fd;
193 } _sigpoll;
6fa3eb70
S
194
195 /* SIGSYS */
196 struct {
197 compat_uptr_t _call_addr; /* calling user insn */
198 int _syscall; /* triggering system call number */
199 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
200 } _sigsys;
751f409d
DV
201 } _sifields;
202} compat_siginfo_t;
203
3dd681d9
WD
204#define COMPAT_OFF_T_MAX 0x7fffffff
205#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
206
207/*
208 * A pointer passed in from user mode. This should not
209 * be used for syscall parameters, just declare them
210 * as pointers because the syscall entry code will have
211 * appropriately converted them already.
212 */
3dd681d9
WD
213
214static inline void __user *compat_ptr(compat_uptr_t uptr)
215{
216 return (void __user *)(unsigned long)uptr;
217}
218
219static inline compat_uptr_t ptr_to_compat(void __user *uptr)
220{
221 return (u32)(unsigned long)uptr;
222}
223
6fa3eb70 224#define compat_user_stack_pointer() (user_stack_pointer(current_pt_regs()))
9b064fc3 225
3dd681d9
WD
226static inline void __user *arch_compat_alloc_user_space(long len)
227{
9b064fc3 228 return (void __user *)compat_user_stack_pointer() - len;
3dd681d9
WD
229}
230
231struct compat_ipc64_perm {
232 compat_key_t key;
233 __compat_uid32_t uid;
234 __compat_gid32_t gid;
235 __compat_uid32_t cuid;
236 __compat_gid32_t cgid;
237 unsigned short mode;
238 unsigned short __pad1;
239 unsigned short seq;
240 unsigned short __pad2;
241 compat_ulong_t unused1;
242 compat_ulong_t unused2;
243};
244
245struct compat_semid64_ds {
246 struct compat_ipc64_perm sem_perm;
247 compat_time_t sem_otime;
248 compat_ulong_t __unused1;
249 compat_time_t sem_ctime;
250 compat_ulong_t __unused2;
251 compat_ulong_t sem_nsems;
252 compat_ulong_t __unused3;
253 compat_ulong_t __unused4;
254};
255
256struct compat_msqid64_ds {
257 struct compat_ipc64_perm msg_perm;
258 compat_time_t msg_stime;
259 compat_ulong_t __unused1;
260 compat_time_t msg_rtime;
261 compat_ulong_t __unused2;
262 compat_time_t msg_ctime;
263 compat_ulong_t __unused3;
264 compat_ulong_t msg_cbytes;
265 compat_ulong_t msg_qnum;
266 compat_ulong_t msg_qbytes;
267 compat_pid_t msg_lspid;
268 compat_pid_t msg_lrpid;
269 compat_ulong_t __unused4;
270 compat_ulong_t __unused5;
271};
272
273struct compat_shmid64_ds {
274 struct compat_ipc64_perm shm_perm;
275 compat_size_t shm_segsz;
276 compat_time_t shm_atime;
277 compat_ulong_t __unused1;
278 compat_time_t shm_dtime;
279 compat_ulong_t __unused2;
280 compat_time_t shm_ctime;
281 compat_ulong_t __unused3;
282 compat_pid_t shm_cpid;
283 compat_pid_t shm_lpid;
284 compat_ulong_t shm_nattch;
285 compat_ulong_t __unused4;
286 compat_ulong_t __unused5;
287};
288
289static inline int is_compat_task(void)
290{
291 return test_thread_flag(TIF_32BIT);
292}
293
294static inline int is_compat_thread(struct thread_info *thread)
295{
296 return test_ti_thread_flag(thread, TIF_32BIT);
297}
298
299#else /* !CONFIG_COMPAT */
300
3dd681d9
WD
301static inline int is_compat_thread(struct thread_info *thread)
302{
303 return 0;
304}
305
306#endif /* CONFIG_COMPAT */
307#endif /* __KERNEL__ */
308#endif /* __ASM_COMPAT_H */