compat.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_COMPAT_H
  3. #define _ASM_X86_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 <asm/processor.h>
  11. #include <asm/user32.h>
  12. #include <asm/unistd.h>
  13. #define compat_mode_t compat_mode_t
  14. typedef u16 compat_mode_t;
  15. #define __compat_uid_t __compat_uid_t
  16. typedef u16 __compat_uid_t;
  17. typedef u16 __compat_gid_t;
  18. #define compat_dev_t compat_dev_t
  19. typedef u16 compat_dev_t;
  20. #define compat_ipc_pid_t compat_ipc_pid_t
  21. typedef u16 compat_ipc_pid_t;
  22. #define compat_statfs compat_statfs
  23. #include <asm-generic/compat.h>
  24. #define COMPAT_UTS_MACHINE "i686\0\0"
  25. typedef u16 compat_nlink_t;
  26. struct compat_stat {
  27. u32 st_dev;
  28. compat_ino_t st_ino;
  29. compat_mode_t st_mode;
  30. compat_nlink_t st_nlink;
  31. __compat_uid_t st_uid;
  32. __compat_gid_t st_gid;
  33. u32 st_rdev;
  34. u32 st_size;
  35. u32 st_blksize;
  36. u32 st_blocks;
  37. u32 st_atime;
  38. u32 st_atime_nsec;
  39. u32 st_mtime;
  40. u32 st_mtime_nsec;
  41. u32 st_ctime;
  42. u32 st_ctime_nsec;
  43. u32 __unused4;
  44. u32 __unused5;
  45. };
  46. /*
  47. * IA32 uses 4 byte alignment for 64 bit quantities, so we need to pack the
  48. * compat flock64 structure.
  49. */
  50. #define __ARCH_NEED_COMPAT_FLOCK64_PACKED
  51. struct compat_statfs {
  52. int f_type;
  53. int f_bsize;
  54. int f_blocks;
  55. int f_bfree;
  56. int f_bavail;
  57. int f_files;
  58. int f_ffree;
  59. compat_fsid_t f_fsid;
  60. int f_namelen; /* SunOS ignores this field. */
  61. int f_frsize;
  62. int f_flags;
  63. int f_spare[4];
  64. };
  65. #ifdef CONFIG_X86_X32_ABI
  66. #define COMPAT_USE_64BIT_TIME \
  67. (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
  68. #endif
  69. static inline bool in_x32_syscall(void)
  70. {
  71. #ifdef CONFIG_X86_X32_ABI
  72. if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)
  73. return true;
  74. #endif
  75. return false;
  76. }
  77. static inline bool in_32bit_syscall(void)
  78. {
  79. return in_ia32_syscall() || in_x32_syscall();
  80. }
  81. #ifdef CONFIG_COMPAT
  82. static inline bool in_compat_syscall(void)
  83. {
  84. return in_32bit_syscall();
  85. }
  86. #define in_compat_syscall in_compat_syscall /* override the generic impl */
  87. #define compat_need_64bit_alignment_fixup in_ia32_syscall
  88. #endif
  89. struct compat_siginfo;
  90. #ifdef CONFIG_X86_X32_ABI
  91. int copy_siginfo_to_user32(struct compat_siginfo __user *to,
  92. const kernel_siginfo_t *from);
  93. #define copy_siginfo_to_user32 copy_siginfo_to_user32
  94. #endif /* CONFIG_X86_X32_ABI */
  95. #endif /* _ASM_X86_COMPAT_H */