1 #ifndef _ASM_X86_COMPAT_H
2 #define _ASM_X86_COMPAT_H
5 * Architecture specific compatibility types
7 #include <linux/types.h>
8 #include <linux/sched.h>
9 #include <asm/processor.h>
10 #include <asm/user32.h>
11 #include <asm/unistd.h>
13 #define COMPAT_USER_HZ 100
14 #define COMPAT_UTS_MACHINE "i686\0\0"
16 typedef u32 compat_size_t
;
17 typedef s32 compat_ssize_t
;
18 typedef s32 compat_time_t
;
19 typedef s32 compat_clock_t
;
20 typedef s32 compat_pid_t
;
21 typedef u16 __compat_uid_t
;
22 typedef u16 __compat_gid_t
;
23 typedef u32 __compat_uid32_t
;
24 typedef u32 __compat_gid32_t
;
25 typedef u16 compat_mode_t
;
26 typedef u32 compat_ino_t
;
27 typedef u16 compat_dev_t
;
28 typedef s32 compat_off_t
;
29 typedef s64 compat_loff_t
;
30 typedef u16 compat_nlink_t
;
31 typedef u16 compat_ipc_pid_t
;
32 typedef s32 compat_daddr_t
;
33 typedef u32 compat_caddr_t
;
34 typedef __kernel_fsid_t compat_fsid_t
;
35 typedef s32 compat_timer_t
;
36 typedef s32 compat_key_t
;
38 typedef s32 compat_int_t
;
39 typedef s32 compat_long_t
;
40 typedef s64
__attribute__((aligned(4))) compat_s64
;
41 typedef u32 compat_uint_t
;
42 typedef u32 compat_ulong_t
;
43 typedef u64
__attribute__((aligned(4))) compat_u64
;
44 typedef u32 compat_uptr_t
;
46 struct compat_timespec
{
51 struct compat_timeval
{
60 compat_mode_t st_mode
;
61 compat_nlink_t st_nlink
;
62 __compat_uid_t st_uid
;
63 __compat_gid_t st_gid
;
87 #define F_GETLK64 12 /* using 'struct flock64' */
92 * IA32 uses 4 byte alignment for 64 bit quantities,
93 * so we need to pack this structure.
95 struct compat_flock64
{
98 compat_loff_t l_start
;
101 } __attribute__((packed
));
103 struct compat_statfs
{
111 compat_fsid_t f_fsid
;
112 int f_namelen
; /* SunOS ignores this field. */
118 #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
119 #define COMPAT_RLIM_INFINITY 0xffffffff
121 typedef u32 compat_old_sigset_t
; /* at least 32 bits */
123 #define _COMPAT_NSIG 64
124 #define _COMPAT_NSIG_BPW 32
126 typedef u32 compat_sigset_word
;
128 typedef union compat_sigval
{
129 compat_int_t sival_int
;
130 compat_uptr_t sival_ptr
;
133 typedef struct compat_siginfo
{
139 int _pad
[128/sizeof(int) - 3];
143 unsigned int _pid
; /* sender's pid */
144 unsigned int _uid
; /* sender's uid */
147 /* POSIX.1b timers */
149 compat_timer_t _tid
; /* timer id */
150 int _overrun
; /* overrun count */
151 compat_sigval_t _sigval
; /* same as below */
152 int _sys_private
; /* not to be passed to user */
153 int _overrun_incr
; /* amount to add to overrun */
156 /* POSIX.1b signals */
158 unsigned int _pid
; /* sender's pid */
159 unsigned int _uid
; /* sender's uid */
160 compat_sigval_t _sigval
;
165 unsigned int _pid
; /* which child */
166 unsigned int _uid
; /* sender's uid */
167 int _status
; /* exit code */
168 compat_clock_t _utime
;
169 compat_clock_t _stime
;
172 /* SIGCHLD (x32 version) */
174 unsigned int _pid
; /* which child */
175 unsigned int _uid
; /* sender's uid */
176 int _status
; /* exit code */
181 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
183 unsigned int _addr
; /* faulting insn/memory ref. */
188 int _band
; /* POLL_IN, POLL_OUT, POLL_MSG */
193 unsigned int _call_addr
; /* calling insn */
194 int _syscall
; /* triggering system call number */
195 unsigned int _arch
; /* AUDIT_ARCH_* of syscall */
200 #define COMPAT_OFF_T_MAX 0x7fffffff
201 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
203 struct compat_ipc64_perm
{
205 __compat_uid32_t uid
;
206 __compat_gid32_t gid
;
207 __compat_uid32_t cuid
;
208 __compat_gid32_t cgid
;
210 unsigned short __pad1
;
212 unsigned short __pad2
;
213 compat_ulong_t unused1
;
214 compat_ulong_t unused2
;
217 struct compat_semid64_ds
{
218 struct compat_ipc64_perm sem_perm
;
219 compat_time_t sem_otime
;
220 compat_ulong_t __unused1
;
221 compat_time_t sem_ctime
;
222 compat_ulong_t __unused2
;
223 compat_ulong_t sem_nsems
;
224 compat_ulong_t __unused3
;
225 compat_ulong_t __unused4
;
228 struct compat_msqid64_ds
{
229 struct compat_ipc64_perm msg_perm
;
230 compat_time_t msg_stime
;
231 compat_ulong_t __unused1
;
232 compat_time_t msg_rtime
;
233 compat_ulong_t __unused2
;
234 compat_time_t msg_ctime
;
235 compat_ulong_t __unused3
;
236 compat_ulong_t msg_cbytes
;
237 compat_ulong_t msg_qnum
;
238 compat_ulong_t msg_qbytes
;
239 compat_pid_t msg_lspid
;
240 compat_pid_t msg_lrpid
;
241 compat_ulong_t __unused4
;
242 compat_ulong_t __unused5
;
245 struct compat_shmid64_ds
{
246 struct compat_ipc64_perm shm_perm
;
247 compat_size_t shm_segsz
;
248 compat_time_t shm_atime
;
249 compat_ulong_t __unused1
;
250 compat_time_t shm_dtime
;
251 compat_ulong_t __unused2
;
252 compat_time_t shm_ctime
;
253 compat_ulong_t __unused3
;
254 compat_pid_t shm_cpid
;
255 compat_pid_t shm_lpid
;
256 compat_ulong_t shm_nattch
;
257 compat_ulong_t __unused4
;
258 compat_ulong_t __unused5
;
262 * The type of struct elf_prstatus.pr_reg in compatible core dumps.
264 #ifdef CONFIG_X86_X32_ABI
265 typedef struct user_regs_struct compat_elf_gregset_t
;
267 #define PR_REG_SIZE(S) (test_thread_flag(TIF_IA32) ? 68 : 216)
268 #define PRSTATUS_SIZE(S) (test_thread_flag(TIF_IA32) ? 144 : 296)
269 #define SET_PR_FPVALID(S,V) \
270 do { *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE(0)) = (V); } \
273 #define COMPAT_USE_64BIT_TIME \
274 (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
276 typedef struct user_regs_struct32 compat_elf_gregset_t
;
280 * A pointer passed in from user mode. This should not
281 * be used for syscall parameters, just declare them
282 * as pointers because the syscall entry code will have
283 * appropriately converted them already.
286 static inline void __user
*compat_ptr(compat_uptr_t uptr
)
288 return (void __user
*)(unsigned long)uptr
;
291 static inline compat_uptr_t
ptr_to_compat(void __user
*uptr
)
293 return (u32
)(unsigned long)uptr
;
296 static inline void __user
*arch_compat_alloc_user_space(long len
)
300 if (test_thread_flag(TIF_IA32
)) {
301 sp
= task_pt_regs(current
)->sp
;
303 /* -128 for the x32 ABI redzone */
304 sp
= task_pt_regs(current
)->sp
- 128;
307 return (void __user
*)round_down(sp
- len
, 16);
310 static inline bool is_x32_task(void)
312 #ifdef CONFIG_X86_X32_ABI
313 if (task_pt_regs(current
)->orig_ax
& __X32_SYSCALL_BIT
)
319 static inline bool in_compat_syscall(void)
321 return is_ia32_task() || is_x32_task();
323 #define in_compat_syscall in_compat_syscall /* override the generic impl */
325 #endif /* _ASM_X86_COMPAT_H */