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_clock_t;
18 typedef s32 compat_suseconds_t;
20 typedef s32 compat_pid_t;
21 typedef s32 __compat_uid_t;
22 typedef s32 __compat_gid_t;
23 typedef __compat_uid_t __compat_uid32_t;
24 typedef __compat_gid_t __compat_gid32_t;
25 typedef u32 compat_mode_t;
26 typedef u32 compat_ino_t;
27 typedef u32 compat_dev_t;
28 typedef s32 compat_off_t;
29 typedef s64 compat_loff_t;
30 typedef u32 compat_nlink_t;
31 typedef s32 compat_ipc_pid_t;
32 typedef s32 compat_daddr_t;
33 typedef s32 compat_caddr_t;
37 typedef s32 compat_timer_t;
38 typedef s32 compat_key_t;
40 typedef s16 compat_short_t;
41 typedef s32 compat_int_t;
42 typedef s32 compat_long_t;
43 typedef s64 compat_s64;
44 typedef u16 compat_ushort_t;
45 typedef u32 compat_uint_t;
46 typedef u32 compat_ulong_t;
47 typedef u64 compat_u64;
48 typedef u32 compat_uptr_t;
54 compat_mode_t st_mode;
55 compat_nlink_t st_nlink;
56 __compat_uid_t st_uid;
57 __compat_gid_t st_gid;
62 compat_time_t st_atime;
64 compat_time_t st_mtime;
66 compat_time_t st_ctime;
87 struct compat_flock64 {
90 compat_loff_t l_start;
95 struct compat_statfs {
104 compat_fsid_t f_fsid;
110 #define COMPAT_RLIM_INFINITY 0x7fffffffUL
112 typedef u32 compat_old_sigset_t; /* at least 32 bits */
114 #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */
115 #define _COMPAT_NSIG_BPW 32
117 typedef u32 compat_sigset_word;
119 #define COMPAT_OFF_T_MAX 0x7fffffff
122 * A pointer passed in from user mode. This should not
123 * be used for syscall parameters, just declare them
124 * as pointers because the syscall entry code will have
125 * appropriately converted them already.
128 static inline void __user *compat_ptr(compat_uptr_t uptr)
130 /* cast to a __user pointer via "unsigned long" makes sparse happy */
131 return (void __user *)(unsigned long)(long)uptr;
134 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
136 return (u32)(unsigned long)uptr;
139 static inline void __user *arch_compat_alloc_user_space(long len)
141 struct pt_regs *regs = (struct pt_regs *)
142 ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1;
144 return (void __user *) (regs->regs[29] - len);
147 struct compat_ipc64_perm {
149 __compat_uid32_t uid;
150 __compat_gid32_t gid;
151 __compat_uid32_t cuid;
152 __compat_gid32_t cgid;
155 unsigned short __pad2;
156 compat_ulong_t __unused1;
157 compat_ulong_t __unused2;
160 struct compat_semid64_ds {
161 struct compat_ipc64_perm sem_perm;
162 compat_ulong_t sem_otime;
163 compat_ulong_t sem_ctime;
164 compat_ulong_t sem_nsems;
165 compat_ulong_t sem_otime_high;
166 compat_ulong_t sem_ctime_high;
169 struct compat_msqid64_ds {
170 struct compat_ipc64_perm msg_perm;
171 #ifndef CONFIG_CPU_LITTLE_ENDIAN
172 compat_ulong_t msg_stime_high;
174 compat_ulong_t msg_stime;
175 #ifdef CONFIG_CPU_LITTLE_ENDIAN
176 compat_ulong_t msg_stime_high;
178 #ifndef CONFIG_CPU_LITTLE_ENDIAN
179 compat_ulong_t msg_rtime_high;
181 compat_ulong_t msg_rtime;
182 #ifdef CONFIG_CPU_LITTLE_ENDIAN
183 compat_ulong_t msg_rtime_high;
185 #ifndef CONFIG_CPU_LITTLE_ENDIAN
186 compat_ulong_t msg_ctime_high;
188 compat_ulong_t msg_ctime;
189 #ifdef CONFIG_CPU_LITTLE_ENDIAN
190 compat_ulong_t msg_ctime_high;
192 compat_ulong_t msg_cbytes;
193 compat_ulong_t msg_qnum;
194 compat_ulong_t msg_qbytes;
195 compat_pid_t msg_lspid;
196 compat_pid_t msg_lrpid;
197 compat_ulong_t __unused4;
198 compat_ulong_t __unused5;
201 struct compat_shmid64_ds {
202 struct compat_ipc64_perm shm_perm;
203 compat_size_t shm_segsz;
204 compat_ulong_t shm_atime;
205 compat_ulong_t shm_dtime;
206 compat_ulong_t shm_ctime;
207 compat_pid_t shm_cpid;
208 compat_pid_t shm_lpid;
209 compat_ulong_t shm_nattch;
210 compat_ushort_t shm_atime_high;
211 compat_ushort_t shm_dtime_high;
212 compat_ushort_t shm_ctime_high;
213 compat_ushort_t __unused2;
216 /* MIPS has unusual order of fields in stack_t */
217 typedef struct compat_sigaltstack {
219 compat_size_t ss_size;
222 #define compat_sigaltstack compat_sigaltstack
224 static inline int is_compat_task(void)
226 return test_thread_flag(TIF_32BIT_ADDR);
229 #endif /* _ASM_COMPAT_H */