1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_PARISC_COMPAT_H 3 #define _ASM_PARISC_COMPAT_H 4 /* 5 * Architecture specific compatibility types 6 */ 7 #include <linux/types.h> 8 #include <linux/sched.h> 9 #include <linux/thread_info.h> 10 11 #define COMPAT_USER_HZ 100 12 #define COMPAT_UTS_MACHINE "parisc\0\0" 13 14 typedef u32 compat_size_t; 15 typedef s32 compat_ssize_t; 16 typedef s32 compat_clock_t; 17 typedef s32 compat_pid_t; 18 typedef u32 __compat_uid_t; 19 typedef u32 __compat_gid_t; 20 typedef u32 __compat_uid32_t; 21 typedef u32 __compat_gid32_t; 22 typedef u16 compat_mode_t; 23 typedef u32 compat_ino_t; 24 typedef u32 compat_dev_t; 25 typedef s32 compat_off_t; 26 typedef s64 compat_loff_t; 27 typedef u16 compat_nlink_t; 28 typedef u16 compat_ipc_pid_t; 29 typedef s32 compat_daddr_t; 30 typedef u32 compat_caddr_t; 31 typedef s32 compat_key_t; 32 typedef s32 compat_timer_t; 33 34 typedef s32 compat_int_t; 35 typedef s32 compat_long_t; 36 typedef s64 compat_s64; 37 typedef u32 compat_uint_t; 38 typedef u32 compat_ulong_t; 39 typedef u64 compat_u64; 40 typedef u32 compat_uptr_t; 41 42 struct compat_stat { 43 compat_dev_t st_dev; /* dev_t is 32 bits on parisc */ 44 compat_ino_t st_ino; /* 32 bits */ 45 compat_mode_t st_mode; /* 16 bits */ 46 compat_nlink_t st_nlink; /* 16 bits */ 47 u16 st_reserved1; /* old st_uid */ 48 u16 st_reserved2; /* old st_gid */ 49 compat_dev_t st_rdev; 50 compat_off_t st_size; 51 compat_time_t st_atime; 52 u32 st_atime_nsec; 53 compat_time_t st_mtime; 54 u32 st_mtime_nsec; 55 compat_time_t st_ctime; 56 u32 st_ctime_nsec; 57 s32 st_blksize; 58 s32 st_blocks; 59 u32 __unused1; /* ACL stuff */ 60 compat_dev_t __unused2; /* network */ 61 compat_ino_t __unused3; /* network */ 62 u32 __unused4; /* cnodes */ 63 u16 __unused5; /* netsite */ 64 short st_fstype; 65 compat_dev_t st_realdev; 66 u16 st_basemode; 67 u16 st_spareshort; 68 __compat_uid32_t st_uid; 69 __compat_gid32_t st_gid; 70 u32 st_spare4[3]; 71 }; 72 73 struct compat_flock { 74 short l_type; 75 short l_whence; 76 compat_off_t l_start; 77 compat_off_t l_len; 78 compat_pid_t l_pid; 79 }; 80 81 struct compat_flock64 { 82 short l_type; 83 short l_whence; 84 compat_loff_t l_start; 85 compat_loff_t l_len; 86 compat_pid_t l_pid; 87 }; 88 89 struct compat_statfs { 90 s32 f_type; 91 s32 f_bsize; 92 s32 f_blocks; 93 s32 f_bfree; 94 s32 f_bavail; 95 s32 f_files; 96 s32 f_ffree; 97 __kernel_fsid_t f_fsid; 98 s32 f_namelen; 99 s32 f_frsize; 100 s32 f_flags; 101 s32 f_spare[4]; 102 }; 103 104 struct compat_sigcontext { 105 compat_int_t sc_flags; 106 compat_int_t sc_gr[32]; /* PSW in sc_gr[0] */ 107 u64 sc_fr[32]; 108 compat_int_t sc_iasq[2]; 109 compat_int_t sc_iaoq[2]; 110 compat_int_t sc_sar; /* cr11 */ 111 }; 112 113 #define COMPAT_RLIM_INFINITY 0xffffffff 114 115 typedef u32 compat_old_sigset_t; /* at least 32 bits */ 116 117 #define _COMPAT_NSIG 64 118 #define _COMPAT_NSIG_BPW 32 119 120 typedef u32 compat_sigset_word; 121 122 #define COMPAT_OFF_T_MAX 0x7fffffff 123 124 struct compat_ipc64_perm { 125 compat_key_t key; 126 __compat_uid_t uid; 127 __compat_gid_t gid; 128 __compat_uid_t cuid; 129 __compat_gid_t cgid; 130 unsigned short int __pad1; 131 compat_mode_t mode; 132 unsigned short int __pad2; 133 unsigned short int seq; 134 unsigned int __pad3; 135 unsigned long __unused1; /* yes they really are 64bit pads */ 136 unsigned long __unused2; 137 }; 138 139 struct compat_semid64_ds { 140 struct compat_ipc64_perm sem_perm; 141 unsigned int sem_otime_high; 142 unsigned int sem_otime; 143 unsigned int sem_ctime_high; 144 unsigned int sem_ctime; 145 compat_ulong_t sem_nsems; 146 compat_ulong_t __unused3; 147 compat_ulong_t __unused4; 148 }; 149 150 struct compat_msqid64_ds { 151 struct compat_ipc64_perm msg_perm; 152 unsigned int msg_stime_high; 153 unsigned int msg_stime; 154 unsigned int msg_rtime_high; 155 unsigned int msg_rtime; 156 unsigned int msg_ctime_high; 157 unsigned int msg_ctime; 158 compat_ulong_t msg_cbytes; 159 compat_ulong_t msg_qnum; 160 compat_ulong_t msg_qbytes; 161 compat_pid_t msg_lspid; 162 compat_pid_t msg_lrpid; 163 compat_ulong_t __unused4; 164 compat_ulong_t __unused5; 165 }; 166 167 struct compat_shmid64_ds { 168 struct compat_ipc64_perm shm_perm; 169 unsigned int shm_atime_high; 170 unsigned int shm_atime; 171 unsigned int shm_dtime_high; 172 unsigned int shm_dtime; 173 unsigned int shm_ctime_high; 174 unsigned int shm_ctime; 175 unsigned int __unused4; 176 compat_size_t shm_segsz; 177 compat_pid_t shm_cpid; 178 compat_pid_t shm_lpid; 179 compat_ulong_t shm_nattch; 180 compat_ulong_t __unused5; 181 compat_ulong_t __unused6; 182 }; 183 184 /* 185 * The type of struct elf_prstatus.pr_reg in compatible core dumps. 186 */ 187 #define COMPAT_ELF_NGREG 80 188 typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; 189 190 /* 191 * A pointer passed in from user mode. This should not 192 * be used for syscall parameters, just declare them 193 * as pointers because the syscall entry code will have 194 * appropriately converted them already. 195 */ 196 197 static inline void __user *compat_ptr(compat_uptr_t uptr) 198 { 199 return (void __user *)(unsigned long)uptr; 200 } 201 202 static inline compat_uptr_t ptr_to_compat(void __user *uptr) 203 { 204 return (u32)(unsigned long)uptr; 205 } 206 207 static __inline__ void __user *arch_compat_alloc_user_space(long len) 208 { 209 struct pt_regs *regs = ¤t->thread.regs; 210 return (void __user *)regs->gr[30]; 211 } 212 213 static inline int __is_compat_task(struct task_struct *t) 214 { 215 return test_ti_thread_flag(task_thread_info(t), TIF_32BIT); 216 } 217 218 static inline int is_compat_task(void) 219 { 220 return __is_compat_task(current); 221 } 222 223 #endif /* _ASM_PARISC_COMPAT_H */ 224