compat.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #ifndef _ASM_X86_COMPAT_H
  2. #define _ASM_X86_COMPAT_H
  3. /*
  4. * Architecture specific compatibility types
  5. */
  6. #include <linux/types.h>
  7. #include <linux/sched.h>
  8. #include <asm/user32.h>
  9. #define COMPAT_USER_HZ 100
  10. typedef u32 compat_size_t;
  11. typedef s32 compat_ssize_t;
  12. typedef s32 compat_time_t;
  13. typedef s32 compat_clock_t;
  14. typedef s32 compat_pid_t;
  15. typedef u16 __compat_uid_t;
  16. typedef u16 __compat_gid_t;
  17. typedef u32 __compat_uid32_t;
  18. typedef u32 __compat_gid32_t;
  19. typedef u16 compat_mode_t;
  20. typedef u32 compat_ino_t;
  21. typedef u16 compat_dev_t;
  22. typedef s32 compat_off_t;
  23. typedef s64 compat_loff_t;
  24. typedef u16 compat_nlink_t;
  25. typedef u16 compat_ipc_pid_t;
  26. typedef s32 compat_daddr_t;
  27. typedef u32 compat_caddr_t;
  28. typedef __kernel_fsid_t compat_fsid_t;
  29. typedef s32 compat_timer_t;
  30. typedef s32 compat_key_t;
  31. typedef s32 compat_int_t;
  32. typedef s32 compat_long_t;
  33. typedef s64 __attribute__((aligned(4))) compat_s64;
  34. typedef u32 compat_uint_t;
  35. typedef u32 compat_ulong_t;
  36. typedef u64 __attribute__((aligned(4))) compat_u64;
  37. struct compat_timespec {
  38. compat_time_t tv_sec;
  39. s32 tv_nsec;
  40. };
  41. struct compat_timeval {
  42. compat_time_t tv_sec;
  43. s32 tv_usec;
  44. };
  45. struct compat_stat {
  46. compat_dev_t st_dev;
  47. u16 __pad1;
  48. compat_ino_t st_ino;
  49. compat_mode_t st_mode;
  50. compat_nlink_t st_nlink;
  51. __compat_uid_t st_uid;
  52. __compat_gid_t st_gid;
  53. compat_dev_t st_rdev;
  54. u16 __pad2;
  55. u32 st_size;
  56. u32 st_blksize;
  57. u32 st_blocks;
  58. u32 st_atime;
  59. u32 st_atime_nsec;
  60. u32 st_mtime;
  61. u32 st_mtime_nsec;
  62. u32 st_ctime;
  63. u32 st_ctime_nsec;
  64. u32 __unused4;
  65. u32 __unused5;
  66. };
  67. struct compat_flock {
  68. short l_type;
  69. short l_whence;
  70. compat_off_t l_start;
  71. compat_off_t l_len;
  72. compat_pid_t l_pid;
  73. };
  74. #define F_GETLK64 12 /* using 'struct flock64' */
  75. #define F_SETLK64 13
  76. #define F_SETLKW64 14
  77. /*
  78. * IA32 uses 4 byte alignment for 64 bit quantities,
  79. * so we need to pack this structure.
  80. */
  81. struct compat_flock64 {
  82. short l_type;
  83. short l_whence;
  84. compat_loff_t l_start;
  85. compat_loff_t l_len;
  86. compat_pid_t l_pid;
  87. } __attribute__((packed));
  88. struct compat_statfs {
  89. int f_type;
  90. int f_bsize;
  91. int f_blocks;
  92. int f_bfree;
  93. int f_bavail;
  94. int f_files;
  95. int f_ffree;
  96. compat_fsid_t f_fsid;
  97. int f_namelen; /* SunOS ignores this field. */
  98. int f_frsize;
  99. int f_spare[5];
  100. };
  101. #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
  102. #define COMPAT_RLIM_INFINITY 0xffffffff
  103. typedef u32 compat_old_sigset_t; /* at least 32 bits */
  104. #define _COMPAT_NSIG 64
  105. #define _COMPAT_NSIG_BPW 32
  106. typedef u32 compat_sigset_word;
  107. #define COMPAT_OFF_T_MAX 0x7fffffff
  108. #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
  109. struct compat_ipc64_perm {
  110. compat_key_t key;
  111. __compat_uid32_t uid;
  112. __compat_gid32_t gid;
  113. __compat_uid32_t cuid;
  114. __compat_gid32_t cgid;
  115. unsigned short mode;
  116. unsigned short __pad1;
  117. unsigned short seq;
  118. unsigned short __pad2;
  119. compat_ulong_t unused1;
  120. compat_ulong_t unused2;
  121. };
  122. struct compat_semid64_ds {
  123. struct compat_ipc64_perm sem_perm;
  124. compat_time_t sem_otime;
  125. compat_ulong_t __unused1;
  126. compat_time_t sem_ctime;
  127. compat_ulong_t __unused2;
  128. compat_ulong_t sem_nsems;
  129. compat_ulong_t __unused3;
  130. compat_ulong_t __unused4;
  131. };
  132. struct compat_msqid64_ds {
  133. struct compat_ipc64_perm msg_perm;
  134. compat_time_t msg_stime;
  135. compat_ulong_t __unused1;
  136. compat_time_t msg_rtime;
  137. compat_ulong_t __unused2;
  138. compat_time_t msg_ctime;
  139. compat_ulong_t __unused3;
  140. compat_ulong_t msg_cbytes;
  141. compat_ulong_t msg_qnum;
  142. compat_ulong_t msg_qbytes;
  143. compat_pid_t msg_lspid;
  144. compat_pid_t msg_lrpid;
  145. compat_ulong_t __unused4;
  146. compat_ulong_t __unused5;
  147. };
  148. struct compat_shmid64_ds {
  149. struct compat_ipc64_perm shm_perm;
  150. compat_size_t shm_segsz;
  151. compat_time_t shm_atime;
  152. compat_ulong_t __unused1;
  153. compat_time_t shm_dtime;
  154. compat_ulong_t __unused2;
  155. compat_time_t shm_ctime;
  156. compat_ulong_t __unused3;
  157. compat_pid_t shm_cpid;
  158. compat_pid_t shm_lpid;
  159. compat_ulong_t shm_nattch;
  160. compat_ulong_t __unused4;
  161. compat_ulong_t __unused5;
  162. };
  163. /*
  164. * The type of struct elf_prstatus.pr_reg in compatible core dumps.
  165. */
  166. typedef struct user_regs_struct32 compat_elf_gregset_t;
  167. /*
  168. * A pointer passed in from user mode. This should not
  169. * be used for syscall parameters, just declare them
  170. * as pointers because the syscall entry code will have
  171. * appropriately converted them already.
  172. */
  173. typedef u32 compat_uptr_t;
  174. static inline void __user *compat_ptr(compat_uptr_t uptr)
  175. {
  176. return (void __user *)(unsigned long)uptr;
  177. }
  178. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  179. {
  180. return (u32)(unsigned long)uptr;
  181. }
  182. static inline void __user *compat_alloc_user_space(long len)
  183. {
  184. struct pt_regs *regs = task_pt_regs(current);
  185. return (void __user *)regs->sp - len;
  186. }
  187. static inline int is_compat_task(void)
  188. {
  189. return current_thread_info()->status & TS_COMPAT;
  190. }
  191. #endif /* _ASM_X86_COMPAT_H */