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