compat.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_COMPAT_H
  15. #define _ASM_TILE_COMPAT_H
  16. /*
  17. * Architecture specific compatibility types
  18. */
  19. #include <linux/types.h>
  20. #include <linux/sched.h>
  21. #define COMPAT_USER_HZ 100
  22. /* "long" and pointer-based types are different. */
  23. typedef s32 compat_long_t;
  24. typedef u32 compat_ulong_t;
  25. typedef u32 compat_size_t;
  26. typedef s32 compat_ssize_t;
  27. typedef s32 compat_off_t;
  28. typedef s32 compat_time_t;
  29. typedef s32 compat_clock_t;
  30. typedef u32 compat_ino_t;
  31. typedef u32 compat_caddr_t;
  32. typedef u32 compat_uptr_t;
  33. /* Many types are "int" or otherwise the same. */
  34. typedef __kernel_pid_t compat_pid_t;
  35. typedef __kernel_uid_t __compat_uid_t;
  36. typedef __kernel_gid_t __compat_gid_t;
  37. typedef __kernel_uid32_t __compat_uid32_t;
  38. typedef __kernel_uid32_t __compat_gid32_t;
  39. typedef __kernel_mode_t compat_mode_t;
  40. typedef __kernel_dev_t compat_dev_t;
  41. typedef __kernel_loff_t compat_loff_t;
  42. typedef __kernel_ipc_pid_t compat_ipc_pid_t;
  43. typedef __kernel_daddr_t compat_daddr_t;
  44. typedef __kernel_fsid_t compat_fsid_t;
  45. typedef __kernel_timer_t compat_timer_t;
  46. typedef __kernel_key_t compat_key_t;
  47. typedef int compat_int_t;
  48. typedef s64 compat_s64;
  49. typedef uint compat_uint_t;
  50. typedef u64 compat_u64;
  51. /* We use the same register dump format in 32-bit images. */
  52. typedef unsigned long compat_elf_greg_t;
  53. #define COMPAT_ELF_NGREG (sizeof(struct pt_regs) / sizeof(compat_elf_greg_t))
  54. typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
  55. struct compat_timespec {
  56. compat_time_t tv_sec;
  57. s32 tv_nsec;
  58. };
  59. struct compat_timeval {
  60. compat_time_t tv_sec;
  61. s32 tv_usec;
  62. };
  63. #define compat_stat stat
  64. #define compat_statfs statfs
  65. struct compat_sysctl {
  66. unsigned int name;
  67. int nlen;
  68. unsigned int oldval;
  69. unsigned int oldlenp;
  70. unsigned int newval;
  71. unsigned int newlen;
  72. unsigned int __unused[4];
  73. };
  74. struct compat_flock {
  75. short l_type;
  76. short l_whence;
  77. compat_off_t l_start;
  78. compat_off_t l_len;
  79. compat_pid_t l_pid;
  80. };
  81. #define F_GETLK64 12 /* using 'struct flock64' */
  82. #define F_SETLK64 13
  83. #define F_SETLKW64 14
  84. struct compat_flock64 {
  85. short l_type;
  86. short l_whence;
  87. compat_loff_t l_start;
  88. compat_loff_t l_len;
  89. compat_pid_t l_pid;
  90. };
  91. #define COMPAT_RLIM_INFINITY 0xffffffff
  92. #define _COMPAT_NSIG 64
  93. #define _COMPAT_NSIG_BPW 32
  94. typedef u32 compat_sigset_word;
  95. #define COMPAT_OFF_T_MAX 0x7fffffff
  96. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  97. struct compat_ipc64_perm {
  98. compat_key_t key;
  99. __compat_uid32_t uid;
  100. __compat_gid32_t gid;
  101. __compat_uid32_t cuid;
  102. __compat_gid32_t cgid;
  103. unsigned short mode;
  104. unsigned short __pad1;
  105. unsigned short seq;
  106. unsigned short __pad2;
  107. compat_ulong_t unused1;
  108. compat_ulong_t unused2;
  109. };
  110. struct compat_semid64_ds {
  111. struct compat_ipc64_perm sem_perm;
  112. compat_time_t sem_otime;
  113. compat_ulong_t __unused1;
  114. compat_time_t sem_ctime;
  115. compat_ulong_t __unused2;
  116. compat_ulong_t sem_nsems;
  117. compat_ulong_t __unused3;
  118. compat_ulong_t __unused4;
  119. };
  120. struct compat_msqid64_ds {
  121. struct compat_ipc64_perm msg_perm;
  122. compat_time_t msg_stime;
  123. compat_ulong_t __unused1;
  124. compat_time_t msg_rtime;
  125. compat_ulong_t __unused2;
  126. compat_time_t msg_ctime;
  127. compat_ulong_t __unused3;
  128. compat_ulong_t msg_cbytes;
  129. compat_ulong_t msg_qnum;
  130. compat_ulong_t msg_qbytes;
  131. compat_pid_t msg_lspid;
  132. compat_pid_t msg_lrpid;
  133. compat_ulong_t __unused4;
  134. compat_ulong_t __unused5;
  135. };
  136. struct compat_shmid64_ds {
  137. struct compat_ipc64_perm shm_perm;
  138. compat_size_t shm_segsz;
  139. compat_time_t shm_atime;
  140. compat_ulong_t __unused1;
  141. compat_time_t shm_dtime;
  142. compat_ulong_t __unused2;
  143. compat_time_t shm_ctime;
  144. compat_ulong_t __unused3;
  145. compat_pid_t shm_cpid;
  146. compat_pid_t shm_lpid;
  147. compat_ulong_t shm_nattch;
  148. compat_ulong_t __unused4;
  149. compat_ulong_t __unused5;
  150. };
  151. /*
  152. * A pointer passed in from user mode. This should not
  153. * be used for syscall parameters, just declare them
  154. * as pointers because the syscall entry code will have
  155. * appropriately converted them already.
  156. */
  157. static inline void __user *compat_ptr(compat_uptr_t uptr)
  158. {
  159. return (void __user *)(long)(s32)uptr;
  160. }
  161. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  162. {
  163. return (u32)(unsigned long)uptr;
  164. }
  165. /* Sign-extend when storing a kernel pointer to a user's ptregs. */
  166. static inline unsigned long ptr_to_compat_reg(void __user *uptr)
  167. {
  168. return (long)(int)(long __force)uptr;
  169. }
  170. static inline void __user *arch_compat_alloc_user_space(long len)
  171. {
  172. struct pt_regs *regs = task_pt_regs(current);
  173. return (void __user *)regs->sp - len;
  174. }
  175. static inline int is_compat_task(void)
  176. {
  177. return current_thread_info()->status & TS_COMPAT;
  178. }
  179. extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka,
  180. siginfo_t *info, sigset_t *set,
  181. struct pt_regs *regs);
  182. /* Compat syscalls. */
  183. struct compat_sigaction;
  184. struct compat_siginfo;
  185. struct compat_sigaltstack;
  186. long compat_sys_execve(const char __user *path,
  187. compat_uptr_t __user *argv,
  188. compat_uptr_t __user *envp, struct pt_regs *);
  189. long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
  190. struct compat_sigaction __user *oact,
  191. size_t sigsetsize);
  192. long compat_sys_rt_sigqueueinfo(int pid, int sig,
  193. struct compat_siginfo __user *uinfo);
  194. long compat_sys_rt_sigreturn(struct pt_regs *);
  195. long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
  196. struct compat_sigaltstack __user *uoss_ptr,
  197. struct pt_regs *);
  198. long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
  199. long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
  200. long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
  201. u32 dummy, u32 low, u32 high);
  202. long compat_sys_pwrite64(unsigned int fd, char __user *ubuf, size_t count,
  203. u32 dummy, u32 low, u32 high);
  204. long compat_sys_lookup_dcookie(u32 low, u32 high, char __user *buf, size_t len);
  205. long compat_sys_sync_file_range2(int fd, unsigned int flags,
  206. u32 offset_lo, u32 offset_hi,
  207. u32 nbytes_lo, u32 nbytes_hi);
  208. long compat_sys_fallocate(int fd, int mode,
  209. u32 offset_lo, u32 offset_hi,
  210. u32 len_lo, u32 len_hi);
  211. long compat_sys_sched_rr_get_interval(compat_pid_t pid,
  212. struct compat_timespec __user *interval);
  213. /* These are the intvec_64.S trampolines. */
  214. long _compat_sys_execve(const char __user *path,
  215. const compat_uptr_t __user *argv,
  216. const compat_uptr_t __user *envp);
  217. long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
  218. struct compat_sigaltstack __user *uoss_ptr);
  219. long _compat_sys_rt_sigreturn(void);
  220. #endif /* _ASM_TILE_COMPAT_H */