1 #ifndef _ASM_S390X_COMPAT_H 2 #define _ASM_S390X_COMPAT_H 3 /* 4 * Architecture specific compatibility types 5 */ 6 #include <linux/types.h> 7 #include <linux/sched.h> 8 #include <linux/sched/task_stack.h> 9 #include <linux/thread_info.h> 10 11 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p(typeof(0?(t)0:0ULL), u64)) 12 13 #define __SC_DELOUSE(t,v) ({ \ 14 BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \ 15 (t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \ 16 }) 17 18 #define PSW32_MASK_PER 0x40000000UL 19 #define PSW32_MASK_DAT 0x04000000UL 20 #define PSW32_MASK_IO 0x02000000UL 21 #define PSW32_MASK_EXT 0x01000000UL 22 #define PSW32_MASK_KEY 0x00F00000UL 23 #define PSW32_MASK_BASE 0x00080000UL /* Always one */ 24 #define PSW32_MASK_MCHECK 0x00040000UL 25 #define PSW32_MASK_WAIT 0x00020000UL 26 #define PSW32_MASK_PSTATE 0x00010000UL 27 #define PSW32_MASK_ASC 0x0000C000UL 28 #define PSW32_MASK_CC 0x00003000UL 29 #define PSW32_MASK_PM 0x00000f00UL 30 #define PSW32_MASK_RI 0x00000080UL 31 32 #define PSW32_MASK_USER 0x0000FF00UL 33 34 #define PSW32_ADDR_AMODE 0x80000000UL 35 #define PSW32_ADDR_INSN 0x7FFFFFFFUL 36 37 #define PSW32_DEFAULT_KEY (((u32) PAGE_DEFAULT_ACC) << 20) 38 39 #define PSW32_ASC_PRIMARY 0x00000000UL 40 #define PSW32_ASC_ACCREG 0x00004000UL 41 #define PSW32_ASC_SECONDARY 0x00008000UL 42 #define PSW32_ASC_HOME 0x0000C000UL 43 44 #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \ 45 PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \ 46 PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \ 47 PSW32_ASC_PRIMARY) 48 49 #define COMPAT_USER_HZ 100 50 #define COMPAT_UTS_MACHINE "s390\0\0\0\0" 51 52 typedef u32 compat_size_t; 53 typedef s32 compat_ssize_t; 54 typedef s32 compat_time_t; 55 typedef s32 compat_clock_t; 56 typedef s32 compat_pid_t; 57 typedef u16 __compat_uid_t; 58 typedef u16 __compat_gid_t; 59 typedef u32 __compat_uid32_t; 60 typedef u32 __compat_gid32_t; 61 typedef u16 compat_mode_t; 62 typedef u32 compat_ino_t; 63 typedef u16 compat_dev_t; 64 typedef s32 compat_off_t; 65 typedef s64 compat_loff_t; 66 typedef u16 compat_nlink_t; 67 typedef u16 compat_ipc_pid_t; 68 typedef s32 compat_daddr_t; 69 typedef u32 compat_caddr_t; 70 typedef __kernel_fsid_t compat_fsid_t; 71 typedef s32 compat_key_t; 72 typedef s32 compat_timer_t; 73 74 typedef s32 compat_int_t; 75 typedef s32 compat_long_t; 76 typedef s64 compat_s64; 77 typedef u32 compat_uint_t; 78 typedef u32 compat_ulong_t; 79 typedef u64 compat_u64; 80 typedef u32 compat_uptr_t; 81 82 typedef struct { 83 u32 mask; 84 u32 addr; 85 } __aligned(8) psw_compat_t; 86 87 typedef struct { 88 psw_compat_t psw; 89 u32 gprs[NUM_GPRS]; 90 u32 acrs[NUM_ACRS]; 91 u32 orig_gpr2; 92 } s390_compat_regs; 93 94 typedef struct { 95 u32 gprs_high[NUM_GPRS]; 96 } s390_compat_regs_high; 97 98 struct compat_timespec { 99 compat_time_t tv_sec; 100 s32 tv_nsec; 101 }; 102 103 struct compat_timeval { 104 compat_time_t tv_sec; 105 s32 tv_usec; 106 }; 107 108 struct compat_stat { 109 compat_dev_t st_dev; 110 u16 __pad1; 111 compat_ino_t st_ino; 112 compat_mode_t st_mode; 113 compat_nlink_t st_nlink; 114 __compat_uid_t st_uid; 115 __compat_gid_t st_gid; 116 compat_dev_t st_rdev; 117 u16 __pad2; 118 u32 st_size; 119 u32 st_blksize; 120 u32 st_blocks; 121 u32 st_atime; 122 u32 st_atime_nsec; 123 u32 st_mtime; 124 u32 st_mtime_nsec; 125 u32 st_ctime; 126 u32 st_ctime_nsec; 127 u32 __unused4; 128 u32 __unused5; 129 }; 130 131 struct compat_flock { 132 short l_type; 133 short l_whence; 134 compat_off_t l_start; 135 compat_off_t l_len; 136 compat_pid_t l_pid; 137 }; 138 139 #define F_GETLK64 12 140 #define F_SETLK64 13 141 #define F_SETLKW64 14 142 143 struct compat_flock64 { 144 short l_type; 145 short l_whence; 146 compat_loff_t l_start; 147 compat_loff_t l_len; 148 compat_pid_t l_pid; 149 }; 150 151 struct compat_statfs { 152 u32 f_type; 153 u32 f_bsize; 154 u32 f_blocks; 155 u32 f_bfree; 156 u32 f_bavail; 157 u32 f_files; 158 u32 f_ffree; 159 compat_fsid_t f_fsid; 160 u32 f_namelen; 161 u32 f_frsize; 162 u32 f_flags; 163 u32 f_spare[4]; 164 }; 165 166 struct compat_statfs64 { 167 u32 f_type; 168 u32 f_bsize; 169 u64 f_blocks; 170 u64 f_bfree; 171 u64 f_bavail; 172 u64 f_files; 173 u64 f_ffree; 174 compat_fsid_t f_fsid; 175 u32 f_namelen; 176 u32 f_frsize; 177 u32 f_flags; 178 u32 f_spare[4]; 179 }; 180 181 #define COMPAT_RLIM_INFINITY 0xffffffff 182 183 typedef u32 compat_old_sigset_t; /* at least 32 bits */ 184 185 #define _COMPAT_NSIG 64 186 #define _COMPAT_NSIG_BPW 32 187 188 typedef u32 compat_sigset_word; 189 190 typedef union compat_sigval { 191 compat_int_t sival_int; 192 compat_uptr_t sival_ptr; 193 } compat_sigval_t; 194 195 typedef struct compat_siginfo { 196 int si_signo; 197 int si_errno; 198 int si_code; 199 200 union { 201 int _pad[128/sizeof(int) - 3]; 202 203 /* kill() */ 204 struct { 205 pid_t _pid; /* sender's pid */ 206 uid_t _uid; /* sender's uid */ 207 } _kill; 208 209 /* POSIX.1b timers */ 210 struct { 211 compat_timer_t _tid; /* timer id */ 212 int _overrun; /* overrun count */ 213 compat_sigval_t _sigval; /* same as below */ 214 int _sys_private; /* not to be passed to user */ 215 } _timer; 216 217 /* POSIX.1b signals */ 218 struct { 219 pid_t _pid; /* sender's pid */ 220 uid_t _uid; /* sender's uid */ 221 compat_sigval_t _sigval; 222 } _rt; 223 224 /* SIGCHLD */ 225 struct { 226 pid_t _pid; /* which child */ 227 uid_t _uid; /* sender's uid */ 228 int _status;/* exit code */ 229 compat_clock_t _utime; 230 compat_clock_t _stime; 231 } _sigchld; 232 233 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ 234 struct { 235 __u32 _addr; /* faulting insn/memory ref. - pointer */ 236 } _sigfault; 237 238 /* SIGPOLL */ 239 struct { 240 int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 241 int _fd; 242 } _sigpoll; 243 } _sifields; 244 } compat_siginfo_t; 245 246 /* 247 * How these fields are to be accessed. 248 */ 249 #define si_pid _sifields._kill._pid 250 #define si_uid _sifields._kill._uid 251 #define si_status _sifields._sigchld._status 252 #define si_utime _sifields._sigchld._utime 253 #define si_stime _sifields._sigchld._stime 254 #define si_value _sifields._rt._sigval 255 #define si_int _sifields._rt._sigval.sival_int 256 #define si_ptr _sifields._rt._sigval.sival_ptr 257 #define si_addr _sifields._sigfault._addr 258 #define si_band _sifields._sigpoll._band 259 #define si_fd _sifields._sigpoll._fd 260 #define si_tid _sifields._timer._tid 261 #define si_overrun _sifields._timer._overrun 262 263 #define COMPAT_OFF_T_MAX 0x7fffffff 264 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL 265 266 /* 267 * A pointer passed in from user mode. This should not 268 * be used for syscall parameters, just declare them 269 * as pointers because the syscall entry code will have 270 * appropriately converted them already. 271 */ 272 273 static inline void __user *compat_ptr(compat_uptr_t uptr) 274 { 275 return (void __user *)(unsigned long)(uptr & 0x7fffffffUL); 276 } 277 278 static inline compat_uptr_t ptr_to_compat(void __user *uptr) 279 { 280 return (u32)(unsigned long)uptr; 281 } 282 283 #ifdef CONFIG_COMPAT 284 285 static inline int is_compat_task(void) 286 { 287 return test_thread_flag(TIF_31BIT); 288 } 289 290 static inline void __user *arch_compat_alloc_user_space(long len) 291 { 292 unsigned long stack; 293 294 stack = KSTK_ESP(current); 295 if (is_compat_task()) 296 stack &= 0x7fffffffUL; 297 return (void __user *) (stack - len); 298 } 299 300 #endif 301 302 struct compat_ipc64_perm { 303 compat_key_t key; 304 __compat_uid32_t uid; 305 __compat_gid32_t gid; 306 __compat_uid32_t cuid; 307 __compat_gid32_t cgid; 308 compat_mode_t mode; 309 unsigned short __pad1; 310 unsigned short seq; 311 unsigned short __pad2; 312 unsigned int __unused1; 313 unsigned int __unused2; 314 }; 315 316 struct compat_semid64_ds { 317 struct compat_ipc64_perm sem_perm; 318 compat_time_t sem_otime; 319 compat_ulong_t __pad1; 320 compat_time_t sem_ctime; 321 compat_ulong_t __pad2; 322 compat_ulong_t sem_nsems; 323 compat_ulong_t __unused1; 324 compat_ulong_t __unused2; 325 }; 326 327 struct compat_msqid64_ds { 328 struct compat_ipc64_perm msg_perm; 329 compat_time_t msg_stime; 330 compat_ulong_t __pad1; 331 compat_time_t msg_rtime; 332 compat_ulong_t __pad2; 333 compat_time_t msg_ctime; 334 compat_ulong_t __pad3; 335 compat_ulong_t msg_cbytes; 336 compat_ulong_t msg_qnum; 337 compat_ulong_t msg_qbytes; 338 compat_pid_t msg_lspid; 339 compat_pid_t msg_lrpid; 340 compat_ulong_t __unused1; 341 compat_ulong_t __unused2; 342 }; 343 344 struct compat_shmid64_ds { 345 struct compat_ipc64_perm shm_perm; 346 compat_size_t shm_segsz; 347 compat_time_t shm_atime; 348 compat_ulong_t __pad1; 349 compat_time_t shm_dtime; 350 compat_ulong_t __pad2; 351 compat_time_t shm_ctime; 352 compat_ulong_t __pad3; 353 compat_pid_t shm_cpid; 354 compat_pid_t shm_lpid; 355 compat_ulong_t shm_nattch; 356 compat_ulong_t __unused1; 357 compat_ulong_t __unused2; 358 }; 359 #endif /* _ASM_S390X_COMPAT_H */ 360