1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_POWERPC_COMPAT_H 3 #define _ASM_POWERPC_COMPAT_H 4 #ifdef __KERNEL__ 5 /* 6 * Architecture specific compatibility types 7 */ 8 #include <linux/types.h> 9 #include <linux/sched.h> 10 11 #include <asm-generic/compat.h> 12 13 #define COMPAT_USER_HZ 100 14 #ifdef __BIG_ENDIAN__ 15 #define COMPAT_UTS_MACHINE "ppc\0\0" 16 #else 17 #define COMPAT_UTS_MACHINE "ppcle\0\0" 18 #endif 19 20 typedef u32 __compat_uid_t; 21 typedef u32 __compat_gid_t; 22 typedef u32 compat_dev_t; 23 typedef s16 compat_nlink_t; 24 typedef u16 compat_ipc_pid_t; 25 typedef __kernel_fsid_t compat_fsid_t; 26 27 struct compat_stat { 28 compat_dev_t st_dev; 29 compat_ino_t st_ino; 30 compat_mode_t st_mode; 31 compat_nlink_t st_nlink; 32 __compat_uid32_t st_uid; 33 __compat_gid32_t st_gid; 34 compat_dev_t st_rdev; 35 compat_off_t st_size; 36 compat_off_t st_blksize; 37 compat_off_t st_blocks; 38 old_time32_t st_atime; 39 u32 st_atime_nsec; 40 old_time32_t st_mtime; 41 u32 st_mtime_nsec; 42 old_time32_t st_ctime; 43 u32 st_ctime_nsec; 44 u32 __unused4[2]; 45 }; 46 47 struct compat_flock { 48 short l_type; 49 short l_whence; 50 compat_off_t l_start; 51 compat_off_t l_len; 52 compat_pid_t l_pid; 53 }; 54 55 #define F_GETLK64 12 /* using 'struct flock64' */ 56 #define F_SETLK64 13 57 #define F_SETLKW64 14 58 59 struct compat_flock64 { 60 short l_type; 61 short l_whence; 62 compat_loff_t l_start; 63 compat_loff_t l_len; 64 compat_pid_t l_pid; 65 }; 66 67 struct compat_statfs { 68 int f_type; 69 int f_bsize; 70 int f_blocks; 71 int f_bfree; 72 int f_bavail; 73 int f_files; 74 int f_ffree; 75 compat_fsid_t f_fsid; 76 int f_namelen; /* SunOS ignores this field. */ 77 int f_frsize; 78 int f_flags; 79 int f_spare[4]; 80 }; 81 82 #define COMPAT_RLIM_INFINITY 0xffffffff 83 84 #define COMPAT_OFF_T_MAX 0x7fffffff 85 86 static inline void __user *arch_compat_alloc_user_space(long len) 87 { 88 struct pt_regs *regs = current->thread.regs; 89 unsigned long usp = regs->gpr[1]; 90 91 /* 92 * We can't access below the stack pointer in the 32bit ABI and 93 * can access 288 bytes in the 64bit big-endian ABI, 94 * or 512 bytes with the new ELFv2 little-endian ABI. 95 */ 96 if (!is_32bit_task()) 97 usp -= USER_REDZONE_SIZE; 98 99 return (void __user *) (usp - len); 100 } 101 102 /* 103 * ipc64_perm is actually 32/64bit clean but since the compat layer refers to 104 * it we may as well define it. 105 */ 106 struct compat_ipc64_perm { 107 compat_key_t key; 108 __compat_uid_t uid; 109 __compat_gid_t gid; 110 __compat_uid_t cuid; 111 __compat_gid_t cgid; 112 compat_mode_t mode; 113 unsigned int seq; 114 unsigned int __pad2; 115 unsigned long __unused1; /* yes they really are 64bit pads */ 116 unsigned long __unused2; 117 }; 118 119 struct compat_semid64_ds { 120 struct compat_ipc64_perm sem_perm; 121 unsigned int sem_otime_high; 122 unsigned int sem_otime; 123 unsigned int sem_ctime_high; 124 unsigned int sem_ctime; 125 compat_ulong_t sem_nsems; 126 compat_ulong_t __unused3; 127 compat_ulong_t __unused4; 128 }; 129 130 struct compat_msqid64_ds { 131 struct compat_ipc64_perm msg_perm; 132 unsigned int msg_stime_high; 133 unsigned int msg_stime; 134 unsigned int msg_rtime_high; 135 unsigned int msg_rtime; 136 unsigned int msg_ctime_high; 137 unsigned int msg_ctime; 138 compat_ulong_t msg_cbytes; 139 compat_ulong_t msg_qnum; 140 compat_ulong_t msg_qbytes; 141 compat_pid_t msg_lspid; 142 compat_pid_t msg_lrpid; 143 compat_ulong_t __unused4; 144 compat_ulong_t __unused5; 145 }; 146 147 struct compat_shmid64_ds { 148 struct compat_ipc64_perm shm_perm; 149 unsigned int shm_atime_high; 150 unsigned int shm_atime; 151 unsigned int shm_dtime_high; 152 unsigned int shm_dtime; 153 unsigned int shm_ctime_high; 154 unsigned int shm_ctime; 155 unsigned int __unused4; 156 compat_size_t shm_segsz; 157 compat_pid_t shm_cpid; 158 compat_pid_t shm_lpid; 159 compat_ulong_t shm_nattch; 160 compat_ulong_t __unused5; 161 compat_ulong_t __unused6; 162 }; 163 164 static inline int is_compat_task(void) 165 { 166 return is_32bit_task(); 167 } 168 169 #endif /* __KERNEL__ */ 170 #endif /* _ASM_POWERPC_COMPAT_H */ 171