1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 ARM Ltd.
10 * Architecture specific compatibility types
12 #include <linux/types.h>
13 #include <linux/sched.h>
14 #include <linux/sched/task_stack.h>
16 #include <asm-generic/compat.h>
18 #define COMPAT_USER_HZ 100
20 #define COMPAT_UTS_MACHINE "armv8b\0\0"
22 #define COMPAT_UTS_MACHINE "armv8l\0\0"
25 typedef u16 __compat_uid_t;
26 typedef u16 __compat_gid_t;
27 typedef u16 __compat_uid16_t;
28 typedef u16 __compat_gid16_t;
29 typedef u32 __compat_uid32_t;
30 typedef u32 __compat_gid32_t;
31 typedef u16 compat_mode_t;
32 typedef u32 compat_dev_t;
33 typedef s32 compat_nlink_t;
34 typedef u16 compat_ipc_pid_t;
35 typedef u32 compat_caddr_t;
36 typedef __kernel_fsid_t compat_fsid_t;
37 typedef s64 compat_s64;
38 typedef u64 compat_u64;
48 compat_mode_t st_mode;
49 compat_ushort_t st_nlink;
50 __compat_uid16_t st_uid;
51 __compat_gid16_t st_gid;
59 compat_off_t st_blksize;
60 compat_off_t st_blocks;
61 old_time32_t st_atime;
62 compat_ulong_t st_atime_nsec;
63 old_time32_t st_mtime;
64 compat_ulong_t st_mtime_nsec;
65 old_time32_t st_ctime;
66 compat_ulong_t st_ctime_nsec;
67 compat_ulong_t __unused4[2];
78 #define F_GETLK64 12 /* using 'struct flock64' */
82 struct compat_flock64 {
85 compat_loff_t l_start;
90 struct compat_statfs {
99 int f_namelen; /* SunOS ignores this field. */
105 #define COMPAT_RLIM_INFINITY 0xffffffff
107 typedef u32 compat_old_sigset_t;
109 #define _COMPAT_NSIG 64
110 #define _COMPAT_NSIG_BPW 32
112 typedef u32 compat_sigset_word;
114 #define COMPAT_OFF_T_MAX 0x7fffffff
117 * A pointer passed in from user mode. This should not
118 * be used for syscall parameters, just declare them
119 * as pointers because the syscall entry code will have
120 * appropriately converted them already.
123 static inline void __user *compat_ptr(compat_uptr_t uptr)
125 return (void __user *)(unsigned long)uptr;
128 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
130 return (u32)(unsigned long)uptr;
133 #define compat_user_stack_pointer() (user_stack_pointer(task_pt_regs(current)))
134 #define COMPAT_MINSIGSTKSZ 2048
136 static inline void __user *arch_compat_alloc_user_space(long len)
138 return (void __user *)compat_user_stack_pointer() - len;
141 struct compat_ipc64_perm {
143 __compat_uid32_t uid;
144 __compat_gid32_t gid;
145 __compat_uid32_t cuid;
146 __compat_gid32_t cgid;
148 unsigned short __pad1;
150 unsigned short __pad2;
151 compat_ulong_t unused1;
152 compat_ulong_t unused2;
155 struct compat_semid64_ds {
156 struct compat_ipc64_perm sem_perm;
157 compat_ulong_t sem_otime;
158 compat_ulong_t sem_otime_high;
159 compat_ulong_t sem_ctime;
160 compat_ulong_t sem_ctime_high;
161 compat_ulong_t sem_nsems;
162 compat_ulong_t __unused3;
163 compat_ulong_t __unused4;
166 struct compat_msqid64_ds {
167 struct compat_ipc64_perm msg_perm;
168 compat_ulong_t msg_stime;
169 compat_ulong_t msg_stime_high;
170 compat_ulong_t msg_rtime;
171 compat_ulong_t msg_rtime_high;
172 compat_ulong_t msg_ctime;
173 compat_ulong_t msg_ctime_high;
174 compat_ulong_t msg_cbytes;
175 compat_ulong_t msg_qnum;
176 compat_ulong_t msg_qbytes;
177 compat_pid_t msg_lspid;
178 compat_pid_t msg_lrpid;
179 compat_ulong_t __unused4;
180 compat_ulong_t __unused5;
183 struct compat_shmid64_ds {
184 struct compat_ipc64_perm shm_perm;
185 compat_size_t shm_segsz;
186 compat_ulong_t shm_atime;
187 compat_ulong_t shm_atime_high;
188 compat_ulong_t shm_dtime;
189 compat_ulong_t shm_dtime_high;
190 compat_ulong_t shm_ctime;
191 compat_ulong_t shm_ctime_high;
192 compat_pid_t shm_cpid;
193 compat_pid_t shm_lpid;
194 compat_ulong_t shm_nattch;
195 compat_ulong_t __unused4;
196 compat_ulong_t __unused5;
199 static inline int is_compat_task(void)
201 return test_thread_flag(TIF_32BIT);
204 static inline int is_compat_thread(struct thread_info *thread)
206 return test_ti_thread_flag(thread, TIF_32BIT);
209 #else /* !CONFIG_COMPAT */
211 static inline int is_compat_thread(struct thread_info *thread)
216 #endif /* CONFIG_COMPAT */
217 #endif /* __ASM_COMPAT_H */