fpu__activate_fpstate_read() can only ever be called for a non-current, non-executing (stopped) task - so make sure this is checked via a warning and remove the current-task logic.
This also fixes an incorrect (but harmless) warning introduced by one of the earlier patches. Cc: Andy Lutomirski <l...@amacapital.net> Cc: Borislav Petkov <b...@alien8.de> Cc: Eric Biggers <ebigge...@gmail.com> Cc: Fenghua Yu <fenghua...@intel.com> Cc: H. Peter Anvin <h...@zytor.com> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Oleg Nesterov <o...@redhat.com> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Thomas Gleixner <t...@linutronix.de> Signed-off-by: Ingo Molnar <mi...@kernel.org> --- arch/x86/kernel/fpu/core.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 93103a909c47..7bd4edb76c1d 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -256,26 +256,18 @@ EXPORT_SYMBOL_GPL(fpu__activate_curr); * * If the task has not used the FPU before then initialize its * fpstate. - * - * If the task has used the FPU before then save it. */ void fpu__activate_fpstate_read(struct fpu *fpu) { - /* - * If fpregs are active (in the current CPU), then - * copy them to the fpstate: - */ - if (fpu->fpstate_active) { - fpu__save(fpu); - } else { - if (!fpu->fpstate_active) { - fpstate_init(&fpu->state); - trace_x86_fpu_init_state(fpu); + WARN_ON_FPU(fpu == ¤t->thread.fpu); - trace_x86_fpu_activate_state(fpu); - /* Safe to do for current and for stopped child tasks: */ - fpu->fpstate_active = 1; - } + if (!fpu->fpstate_active) { + fpstate_init(&fpu->state); + trace_x86_fpu_init_state(fpu); + + trace_x86_fpu_activate_state(fpu); + /* Safe to do for current and for stopped child tasks: */ + fpu->fpstate_active = 1; } } -- 2.11.0