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 12 #define compat_mode_t compat_mode_t 13 typedef u16 compat_mode_t; 14 15 #include <asm-generic/compat.h> 16 17 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \ 18 typeof(0?(__force t)0:0ULL), u64)) 19 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)); \ 23 }) 24 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 38 39 #define PSW32_MASK_USER 0x0000FF00UL 40 41 #define PSW32_ADDR_AMODE 0x80000000UL 42 #define PSW32_ADDR_INSN 0x7FFFFFFFUL 43 44 #define PSW32_DEFAULT_KEY (((u32) PAGE_DEFAULT_ACC) << 20) 45 46 #define PSW32_ASC_PRIMARY 0x00000000UL 47 #define PSW32_ASC_ACCREG 0x00004000UL 48 #define PSW32_ASC_SECONDARY 0x00008000UL 49 #define PSW32_ASC_HOME 0x0000C000UL 50 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 | \ 54 PSW32_ASC_PRIMARY) 55 56 #define COMPAT_USER_HZ 100 57 #define COMPAT_UTS_MACHINE "s390\0\0\0\0" 58 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; 65 66 typedef struct { 67 u32 mask; 68 u32 addr; 69 } __aligned(8) psw_compat_t; 70 71 typedef struct { 72 psw_compat_t psw; 73 u32 gprs[NUM_GPRS]; 74 u32 acrs[NUM_ACRS]; 75 u32 orig_gpr2; 76 } s390_compat_regs; 77 78 typedef struct { 79 u32 gprs_high[NUM_GPRS]; 80 } s390_compat_regs_high; 81 82 struct compat_stat { 83 compat_dev_t st_dev; 84 u16 __pad1; 85 compat_ino_t st_ino; 86 compat_mode_t st_mode; 87 compat_nlink_t st_nlink; 88 __compat_uid_t st_uid; 89 __compat_gid_t st_gid; 90 compat_dev_t st_rdev; 91 u16 __pad2; 92 u32 st_size; 93 u32 st_blksize; 94 u32 st_blocks; 95 u32 st_atime; 96 u32 st_atime_nsec; 97 u32 st_mtime; 98 u32 st_mtime_nsec; 99 u32 st_ctime; 100 u32 st_ctime_nsec; 101 u32 __unused4; 102 u32 __unused5; 103 }; 104 105 struct compat_flock { 106 short l_type; 107 short l_whence; 108 compat_off_t l_start; 109 compat_off_t l_len; 110 compat_pid_t l_pid; 111 }; 112 113 #define F_GETLK64 12 114 #define F_SETLK64 13 115 #define F_SETLKW64 14 116 117 struct compat_flock64 { 118 short l_type; 119 short l_whence; 120 compat_loff_t l_start; 121 compat_loff_t l_len; 122 compat_pid_t l_pid; 123 }; 124 125 struct compat_statfs { 126 u32 f_type; 127 u32 f_bsize; 128 u32 f_blocks; 129 u32 f_bfree; 130 u32 f_bavail; 131 u32 f_files; 132 u32 f_ffree; 133 compat_fsid_t f_fsid; 134 u32 f_namelen; 135 u32 f_frsize; 136 u32 f_flags; 137 u32 f_spare[4]; 138 }; 139 140 struct compat_statfs64 { 141 u32 f_type; 142 u32 f_bsize; 143 u64 f_blocks; 144 u64 f_bfree; 145 u64 f_bavail; 146 u64 f_files; 147 u64 f_ffree; 148 compat_fsid_t f_fsid; 149 u32 f_namelen; 150 u32 f_frsize; 151 u32 f_flags; 152 u32 f_spare[4]; 153 }; 154 155 #define COMPAT_RLIM_INFINITY 0xffffffff 156 157 #define COMPAT_OFF_T_MAX 0x7fffffff 158 159 /* 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. 164 */ 165 compat_ptr(compat_uptr_t uptr)166static inline void __user *compat_ptr(compat_uptr_t uptr) 167 { 168 return (void __user *)(unsigned long)(uptr & 0x7fffffffUL); 169 } 170 #define compat_ptr(uptr) compat_ptr(uptr) 171 172 #ifdef CONFIG_COMPAT 173 is_compat_task(void)174static inline int is_compat_task(void) 175 { 176 return test_thread_flag(TIF_31BIT); 177 } 178 179 #endif 180 181 struct compat_ipc64_perm { 182 compat_key_t key; 183 __compat_uid32_t uid; 184 __compat_gid32_t gid; 185 __compat_uid32_t cuid; 186 __compat_gid32_t cgid; 187 compat_mode_t mode; 188 unsigned short __pad1; 189 unsigned short seq; 190 unsigned short __pad2; 191 unsigned int __unused1; 192 unsigned int __unused2; 193 }; 194 195 struct compat_semid64_ds { 196 struct compat_ipc64_perm sem_perm; 197 compat_ulong_t sem_otime; 198 compat_ulong_t sem_otime_high; 199 compat_ulong_t sem_ctime; 200 compat_ulong_t sem_ctime_high; 201 compat_ulong_t sem_nsems; 202 compat_ulong_t __unused1; 203 compat_ulong_t __unused2; 204 }; 205 206 struct compat_msqid64_ds { 207 struct compat_ipc64_perm msg_perm; 208 compat_ulong_t msg_stime; 209 compat_ulong_t msg_stime_high; 210 compat_ulong_t msg_rtime; 211 compat_ulong_t msg_rtime_high; 212 compat_ulong_t msg_ctime; 213 compat_ulong_t msg_ctime_high; 214 compat_ulong_t msg_cbytes; 215 compat_ulong_t msg_qnum; 216 compat_ulong_t msg_qbytes; 217 compat_pid_t msg_lspid; 218 compat_pid_t msg_lrpid; 219 compat_ulong_t __unused1; 220 compat_ulong_t __unused2; 221 }; 222 223 struct compat_shmid64_ds { 224 struct compat_ipc64_perm shm_perm; 225 compat_size_t shm_segsz; 226 compat_ulong_t shm_atime; 227 compat_ulong_t shm_atime_high; 228 compat_ulong_t shm_dtime; 229 compat_ulong_t shm_dtime_high; 230 compat_ulong_t shm_ctime; 231 compat_ulong_t shm_ctime_high; 232 compat_pid_t shm_cpid; 233 compat_pid_t shm_lpid; 234 compat_ulong_t shm_nattch; 235 compat_ulong_t __unused1; 236 compat_ulong_t __unused2; 237 }; 238 #endif /* _ASM_S390X_COMPAT_H */ 239