1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_SPARC64_COMPAT_H 3 #define _ASM_SPARC64_COMPAT_H 4 /* 5 * Architecture specific compatibility types 6 */ 7 #include <linux/types.h> 8 9 #define compat_mode_t compat_mode_t 10 typedef u16 compat_mode_t; 11 12 #include <asm-generic/compat.h> 13 14 #define COMPAT_USER_HZ 100 15 #define COMPAT_UTS_MACHINE "sparc\0\0" 16 17 typedef u16 __compat_uid_t; 18 typedef u16 __compat_gid_t; 19 typedef u16 compat_dev_t; 20 typedef s16 compat_nlink_t; 21 typedef u16 compat_ipc_pid_t; 22 typedef __kernel_fsid_t compat_fsid_t; 23 24 struct compat_stat { 25 compat_dev_t st_dev; 26 compat_ino_t st_ino; 27 compat_mode_t st_mode; 28 compat_nlink_t st_nlink; 29 __compat_uid_t st_uid; 30 __compat_gid_t st_gid; 31 compat_dev_t st_rdev; 32 compat_off_t st_size; 33 old_time32_t st_atime; 34 compat_ulong_t st_atime_nsec; 35 old_time32_t st_mtime; 36 compat_ulong_t st_mtime_nsec; 37 old_time32_t st_ctime; 38 compat_ulong_t st_ctime_nsec; 39 compat_off_t st_blksize; 40 compat_off_t st_blocks; 41 u32 __unused4[2]; 42 }; 43 44 struct compat_stat64 { 45 unsigned long long st_dev; 46 47 unsigned long long st_ino; 48 49 unsigned int st_mode; 50 unsigned int st_nlink; 51 52 unsigned int st_uid; 53 unsigned int st_gid; 54 55 unsigned long long st_rdev; 56 57 unsigned char __pad3[8]; 58 59 long long st_size; 60 unsigned int st_blksize; 61 62 unsigned char __pad4[8]; 63 unsigned int st_blocks; 64 65 unsigned int st_atime; 66 unsigned int st_atime_nsec; 67 68 unsigned int st_mtime; 69 unsigned int st_mtime_nsec; 70 71 unsigned int st_ctime; 72 unsigned int st_ctime_nsec; 73 74 unsigned int __unused4; 75 unsigned int __unused5; 76 }; 77 78 struct compat_flock { 79 short l_type; 80 short l_whence; 81 compat_off_t l_start; 82 compat_off_t l_len; 83 compat_pid_t l_pid; 84 short __unused; 85 }; 86 87 struct compat_flock64 { 88 short l_type; 89 short l_whence; 90 compat_loff_t l_start; 91 compat_loff_t l_len; 92 compat_pid_t l_pid; 93 short __unused; 94 }; 95 96 struct compat_statfs { 97 int f_type; 98 int f_bsize; 99 int f_blocks; 100 int f_bfree; 101 int f_bavail; 102 int f_files; 103 int f_ffree; 104 compat_fsid_t f_fsid; 105 int f_namelen; /* SunOS ignores this field. */ 106 int f_frsize; 107 int f_flags; 108 int f_spare[4]; 109 }; 110 111 #define COMPAT_RLIM_INFINITY 0x7fffffff 112 113 #define COMPAT_OFF_T_MAX 0x7fffffff 114 115 struct compat_ipc64_perm { 116 compat_key_t key; 117 __compat_uid32_t uid; 118 __compat_gid32_t gid; 119 __compat_uid32_t cuid; 120 __compat_gid32_t cgid; 121 unsigned short __pad1; 122 compat_mode_t mode; 123 unsigned short __pad2; 124 unsigned short seq; 125 unsigned long __unused1; /* yes they really are 64bit pads */ 126 unsigned long __unused2; 127 }; 128 129 struct compat_semid64_ds { 130 struct compat_ipc64_perm sem_perm; 131 unsigned int sem_otime_high; 132 unsigned int sem_otime; 133 unsigned int sem_ctime_high; 134 unsigned int sem_ctime; 135 u32 sem_nsems; 136 u32 __unused1; 137 u32 __unused2; 138 }; 139 140 struct compat_msqid64_ds { 141 struct compat_ipc64_perm msg_perm; 142 unsigned int msg_stime_high; 143 unsigned int msg_stime; 144 unsigned int msg_rtime_high; 145 unsigned int msg_rtime; 146 unsigned int msg_ctime_high; 147 unsigned int msg_ctime; 148 unsigned int msg_cbytes; 149 unsigned int msg_qnum; 150 unsigned int msg_qbytes; 151 compat_pid_t msg_lspid; 152 compat_pid_t msg_lrpid; 153 unsigned int __unused1; 154 unsigned int __unused2; 155 }; 156 157 struct compat_shmid64_ds { 158 struct compat_ipc64_perm shm_perm; 159 unsigned int shm_atime_high; 160 unsigned int shm_atime; 161 unsigned int shm_dtime_high; 162 unsigned int shm_dtime; 163 unsigned int shm_ctime_high; 164 unsigned int shm_ctime; 165 compat_size_t shm_segsz; 166 compat_pid_t shm_cpid; 167 compat_pid_t shm_lpid; 168 unsigned int shm_nattch; 169 unsigned int __unused1; 170 unsigned int __unused2; 171 }; 172 173 #ifdef CONFIG_COMPAT 174 static inline int is_compat_task(void) 175 { 176 return test_thread_flag(TIF_32BIT); 177 } 178 179 static inline bool in_compat_syscall(void) 180 { 181 /* Vector 0x110 is LINUX_32BIT_SYSCALL_TRAP */ 182 return pt_regs_trap_type(current_pt_regs()) == 0x110; 183 } 184 #define in_compat_syscall in_compat_syscall 185 #endif 186 187 #endif /* _ASM_SPARC64_COMPAT_H */ 188