1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390X_COMPAT_H
3 #define _ASM_S390X_COMPAT_H
5 * Architecture specific compatibility types
7 #include <linux/types.h>
8 #include <linux/sched.h>
9 #include <linux/sched/task_stack.h>
10 #include <linux/thread_info.h>
12 #define compat_mode_t compat_mode_t
13 typedef u16 compat_mode_t;
15 #include <asm-generic/compat.h>
17 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \
18 typeof(0?(__force t)0:0ULL), u64))
20 #define __SC_DELOUSE(t,v) ({ \
21 BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \
22 (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \
25 #define PSW32_MASK_PER 0x40000000UL
26 #define PSW32_MASK_DAT 0x04000000UL
27 #define PSW32_MASK_IO 0x02000000UL
28 #define PSW32_MASK_EXT 0x01000000UL
29 #define PSW32_MASK_KEY 0x00F00000UL
30 #define PSW32_MASK_BASE 0x00080000UL /* Always one */
31 #define PSW32_MASK_MCHECK 0x00040000UL
32 #define PSW32_MASK_WAIT 0x00020000UL
33 #define PSW32_MASK_PSTATE 0x00010000UL
34 #define PSW32_MASK_ASC 0x0000C000UL
35 #define PSW32_MASK_CC 0x00003000UL
36 #define PSW32_MASK_PM 0x00000f00UL
37 #define PSW32_MASK_RI 0x00000080UL
39 #define PSW32_MASK_USER 0x0000FF00UL
41 #define PSW32_ADDR_AMODE 0x80000000UL
42 #define PSW32_ADDR_INSN 0x7FFFFFFFUL
44 #define PSW32_DEFAULT_KEY (((u32) PAGE_DEFAULT_ACC) << 20)
46 #define PSW32_ASC_PRIMARY 0x00000000UL
47 #define PSW32_ASC_ACCREG 0x00004000UL
48 #define PSW32_ASC_SECONDARY 0x00008000UL
49 #define PSW32_ASC_HOME 0x0000C000UL
51 #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \
52 PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \
53 PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \
56 #define COMPAT_USER_HZ 100
57 #define COMPAT_UTS_MACHINE "s390\0\0\0\0"
59 typedef u16 __compat_uid_t;
60 typedef u16 __compat_gid_t;
61 typedef u16 compat_dev_t;
62 typedef u16 compat_nlink_t;
63 typedef u16 compat_ipc_pid_t;
64 typedef __kernel_fsid_t compat_fsid_t;
69 } __aligned(8) psw_compat_t;
79 u32 gprs_high[NUM_GPRS];
80 } s390_compat_regs_high;
86 compat_mode_t st_mode;
87 compat_nlink_t st_nlink;
88 __compat_uid_t st_uid;
89 __compat_gid_t st_gid;
105 struct compat_flock {
108 compat_off_t l_start;
115 #define F_SETLKW64 14
117 struct compat_flock64 {
120 compat_loff_t l_start;
125 struct compat_statfs {
133 compat_fsid_t f_fsid;
140 struct compat_statfs64 {
148 compat_fsid_t f_fsid;
155 #define COMPAT_RLIM_INFINITY 0xffffffff
157 #define COMPAT_OFF_T_MAX 0x7fffffff
160 * A pointer passed in from user mode. This should not
161 * be used for syscall parameters, just declare them
162 * as pointers because the syscall entry code will have
163 * appropriately converted them already.
166 static inline void __user *compat_ptr(compat_uptr_t uptr)
168 return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
170 #define compat_ptr(uptr) compat_ptr(uptr)
174 static inline int is_compat_task(void)
176 return test_thread_flag(TIF_31BIT);
179 static inline void __user *arch_compat_alloc_user_space(long len)
183 stack = KSTK_ESP(current);
184 if (is_compat_task())
185 stack &= 0x7fffffffUL;
186 return (void __user *) (stack - len);
191 struct compat_ipc64_perm {
193 __compat_uid32_t uid;
194 __compat_gid32_t gid;
195 __compat_uid32_t cuid;
196 __compat_gid32_t cgid;
198 unsigned short __pad1;
200 unsigned short __pad2;
201 unsigned int __unused1;
202 unsigned int __unused2;
205 struct compat_semid64_ds {
206 struct compat_ipc64_perm sem_perm;
207 compat_ulong_t sem_otime;
208 compat_ulong_t sem_otime_high;
209 compat_ulong_t sem_ctime;
210 compat_ulong_t sem_ctime_high;
211 compat_ulong_t sem_nsems;
212 compat_ulong_t __unused1;
213 compat_ulong_t __unused2;
216 struct compat_msqid64_ds {
217 struct compat_ipc64_perm msg_perm;
218 compat_ulong_t msg_stime;
219 compat_ulong_t msg_stime_high;
220 compat_ulong_t msg_rtime;
221 compat_ulong_t msg_rtime_high;
222 compat_ulong_t msg_ctime;
223 compat_ulong_t msg_ctime_high;
224 compat_ulong_t msg_cbytes;
225 compat_ulong_t msg_qnum;
226 compat_ulong_t msg_qbytes;
227 compat_pid_t msg_lspid;
228 compat_pid_t msg_lrpid;
229 compat_ulong_t __unused1;
230 compat_ulong_t __unused2;
233 struct compat_shmid64_ds {
234 struct compat_ipc64_perm shm_perm;
235 compat_size_t shm_segsz;
236 compat_ulong_t shm_atime;
237 compat_ulong_t shm_atime_high;
238 compat_ulong_t shm_dtime;
239 compat_ulong_t shm_dtime_high;
240 compat_ulong_t shm_ctime;
241 compat_ulong_t shm_ctime_high;
242 compat_pid_t shm_cpid;
243 compat_pid_t shm_lpid;
244 compat_ulong_t shm_nattch;
245 compat_ulong_t __unused1;
246 compat_ulong_t __unused2;
248 #endif /* _ASM_S390X_COMPAT_H */