1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_COMPAT_H 3 #define _ASM_COMPAT_H 4 /* 5 * Architecture specific compatibility types 6 */ 7 #include <linux/thread_info.h> 8 #include <linux/types.h> 9 #include <asm/page.h> 10 #include <asm/ptrace.h> 11 12 typedef s32 __compat_uid_t; 13 typedef s32 __compat_gid_t; 14 typedef __compat_uid_t __compat_uid32_t; 15 typedef __compat_gid_t __compat_gid32_t; 16 #define __compat_uid32_t __compat_uid32_t 17 #define __compat_gid32_t __compat_gid32_t 18 19 #define _COMPAT_NSIG 128 /* Don't ask !$@#% ... */ 20 #define _COMPAT_NSIG_BPW 32 21 typedef u32 compat_sigset_word; 22 23 #include <asm-generic/compat.h> 24 25 #define COMPAT_USER_HZ 100 26 #define COMPAT_UTS_MACHINE "mips\0\0\0" 27 28 typedef u32 compat_dev_t; 29 typedef u32 compat_nlink_t; 30 typedef s32 compat_ipc_pid_t; 31 typedef struct { 32 s32 val[2]; 33 } compat_fsid_t; 34 35 struct compat_stat { 36 compat_dev_t st_dev; 37 s32 st_pad1[3]; 38 compat_ino_t st_ino; 39 compat_mode_t st_mode; 40 compat_nlink_t st_nlink; 41 __compat_uid_t st_uid; 42 __compat_gid_t st_gid; 43 compat_dev_t st_rdev; 44 s32 st_pad2[2]; 45 compat_off_t st_size; 46 s32 st_pad3; 47 old_time32_t st_atime; 48 s32 st_atime_nsec; 49 old_time32_t st_mtime; 50 s32 st_mtime_nsec; 51 old_time32_t st_ctime; 52 s32 st_ctime_nsec; 53 s32 st_blksize; 54 s32 st_blocks; 55 s32 st_pad4[14]; 56 }; 57 58 struct compat_flock { 59 short l_type; 60 short l_whence; 61 compat_off_t l_start; 62 compat_off_t l_len; 63 s32 l_sysid; 64 compat_pid_t l_pid; 65 s32 pad[4]; 66 }; 67 68 #define F_GETLK64 33 69 #define F_SETLK64 34 70 #define F_SETLKW64 35 71 72 struct compat_flock64 { 73 short l_type; 74 short l_whence; 75 compat_loff_t l_start; 76 compat_loff_t l_len; 77 compat_pid_t l_pid; 78 }; 79 80 struct compat_statfs { 81 int f_type; 82 int f_bsize; 83 int f_frsize; 84 int f_blocks; 85 int f_bfree; 86 int f_files; 87 int f_ffree; 88 int f_bavail; 89 compat_fsid_t f_fsid; 90 int f_namelen; 91 int f_flags; 92 int f_spare[5]; 93 }; 94 95 #define COMPAT_RLIM_INFINITY 0x7fffffffUL 96 97 #define COMPAT_OFF_T_MAX 0x7fffffff 98 99 static inline void __user *arch_compat_alloc_user_space(long len) 100 { 101 struct pt_regs *regs = (struct pt_regs *) 102 ((unsigned long) current_thread_info() + THREAD_SIZE - 32) - 1; 103 104 return (void __user *) (regs->regs[29] - len); 105 } 106 107 struct compat_ipc64_perm { 108 compat_key_t key; 109 __compat_uid32_t uid; 110 __compat_gid32_t gid; 111 __compat_uid32_t cuid; 112 __compat_gid32_t cgid; 113 compat_mode_t mode; 114 unsigned short seq; 115 unsigned short __pad2; 116 compat_ulong_t __unused1; 117 compat_ulong_t __unused2; 118 }; 119 120 struct compat_semid64_ds { 121 struct compat_ipc64_perm sem_perm; 122 compat_ulong_t sem_otime; 123 compat_ulong_t sem_ctime; 124 compat_ulong_t sem_nsems; 125 compat_ulong_t sem_otime_high; 126 compat_ulong_t sem_ctime_high; 127 }; 128 129 struct compat_msqid64_ds { 130 struct compat_ipc64_perm msg_perm; 131 #ifndef CONFIG_CPU_LITTLE_ENDIAN 132 compat_ulong_t msg_stime_high; 133 #endif 134 compat_ulong_t msg_stime; 135 #ifdef CONFIG_CPU_LITTLE_ENDIAN 136 compat_ulong_t msg_stime_high; 137 #endif 138 #ifndef CONFIG_CPU_LITTLE_ENDIAN 139 compat_ulong_t msg_rtime_high; 140 #endif 141 compat_ulong_t msg_rtime; 142 #ifdef CONFIG_CPU_LITTLE_ENDIAN 143 compat_ulong_t msg_rtime_high; 144 #endif 145 #ifndef CONFIG_CPU_LITTLE_ENDIAN 146 compat_ulong_t msg_ctime_high; 147 #endif 148 compat_ulong_t msg_ctime; 149 #ifdef CONFIG_CPU_LITTLE_ENDIAN 150 compat_ulong_t msg_ctime_high; 151 #endif 152 compat_ulong_t msg_cbytes; 153 compat_ulong_t msg_qnum; 154 compat_ulong_t msg_qbytes; 155 compat_pid_t msg_lspid; 156 compat_pid_t msg_lrpid; 157 compat_ulong_t __unused4; 158 compat_ulong_t __unused5; 159 }; 160 161 struct compat_shmid64_ds { 162 struct compat_ipc64_perm shm_perm; 163 compat_size_t shm_segsz; 164 compat_ulong_t shm_atime; 165 compat_ulong_t shm_dtime; 166 compat_ulong_t shm_ctime; 167 compat_pid_t shm_cpid; 168 compat_pid_t shm_lpid; 169 compat_ulong_t shm_nattch; 170 compat_ushort_t shm_atime_high; 171 compat_ushort_t shm_dtime_high; 172 compat_ushort_t shm_ctime_high; 173 compat_ushort_t __unused2; 174 }; 175 176 /* MIPS has unusual order of fields in stack_t */ 177 typedef struct compat_sigaltstack { 178 compat_uptr_t ss_sp; 179 compat_size_t ss_size; 180 int ss_flags; 181 } compat_stack_t; 182 #define compat_sigaltstack compat_sigaltstack 183 184 static inline int is_compat_task(void) 185 { 186 return test_thread_flag(TIF_32BIT_ADDR); 187 } 188 189 #endif /* _ASM_COMPAT_H */ 190