compat.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390X_COMPAT_H
  3. #define _ASM_S390X_COMPAT_H
  4. /*
  5. * Architecture specific compatibility types
  6. */
  7. #include <linux/types.h>
  8. #include <linux/sched.h>
  9. #include <linux/sched/task_stack.h>
  10. #include <linux/thread_info.h>
  11. #include <asm/ptrace.h>
  12. #define compat_mode_t compat_mode_t
  13. typedef u16 compat_mode_t;
  14. #define __compat_uid_t __compat_uid_t
  15. typedef u16 __compat_uid_t;
  16. typedef u16 __compat_gid_t;
  17. #define compat_dev_t compat_dev_t
  18. typedef u16 compat_dev_t;
  19. #define compat_ipc_pid_t compat_ipc_pid_t
  20. typedef u16 compat_ipc_pid_t;
  21. #define compat_statfs compat_statfs
  22. #include <asm-generic/compat.h>
  23. #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \
  24. typeof(0?(__force t)0:0ULL), u64))
  25. #define __SC_DELOUSE(t,v) ({ \
  26. BUILD_BUG_ON(sizeof(t) > 4 && !__TYPE_IS_PTR(t)); \
  27. (__force t)(__TYPE_IS_PTR(t) ? ((v) & 0x7fffffff) : (v)); \
  28. })
  29. #define PSW32_MASK_USER 0x0000FF00UL
  30. #define PSW32_USER_BITS (PSW32_MASK_DAT | PSW32_MASK_IO | PSW32_MASK_EXT | \
  31. PSW32_DEFAULT_KEY | PSW32_MASK_BASE | \
  32. PSW32_MASK_MCHECK | PSW32_MASK_PSTATE | \
  33. PSW32_ASC_PRIMARY)
  34. #define COMPAT_UTS_MACHINE "s390\0\0\0\0"
  35. typedef u16 compat_nlink_t;
  36. typedef struct {
  37. u32 mask;
  38. u32 addr;
  39. } __aligned(8) psw_compat_t;
  40. typedef struct {
  41. psw_compat_t psw;
  42. u32 gprs[NUM_GPRS];
  43. u32 acrs[NUM_ACRS];
  44. u32 orig_gpr2;
  45. } s390_compat_regs;
  46. typedef struct {
  47. u32 gprs_high[NUM_GPRS];
  48. } s390_compat_regs_high;
  49. struct compat_stat {
  50. compat_dev_t st_dev;
  51. u16 __pad1;
  52. compat_ino_t st_ino;
  53. compat_mode_t st_mode;
  54. compat_nlink_t st_nlink;
  55. __compat_uid_t st_uid;
  56. __compat_gid_t st_gid;
  57. compat_dev_t st_rdev;
  58. u16 __pad2;
  59. u32 st_size;
  60. u32 st_blksize;
  61. u32 st_blocks;
  62. u32 st_atime;
  63. u32 st_atime_nsec;
  64. u32 st_mtime;
  65. u32 st_mtime_nsec;
  66. u32 st_ctime;
  67. u32 st_ctime_nsec;
  68. u32 __unused4;
  69. u32 __unused5;
  70. };
  71. struct compat_statfs {
  72. u32 f_type;
  73. u32 f_bsize;
  74. u32 f_blocks;
  75. u32 f_bfree;
  76. u32 f_bavail;
  77. u32 f_files;
  78. u32 f_ffree;
  79. compat_fsid_t f_fsid;
  80. u32 f_namelen;
  81. u32 f_frsize;
  82. u32 f_flags;
  83. u32 f_spare[4];
  84. };
  85. struct compat_statfs64 {
  86. u32 f_type;
  87. u32 f_bsize;
  88. u64 f_blocks;
  89. u64 f_bfree;
  90. u64 f_bavail;
  91. u64 f_files;
  92. u64 f_ffree;
  93. compat_fsid_t f_fsid;
  94. u32 f_namelen;
  95. u32 f_frsize;
  96. u32 f_flags;
  97. u32 f_spare[4];
  98. };
  99. /*
  100. * A pointer passed in from user mode. This should not
  101. * be used for syscall parameters, just declare them
  102. * as pointers because the syscall entry code will have
  103. * appropriately converted them already.
  104. */
  105. static inline void __user *compat_ptr(compat_uptr_t uptr)
  106. {
  107. return (void __user *)(unsigned long)(uptr & 0x7fffffffUL);
  108. }
  109. #define compat_ptr(uptr) compat_ptr(uptr)
  110. #ifdef CONFIG_COMPAT
  111. static inline int is_compat_task(void)
  112. {
  113. return test_thread_flag(TIF_31BIT);
  114. }
  115. #endif
  116. #endif /* _ASM_S390X_COMPAT_H */