compat.h 4.7 KB

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