compat.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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_OLD_INFINITY 0x7fffffff
  102. #define COMPAT_RLIM_INFINITY 0xffffffff
  103. typedef u32 compat_old_sigset_t;
  104. #define _COMPAT_NSIG 64
  105. #define _COMPAT_NSIG_BPW 32
  106. typedef u32 compat_sigset_word;
  107. typedef union compat_sigval {
  108. compat_int_t sival_int;
  109. compat_uptr_t sival_ptr;
  110. } compat_sigval_t;
  111. #define SI_PAD_SIZE32 (128/sizeof(int) - 3)
  112. typedef struct compat_siginfo {
  113. int si_signo;
  114. int si_errno;
  115. int si_code;
  116. union {
  117. int _pad[SI_PAD_SIZE32];
  118. /* kill() */
  119. struct {
  120. compat_pid_t _pid; /* sender's pid */
  121. __compat_uid_t _uid; /* sender's uid */
  122. } _kill;
  123. /* POSIX.1b timers */
  124. struct {
  125. compat_timer_t _tid; /* timer id */
  126. int _overrun; /* overrun count */
  127. compat_sigval_t _sigval; /* same as below */
  128. int _sys_private; /* not to be passed to user */
  129. } _timer;
  130. /* POSIX.1b signals */
  131. struct {
  132. compat_pid_t _pid; /* sender's pid */
  133. __compat_uid_t _uid; /* sender's uid */
  134. compat_sigval_t _sigval;
  135. } _rt;
  136. /* SIGCHLD */
  137. struct {
  138. compat_pid_t _pid; /* which child */
  139. __compat_uid_t _uid; /* sender's uid */
  140. int _status; /* exit code */
  141. compat_clock_t _utime;
  142. compat_clock_t _stime;
  143. } _sigchld;
  144. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
  145. struct {
  146. unsigned int _addr; /* faulting insn/memory ref. */
  147. } _sigfault;
  148. /* SIGPOLL */
  149. struct {
  150. int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  151. int _fd;
  152. } _sigpoll;
  153. /* SIGSYS */
  154. struct {
  155. unsigned int _call_addr; /* calling insn */
  156. int _syscall; /* triggering system call number */
  157. unsigned int _arch; /* AUDIT_ARCH_* of syscall */
  158. } _sigsys;
  159. } _sifields;
  160. } compat_siginfo_t;
  161. #define COMPAT_OFF_T_MAX 0x7fffffff
  162. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  163. /*
  164. * A pointer passed in from user mode. This should not
  165. * be used for syscall parameters, just declare them
  166. * as pointers because the syscall entry code will have
  167. * appropriately converted them already.
  168. */
  169. static inline void __user *compat_ptr(compat_uptr_t uptr)
  170. {
  171. return (void __user *)(unsigned long)uptr;
  172. }
  173. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  174. {
  175. return (u32)(unsigned long)uptr;
  176. }
  177. static inline void __user *arch_compat_alloc_user_space(long len)
  178. {
  179. struct pt_regs *regs = current->thread.regs;
  180. unsigned long usp = regs->gpr[1];
  181. /*
  182. * We can't access below the stack pointer in the 32bit ABI and
  183. * can access 288 bytes in the 64bit big-endian ABI,
  184. * or 512 bytes with the new ELFv2 little-endian ABI.
  185. */
  186. if (!is_32bit_task())
  187. usp -= USER_REDZONE_SIZE;
  188. return (void __user *) (usp - len);
  189. }
  190. /*
  191. * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
  192. * it we may as well define it.
  193. */
  194. struct compat_ipc64_perm {
  195. compat_key_t key;
  196. __compat_uid_t uid;
  197. __compat_gid_t gid;
  198. __compat_uid_t cuid;
  199. __compat_gid_t cgid;
  200. compat_mode_t mode;
  201. unsigned int seq;
  202. unsigned int __pad2;
  203. unsigned long __unused1; /* yes they really are 64bit pads */
  204. unsigned long __unused2;
  205. };
  206. struct compat_semid64_ds {
  207. struct compat_ipc64_perm sem_perm;
  208. unsigned int __unused1;
  209. compat_time_t sem_otime;
  210. unsigned int __unused2;
  211. compat_time_t sem_ctime;
  212. compat_ulong_t sem_nsems;
  213. compat_ulong_t __unused3;
  214. compat_ulong_t __unused4;
  215. };
  216. struct compat_msqid64_ds {
  217. struct compat_ipc64_perm msg_perm;
  218. unsigned int __unused1;
  219. compat_time_t msg_stime;
  220. unsigned int __unused2;
  221. compat_time_t msg_rtime;
  222. unsigned int __unused3;
  223. compat_time_t msg_ctime;
  224. compat_ulong_t msg_cbytes;
  225. compat_ulong_t msg_qnum;
  226. compat_ulong_t msg_qbytes;
  227. compat_pid_t msg_lspid;
  228. compat_pid_t msg_lrpid;
  229. compat_ulong_t __unused4;
  230. compat_ulong_t __unused5;
  231. };
  232. struct compat_shmid64_ds {
  233. struct compat_ipc64_perm shm_perm;
  234. unsigned int __unused1;
  235. compat_time_t shm_atime;
  236. unsigned int __unused2;
  237. compat_time_t shm_dtime;
  238. unsigned int __unused3;
  239. compat_time_t shm_ctime;
  240. unsigned int __unused4;
  241. compat_size_t shm_segsz;
  242. compat_pid_t shm_cpid;
  243. compat_pid_t shm_lpid;
  244. compat_ulong_t shm_nattch;
  245. compat_ulong_t __unused5;
  246. compat_ulong_t __unused6;
  247. };
  248. static inline int is_compat_task(void)
  249. {
  250. return is_32bit_task();
  251. }
  252. #endif /* __KERNEL__ */
  253. #endif /* _ASM_POWERPC_COMPAT_H */