diff options
Diffstat (limited to 'arch/x86/include/asm/compat.h')
-rw-r--r-- | arch/x86/include/asm/compat.h | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h index 30d737ef2a42..355edc091604 100644 --- a/arch/x86/include/asm/compat.h +++ b/arch/x86/include/asm/compat.h | |||
@@ -6,7 +6,9 @@ | |||
6 | */ | 6 | */ |
7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
8 | #include <linux/sched.h> | 8 | #include <linux/sched.h> |
9 | #include <asm/processor.h> | ||
9 | #include <asm/user32.h> | 10 | #include <asm/user32.h> |
11 | #include <asm/unistd.h> | ||
10 | 12 | ||
11 | #define COMPAT_USER_HZ 100 | 13 | #define COMPAT_USER_HZ 100 |
12 | #define COMPAT_UTS_MACHINE "i686\0\0" | 14 | #define COMPAT_UTS_MACHINE "i686\0\0" |
@@ -186,7 +188,20 @@ struct compat_shmid64_ds { | |||
186 | /* | 188 | /* |
187 | * The type of struct elf_prstatus.pr_reg in compatible core dumps. | 189 | * The type of struct elf_prstatus.pr_reg in compatible core dumps. |
188 | */ | 190 | */ |
191 | #ifdef CONFIG_X86_X32_ABI | ||
192 | typedef struct user_regs_struct compat_elf_gregset_t; | ||
193 | |||
194 | #define PR_REG_SIZE(S) (test_thread_flag(TIF_IA32) ? 68 : 216) | ||
195 | #define PRSTATUS_SIZE(S) (test_thread_flag(TIF_IA32) ? 144 : 296) | ||
196 | #define SET_PR_FPVALID(S,V) \ | ||
197 | do { *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE(0)) = (V); } \ | ||
198 | while (0) | ||
199 | |||
200 | #define COMPAT_USE_64BIT_TIME \ | ||
201 | (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) | ||
202 | #else | ||
189 | typedef struct user_regs_struct32 compat_elf_gregset_t; | 203 | typedef struct user_regs_struct32 compat_elf_gregset_t; |
204 | #endif | ||
190 | 205 | ||
191 | /* | 206 | /* |
192 | * A pointer passed in from user mode. This should not | 207 | * A pointer passed in from user mode. This should not |
@@ -208,13 +223,39 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr) | |||
208 | 223 | ||
209 | static inline void __user *arch_compat_alloc_user_space(long len) | 224 | static inline void __user *arch_compat_alloc_user_space(long len) |
210 | { | 225 | { |
211 | struct pt_regs *regs = task_pt_regs(current); | 226 | compat_uptr_t sp; |
212 | return (void __user *)regs->sp - len; | 227 | |
228 | if (test_thread_flag(TIF_IA32)) { | ||
229 | sp = task_pt_regs(current)->sp; | ||
230 | } else { | ||
231 | /* -128 for the x32 ABI redzone */ | ||
232 | sp = percpu_read(old_rsp) - 128; | ||
233 | } | ||
234 | |||
235 | return (void __user *)round_down(sp - len, 16); | ||
236 | } | ||
237 | |||
238 | static inline bool is_ia32_task(void) | ||
239 | { | ||
240 | #ifdef CONFIG_IA32_EMULATION | ||
241 | if (current_thread_info()->status & TS_COMPAT) | ||
242 | return true; | ||
243 | #endif | ||
244 | return false; | ||
245 | } | ||
246 | |||
247 | static inline bool is_x32_task(void) | ||
248 | { | ||
249 | #ifdef CONFIG_X86_X32_ABI | ||
250 | if (task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT) | ||
251 | return true; | ||
252 | #endif | ||
253 | return false; | ||
213 | } | 254 | } |
214 | 255 | ||
215 | static inline int is_compat_task(void) | 256 | static inline bool is_compat_task(void) |
216 | { | 257 | { |
217 | return current_thread_info()->status & TS_COMPAT; | 258 | return is_ia32_task() || is_x32_task(); |
218 | } | 259 | } |
219 | 260 | ||
220 | #endif /* _ASM_X86_COMPAT_H */ | 261 | #endif /* _ASM_X86_COMPAT_H */ |