1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_COMPAT_H
3 #define _ASM_X86_COMPAT_H
6 * Architecture specific compatibility types
8 #include <linux/types.h>
9 #include <linux/sched.h>
10 #include <linux/sched/task_stack.h>
11 #include <asm/processor.h>
12 #include <asm/user32.h>
13 #include <asm/unistd.h>
15 #define compat_mode_t compat_mode_t
16 typedef u16 compat_mode_t;
18 #include <asm-generic/compat.h>
20 #define COMPAT_USER_HZ 100
21 #define COMPAT_UTS_MACHINE "i686\0\0"
23 typedef u16 __compat_uid_t;
24 typedef u16 __compat_gid_t;
25 typedef u16 compat_dev_t;
26 typedef u16 compat_nlink_t;
27 typedef u16 compat_ipc_pid_t;
28 typedef __kernel_fsid_t compat_fsid_t;
34 compat_mode_t st_mode;
35 compat_nlink_t st_nlink;
36 __compat_uid_t st_uid;
37 __compat_gid_t st_gid;
61 #define F_GETLK64 12 /* using 'struct flock64' */
66 * IA32 uses 4 byte alignment for 64 bit quantities,
67 * so we need to pack this structure.
69 struct compat_flock64 {
72 compat_loff_t l_start;
75 } __attribute__((packed));
77 struct compat_statfs {
86 int f_namelen; /* SunOS ignores this field. */
92 #define COMPAT_RLIM_INFINITY 0xffffffff
94 #define COMPAT_OFF_T_MAX 0x7fffffff
96 struct compat_ipc64_perm {
100 __compat_uid32_t cuid;
101 __compat_gid32_t cgid;
103 unsigned short __pad1;
105 unsigned short __pad2;
106 compat_ulong_t unused1;
107 compat_ulong_t unused2;
110 struct compat_semid64_ds {
111 struct compat_ipc64_perm sem_perm;
112 compat_ulong_t sem_otime;
113 compat_ulong_t sem_otime_high;
114 compat_ulong_t sem_ctime;
115 compat_ulong_t sem_ctime_high;
116 compat_ulong_t sem_nsems;
117 compat_ulong_t __unused3;
118 compat_ulong_t __unused4;
121 struct compat_msqid64_ds {
122 struct compat_ipc64_perm msg_perm;
123 compat_ulong_t msg_stime;
124 compat_ulong_t msg_stime_high;
125 compat_ulong_t msg_rtime;
126 compat_ulong_t msg_rtime_high;
127 compat_ulong_t msg_ctime;
128 compat_ulong_t msg_ctime_high;
129 compat_ulong_t msg_cbytes;
130 compat_ulong_t msg_qnum;
131 compat_ulong_t msg_qbytes;
132 compat_pid_t msg_lspid;
133 compat_pid_t msg_lrpid;
134 compat_ulong_t __unused4;
135 compat_ulong_t __unused5;
138 struct compat_shmid64_ds {
139 struct compat_ipc64_perm shm_perm;
140 compat_size_t shm_segsz;
141 compat_ulong_t shm_atime;
142 compat_ulong_t shm_atime_high;
143 compat_ulong_t shm_dtime;
144 compat_ulong_t shm_dtime_high;
145 compat_ulong_t shm_ctime;
146 compat_ulong_t shm_ctime_high;
147 compat_pid_t shm_cpid;
148 compat_pid_t shm_lpid;
149 compat_ulong_t shm_nattch;
150 compat_ulong_t __unused4;
151 compat_ulong_t __unused5;
154 #ifdef CONFIG_X86_X32_ABI
155 #define COMPAT_USE_64BIT_TIME \
156 (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
159 static inline bool in_x32_syscall(void)
161 #ifdef CONFIG_X86_X32_ABI
162 if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)
168 static inline bool in_32bit_syscall(void)
170 return in_ia32_syscall() || in_x32_syscall();
174 static inline bool in_compat_syscall(void)
176 return in_32bit_syscall();
178 #define in_compat_syscall in_compat_syscall /* override the generic impl */
179 #define compat_need_64bit_alignment_fixup in_ia32_syscall
182 struct compat_siginfo;
184 #ifdef CONFIG_X86_X32_ABI
185 int copy_siginfo_to_user32(struct compat_siginfo __user *to,
186 const kernel_siginfo_t *from);
187 #define copy_siginfo_to_user32 copy_siginfo_to_user32
188 #endif /* CONFIG_X86_X32_ABI */
190 #endif /* _ASM_X86_COMPAT_H */