1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 ARM Ltd.
8 #include <asm-generic/compat.h>
13 * Architecture specific compatibility types
15 #include <linux/types.h>
16 #include <linux/sched.h>
17 #include <linux/sched/task_stack.h>
19 #define COMPAT_USER_HZ 100
21 #define COMPAT_UTS_MACHINE "armv8b\0\0"
23 #define COMPAT_UTS_MACHINE "armv8l\0\0"
26 typedef u16 __compat_uid_t
;
27 typedef u16 __compat_gid_t
;
28 typedef u16 __compat_uid16_t
;
29 typedef u16 __compat_gid16_t
;
30 typedef u32 __compat_uid32_t
;
31 typedef u32 __compat_gid32_t
;
32 typedef u16 compat_mode_t
;
33 typedef u32 compat_dev_t
;
34 typedef s32 compat_nlink_t
;
35 typedef u16 compat_ipc_pid_t
;
36 typedef u32 compat_caddr_t
;
37 typedef __kernel_fsid_t compat_fsid_t
;
47 compat_mode_t st_mode
;
48 compat_ushort_t st_nlink
;
49 __compat_uid16_t st_uid
;
50 __compat_gid16_t st_gid
;
58 compat_off_t st_blksize
;
59 compat_off_t st_blocks
;
60 old_time32_t st_atime
;
61 compat_ulong_t st_atime_nsec
;
62 old_time32_t st_mtime
;
63 compat_ulong_t st_mtime_nsec
;
64 old_time32_t st_ctime
;
65 compat_ulong_t st_ctime_nsec
;
66 compat_ulong_t __unused4
[2];
77 #define F_GETLK64 12 /* using 'struct flock64' */
81 struct compat_flock64
{
84 compat_loff_t l_start
;
89 struct compat_statfs
{
98 int f_namelen
; /* SunOS ignores this field. */
104 #define COMPAT_RLIM_INFINITY 0xffffffff
106 typedef u32 compat_old_sigset_t
;
108 #define _COMPAT_NSIG 64
109 #define _COMPAT_NSIG_BPW 32
111 typedef u32 compat_sigset_word
;
113 #define COMPAT_OFF_T_MAX 0x7fffffff
115 #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
116 #define COMPAT_MINSIGSTKSZ 2048
118 static inline void __user
*arch_compat_alloc_user_space(long len
)
120 return (void __user
*)compat_user_stack_pointer() - len
;
123 struct compat_ipc64_perm
{
125 __compat_uid32_t uid
;
126 __compat_gid32_t gid
;
127 __compat_uid32_t cuid
;
128 __compat_gid32_t cgid
;
130 unsigned short __pad1
;
132 unsigned short __pad2
;
133 compat_ulong_t unused1
;
134 compat_ulong_t unused2
;
137 struct compat_semid64_ds
{
138 struct compat_ipc64_perm sem_perm
;
139 compat_ulong_t sem_otime
;
140 compat_ulong_t sem_otime_high
;
141 compat_ulong_t sem_ctime
;
142 compat_ulong_t sem_ctime_high
;
143 compat_ulong_t sem_nsems
;
144 compat_ulong_t __unused3
;
145 compat_ulong_t __unused4
;
148 struct compat_msqid64_ds
{
149 struct compat_ipc64_perm msg_perm
;
150 compat_ulong_t msg_stime
;
151 compat_ulong_t msg_stime_high
;
152 compat_ulong_t msg_rtime
;
153 compat_ulong_t msg_rtime_high
;
154 compat_ulong_t msg_ctime
;
155 compat_ulong_t msg_ctime_high
;
156 compat_ulong_t msg_cbytes
;
157 compat_ulong_t msg_qnum
;
158 compat_ulong_t msg_qbytes
;
159 compat_pid_t msg_lspid
;
160 compat_pid_t msg_lrpid
;
161 compat_ulong_t __unused4
;
162 compat_ulong_t __unused5
;
165 struct compat_shmid64_ds
{
166 struct compat_ipc64_perm shm_perm
;
167 compat_size_t shm_segsz
;
168 compat_ulong_t shm_atime
;
169 compat_ulong_t shm_atime_high
;
170 compat_ulong_t shm_dtime
;
171 compat_ulong_t shm_dtime_high
;
172 compat_ulong_t shm_ctime
;
173 compat_ulong_t shm_ctime_high
;
174 compat_pid_t shm_cpid
;
175 compat_pid_t shm_lpid
;
176 compat_ulong_t shm_nattch
;
177 compat_ulong_t __unused4
;
178 compat_ulong_t __unused5
;
181 static inline int is_compat_task(void)
183 return test_thread_flag(TIF_32BIT
);
186 static inline int is_compat_thread(struct thread_info
*thread
)
188 return test_ti_thread_flag(thread
, TIF_32BIT
);
191 #else /* !CONFIG_COMPAT */
193 static inline int is_compat_thread(struct thread_info
*thread
)
198 #endif /* CONFIG_COMPAT */
199 #endif /* __ASM_COMPAT_H */