aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2015-03-16 05:21:55 -0400
committerIngo Molnar <mingo@kernel.org>2015-03-23 05:13:59 -0400
commitb85e67d1483c72b77d1bdc265aa8ba91590794c1 (patch)
treed79460926c6fd09bc35d9d3428fa24cc12fa95ea
parentd2d0ac9a4644e00120bb9b7427a512a99d2cacc5 (diff)
x86/fpu: Rename drop_init_fpu() to fpu_reset_state()
Call it what it does and in accordance with the context where it is used: we reset the FPU state either because we were unable to restore it from the one saved in the task or because we simply want to reset it. Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Oleg Nesterov <oleg@redhat.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/fpu-internal.h8
-rw-r--r--arch/x86/kernel/i387.c2
-rw-r--r--arch/x86/kernel/signal.c2
-rw-r--r--arch/x86/kernel/traps.c2
-rw-r--r--arch/x86/kernel/xsave.c4
5 files changed, 11 insertions, 7 deletions
diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index 2d4adff428ac..da5e96756570 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -406,7 +406,11 @@ static inline void restore_init_xstate(void)
406 fxrstor_checking(&init_xstate_buf->i387); 406 fxrstor_checking(&init_xstate_buf->i387);
407} 407}
408 408
409static inline void drop_init_fpu(struct task_struct *tsk) 409/*
410 * Reset the FPU state in the eager case and drop it in the lazy case (later use
411 * will reinit it).
412 */
413static inline void fpu_reset_state(struct task_struct *tsk)
410{ 414{
411 if (!use_eager_fpu()) 415 if (!use_eager_fpu())
412 drop_fpu(tsk); 416 drop_fpu(tsk);
@@ -480,7 +484,7 @@ static inline void switch_fpu_finish(struct task_struct *new, fpu_switch_t fpu)
480{ 484{
481 if (fpu.preload) { 485 if (fpu.preload) {
482 if (unlikely(restore_fpu_checking(new))) 486 if (unlikely(restore_fpu_checking(new)))
483 drop_init_fpu(new); 487 fpu_reset_state(new);
484 } 488 }
485} 489}
486 490
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 29e982ada854..41575b9b1021 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -108,7 +108,7 @@ void __kernel_fpu_end(void)
108 108
109 if (__thread_has_fpu(me)) { 109 if (__thread_has_fpu(me)) {
110 if (WARN_ON(restore_fpu_checking(me))) 110 if (WARN_ON(restore_fpu_checking(me)))
111 drop_init_fpu(me); 111 fpu_reset_state(me);
112 } else if (!use_eager_fpu()) { 112 } else if (!use_eager_fpu()) {
113 stts(); 113 stts();
114 } 114 }
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index e5042463c1bc..59eaae6185e2 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -679,7 +679,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
679 * Ensure the signal handler starts with the new fpu state. 679 * Ensure the signal handler starts with the new fpu state.
680 */ 680 */
681 if (used_math()) 681 if (used_math())
682 drop_init_fpu(current); 682 fpu_reset_state(current);
683 } 683 }
684 signal_setup_done(failed, ksig, test_thread_flag(TIF_SINGLESTEP)); 684 signal_setup_done(failed, ksig, test_thread_flag(TIF_SINGLESTEP));
685} 685}
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 7ee7369d5aec..edf66c066da9 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -863,7 +863,7 @@ void math_state_restore(void)
863 kernel_fpu_disable(); 863 kernel_fpu_disable();
864 __thread_fpu_begin(tsk); 864 __thread_fpu_begin(tsk);
865 if (unlikely(restore_fpu_checking(tsk))) { 865 if (unlikely(restore_fpu_checking(tsk))) {
866 drop_init_fpu(tsk); 866 fpu_reset_state(tsk);
867 force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk); 867 force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk);
868 } else { 868 } else {
869 tsk->thread.fpu_counter++; 869 tsk->thread.fpu_counter++;
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index 0bf82c5ac529..65c29b070e09 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -342,7 +342,7 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
342 config_enabled(CONFIG_IA32_EMULATION)); 342 config_enabled(CONFIG_IA32_EMULATION));
343 343
344 if (!buf) { 344 if (!buf) {
345 drop_init_fpu(tsk); 345 fpu_reset_state(tsk);
346 return 0; 346 return 0;
347 } 347 }
348 348
@@ -416,7 +416,7 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
416 */ 416 */
417 user_fpu_begin(); 417 user_fpu_begin();
418 if (restore_user_xstate(buf_fx, xstate_bv, fx_only)) { 418 if (restore_user_xstate(buf_fx, xstate_bv, fx_only)) {
419 drop_init_fpu(tsk); 419 fpu_reset_state(tsk);
420 return -1; 420 return -1;
421 } 421 }
422 } 422 }