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 __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \
13 typeof(0?(__force t)0:0ULL), u64))
15 #define __SC_DELOUSE(t,v) ({ \
16 BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \
17 (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \
20 #define PSW32_MASK_PER 0x40000000UL
21 #define PSW32_MASK_DAT 0x04000000UL
22 #define PSW32_MASK_IO 0x02000000UL
23 #define PSW32_MASK_EXT 0x01000000UL
24 #define PSW32_MASK_KEY 0x00F00000UL
25 #define PSW32_MASK_BASE 0x00080000UL /* Always one */
26 #define PSW32_MASK_MCHECK 0x00040000UL
27 #define PSW32_MASK_WAIT 0x00020000UL
28 #define PSW32_MASK_PSTATE 0x00010000UL
29 #define PSW32_MASK_ASC 0x0000C000UL
30 #define PSW32_MASK_CC 0x00003000UL
31 #define PSW32_MASK_PM 0x00000f00UL
32 #define PSW32_MASK_RI 0x00000080UL
34 #define PSW32_MASK_USER 0x0000FF00UL
36 #define PSW32_ADDR_AMODE 0x80000000UL
37 #define PSW32_ADDR_INSN 0x7FFFFFFFUL
39 #define PSW32_DEFAULT_KEY (((u32) PAGE_DEFAULT_ACC) << 20)
41 #define PSW32_ASC_PRIMARY 0x00000000UL
42 #define PSW32_ASC_ACCREG 0x00004000UL
43 #define PSW32_ASC_SECONDARY 0x00008000UL
44 #define PSW32_ASC_HOME 0x0000C000UL
46 #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \
47 PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \
48 PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \
51 #define COMPAT_USER_HZ 100
52 #define COMPAT_UTS_MACHINE "s390\0\0\0\0"
54 typedef u32 compat_size_t
;
55 typedef s32 compat_ssize_t
;
56 typedef s32 compat_time_t
;
57 typedef s32 compat_clock_t
;
58 typedef s32 compat_pid_t
;
59 typedef u16 __compat_uid_t
;
60 typedef u16 __compat_gid_t
;
61 typedef u32 __compat_uid32_t
;
62 typedef u32 __compat_gid32_t
;
63 typedef u16 compat_mode_t
;
64 typedef u32 compat_ino_t
;
65 typedef u16 compat_dev_t
;
66 typedef s32 compat_off_t
;
67 typedef s64 compat_loff_t
;
68 typedef u16 compat_nlink_t
;
69 typedef u16 compat_ipc_pid_t
;
70 typedef s32 compat_daddr_t
;
71 typedef u32 compat_caddr_t
;
72 typedef __kernel_fsid_t compat_fsid_t
;
73 typedef s32 compat_key_t
;
74 typedef s32 compat_timer_t
;
76 typedef s32 compat_int_t
;
77 typedef s32 compat_long_t
;
78 typedef s64 compat_s64
;
79 typedef u32 compat_uint_t
;
80 typedef u32 compat_ulong_t
;
81 typedef u64 compat_u64
;
82 typedef u32 compat_uptr_t
;
87 } __aligned(8) psw_compat_t
;
97 u32 gprs_high
[NUM_GPRS
];
98 } s390_compat_regs_high
;
100 struct compat_timespec
{
101 compat_time_t tv_sec
;
105 struct compat_timeval
{
106 compat_time_t tv_sec
;
114 compat_mode_t st_mode
;
115 compat_nlink_t st_nlink
;
116 __compat_uid_t st_uid
;
117 __compat_gid_t st_gid
;
118 compat_dev_t st_rdev
;
133 struct compat_flock
{
136 compat_off_t l_start
;
143 #define F_SETLKW64 14
145 struct compat_flock64
{
148 compat_loff_t l_start
;
153 struct compat_statfs
{
161 compat_fsid_t f_fsid
;
168 struct compat_statfs64
{
176 compat_fsid_t f_fsid
;
183 #define COMPAT_RLIM_INFINITY 0xffffffff
185 typedef u32 compat_old_sigset_t
; /* at least 32 bits */
187 #define _COMPAT_NSIG 64
188 #define _COMPAT_NSIG_BPW 32
190 typedef u32 compat_sigset_word
;
192 #define COMPAT_OFF_T_MAX 0x7fffffff
195 * A pointer passed in from user mode. This should not
196 * be used for syscall parameters, just declare them
197 * as pointers because the syscall entry code will have
198 * appropriately converted them already.
201 static inline void __user
*compat_ptr(compat_uptr_t uptr
)
203 return (void __user
*)(unsigned long)(uptr
& 0x7fffffffUL
);
206 static inline compat_uptr_t
ptr_to_compat(void __user
*uptr
)
208 return (u32
)(unsigned long)uptr
;
213 static inline int is_compat_task(void)
215 return test_thread_flag(TIF_31BIT
);
218 static inline void __user
*arch_compat_alloc_user_space(long len
)
222 stack
= KSTK_ESP(current
);
223 if (is_compat_task())
224 stack
&= 0x7fffffffUL
;
225 return (void __user
*) (stack
- len
);
230 struct compat_ipc64_perm
{
232 __compat_uid32_t uid
;
233 __compat_gid32_t gid
;
234 __compat_uid32_t cuid
;
235 __compat_gid32_t cgid
;
237 unsigned short __pad1
;
239 unsigned short __pad2
;
240 unsigned int __unused1
;
241 unsigned int __unused2
;
244 struct compat_semid64_ds
{
245 struct compat_ipc64_perm sem_perm
;
246 compat_time_t sem_otime
;
247 compat_ulong_t __pad1
;
248 compat_time_t sem_ctime
;
249 compat_ulong_t __pad2
;
250 compat_ulong_t sem_nsems
;
251 compat_ulong_t __unused1
;
252 compat_ulong_t __unused2
;
255 struct compat_msqid64_ds
{
256 struct compat_ipc64_perm msg_perm
;
257 compat_time_t msg_stime
;
258 compat_ulong_t __pad1
;
259 compat_time_t msg_rtime
;
260 compat_ulong_t __pad2
;
261 compat_time_t msg_ctime
;
262 compat_ulong_t __pad3
;
263 compat_ulong_t msg_cbytes
;
264 compat_ulong_t msg_qnum
;
265 compat_ulong_t msg_qbytes
;
266 compat_pid_t msg_lspid
;
267 compat_pid_t msg_lrpid
;
268 compat_ulong_t __unused1
;
269 compat_ulong_t __unused2
;
272 struct compat_shmid64_ds
{
273 struct compat_ipc64_perm shm_perm
;
274 compat_size_t shm_segsz
;
275 compat_time_t shm_atime
;
276 compat_ulong_t __pad1
;
277 compat_time_t shm_dtime
;
278 compat_ulong_t __pad2
;
279 compat_time_t shm_ctime
;
280 compat_ulong_t __pad3
;
281 compat_pid_t shm_cpid
;
282 compat_pid_t shm_lpid
;
283 compat_ulong_t shm_nattch
;
284 compat_ulong_t __unused1
;
285 compat_ulong_t __unused2
;
287 #endif /* _ASM_S390X_COMPAT_H */