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/user32.h>
10 #include <asm/unistd.h>
12 #define COMPAT_USER_HZ 100
13 #define COMPAT_UTS_MACHINE "i686\0\0"
15 typedef u32 compat_size_t;
16 typedef s32 compat_ssize_t;
17 typedef s32 compat_time_t;
18 typedef s32 compat_clock_t;
19 typedef s32 compat_pid_t;
20 typedef u16 __compat_uid_t;
21 typedef u16 __compat_gid_t;
22 typedef u32 __compat_uid32_t;
23 typedef u32 __compat_gid32_t;
24 typedef u16 compat_mode_t;
25 typedef u32 compat_ino_t;
26 typedef u16 compat_dev_t;
27 typedef s32 compat_off_t;
28 typedef s64 compat_loff_t;
29 typedef u16 compat_nlink_t;
30 typedef u16 compat_ipc_pid_t;
31 typedef s32 compat_daddr_t;
32 typedef u32 compat_caddr_t;
33 typedef __kernel_fsid_t compat_fsid_t;
34 typedef s32 compat_timer_t;
35 typedef s32 compat_key_t;
37 typedef s32 compat_int_t;
38 typedef s32 compat_long_t;
39 typedef s64 __attribute__((aligned(4))) compat_s64;
40 typedef u32 compat_uint_t;
41 typedef u32 compat_ulong_t;
42 typedef u64 __attribute__((aligned(4))) compat_u64;
44 struct compat_timespec {
49 struct compat_timeval {
58 compat_mode_t st_mode;
59 compat_nlink_t st_nlink;
60 __compat_uid_t st_uid;
61 __compat_gid_t st_gid;
85 #define F_GETLK64 12 /* using 'struct flock64' */
90 * IA32 uses 4 byte alignment for 64 bit quantities,
91 * so we need to pack this structure.
93 struct compat_flock64 {
96 compat_loff_t l_start;
99 } __attribute__((packed));
101 struct compat_statfs {
109 compat_fsid_t f_fsid;
110 int f_namelen; /* SunOS ignores this field. */
116 #define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
117 #define COMPAT_RLIM_INFINITY 0xffffffff
119 typedef u32 compat_old_sigset_t; /* at least 32 bits */
121 #define _COMPAT_NSIG 64
122 #define _COMPAT_NSIG_BPW 32
124 typedef u32 compat_sigset_word;
126 #define COMPAT_OFF_T_MAX 0x7fffffff
127 #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
129 struct compat_ipc64_perm {
131 __compat_uid32_t uid;
132 __compat_gid32_t gid;
133 __compat_uid32_t cuid;
134 __compat_gid32_t cgid;
136 unsigned short __pad1;
138 unsigned short __pad2;
139 compat_ulong_t unused1;
140 compat_ulong_t unused2;
143 struct compat_semid64_ds {
144 struct compat_ipc64_perm sem_perm;
145 compat_time_t sem_otime;
146 compat_ulong_t __unused1;
147 compat_time_t sem_ctime;
148 compat_ulong_t __unused2;
149 compat_ulong_t sem_nsems;
150 compat_ulong_t __unused3;
151 compat_ulong_t __unused4;
154 struct compat_msqid64_ds {
155 struct compat_ipc64_perm msg_perm;
156 compat_time_t msg_stime;
157 compat_ulong_t __unused1;
158 compat_time_t msg_rtime;
159 compat_ulong_t __unused2;
160 compat_time_t msg_ctime;
161 compat_ulong_t __unused3;
162 compat_ulong_t msg_cbytes;
163 compat_ulong_t msg_qnum;
164 compat_ulong_t msg_qbytes;
165 compat_pid_t msg_lspid;
166 compat_pid_t msg_lrpid;
167 compat_ulong_t __unused4;
168 compat_ulong_t __unused5;
171 struct compat_shmid64_ds {
172 struct compat_ipc64_perm shm_perm;
173 compat_size_t shm_segsz;
174 compat_time_t shm_atime;
175 compat_ulong_t __unused1;
176 compat_time_t shm_dtime;
177 compat_ulong_t __unused2;
178 compat_time_t shm_ctime;
179 compat_ulong_t __unused3;
180 compat_pid_t shm_cpid;
181 compat_pid_t shm_lpid;
182 compat_ulong_t shm_nattch;
183 compat_ulong_t __unused4;
184 compat_ulong_t __unused5;
188 * The type of struct elf_prstatus.pr_reg in compatible core dumps.
190 typedef struct user_regs_struct32 compat_elf_gregset_t;
193 * A pointer passed in from user mode. This should not
194 * be used for syscall parameters, just declare them
195 * as pointers because the syscall entry code will have
196 * appropriately converted them already.
198 typedef u32 compat_uptr_t;
200 static inline void __user *compat_ptr(compat_uptr_t uptr)
202 return (void __user *)(unsigned long)uptr;
205 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
207 return (u32)(unsigned long)uptr;
210 static inline void __user *arch_compat_alloc_user_space(long len)
212 struct pt_regs *regs = task_pt_regs(current);
213 return (void __user *)regs->sp - len;
216 static inline bool is_compat_task(void)
218 #ifdef CONFIG_IA32_EMULATION
219 if (current_thread_info()->status & TS_COMPAT)
222 #ifdef CONFIG_X86_X32_ABI
223 if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)
229 #endif /* _ASM_X86_COMPAT_H */