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
30 #define COMPAT_UTS_MACHINE "armv8b\0\0"
32 #define COMPAT_UTS_MACHINE "armv8l\0\0"
35 typedef u32 compat_size_t
;
36 typedef s32 compat_ssize_t
;
37 typedef s32 compat_time_t
;
38 typedef s32 compat_clock_t
;
39 typedef s32 compat_pid_t
;
40 typedef u16 __compat_uid_t
;
41 typedef u16 __compat_gid_t
;
42 typedef u16 __compat_uid16_t
;
43 typedef u16 __compat_gid16_t
;
44 typedef u32 __compat_uid32_t
;
45 typedef u32 __compat_gid32_t
;
46 typedef u16 compat_mode_t
;
47 typedef u32 compat_ino_t
;
48 typedef u32 compat_dev_t
;
49 typedef s32 compat_off_t
;
50 typedef s64 compat_loff_t
;
51 typedef s32 compat_nlink_t
;
52 typedef u16 compat_ipc_pid_t
;
53 typedef s32 compat_daddr_t
;
54 typedef u32 compat_caddr_t
;
55 typedef __kernel_fsid_t compat_fsid_t
;
56 typedef s32 compat_key_t
;
57 typedef s32 compat_timer_t
;
59 typedef s16 compat_short_t
;
60 typedef s32 compat_int_t
;
61 typedef s32 compat_long_t
;
62 typedef s64 compat_s64
;
63 typedef u16 compat_ushort_t
;
64 typedef u32 compat_uint_t
;
65 typedef u32 compat_ulong_t
;
66 typedef u64 compat_u64
;
67 typedef u32 compat_uptr_t
;
69 struct compat_timespec
{
74 struct compat_timeval
{
87 compat_mode_t st_mode
;
88 compat_ushort_t st_nlink
;
89 __compat_uid16_t st_uid
;
90 __compat_gid16_t st_gid
;
98 compat_off_t st_blksize
;
99 compat_off_t st_blocks
;
100 compat_time_t st_atime
;
101 compat_ulong_t st_atime_nsec
;
102 compat_time_t st_mtime
;
103 compat_ulong_t st_mtime_nsec
;
104 compat_time_t st_ctime
;
105 compat_ulong_t st_ctime_nsec
;
106 compat_ulong_t __unused4
[2];
109 struct compat_flock
{
112 compat_off_t l_start
;
117 #define F_GETLK64 12 /* using 'struct flock64' */
119 #define F_SETLKW64 14
121 struct compat_flock64
{
124 compat_loff_t l_start
;
129 struct compat_statfs
{
137 compat_fsid_t f_fsid
;
138 int f_namelen
; /* SunOS ignores this field. */
144 #define COMPAT_RLIM_INFINITY 0xffffffff
146 typedef u32 compat_old_sigset_t
;
148 #define _COMPAT_NSIG 64
149 #define _COMPAT_NSIG_BPW 32
151 typedef u32 compat_sigset_word
;
153 typedef union compat_sigval
{
154 compat_int_t sival_int
;
155 compat_uptr_t sival_ptr
;
158 typedef struct compat_siginfo
{
164 /* The padding is the same size as AArch64. */
165 int _pad
[128/sizeof(int) - 3];
169 compat_pid_t _pid
; /* sender's pid */
170 __compat_uid32_t _uid
; /* sender's uid */
173 /* POSIX.1b timers */
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 */
181 /* POSIX.1b signals */
183 compat_pid_t _pid
; /* sender's pid */
184 __compat_uid32_t _uid
; /* sender's uid */
185 compat_sigval_t _sigval
;
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
;
197 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
199 compat_uptr_t _addr
; /* faulting insn/memory ref. */
200 short _addr_lsb
; /* LSB of the reported address */
205 compat_long_t _band
; /* POLL_IN, POLL_OUT, POLL_MSG */
211 #define COMPAT_OFF_T_MAX 0x7fffffff
212 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
215 * A pointer passed in from user mode. This should not
216 * be used for syscall parameters, just declare them
217 * as pointers because the syscall entry code will have
218 * appropriately converted them already.
221 static inline void __user
*compat_ptr(compat_uptr_t uptr
)
223 return (void __user
*)(unsigned long)uptr
;
226 static inline compat_uptr_t
ptr_to_compat(void __user
*uptr
)
228 return (u32
)(unsigned long)uptr
;
231 #define compat_user_stack_pointer() (current_pt_regs()->compat_sp)
233 static inline void __user
*arch_compat_alloc_user_space(long len
)
235 return (void __user
*)compat_user_stack_pointer() - len
;
238 struct compat_ipc64_perm
{
240 __compat_uid32_t uid
;
241 __compat_gid32_t gid
;
242 __compat_uid32_t cuid
;
243 __compat_gid32_t cgid
;
245 unsigned short __pad1
;
247 unsigned short __pad2
;
248 compat_ulong_t unused1
;
249 compat_ulong_t unused2
;
252 struct compat_semid64_ds
{
253 struct compat_ipc64_perm sem_perm
;
254 compat_time_t sem_otime
;
255 compat_ulong_t __unused1
;
256 compat_time_t sem_ctime
;
257 compat_ulong_t __unused2
;
258 compat_ulong_t sem_nsems
;
259 compat_ulong_t __unused3
;
260 compat_ulong_t __unused4
;
263 struct compat_msqid64_ds
{
264 struct compat_ipc64_perm msg_perm
;
265 compat_time_t msg_stime
;
266 compat_ulong_t __unused1
;
267 compat_time_t msg_rtime
;
268 compat_ulong_t __unused2
;
269 compat_time_t msg_ctime
;
270 compat_ulong_t __unused3
;
271 compat_ulong_t msg_cbytes
;
272 compat_ulong_t msg_qnum
;
273 compat_ulong_t msg_qbytes
;
274 compat_pid_t msg_lspid
;
275 compat_pid_t msg_lrpid
;
276 compat_ulong_t __unused4
;
277 compat_ulong_t __unused5
;
280 struct compat_shmid64_ds
{
281 struct compat_ipc64_perm shm_perm
;
282 compat_size_t shm_segsz
;
283 compat_time_t shm_atime
;
284 compat_ulong_t __unused1
;
285 compat_time_t shm_dtime
;
286 compat_ulong_t __unused2
;
287 compat_time_t shm_ctime
;
288 compat_ulong_t __unused3
;
289 compat_pid_t shm_cpid
;
290 compat_pid_t shm_lpid
;
291 compat_ulong_t shm_nattch
;
292 compat_ulong_t __unused4
;
293 compat_ulong_t __unused5
;
296 static inline int is_compat_task(void)
298 return test_thread_flag(TIF_32BIT
);
301 static inline int is_compat_thread(struct thread_info
*thread
)
303 return test_ti_thread_flag(thread
, TIF_32BIT
);
306 #else /* !CONFIG_COMPAT */
308 static inline int is_compat_task(void)
313 static inline int is_compat_thread(struct thread_info
*thread
)
318 #endif /* CONFIG_COMPAT */
319 #endif /* __KERNEL__ */
320 #endif /* __ASM_COMPAT_H */