diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-04-30 07:12:46 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-05-19 15:48:05 +0200 |
commit | fbce7782467553d09cfde39473d23bde4ad78270 (patch) | |
tree | 80010c081a5ebf198ebdf0bf2bd8bceb93b03e8f /arch/x86/kernel/fpu | |
parent | 82c0e45eb5c839a8cee3d8d8a82d0592c4f42773 (diff) | |
download | linux-fbce7782467553d09cfde39473d23bde4ad78270.tar.gz linux-fbce7782467553d09cfde39473d23bde4ad78270.tar.bz2 linux-fbce7782467553d09cfde39473d23bde4ad78270.zip |
x86/fpu: Merge fpu__reset() and fpu__clear()
With recent cleanups and fixes the fpu__reset() and fpu__clear()
functions have become almost identical in functionality: the only
difference is that fpu__reset() assumed that the fpstate
was already active in the eagerfpu case, while fpu__clear()
activated it if it was inactive.
This distinction almost never matters, the only case where such
fpstate activation happens if if the init thread (PID 1) gets exec()-ed
for the first time.
So keep fpu__clear() and change all fpu__reset() uses to
fpu__clear() to simpify the logic.
( In a later patch we'll further simplify fpu__clear() by making
sure that all contexts it is called on are already active. )
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel/fpu')
-rw-r--r-- | arch/x86/kernel/fpu/core.c | 21 | ||||
-rw-r--r-- | arch/x86/kernel/fpu/xstate.c | 4 |
2 files changed, 8 insertions, 17 deletions
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 0ccdd8348872..1ba866cce00a 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -116,7 +116,7 @@ void __kernel_fpu_end(void) if (fpu->fpregs_active) { if (WARN_ON(copy_fpstate_to_fpregs(fpu))) - fpu__reset(fpu); + fpu__clear(fpu); } else { __fpregs_deactivate_hw(); } @@ -339,7 +339,7 @@ void fpu__restore(void) kernel_fpu_disable(); fpregs_activate(fpu); if (unlikely(copy_fpstate_to_fpregs(fpu))) { - fpu__reset(fpu); + fpu__clear(fpu); force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk); } else { tsk->thread.fpu.counter++; @@ -376,19 +376,10 @@ void fpu__drop(struct fpu *fpu) } /* - * Reset the FPU state back to init state: - */ -void fpu__reset(struct fpu *fpu) -{ - if (!use_eager_fpu()) - fpu__drop(fpu); - else - restore_init_xstate(); -} - -/* - * Called by sys_execve() to clear the FPU fpregs, so that FPU state - * of the previous binary does not leak over into the exec()ed binary: + * Clear the FPU state back to init state. + * + * Called by sys_execve(), by the signal handler code and by various + * error paths. */ void fpu__clear(struct fpu *fpu) { diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 810f080fadf3..9bc3734acc16 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -401,7 +401,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) config_enabled(CONFIG_IA32_EMULATION)); if (!buf) { - fpu__reset(fpu); + fpu__clear(fpu); return 0; } @@ -474,7 +474,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) */ user_fpu_begin(); if (restore_user_xstate(buf_fx, xfeatures, fx_only)) { - fpu__reset(fpu); + fpu__clear(fpu); return -1; } } |