1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_S390X_COMPAT_H 3 #define _ASM_S390X_COMPAT_H 4 /* 5 * Architecture specific compatibility types 6 */ 7 #include <linux/types.h> 8 #include <linux/sched.h> 9 #include <linux/sched/task_stack.h> 10 #include <linux/thread_info.h> 11 #include <asm/ptrace.h> 12 13 #define compat_mode_t compat_mode_t 14 typedef u16 compat_mode_t; 15 16 #include <asm-generic/compat.h> 17 18 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \ 19 typeof(0?(__force t)0:0ULL), u64)) 20 21 #define __SC_DELOUSE(t,v) ({ \ 22 BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \ 23 (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \ 24 }) 25 26 #define PSW32_MASK_USER 0x0000FF00UL 27 28 #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \ 29 PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \ 30 PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \ 31 PSW32_ASC_PRIMARY) 32 33 #define COMPAT_USER_HZ 100 34 #define COMPAT_UTS_MACHINE "s390\0\0\0\0" 35 36 typedef u16 __compat_uid_t; 37 typedef u16 __compat_gid_t; 38 typedef u16 compat_dev_t; 39 typedef u16 compat_nlink_t; 40 typedef u16 compat_ipc_pid_t; 41 typedef __kernel_fsid_t compat_fsid_t; 42 43 typedef struct { 44 u32 mask; 45 u32 addr; 46 } __aligned(8) psw_compat_t; 47 48 typedef struct { 49 psw_compat_t psw; 50 u32 gprs[NUM_GPRS]; 51 u32 acrs[NUM_ACRS]; 52 u32 orig_gpr2; 53 } s390_compat_regs; 54 55 typedef struct { 56 u32 gprs_high[NUM_GPRS]; 57 } s390_compat_regs_high; 58 59 struct compat_stat { 60 compat_dev_t st_dev; 61 u16 __pad1; 62 compat_ino_t st_ino; 63 compat_mode_t st_mode; 64 compat_nlink_t st_nlink; 65 __compat_uid_t st_uid; 66 __compat_gid_t st_gid; 67 compat_dev_t st_rdev; 68 u16 __pad2; 69 u32 st_size; 70 u32 st_blksize; 71 u32 st_blocks; 72 u32 st_atime; 73 u32 st_atime_nsec; 74 u32 st_mtime; 75 u32 st_mtime_nsec; 76 u32 st_ctime; 77 u32 st_ctime_nsec; 78 u32 __unused4; 79 u32 __unused5; 80 }; 81 82 struct compat_flock { 83 short l_type; 84 short l_whence; 85 compat_off_t l_start; 86 compat_off_t l_len; 87 compat_pid_t l_pid; 88 }; 89 90 #define F_GETLK64 12 91 #define F_SETLK64 13 92 #define F_SETLKW64 14 93 94 struct compat_flock64 { 95 short l_type; 96 short l_whence; 97 compat_loff_t l_start; 98 compat_loff_t l_len; 99 compat_pid_t l_pid; 100 }; 101 102 struct compat_statfs { 103 u32 f_type; 104 u32 f_bsize; 105 u32 f_blocks; 106 u32 f_bfree; 107 u32 f_bavail; 108 u32 f_files; 109 u32 f_ffree; 110 compat_fsid_t f_fsid; 111 u32 f_namelen; 112 u32 f_frsize; 113 u32 f_flags; 114 u32 f_spare[4]; 115 }; 116 117 struct compat_statfs64 { 118 u32 f_type; 119 u32 f_bsize; 120 u64 f_blocks; 121 u64 f_bfree; 122 u64 f_bavail; 123 u64 f_files; 124 u64 f_ffree; 125 compat_fsid_t f_fsid; 126 u32 f_namelen; 127 u32 f_frsize; 128 u32 f_flags; 129 u32 f_spare[4]; 130 }; 131 132 #define COMPAT_RLIM_INFINITY 0xffffffff 133 134 #define COMPAT_OFF_T_MAX 0x7fffffff 135 136 /* 137 * A pointer passed in from user mode. This should not 138 * be used for syscall parameters, just declare them 139 * as pointers because the syscall entry code will have 140 * appropriately converted them already. 141 */ 142 143 static inline void __user *compat_ptr(compat_uptr_t uptr) 144 { 145 return (void __user *)(unsigned long)(uptr & 0x7fffffffUL); 146 } 147 #define compat_ptr(uptr) compat_ptr(uptr) 148 149 #ifdef CONFIG_COMPAT 150 151 static inline int is_compat_task(void) 152 { 153 return test_thread_flag(TIF_31BIT); 154 } 155 156 #endif 157 158 struct compat_ipc64_perm { 159 compat_key_t key; 160 __compat_uid32_t uid; 161 __compat_gid32_t gid; 162 __compat_uid32_t cuid; 163 __compat_gid32_t cgid; 164 compat_mode_t mode; 165 unsigned short __pad1; 166 unsigned short seq; 167 unsigned short __pad2; 168 unsigned int __unused1; 169 unsigned int __unused2; 170 }; 171 172 struct compat_semid64_ds { 173 struct compat_ipc64_perm sem_perm; 174 compat_ulong_t sem_otime; 175 compat_ulong_t sem_otime_high; 176 compat_ulong_t sem_ctime; 177 compat_ulong_t sem_ctime_high; 178 compat_ulong_t sem_nsems; 179 compat_ulong_t __unused1; 180 compat_ulong_t __unused2; 181 }; 182 183 struct compat_msqid64_ds { 184 struct compat_ipc64_perm msg_perm; 185 compat_ulong_t msg_stime; 186 compat_ulong_t msg_stime_high; 187 compat_ulong_t msg_rtime; 188 compat_ulong_t msg_rtime_high; 189 compat_ulong_t msg_ctime; 190 compat_ulong_t msg_ctime_high; 191 compat_ulong_t msg_cbytes; 192 compat_ulong_t msg_qnum; 193 compat_ulong_t msg_qbytes; 194 compat_pid_t msg_lspid; 195 compat_pid_t msg_lrpid; 196 compat_ulong_t __unused1; 197 compat_ulong_t __unused2; 198 }; 199 200 struct compat_shmid64_ds { 201 struct compat_ipc64_perm shm_perm; 202 compat_size_t shm_segsz; 203 compat_ulong_t shm_atime; 204 compat_ulong_t shm_atime_high; 205 compat_ulong_t shm_dtime; 206 compat_ulong_t shm_dtime_high; 207 compat_ulong_t shm_ctime; 208 compat_ulong_t shm_ctime_high; 209 compat_pid_t shm_cpid; 210 compat_pid_t shm_lpid; 211 compat_ulong_t shm_nattch; 212 compat_ulong_t __unused1; 213 compat_ulong_t __unused2; 214 }; 215 #endif /* _ASM_S390X_COMPAT_H */ 216