compat.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. #ifndef _ASM_POWERPC_COMPAT_H
  2. #define _ASM_POWERPC_COMPAT_H
  3. #ifdef __KERNEL__
  4. /*
  5. * Architecture specific compatibility types
  6. */
  7. #include <linux/types.h>
  8. #include <linux/sched.h>
  9. #define COMPAT_USER_HZ 100
  10. #ifdef __BIG_ENDIAN__
  11. #define COMPAT_UTS_MACHINE "ppc\0\0"
  12. #else
  13. #define COMPAT_UTS_MACHINE "ppcle\0\0"
  14. #endif
  15. typedef u32 compat_size_t;
  16. typedef s32 compat_ssize_t;
  17. typedef s32 compat_time_t;
  18. typedef s32 compat_clock_t;
  19. typedef s32 compat_pid_t;
  20. typedef u32 __compat_uid_t;
  21. typedef u32 __compat_gid_t;
  22. typedef u32 __compat_uid32_t;
  23. typedef u32 __compat_gid32_t;
  24. typedef u32 compat_mode_t;
  25. typedef u32 compat_ino_t;
  26. typedef u32 compat_dev_t;
  27. typedef s32 compat_off_t;
  28. typedef s64 compat_loff_t;
  29. typedef s16 compat_nlink_t;
  30. typedef u16 compat_ipc_pid_t;
  31. typedef s32 compat_daddr_t;
  32. typedef u32 compat_caddr_t;
  33. typedef __kernel_fsid_t compat_fsid_t;
  34. typedef s32 compat_key_t;
  35. typedef s32 compat_timer_t;
  36. typedef s32 compat_int_t;
  37. typedef s32 compat_long_t;
  38. typedef s64 compat_s64;
  39. typedef u32 compat_uint_t;
  40. typedef u32 compat_ulong_t;
  41. typedef u64 compat_u64;
  42. typedef u32 compat_uptr_t;
  43. struct compat_timespec {
  44. compat_time_t tv_sec;
  45. s32 tv_nsec;
  46. };
  47. struct compat_timeval {
  48. compat_time_t tv_sec;
  49. s32 tv_usec;
  50. };
  51. struct compat_stat {
  52. compat_dev_t st_dev;
  53. compat_ino_t st_ino;
  54. compat_mode_t st_mode;
  55. compat_nlink_t st_nlink;
  56. __compat_uid32_t st_uid;
  57. __compat_gid32_t st_gid;
  58. compat_dev_t st_rdev;
  59. compat_off_t st_size;
  60. compat_off_t st_blksize;
  61. compat_off_t st_blocks;
  62. compat_time_t st_atime;
  63. u32 st_atime_nsec;
  64. compat_time_t st_mtime;
  65. u32 st_mtime_nsec;
  66. compat_time_t st_ctime;
  67. u32 st_ctime_nsec;
  68. u32 __unused4[2];
  69. };
  70. struct compat_flock {
  71. short l_type;
  72. short l_whence;
  73. compat_off_t l_start;
  74. compat_off_t l_len;
  75. compat_pid_t l_pid;
  76. };
  77. #define F_GETLK64 12 /* using 'struct flock64' */
  78. #define F_SETLK64 13
  79. #define F_SETLKW64 14
  80. struct compat_flock64 {
  81. short l_type;
  82. short l_whence;
  83. compat_loff_t l_start;
  84. compat_loff_t l_len;
  85. compat_pid_t l_pid;
  86. };
  87. struct compat_statfs {
  88. int f_type;
  89. int f_bsize;
  90. int f_blocks;
  91. int f_bfree;
  92. int f_bavail;
  93. int f_files;
  94. int f_ffree;
  95. compat_fsid_t f_fsid;
  96. int f_namelen; /* SunOS ignores this field. */
  97. int f_frsize;
  98. int f_flags;
  99. int f_spare[4];
  100. };
  101. #define COMPAT_RLIM_INFINITY 0xffffffff
  102. typedef u32 compat_old_sigset_t;
  103. #define _COMPAT_NSIG 64
  104. #define _COMPAT_NSIG_BPW 32
  105. typedef u32 compat_sigset_word;
  106. typedef union compat_sigval {
  107. compat_int_t sival_int;
  108. compat_uptr_t sival_ptr;
  109. } compat_sigval_t;
  110. #define SI_PAD_SIZE32 (128/sizeof(int) - 3)
  111. typedef struct compat_siginfo {
  112. int si_signo;
  113. int si_errno;
  114. int si_code;
  115. union {
  116. int _pad[SI_PAD_SIZE32];
  117. /* kill() */
  118. struct {
  119. compat_pid_t _pid; /* sender's pid */
  120. __compat_uid_t _uid; /* sender's uid */
  121. } _kill;
  122. /* POSIX.1b timers */
  123. struct {
  124. compat_timer_t _tid; /* timer id */
  125. int _overrun; /* overrun count */
  126. compat_sigval_t _sigval; /* same as below */
  127. int _sys_private; /* not to be passed to user */
  128. } _timer;
  129. /* POSIX.1b signals */
  130. struct {
  131. compat_pid_t _pid; /* sender's pid */
  132. __compat_uid_t _uid; /* sender's uid */
  133. compat_sigval_t _sigval;
  134. } _rt;
  135. /* SIGCHLD */
  136. struct {
  137. compat_pid_t _pid; /* which child */
  138. __compat_uid_t _uid; /* sender's uid */
  139. int _status; /* exit code */
  140. compat_clock_t _utime;
  141. compat_clock_t _stime;
  142. } _sigchld;
  143. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
  144. struct {
  145. unsigned int _addr; /* faulting insn/memory ref. */
  146. } _sigfault;
  147. /* SIGPOLL */
  148. struct {
  149. int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  150. int _fd;
  151. } _sigpoll;
  152. /* SIGSYS */
  153. struct {
  154. unsigned int _call_addr; /* calling insn */
  155. int _syscall; /* triggering system call number */
  156. unsigned int _arch; /* AUDIT_ARCH_* of syscall */
  157. } _sigsys;
  158. } _sifields;
  159. } compat_siginfo_t;
  160. #define COMPAT_OFF_T_MAX 0x7fffffff
  161. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  162. /*
  163. * A pointer passed in from user mode. This should not
  164. * be used for syscall parameters, just declare them
  165. * as pointers because the syscall entry code will have
  166. * appropriately converted them already.
  167. */
  168. static inline void __user *compat_ptr(compat_uptr_t uptr)
  169. {
  170. return (void __user *)(unsigned long)uptr;
  171. }
  172. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  173. {
  174. return (u32)(unsigned long)uptr;
  175. }
  176. static inline void __user *arch_compat_alloc_user_space(long len)
  177. {
  178. struct pt_regs *regs = current->thread.regs;
  179. unsigned long usp = regs->gpr[1];
  180. /*
  181. * We can't access below the stack pointer in the 32bit ABI and
  182. * can access 288 bytes in the 64bit big-endian ABI,
  183. * or 512 bytes with the new ELFv2 little-endian ABI.
  184. */
  185. if (!is_32bit_task())
  186. usp -= USER_REDZONE_SIZE;
  187. return (void __user *) (usp - len);
  188. }
  189. /*
  190. * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
  191. * it we may as well define it.
  192. */
  193. struct compat_ipc64_perm {
  194. compat_key_t key;
  195. __compat_uid_t uid;
  196. __compat_gid_t gid;
  197. __compat_uid_t cuid;
  198. __compat_gid_t cgid;
  199. compat_mode_t mode;
  200. unsigned int seq;
  201. unsigned int __pad2;
  202. unsigned long __unused1; /* yes they really are 64bit pads */
  203. unsigned long __unused2;
  204. };
  205. struct compat_semid64_ds {
  206. struct compat_ipc64_perm sem_perm;
  207. unsigned int __unused1;
  208. compat_time_t sem_otime;
  209. unsigned int __unused2;
  210. compat_time_t sem_ctime;
  211. compat_ulong_t sem_nsems;
  212. compat_ulong_t __unused3;
  213. compat_ulong_t __unused4;
  214. };
  215. struct compat_msqid64_ds {
  216. struct compat_ipc64_perm msg_perm;
  217. unsigned int __unused1;
  218. compat_time_t msg_stime;
  219. unsigned int __unused2;
  220. compat_time_t msg_rtime;
  221. unsigned int __unused3;
  222. compat_time_t msg_ctime;
  223. compat_ulong_t msg_cbytes;
  224. compat_ulong_t msg_qnum;
  225. compat_ulong_t msg_qbytes;
  226. compat_pid_t msg_lspid;
  227. compat_pid_t msg_lrpid;
  228. compat_ulong_t __unused4;
  229. compat_ulong_t __unused5;
  230. };
  231. struct compat_shmid64_ds {
  232. struct compat_ipc64_perm shm_perm;
  233. unsigned int __unused1;
  234. compat_time_t shm_atime;
  235. unsigned int __unused2;
  236. compat_time_t shm_dtime;
  237. unsigned int __unused3;
  238. compat_time_t shm_ctime;
  239. unsigned int __unused4;
  240. compat_size_t shm_segsz;
  241. compat_pid_t shm_cpid;
  242. compat_pid_t shm_lpid;
  243. compat_ulong_t shm_nattch;
  244. compat_ulong_t __unused5;
  245. compat_ulong_t __unused6;
  246. };
  247. static inline int is_compat_task(void)
  248. {
  249. return is_32bit_task();
  250. }
  251. #endif /* __KERNEL__ */
  252. #endif /* _ASM_POWERPC_COMPAT_H */