compat.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_PARISC_COMPAT_H
  3. #define _ASM_PARISC_COMPAT_H
  4. /*
  5. * Architecture specific compatibility types
  6. */
  7. #include <linux/types.h>
  8. #include <linux/sched.h>
  9. #include <linux/thread_info.h>
  10. #define COMPAT_USER_HZ 100
  11. #define COMPAT_UTS_MACHINE "parisc\0\0"
  12. typedef u32 compat_size_t;
  13. typedef s32 compat_ssize_t;
  14. typedef s32 compat_clock_t;
  15. typedef s32 compat_pid_t;
  16. typedef u32 __compat_uid_t;
  17. typedef u32 __compat_gid_t;
  18. typedef u32 __compat_uid32_t;
  19. typedef u32 __compat_gid32_t;
  20. typedef u16 compat_mode_t;
  21. typedef u32 compat_ino_t;
  22. typedef u32 compat_dev_t;
  23. typedef s32 compat_off_t;
  24. typedef s64 compat_loff_t;
  25. typedef u16 compat_nlink_t;
  26. typedef u16 compat_ipc_pid_t;
  27. typedef s32 compat_daddr_t;
  28. typedef u32 compat_caddr_t;
  29. typedef s32 compat_key_t;
  30. typedef s32 compat_timer_t;
  31. typedef s32 compat_int_t;
  32. typedef s32 compat_long_t;
  33. typedef s64 compat_s64;
  34. typedef u32 compat_uint_t;
  35. typedef u32 compat_ulong_t;
  36. typedef u64 compat_u64;
  37. typedef u32 compat_uptr_t;
  38. struct compat_stat {
  39. compat_dev_t st_dev; /* dev_t is 32 bits on parisc */
  40. compat_ino_t st_ino; /* 32 bits */
  41. compat_mode_t st_mode; /* 16 bits */
  42. compat_nlink_t st_nlink; /* 16 bits */
  43. u16 st_reserved1; /* old st_uid */
  44. u16 st_reserved2; /* old st_gid */
  45. compat_dev_t st_rdev;
  46. compat_off_t st_size;
  47. old_time32_t st_atime;
  48. u32 st_atime_nsec;
  49. old_time32_t st_mtime;
  50. u32 st_mtime_nsec;
  51. old_time32_t st_ctime;
  52. u32 st_ctime_nsec;
  53. s32 st_blksize;
  54. s32 st_blocks;
  55. u32 __unused1; /* ACL stuff */
  56. compat_dev_t __unused2; /* network */
  57. compat_ino_t __unused3; /* network */
  58. u32 __unused4; /* cnodes */
  59. u16 __unused5; /* netsite */
  60. short st_fstype;
  61. compat_dev_t st_realdev;
  62. u16 st_basemode;
  63. u16 st_spareshort;
  64. __compat_uid32_t st_uid;
  65. __compat_gid32_t st_gid;
  66. u32 st_spare4[3];
  67. };
  68. struct compat_flock {
  69. short l_type;
  70. short l_whence;
  71. compat_off_t l_start;
  72. compat_off_t l_len;
  73. compat_pid_t l_pid;
  74. };
  75. struct compat_flock64 {
  76. short l_type;
  77. short l_whence;
  78. compat_loff_t l_start;
  79. compat_loff_t l_len;
  80. compat_pid_t l_pid;
  81. };
  82. struct compat_statfs {
  83. s32 f_type;
  84. s32 f_bsize;
  85. s32 f_blocks;
  86. s32 f_bfree;
  87. s32 f_bavail;
  88. s32 f_files;
  89. s32 f_ffree;
  90. __kernel_fsid_t f_fsid;
  91. s32 f_namelen;
  92. s32 f_frsize;
  93. s32 f_flags;
  94. s32 f_spare[4];
  95. };
  96. struct compat_sigcontext {
  97. compat_int_t sc_flags;
  98. compat_int_t sc_gr[32]; /* PSW in sc_gr[0] */
  99. u64 sc_fr[32];
  100. compat_int_t sc_iasq[2];
  101. compat_int_t sc_iaoq[2];
  102. compat_int_t sc_sar; /* cr11 */
  103. };
  104. #define COMPAT_RLIM_INFINITY 0xffffffff
  105. typedef u32 compat_old_sigset_t; /* at least 32 bits */
  106. #define _COMPAT_NSIG 64
  107. #define _COMPAT_NSIG_BPW 32
  108. typedef u32 compat_sigset_word;
  109. #define COMPAT_OFF_T_MAX 0x7fffffff
  110. struct compat_ipc64_perm {
  111. compat_key_t key;
  112. __compat_uid_t uid;
  113. __compat_gid_t gid;
  114. __compat_uid_t cuid;
  115. __compat_gid_t cgid;
  116. unsigned short int __pad1;
  117. compat_mode_t mode;
  118. unsigned short int __pad2;
  119. unsigned short int seq;
  120. unsigned int __pad3;
  121. unsigned long __unused1; /* yes they really are 64bit pads */
  122. unsigned long __unused2;
  123. };
  124. struct compat_semid64_ds {
  125. struct compat_ipc64_perm sem_perm;
  126. unsigned int sem_otime_high;
  127. unsigned int sem_otime;
  128. unsigned int sem_ctime_high;
  129. unsigned int sem_ctime;
  130. compat_ulong_t sem_nsems;
  131. compat_ulong_t __unused3;
  132. compat_ulong_t __unused4;
  133. };
  134. struct compat_msqid64_ds {
  135. struct compat_ipc64_perm msg_perm;
  136. unsigned int msg_stime_high;
  137. unsigned int msg_stime;
  138. unsigned int msg_rtime_high;
  139. unsigned int msg_rtime;
  140. unsigned int msg_ctime_high;
  141. unsigned int msg_ctime;
  142. compat_ulong_t msg_cbytes;
  143. compat_ulong_t msg_qnum;
  144. compat_ulong_t msg_qbytes;
  145. compat_pid_t msg_lspid;
  146. compat_pid_t msg_lrpid;
  147. compat_ulong_t __unused4;
  148. compat_ulong_t __unused5;
  149. };
  150. struct compat_shmid64_ds {
  151. struct compat_ipc64_perm shm_perm;
  152. unsigned int shm_atime_high;
  153. unsigned int shm_atime;
  154. unsigned int shm_dtime_high;
  155. unsigned int shm_dtime;
  156. unsigned int shm_ctime_high;
  157. unsigned int shm_ctime;
  158. unsigned int __unused4;
  159. compat_size_t shm_segsz;
  160. compat_pid_t shm_cpid;
  161. compat_pid_t shm_lpid;
  162. compat_ulong_t shm_nattch;
  163. compat_ulong_t __unused5;
  164. compat_ulong_t __unused6;
  165. };
  166. /*
  167. * The type of struct elf_prstatus.pr_reg in compatible core dumps.
  168. */
  169. #define COMPAT_ELF_NGREG 80
  170. typedef compat_ulong_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
  171. /*
  172. * A pointer passed in from user mode. This should not
  173. * be used for syscall parameters, just declare them
  174. * as pointers because the syscall entry code will have
  175. * appropriately converted them already.
  176. */
  177. static inline void __user *compat_ptr(compat_uptr_t uptr)
  178. {
  179. return (void __user *)(unsigned long)uptr;
  180. }
  181. static inline compat_uptr_t ptr_to_compat(void __user *uptr)
  182. {
  183. return (u32)(unsigned long)uptr;
  184. }
  185. static __inline__ void __user *arch_compat_alloc_user_space(long len)
  186. {
  187. struct pt_regs *regs = &current->thread.regs;
  188. return (void __user *)regs->gr[30];
  189. }
  190. static inline int __is_compat_task(struct task_struct *t)
  191. {
  192. return test_ti_thread_flag(task_thread_info(t), TIF_32BIT);
  193. }
  194. static inline int is_compat_task(void)
  195. {
  196. return __is_compat_task(current);
  197. }
  198. #endif /* _ASM_PARISC_COMPAT_H */