Commit 4618e909 authored by Ingo Molnar's avatar Ingo Molnar

x86/fpu: Fix fpu__activate_fpstate_read() and update comments

fpu__activate_fpstate_read() can be called for the current task
when coredumping - or for stopped tasks when ptrace-ing.

Implement this properly in the code and update the comments.

This also fixes an incorrect (but harmless) warning introduced by
one of the earlier patches.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/20170923130016.21448-28-mingo@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent d5c8028b
...@@ -254,18 +254,21 @@ EXPORT_SYMBOL_GPL(fpu__activate_curr); ...@@ -254,18 +254,21 @@ EXPORT_SYMBOL_GPL(fpu__activate_curr);
/* /*
* This function must be called before we read a task's fpstate. * This function must be called before we read a task's fpstate.
* *
* If the task has not used the FPU before then initialize its * There's two cases where this gets called:
* fpstate. *
* - for the current task (when coredumping), in which case we have
* to save the latest FPU registers into the fpstate,
*
* - or it's called for stopped tasks (ptrace), in which case the
* registers were already saved by the context-switch code when
* the task scheduled out - we only have to initialize the registers
* if they've never been initialized.
* *
* If the task has used the FPU before then save it. * If the task has used the FPU before then save it.
*/ */
void fpu__activate_fpstate_read(struct fpu *fpu) void fpu__activate_fpstate_read(struct fpu *fpu)
{ {
/* if (fpu == &current->thread.fpu) {
* If fpregs are active (in the current CPU), then
* copy them to the fpstate:
*/
if (fpu->fpstate_active) {
fpu__save(fpu); fpu__save(fpu);
} else { } else {
if (!fpu->fpstate_active) { if (!fpu->fpstate_active) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment