From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752206AbdIWNBR (ORCPT ); Sat, 23 Sep 2017 09:01:17 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:37645 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbdIWNBK (ORCPT ); Sat, 23 Sep 2017 09:01:10 -0400 X-Google-Smtp-Source: AOwi7QBkCPrEO0ikLuueKEfRl34mfukNL/G9bRrEtgbub0ILuaaF8v3H6dXHYuBkylmvZmEHT++18g== From: Ingo Molnar To: linux-kernel@vger.kernel.org Cc: Andrew Morton , Eric Biggers , Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , "H . Peter Anvin" , Linus Torvalds , Oleg Nesterov , Peter Zijlstra , Rik van Riel , Thomas Gleixner , Yu-cheng Yu Subject: [PATCH 27/33] x86/fpu: Simplify fpu__activate_fpstate_read() Date: Sat, 23 Sep 2017 15:00:10 +0200 Message-Id: <20170923130016.21448-28-mingo@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170923130016.21448-1-mingo@kernel.org> References: <20170923130016.21448-1-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Borislav Petkov Cc: Eric Biggers Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Signed-off-by: Ingo Molnar --- 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