From: Ingo Molnar <mingo@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Andy Lutomirski <luto@amacapital.net>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Fenghua Yu <fenghua.yu@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 008/208] x86/fpu: Rename init_fpu() to fpu__unlazy_stopped() and add debugging check
Date: Tue, 5 May 2015 18:23:48 +0200 [thread overview]
Message-ID: <1430843228-13749-9-git-send-email-mingo@kernel.org> (raw)
In-Reply-To: <1430843228-13749-1-git-send-email-mingo@kernel.org>
This function name is a misnomer now that we've split out all the
other users from it. Rename it accordingly: it's used to save
the FPU state of (ptrace-)stopped child tasks.
Add debugging check to double check this intended usage: that this
function is only called for non-current, stopped child tasks.
Reviewed-by: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
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: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/i387.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 95079026c386..909d10d2fb70 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -283,27 +283,30 @@ EXPORT_SYMBOL_GPL(fpstate_alloc_init);
* value at reset if we support XMM instructions and then
* remember the current task has used the FPU.
*/
-static int init_fpu(struct task_struct *tsk)
+static int fpu__unlazy_stopped(struct task_struct *child)
{
int ret;
- if (tsk_used_math(tsk)) {
- if (cpu_has_fpu && tsk == current)
- fpu__save(tsk);
- task_disable_lazy_fpu_restore(tsk);
+ if (WARN_ON_ONCE(child == current))
+ return -EINVAL;
+
+ if (tsk_used_math(child)) {
+ if (cpu_has_fpu && child == current)
+ fpu__save(child);
+ task_disable_lazy_fpu_restore(child);
return 0;
}
/*
* Memory allocation at the first usage of the FPU and other state.
*/
- ret = fpu_alloc(&tsk->thread.fpu);
+ ret = fpu_alloc(&child->thread.fpu);
if (ret)
return ret;
- fpu_finit(&tsk->thread.fpu);
+ fpu_finit(&child->thread.fpu);
- set_stopped_child_used_math(tsk);
+ set_stopped_child_used_math(child);
return 0;
}
@@ -331,7 +334,7 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,
if (!cpu_has_fxsr)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
@@ -350,7 +353,7 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
if (!cpu_has_fxsr)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
@@ -384,7 +387,7 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
if (!cpu_has_xsave)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
@@ -414,7 +417,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
if (!cpu_has_xsave)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
@@ -577,7 +580,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,
struct user_i387_ia32_struct env;
int ret;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
@@ -608,7 +611,7 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,
struct user_i387_ia32_struct env;
int ret;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
--
2.1.0
next prev parent reply other threads:[~2015-05-05 17:07 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 16:23 [PATCH 000/208] big x86 FPU code rewrite Ingo Molnar
2015-05-05 16:23 ` [PATCH 001/208] x86/fpu: Rename unlazy_fpu() to fpu__save() Ingo Molnar
2015-05-05 16:23 ` [PATCH 002/208] x86/fpu: Add comments to fpu__save() and restrict its export Ingo Molnar
2015-05-05 16:23 ` [PATCH 003/208] x86/fpu: Add debugging check to fpu__save() Ingo Molnar
2015-05-05 16:23 ` [PATCH 004/208] x86/fpu: Rename fpu_detect() to fpu__detect() Ingo Molnar
2015-05-05 16:23 ` [PATCH 005/208] x86/fpu: Remove stale init_fpu() prototype Ingo Molnar
2015-05-05 16:23 ` [PATCH 006/208] x86/fpu: Split an fpstate_alloc_init() function out of init_fpu() Ingo Molnar
2015-05-05 16:23 ` [PATCH 007/208] x86/fpu: Make init_fpu() static Ingo Molnar
2015-05-05 16:23 ` Ingo Molnar [this message]
2015-05-05 16:23 ` [PATCH 009/208] x86/fpu: Optimize fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:23 ` [PATCH 010/208] x86/fpu: Simplify fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:23 ` [PATCH 011/208] x86/fpu: Remove fpu_allocated() Ingo Molnar
2015-05-05 16:23 ` [PATCH 012/208] x86/fpu: Move fpu_alloc() out of line Ingo Molnar
2015-05-05 16:23 ` [PATCH 013/208] x86/fpu: Rename fpu_alloc() to fpstate_alloc() Ingo Molnar
2015-05-05 16:23 ` [PATCH 014/208] x86/fpu: Rename fpu_free() to fpstate_free() Ingo Molnar
2015-05-05 16:23 ` [PATCH 015/208] x86/fpu: Rename fpu_finit() to fpstate_init() Ingo Molnar
2015-05-05 16:23 ` [PATCH 016/208] x86/fpu: Rename fpu_init() to fpu__cpu_init() Ingo Molnar
2015-05-05 16:23 ` [PATCH 017/208] x86/fpu: Rename init_thread_xstate() to fpstate_xstate_init_size() Ingo Molnar
2015-05-05 16:23 ` [PATCH 018/208] x86/fpu: Move thread_info::fpu_counter into thread_info::fpu.counter Ingo Molnar
2015-05-05 16:23 ` [PATCH 019/208] x86/fpu: Improve the comment for the fpu::counter field Ingo Molnar
2015-05-05 16:24 ` [PATCH 020/208] x86/fpu: Move FPU data structures to asm/fpu_types.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 021/208] x86/fpu: Clean up asm/fpu/types.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 022/208] x86/fpu: Move i387.c and xsave.c to arch/x86/kernel/fpu/ Ingo Molnar
2015-05-05 16:24 ` [PATCH 023/208] x86/fpu: Fix header file dependencies of fpu-internal.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 024/208] x86/fpu: Split out the boot time FPU init code into fpu/init.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 025/208] x86/fpu: Remove unnecessary includes from core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 026/208] x86/fpu: Move the no_387 handling and FPU detection code into init.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 027/208] x86/fpu: Remove the free_thread_xstate() complication Ingo Molnar
2015-05-05 16:24 ` [PATCH 028/208] x86/fpu: Factor out fpu__flush_thread() from flush_thread() Ingo Molnar
2015-05-05 16:24 ` [PATCH 029/208] x86/fpu: Move math_state_restore() to fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 030/208] x86/fpu: Rename math_state_restore() to fpu__restore() Ingo Molnar
2015-05-05 16:24 ` [PATCH 031/208] x86/fpu: Factor out the FPU bug detection code into fpu__init_check_bugs() Ingo Molnar
2015-05-05 16:24 ` [PATCH 032/208] x86/fpu: Simplify the xsave_state*() methods Ingo Molnar
2015-05-05 16:24 ` [PATCH 033/208] x86/fpu: Remove fpu_xsave() Ingo Molnar
2015-05-05 16:24 ` [PATCH 034/208] x86/fpu: Move task_xstate_cachep handling to core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 035/208] x86/fpu: Factor out fpu__copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 036/208] x86/fpu: Uninline fpstate_free() and move it next to the allocation function Ingo Molnar
2015-05-05 16:24 ` [PATCH 037/208] x86/fpu: Make task_xstate_cachep static Ingo Molnar
2015-05-05 16:24 ` [PATCH 038/208] x86/fpu: Make kernel_fpu_disable/enable() static Ingo Molnar
2015-05-05 16:24 ` [PATCH 039/208] x86/fpu: Add debug check to kernel_fpu_disable() Ingo Molnar
2015-05-05 16:24 ` [PATCH 040/208] x86/fpu: Add kernel_fpu_disabled() Ingo Molnar
2015-05-05 16:24 ` [PATCH 041/208] x86/fpu: Remove __save_init_fpu() Ingo Molnar
2015-05-05 16:24 ` [PATCH 042/208] x86/fpu: Move fpu_copy() to fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 043/208] x86/fpu: Add debugging check to fpu_copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 044/208] x86/fpu: Print out whether we are doing lazy/eager FPU context switches Ingo Molnar
2015-05-05 16:24 ` [PATCH 045/208] x86/fpu: Eliminate the __thread_has_fpu() wrapper Ingo Molnar
2015-05-05 16:24 ` [PATCH 046/208] x86/fpu: Change __thread_clear_has_fpu() to 'struct fpu' parameter Ingo Molnar
2015-05-05 16:24 ` [PATCH 047/208] x86/fpu: Move 'PER_CPU(fpu_owner_task)' to fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 048/208] x86/fpu: Change fpu_owner_task to fpu_fpregs_owner_ctx Ingo Molnar
2015-05-05 16:24 ` [PATCH 049/208] x86/fpu: Remove 'struct task_struct' usage from __thread_set_has_fpu() Ingo Molnar
2015-05-05 16:24 ` [PATCH 050/208] x86/fpu: Remove 'struct task_struct' usage from __thread_fpu_end() Ingo Molnar
2015-05-05 16:24 ` [PATCH 051/208] x86/fpu: Remove 'struct task_struct' usage from __thread_fpu_begin() Ingo Molnar
2015-05-05 16:24 ` [PATCH 052/208] x86/fpu: Open code PF_USED_MATH usages Ingo Molnar
2015-05-05 16:24 ` [PATCH 053/208] x86/fpu: Document fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:24 ` [PATCH 054/208] x86/fpu: Get rid of PF_USED_MATH usage, convert it to fpu->fpstate_active Ingo Molnar
2015-05-06 0:51 ` Andy Lutomirski
2015-05-06 3:24 ` Ingo Molnar
2015-05-05 16:24 ` [PATCH 055/208] x86/fpu: Remove 'struct task_struct' usage from drop_fpu() Ingo Molnar
2015-05-05 16:24 ` [PATCH 056/208] x86/fpu: Remove task_disable_lazy_fpu_restore() Ingo Molnar
2015-05-05 16:24 ` [PATCH 057/208] x86/fpu: Use 'struct fpu' in fpu_lazy_restore() Ingo Molnar
2015-05-05 16:24 ` [PATCH 058/208] x86/fpu: Use 'struct fpu' in restore_fpu_checking() Ingo Molnar
2015-05-05 16:24 ` [PATCH 059/208] x86/fpu: Use 'struct fpu' in fpu_reset_state() Ingo Molnar
2015-05-05 16:24 ` [PATCH 060/208] x86/fpu: Use 'struct fpu' in switch_fpu_prepare() Ingo Molnar
2015-05-05 16:24 ` [PATCH 061/208] x86/fpu: Use 'struct fpu' in switch_fpu_finish() Ingo Molnar
2015-05-05 16:24 ` [PATCH 062/208] x86/fpu: Move __save_fpu() into fpu/core.c Ingo Molnar
2015-05-05 16:24 ` [PATCH 063/208] x86/fpu: Use 'struct fpu' in __fpu_save() Ingo Molnar
2015-05-05 16:24 ` [PATCH 064/208] x86/fpu: Use 'struct fpu' in fpu__save() Ingo Molnar
2015-05-05 16:24 ` [PATCH 065/208] x86/fpu: Use 'struct fpu' in fpu_copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 066/208] x86/fpu: Use 'struct fpu' in fpu__copy() Ingo Molnar
2015-05-05 16:24 ` [PATCH 067/208] x86/fpu: Use 'struct fpu' in fpstate_alloc_init() Ingo Molnar
2015-05-05 16:24 ` [PATCH 068/208] x86/fpu: Use 'struct fpu' in fpu__unlazy_stopped() Ingo Molnar
2015-05-05 16:24 ` [PATCH 069/208] x86/fpu: Rename fpu__flush_thread() to fpu__clear() Ingo Molnar
2015-05-05 16:24 ` [PATCH 070/208] x86/fpu: Clean up fpu__clear() a bit Ingo Molnar
2015-05-05 16:24 ` [PATCH 071/208] x86/fpu: Rename i387.h to fpu/api.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 072/208] x86/fpu: Move xsave.h to fpu/xsave.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 073/208] x86/fpu: Rename fpu-internal.h to fpu/internal.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 074/208] x86/fpu: Move MXCSR_DEFAULT " Ingo Molnar
2015-05-05 16:24 ` [PATCH 075/208] x86/fpu: Remove xsave_init() __init obfuscation Ingo Molnar
2015-05-05 16:24 ` [PATCH 076/208] x86/fpu: Remove assembly guard from asm/fpu/api.h Ingo Molnar
2015-05-05 16:24 ` [PATCH 077/208] x86/fpu: Improve FPU detection kernel messages Ingo Molnar
2015-05-05 16:24 ` [PATCH 078/208] x86/fpu: Print supported xstate features in human readable way Ingo Molnar
2015-05-05 16:24 ` [PATCH 079/208] x86/fpu: Rename 'pcntxt_mask' to 'xfeatures_mask' Ingo Molnar
2015-05-05 17:14 ` [PATCH 000/208] big x86 FPU code rewrite Linus Torvalds
2015-05-05 17:50 ` Ingo Molnar
2015-07-17 23:52 ` Andy Lutomirski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430843228-13749-9-git-send-email-mingo@kernel.org \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox