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