diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2009-04-08 07:31:58 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-08 07:46:00 -0400 |
commit | fcb2ac5bdfa3a7a04fb9749b916f64400f4c35a8 (patch) | |
tree | c251c870e6f01dafea5e370898e74968b3cda8c4 /arch | |
parent | 577c9c456f0e1371cbade38eaf91ae8e8a308555 (diff) |
x86_32: introduce restore_fpu_checking()
Impact: cleanup, prepare FPU code unificaton
Like on x86_64, return an error from restore_fpu and kill the task
if it fails.
Also rename restore_fpu to restore_fpu_checking which allows ifdefs
to be removed in math_state_restore().
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
LKML-Reference: <1239190320-23952-1-git-send-email-jirislaby@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/i387.h | 9 | ||||
-rw-r--r-- | arch/x86/kernel/traps.c | 5 |
2 files changed, 5 insertions, 9 deletions
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h index 71c9e5183982..09a2d6dfd85b 100644 --- a/arch/x86/include/asm/i387.h +++ b/arch/x86/include/asm/i387.h | |||
@@ -185,12 +185,10 @@ static inline void tolerant_fwait(void) | |||
185 | asm volatile("fnclex ; fwait"); | 185 | asm volatile("fnclex ; fwait"); |
186 | } | 186 | } |
187 | 187 | ||
188 | static inline void restore_fpu(struct task_struct *tsk) | 188 | static inline int restore_fpu_checking(struct task_struct *tsk) |
189 | { | 189 | { |
190 | if (task_thread_info(tsk)->status & TS_XSAVE) { | 190 | if (task_thread_info(tsk)->status & TS_XSAVE) |
191 | xrstor_checking(&tsk->thread.xstate->xsave); | 191 | return xrstor_checking(&tsk->thread.xstate->xsave); |
192 | return; | ||
193 | } | ||
194 | /* | 192 | /* |
195 | * The "nop" is needed to make the instructions the same | 193 | * The "nop" is needed to make the instructions the same |
196 | * length. | 194 | * length. |
@@ -200,6 +198,7 @@ static inline void restore_fpu(struct task_struct *tsk) | |||
200 | "fxrstor %1", | 198 | "fxrstor %1", |
201 | X86_FEATURE_FXSR, | 199 | X86_FEATURE_FXSR, |
202 | "m" (tsk->thread.xstate->fxsave)); | 200 | "m" (tsk->thread.xstate->fxsave)); |
201 | return 0; | ||
203 | } | 202 | } |
204 | 203 | ||
205 | /* We need a safe address that is cheap to find and that is already | 204 | /* We need a safe address that is cheap to find and that is already |
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index a1d288327ff0..d696145855b5 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c | |||
@@ -839,9 +839,6 @@ asmlinkage void math_state_restore(void) | |||
839 | } | 839 | } |
840 | 840 | ||
841 | clts(); /* Allow maths ops (or we recurse) */ | 841 | clts(); /* Allow maths ops (or we recurse) */ |
842 | #ifdef CONFIG_X86_32 | ||
843 | restore_fpu(tsk); | ||
844 | #else | ||
845 | /* | 842 | /* |
846 | * Paranoid restore. send a SIGSEGV if we fail to restore the state. | 843 | * Paranoid restore. send a SIGSEGV if we fail to restore the state. |
847 | */ | 844 | */ |
@@ -850,7 +847,7 @@ asmlinkage void math_state_restore(void) | |||
850 | force_sig(SIGSEGV, tsk); | 847 | force_sig(SIGSEGV, tsk); |
851 | return; | 848 | return; |
852 | } | 849 | } |
853 | #endif | 850 | |
854 | thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */ | 851 | thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */ |
855 | tsk->fpu_counter++; | 852 | tsk->fpu_counter++; |
856 | } | 853 | } |