aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/i387.c105
-rw-r--r--arch/x86/kernel/process_32.c16
-rw-r--r--arch/x86/kernel/process_64.c19
-rw-r--r--arch/x86/math-emu/fpu_entry.c14
-rw-r--r--include/asm-x86/elf.h68
-rw-r--r--include/asm-x86/i387.h14
-rw-r--r--include/asm-x86/math_emu.h5
7 files changed, 9 insertions, 232 deletions
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index f7f7568dd7bc..26719bd2c77c 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -454,113 +454,26 @@ int restore_i387_ia32(struct _fpstate_ia32 __user *buf)
454 return err; 454 return err;
455} 455}
456 456
457#endif /* CONFIG_X86_32 || CONFIG_IA32_EMULATION */
458
459#ifdef CONFIG_X86_64
460
461int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *tsk)
462{
463 return xfpregs_get(tsk, NULL, 0, sizeof(*buf), NULL, buf);
464}
465
466int set_fpregs(struct task_struct *tsk, struct user_i387_struct __user *buf)
467{
468 return xfpregs_set(tsk, NULL, 0, sizeof(*buf), NULL, buf);
469}
470
471#else
472
473int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *tsk)
474{
475 return fpregs_get(tsk, NULL, 0, sizeof(*buf), NULL, buf);
476}
477
478int set_fpregs(struct task_struct *tsk, struct user_i387_struct __user *buf)
479{
480 return fpregs_set(tsk, NULL, 0, sizeof(*buf), NULL, buf);
481}
482
483int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *tsk)
484{
485 return xfpregs_get(tsk, NULL, 0, sizeof(*buf), NULL, buf);
486}
487
488int set_fpxregs(struct task_struct *tsk, struct user_fxsr_struct __user *buf)
489{
490 return xfpregs_get(tsk, NULL, 0, sizeof(*buf), NULL, buf);
491}
492
493#endif
494
495/* 457/*
496 * FPU state for core dumps. 458 * FPU state for core dumps.
459 * This is only used for a.out dumps now.
460 * It is declared generically using elf_fpregset_t (which is
461 * struct user_i387_struct) but is in fact only used for 32-bit
462 * dumps, so on 64-bit it is really struct user_i387_ia32_struct.
497 */ 463 */
498
499static inline void copy_fpu_fsave(struct task_struct *tsk,
500 struct user_i387_struct *fpu)
501{
502 memcpy(fpu, &tsk->thread.i387.fsave,
503 sizeof(struct user_i387_struct));
504}
505
506static inline void copy_fpu_fxsave(struct task_struct *tsk,
507 struct user_i387_struct *fpu)
508{
509 unsigned short *to;
510 unsigned short *from;
511 int i;
512
513 memcpy(fpu, &tsk->thread.i387.fxsave, 7 * sizeof(long));
514
515 to = (unsigned short *)&fpu->st_space[0];
516 from = (unsigned short *)&tsk->thread.i387.fxsave.st_space[0];
517 for (i = 0; i < 8; i++, to += 5, from += 8)
518 memcpy(to, from, 5 * sizeof(unsigned short));
519}
520
521int dump_fpu(struct pt_regs *regs, struct user_i387_struct *fpu) 464int dump_fpu(struct pt_regs *regs, struct user_i387_struct *fpu)
522{ 465{
523 int fpvalid; 466 int fpvalid;
524 struct task_struct *tsk = current; 467 struct task_struct *tsk = current;
525 468
526 fpvalid = !!used_math(); 469 fpvalid = !!used_math();
527 if (fpvalid) { 470 if (fpvalid)
528 unlazy_fpu(tsk); 471 fpvalid = !fpregs_get(tsk, NULL,
529 if (cpu_has_fxsr) { 472 0, sizeof(struct user_i387_ia32_struct),
530 copy_fpu_fxsave(tsk, fpu); 473 fpu, NULL);
531 } else {
532 copy_fpu_fsave(tsk, fpu);
533 }
534 }
535 474
536 return fpvalid; 475 return fpvalid;
537} 476}
538EXPORT_SYMBOL(dump_fpu); 477EXPORT_SYMBOL(dump_fpu);
539 478
540int dump_task_fpu(struct task_struct *tsk, struct user_i387_struct *fpu) 479#endif /* CONFIG_X86_32 || CONFIG_IA32_EMULATION */
541{
542 int fpvalid = !!tsk_used_math(tsk);
543
544 if (fpvalid) {
545 if (tsk == current)
546 unlazy_fpu(tsk);
547 if (cpu_has_fxsr)
548 copy_fpu_fxsave(tsk, fpu);
549 else
550 copy_fpu_fsave(tsk, fpu);
551 }
552 return fpvalid;
553}
554
555int dump_task_extended_fpu(struct task_struct *tsk,
556 struct user32_fxsr_struct *fpu)
557{
558 int fpvalid = tsk_used_math(tsk) && cpu_has_fxsr;
559
560 if (fpvalid) {
561 if (tsk == current)
562 unlazy_fpu(tsk);
563 memcpy(fpu, &tsk->thread.i387.fxsave, sizeof(*fpu));
564 }
565 return fpvalid;
566}
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 40cc29695eba..35a6f318c541 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -571,22 +571,6 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
571} 571}
572EXPORT_SYMBOL(dump_thread); 572EXPORT_SYMBOL(dump_thread);
573 573
574/*
575 * Capture the user space registers if the task is not running (in user space)
576 */
577int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
578{
579 struct pt_regs ptregs = *task_pt_regs(tsk);
580 ptregs.cs &= 0xffff;
581 ptregs.ds &= 0xffff;
582 ptregs.es &= 0xffff;
583 ptregs.ss &= 0xffff;
584
585 elf_core_copy_regs(regs, &ptregs);
586
587 return 1;
588}
589
590#ifdef CONFIG_SECCOMP 574#ifdef CONFIG_SECCOMP
591static void hard_disable_TSC(void) 575static void hard_disable_TSC(void)
592{ 576{
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index e3a3610ade10..78d80067b7f9 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -544,24 +544,6 @@ out:
544 */ 544 */
545#define loaddebug(thread, r) set_debugreg(thread->debugreg ## r, r) 545#define loaddebug(thread, r) set_debugreg(thread->debugreg ## r, r)
546 546
547/*
548 * Capture the user space registers if the task is not running (in user space)
549 */
550int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
551{
552 struct pt_regs *pp, ptregs;
553
554 pp = task_pt_regs(tsk);
555
556 ptregs = *pp;
557 ptregs.cs &= 0xffff;
558 ptregs.ss &= 0xffff;
559
560 elf_core_copy_regs(regs, &ptregs);
561
562 return 1;
563}
564
565static inline void __switch_to_xtra(struct task_struct *prev_p, 547static inline void __switch_to_xtra(struct task_struct *prev_p,
566 struct task_struct *next_p, 548 struct task_struct *next_p,
567 struct tss_struct *tss) 549 struct tss_struct *tss)
@@ -929,4 +911,3 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
929 unsigned long range_end = mm->brk + 0x02000000; 911 unsigned long range_end = mm->brk + 0x02000000;
930 return randomize_range(mm->brk, range_end, 0) ? : mm->brk; 912 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
931} 913}
932
diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c
index cfbdaa1532ce..760baeea5f07 100644
--- a/arch/x86/math-emu/fpu_entry.c
+++ b/arch/x86/math-emu/fpu_entry.c
@@ -761,17 +761,3 @@ int fpregs_soft_get(struct task_struct *target,
761 761
762 return ret; 762 return ret;
763} 763}
764
765int save_i387_soft(void *s387, struct _fpstate __user *buf)
766{
767 return fpregs_soft_get(current, NULL,
768 0, sizeof(struct user_i387_struct),
769 NULL, buf) ? -1 : 1;
770}
771
772int restore_i387_soft(void *s387, struct _fpstate __user *buf)
773{
774 return fpregs_soft_set(current, NULL,
775 0, sizeof(struct user_i387_struct),
776 NULL, buf) ? -1 : 1;
777}
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index 123e2d599c6d..d6bf7421d7b0 100644
--- a/include/asm-x86/elf.h
+++ b/include/asm-x86/elf.h
@@ -104,28 +104,6 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
104 _r->ax = 0; \ 104 _r->ax = 0; \
105} while (0) 105} while (0)
106 106
107/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
108 now struct_user_regs, they are different) */
109
110#define ELF_CORE_COPY_REGS(pr_reg, regs) \
111 pr_reg[0] = regs->bx; \
112 pr_reg[1] = regs->cx; \
113 pr_reg[2] = regs->dx; \
114 pr_reg[3] = regs->si; \
115 pr_reg[4] = regs->di; \
116 pr_reg[5] = regs->bp; \
117 pr_reg[6] = regs->ax; \
118 pr_reg[7] = regs->ds & 0xffff; \
119 pr_reg[8] = regs->es & 0xffff; \
120 pr_reg[9] = regs->fs & 0xffff; \
121 savesegment(gs,pr_reg[10]); \
122 pr_reg[11] = regs->orig_ax; \
123 pr_reg[12] = regs->ip; \
124 pr_reg[13] = regs->cs & 0xffff; \
125 pr_reg[14] = regs->flags; \
126 pr_reg[15] = regs->sp; \
127 pr_reg[16] = regs->ss & 0xffff;
128
129#define ELF_PLATFORM (utsname()->machine) 107#define ELF_PLATFORM (utsname()->machine)
130#define set_personality_64bit() do { } while (0) 108#define set_personality_64bit() do { } while (0)
131extern unsigned int vdso_enabled; 109extern unsigned int vdso_enabled;
@@ -159,41 +137,6 @@ extern unsigned int vdso_enabled;
159 clear_thread_flag(TIF_IA32); \ 137 clear_thread_flag(TIF_IA32); \
160} while (0) 138} while (0)
161 139
162/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
163 now struct_user_regs, they are different). Assumes current is the process
164 getting dumped. */
165
166#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
167 unsigned v; \
168 (pr_reg)[0] = (regs)->r15; \
169 (pr_reg)[1] = (regs)->r14; \
170 (pr_reg)[2] = (regs)->r13; \
171 (pr_reg)[3] = (regs)->r12; \
172 (pr_reg)[4] = (regs)->bp; \
173 (pr_reg)[5] = (regs)->bx; \
174 (pr_reg)[6] = (regs)->r11; \
175 (pr_reg)[7] = (regs)->r10; \
176 (pr_reg)[8] = (regs)->r9; \
177 (pr_reg)[9] = (regs)->r8; \
178 (pr_reg)[10] = (regs)->ax; \
179 (pr_reg)[11] = (regs)->cx; \
180 (pr_reg)[12] = (regs)->dx; \
181 (pr_reg)[13] = (regs)->si; \
182 (pr_reg)[14] = (regs)->di; \
183 (pr_reg)[15] = (regs)->orig_ax; \
184 (pr_reg)[16] = (regs)->ip; \
185 (pr_reg)[17] = (regs)->cs; \
186 (pr_reg)[18] = (regs)->flags; \
187 (pr_reg)[19] = (regs)->sp; \
188 (pr_reg)[20] = (regs)->ss; \
189 (pr_reg)[21] = current->thread.fs; \
190 (pr_reg)[22] = current->thread.gs; \
191 asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \
192 asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \
193 asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \
194 asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \
195} while(0);
196
197/* I'm not sure if we can use '-' here */ 140/* I'm not sure if we can use '-' here */
198#define ELF_PLATFORM ("x86_64") 141#define ELF_PLATFORM ("x86_64")
199extern void set_personality_64bit(void); 142extern void set_personality_64bit(void);
@@ -236,18 +179,7 @@ extern int vdso_enabled;
236 179
237struct task_struct; 180struct task_struct;
238 181
239extern int dump_task_regs (struct task_struct *, elf_gregset_t *);
240extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
241
242#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
243#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
244
245#ifdef CONFIG_X86_32 182#ifdef CONFIG_X86_32
246extern int dump_task_extended_fpu (struct task_struct *,
247 struct user_fxsr_struct *);
248#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) \
249 dump_task_extended_fpu(tsk, elf_xfpregs)
250#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
251 183
252#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) 184#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
253 185
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h
index de435b9114df..ba8105ca822b 100644
--- a/include/asm-x86/i387.h
+++ b/include/asm-x86/i387.h
@@ -328,20 +328,6 @@ static inline void clear_fpu(struct task_struct *tsk)
328#endif /* CONFIG_X86_64 */ 328#endif /* CONFIG_X86_64 */
329 329
330/* 330/*
331 * ptrace request handlers...
332 */
333extern int get_fpregs(struct user_i387_struct __user *buf,
334 struct task_struct *tsk);
335extern int set_fpregs(struct task_struct *tsk,
336 struct user_i387_struct __user *buf);
337
338struct user_fxsr_struct;
339extern int get_fpxregs(struct user_fxsr_struct __user *buf,
340 struct task_struct *tsk);
341extern int set_fpxregs(struct task_struct *tsk,
342 struct user_fxsr_struct __user *buf);
343
344/*
345 * i387 state interaction 331 * i387 state interaction
346 */ 332 */
347static inline unsigned short get_fpu_cwd(struct task_struct *tsk) 333static inline unsigned short get_fpu_cwd(struct task_struct *tsk)
diff --git a/include/asm-x86/math_emu.h b/include/asm-x86/math_emu.h
index a4b0aa3320e6..9bf4ae93ab10 100644
--- a/include/asm-x86/math_emu.h
+++ b/include/asm-x86/math_emu.h
@@ -1,11 +1,6 @@
1#ifndef _I386_MATH_EMU_H 1#ifndef _I386_MATH_EMU_H
2#define _I386_MATH_EMU_H 2#define _I386_MATH_EMU_H
3 3
4#include <asm/sigcontext.h>
5
6int restore_i387_soft(void *s387, struct _fpstate __user *buf);
7int save_i387_soft(void *s387, struct _fpstate __user *buf);
8
9/* This structure matches the layout of the data saved to the stack 4/* This structure matches the layout of the data saved to the stack
10 following a device-not-present interrupt, part of it saved 5 following a device-not-present interrupt, part of it saved
11 automatically by the 80386/80486. 6 automatically by the 80386/80486.