2 * Copyright (C) 2012 ARM Ltd.
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.
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.
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/>.
16 #ifndef __ASM_COMPAT_H
17 #define __ASM_COMPAT_H
22 * Architecture specific compatibility types
24 #include <linux/types.h>
25 #include <linux/sched.h>
26 #include <linux/ptrace.h>
28 #define COMPAT_USER_HZ 100
29 #define COMPAT_UTS_MACHINE "armv8l\0\0"
31 typedef u32 compat_size_t;
32 typedef s32 compat_ssize_t;
33 typedef s32 compat_time_t;
34 typedef s32 compat_clock_t;
35 typedef s32 compat_pid_t;
36 typedef u32 __compat_uid_t;
37 typedef u32 __compat_gid_t;
38 typedef u16 __compat_uid16_t;
39 typedef u16 __compat_gid16_t;
40 typedef u32 __compat_uid32_t;
41 typedef u32 __compat_gid32_t;
42 typedef u16 compat_mode_t;
43 typedef u32 compat_ino_t;
44 typedef u32 compat_dev_t;
45 typedef s32 compat_off_t;
46 typedef s64 compat_loff_t;
47 typedef s32 compat_nlink_t;
48 typedef u16 compat_ipc_pid_t;
49 typedef s32 compat_daddr_t;
50 typedef u32 compat_caddr_t;
51 typedef __kernel_fsid_t compat_fsid_t;
52 typedef s32 compat_key_t;
53 typedef s32 compat_timer_t;
55 typedef s16 compat_short_t;
56 typedef s32 compat_int_t;
57 typedef s32 compat_long_t;
58 typedef s64 compat_s64;
59 typedef u16 compat_ushort_t;
60 typedef u32 compat_uint_t;
61 typedef u32 compat_ulong_t;
62 typedef u64 compat_u64;
63 typedef u32 compat_uptr_t;
65 struct compat_timespec {
70 struct compat_timeval {
78 compat_mode_t st_mode;
79 compat_ushort_t st_nlink;
80 __compat_uid16_t st_uid;
81 __compat_gid16_t st_gid;
84 compat_off_t st_blksize;
85 compat_off_t st_blocks;
86 compat_time_t st_atime;
87 compat_ulong_t st_atime_nsec;
88 compat_time_t st_mtime;
89 compat_ulong_t st_mtime_nsec;
90 compat_time_t st_ctime;
91 compat_ulong_t st_ctime_nsec;
92 compat_ulong_t __unused4[2];
103 #define F_GETLK64 12 /* using 'struct flock64' */
105 #define F_SETLKW64 14
107 struct compat_flock64 {
110 compat_loff_t l_start;
115 struct compat_statfs {
123 compat_fsid_t f_fsid;
124 int f_namelen; /* SunOS ignores this field. */
130 #define COMPAT_RLIM_INFINITY 0xffffffff
132 typedef u32 compat_old_sigset_t;
134 #define _COMPAT_NSIG 64
135 #define _COMPAT_NSIG_BPW 32
137 typedef u32 compat_sigset_word;
139 typedef union compat_sigval {
140 compat_int_t sival_int;
141 compat_uptr_t sival_ptr;
144 typedef struct compat_siginfo {
150 /* The padding is the same size as AArch64. */
151 int _pad[128/sizeof(int) - 3];
155 compat_pid_t _pid; /* sender's pid */
156 __compat_uid32_t _uid; /* sender's uid */
159 /* POSIX.1b timers */
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 */
167 /* POSIX.1b signals */
169 compat_pid_t _pid; /* sender's pid */
170 __compat_uid32_t _uid; /* sender's uid */
171 compat_sigval_t _sigval;
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;
183 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
185 compat_uptr_t _addr; /* faulting insn/memory ref. */
186 short _addr_lsb; /* LSB of the reported address */
191 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
197 #define COMPAT_OFF_T_MAX 0x7fffffff
198 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
201 * A pointer passed in from user mode. This should not
202 * be used for syscall parameters, just declare them
203 * as pointers because the syscall entry code will have
204 * appropriately converted them already.
207 static inline void __user *compat_ptr(compat_uptr_t uptr)
209 return (void __user *)(unsigned long)uptr;
212 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
214 return (u32)(unsigned long)uptr;
217 #define compat_user_stack_pointer() (user_stack_pointer(current_pt_regs()))
219 static inline void __user *arch_compat_alloc_user_space(long len)
221 return (void __user *)compat_user_stack_pointer() - len;
224 struct compat_ipc64_perm {
226 __compat_uid32_t uid;
227 __compat_gid32_t gid;
228 __compat_uid32_t cuid;
229 __compat_gid32_t cgid;
231 unsigned short __pad1;
233 unsigned short __pad2;
234 compat_ulong_t unused1;
235 compat_ulong_t unused2;
238 struct compat_semid64_ds {
239 struct compat_ipc64_perm sem_perm;
240 compat_time_t sem_otime;
241 compat_ulong_t __unused1;
242 compat_time_t sem_ctime;
243 compat_ulong_t __unused2;
244 compat_ulong_t sem_nsems;
245 compat_ulong_t __unused3;
246 compat_ulong_t __unused4;
249 struct compat_msqid64_ds {
250 struct compat_ipc64_perm msg_perm;
251 compat_time_t msg_stime;
252 compat_ulong_t __unused1;
253 compat_time_t msg_rtime;
254 compat_ulong_t __unused2;
255 compat_time_t msg_ctime;
256 compat_ulong_t __unused3;
257 compat_ulong_t msg_cbytes;
258 compat_ulong_t msg_qnum;
259 compat_ulong_t msg_qbytes;
260 compat_pid_t msg_lspid;
261 compat_pid_t msg_lrpid;
262 compat_ulong_t __unused4;
263 compat_ulong_t __unused5;
266 struct compat_shmid64_ds {
267 struct compat_ipc64_perm shm_perm;
268 compat_size_t shm_segsz;
269 compat_time_t shm_atime;
270 compat_ulong_t __unused1;
271 compat_time_t shm_dtime;
272 compat_ulong_t __unused2;
273 compat_time_t shm_ctime;
274 compat_ulong_t __unused3;
275 compat_pid_t shm_cpid;
276 compat_pid_t shm_lpid;
277 compat_ulong_t shm_nattch;
278 compat_ulong_t __unused4;
279 compat_ulong_t __unused5;
282 static inline int is_compat_task(void)
284 return test_thread_flag(TIF_32BIT);
287 static inline int is_compat_thread(struct thread_info *thread)
289 return test_ti_thread_flag(thread, TIF_32BIT);
292 #else /* !CONFIG_COMPAT */
294 static inline int is_compat_thread(struct thread_info *thread)
299 #endif /* CONFIG_COMPAT */
300 #endif /* __KERNEL__ */
301 #endif /* __ASM_COMPAT_H */