1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Architecture specific compatibility types
7 #include <linux/thread_info.h>
8 #include <linux/types.h>
10 #include <asm/ptrace.h>
12 #define COMPAT_USER_HZ 100
13 #define COMPAT_UTS_MACHINE "mips\0\0\0"
15 typedef u32 compat_size_t;
16 typedef s32 compat_ssize_t;
17 typedef s32 compat_time_t;
18 typedef s32 compat_clock_t;
19 typedef s32 compat_suseconds_t;
21 typedef s32 compat_pid_t;
22 typedef s32 __compat_uid_t;
23 typedef s32 __compat_gid_t;
24 typedef __compat_uid_t __compat_uid32_t;
25 typedef __compat_gid_t __compat_gid32_t;
26 typedef u32 compat_mode_t;
27 typedef u32 compat_ino_t;
28 typedef u32 compat_dev_t;
29 typedef s32 compat_off_t;
30 typedef s64 compat_loff_t;
31 typedef u32 compat_nlink_t;
32 typedef s32 compat_ipc_pid_t;
33 typedef s32 compat_daddr_t;
34 typedef s32 compat_caddr_t;
38 typedef s32 compat_timer_t;
39 typedef s32 compat_key_t;
41 typedef s32 compat_int_t;
42 typedef s32 compat_long_t;
43 typedef s64 compat_s64;
44 typedef u32 compat_uint_t;
45 typedef u32 compat_ulong_t;
46 typedef u64 compat_u64;
47 typedef u32 compat_uptr_t;
49 struct compat_timespec {
54 struct compat_timeval {
63 compat_mode_t st_mode;
64 compat_nlink_t st_nlink;
65 __compat_uid_t st_uid;
66 __compat_gid_t st_gid;
71 compat_time_t st_atime;
73 compat_time_t st_mtime;
75 compat_time_t st_ctime;
96 struct compat_flock64 {
99 compat_loff_t l_start;
104 struct compat_statfs {
113 compat_fsid_t f_fsid;
119 #define COMPAT_RLIM_INFINITY 0x7fffffffUL
121 typedef u32 compat_old_sigset_t; /* at least 32 bits */
123 #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */
124 #define _COMPAT_NSIG_BPW 32
126 typedef u32 compat_sigset_word;
128 typedef union compat_sigval {
129 compat_int_t sival_int;
130 compat_uptr_t sival_ptr;
133 /* Can't use the generic version because si_code and si_errno are swapped */
135 #define SI_PAD_SIZE32 (128/sizeof(int) - 3)
137 typedef struct compat_siginfo {
143 int _pad[128 / sizeof(int) - 3];
147 compat_pid_t _pid; /* sender's pid */
148 __compat_uid32_t _uid; /* sender's uid */
151 /* POSIX.1b timers */
153 compat_timer_t _tid; /* timer id */
154 int _overrun; /* overrun count */
155 compat_sigval_t _sigval; /* same as below */
158 /* POSIX.1b signals */
160 compat_pid_t _pid; /* sender's pid */
161 __compat_uid32_t _uid; /* sender's uid */
162 compat_sigval_t _sigval;
167 compat_pid_t _pid; /* which child */
168 __compat_uid32_t _uid; /* sender's uid */
169 int _status; /* exit code */
170 compat_clock_t _utime;
171 compat_clock_t _stime;
174 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
176 compat_uptr_t _addr; /* faulting insn/memory ref. */
177 #ifdef __ARCH_SI_TRAPNO
178 int _trapno; /* TRAP # which caused the signal */
180 short _addr_lsb; /* LSB of the reported address */
182 compat_uptr_t _lower;
183 compat_uptr_t _upper;
189 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
194 compat_uptr_t _call_addr; /* calling insn */
195 int _syscall; /* triggering system call number */
196 compat_uint_t _arch; /* AUDIT_ARCH_* of syscall */
201 #define COMPAT_OFF_T_MAX 0x7fffffff
204 * A pointer passed in from user mode. This should not
205 * be used for syscall parameters, just declare them
206 * as pointers because the syscall entry code will have
207 * appropriately converted them already.
210 static inline void __user *compat_ptr(compat_uptr_t uptr)
212 /* cast to a __user pointer via "unsigned long" makes sparse happy */
213 return (void __user *)(unsigned long)(long)uptr;
216 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
218 return (u32)(unsigned long)uptr;
221 static inline void __user *arch_compat_alloc_user_space(long len)
223 struct pt_regs *regs = (struct pt_regs *)
224 ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
226 return (void __user *) (regs->regs[29] - len);
229 struct compat_ipc64_perm {
231 __compat_uid32_t uid;
232 __compat_gid32_t gid;
233 __compat_uid32_t cuid;
234 __compat_gid32_t cgid;
237 unsigned short __pad2;
238 compat_ulong_t __unused1;
239 compat_ulong_t __unused2;
242 struct compat_semid64_ds {
243 struct compat_ipc64_perm sem_perm;
244 compat_time_t sem_otime;
245 compat_time_t sem_ctime;
246 compat_ulong_t sem_nsems;
247 compat_ulong_t __unused1;
248 compat_ulong_t __unused2;
251 struct compat_msqid64_ds {
252 struct compat_ipc64_perm msg_perm;
253 #ifndef CONFIG_CPU_LITTLE_ENDIAN
254 compat_ulong_t __unused1;
256 compat_time_t msg_stime;
257 #ifdef CONFIG_CPU_LITTLE_ENDIAN
258 compat_ulong_t __unused1;
260 #ifndef CONFIG_CPU_LITTLE_ENDIAN
261 compat_ulong_t __unused2;
263 compat_time_t msg_rtime;
264 #ifdef CONFIG_CPU_LITTLE_ENDIAN
265 compat_ulong_t __unused2;
267 #ifndef CONFIG_CPU_LITTLE_ENDIAN
268 compat_ulong_t __unused3;
270 compat_time_t msg_ctime;
271 #ifdef CONFIG_CPU_LITTLE_ENDIAN
272 compat_ulong_t __unused3;
274 compat_ulong_t msg_cbytes;
275 compat_ulong_t msg_qnum;
276 compat_ulong_t msg_qbytes;
277 compat_pid_t msg_lspid;
278 compat_pid_t msg_lrpid;
279 compat_ulong_t __unused4;
280 compat_ulong_t __unused5;
283 struct compat_shmid64_ds {
284 struct compat_ipc64_perm shm_perm;
285 compat_size_t shm_segsz;
286 compat_time_t shm_atime;
287 compat_time_t shm_dtime;
288 compat_time_t shm_ctime;
289 compat_pid_t shm_cpid;
290 compat_pid_t shm_lpid;
291 compat_ulong_t shm_nattch;
292 compat_ulong_t __unused1;
293 compat_ulong_t __unused2;
296 /* MIPS has unusual order of fields in stack_t */
297 typedef struct compat_sigaltstack {
299 compat_size_t ss_size;
302 #define compat_sigaltstack compat_sigaltstack
304 static inline int is_compat_task(void)
306 return test_thread_flag(TIF_32BIT_ADDR);
309 #endif /* _ASM_COMPAT_H */