From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968210AbdIZIiT (ORCPT ); Tue, 26 Sep 2017 04:38:19 -0400 Received: from terminus.zytor.com ([65.50.211.136]:41591 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934942AbdIZIiR (ORCPT ); Tue, 26 Sep 2017 04:38:17 -0400 Date: Tue, 26 Sep 2017 01:31:43 -0700 From: tip-bot for Ingo Molnar Message-ID: Cc: fenghua.yu@intel.com, ebiggers3@gmail.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@linux.intel.com, peterz@infradead.org, yu-cheng.yu@intel.com, mingo@kernel.org, hpa@zytor.com, riel@redhat.com, oleg@redhat.com, luto@amacapital.net, bp@alien8.de, torvalds@linux-foundation.org, tglx@linutronix.de Reply-To: bp@alien8.de, torvalds@linux-foundation.org, tglx@linutronix.de, yu-cheng.yu@intel.com, mingo@kernel.org, oleg@redhat.com, hpa@zytor.com, riel@redhat.com, luto@amacapital.net, akpm@linux-foundation.org, dave.hansen@linux.intel.com, peterz@infradead.org, fenghua.yu@intel.com, ebiggers3@gmail.com, linux-kernel@vger.kernel.org In-Reply-To: <20170923130016.21448-28-mingo@kernel.org> References: <20170923130016.21448-28-mingo@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Fix fpu__activate_fpstate_read() and update comments Git-Commit-ID: 4618e90965f272fe522f2af2523a60d0d4bc78f3 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4618e90965f272fe522f2af2523a60d0d4bc78f3 Gitweb: http://git.kernel.org/tip/4618e90965f272fe522f2af2523a60d0d4bc78f3 Author: Ingo Molnar AuthorDate: Sat, 23 Sep 2017 15:00:10 +0200 Committer: Ingo Molnar CommitDate: Tue, 26 Sep 2017 09:41:09 +0200 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 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Eric Biggers Cc: Fenghua Yu Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Cc: Yu-cheng Yu Link: http://lkml.kernel.org/r/20170923130016.21448-28-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 93103a9..afd3f2a 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -254,18 +254,21 @@ EXPORT_SYMBOL_GPL(fpu__activate_curr); /* * This function must be called before we read a task's fpstate. * - * If the task has not used the FPU before then initialize its - * fpstate. + * There's two cases where this gets called: + * + * - 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. */ 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) { + if (fpu == ¤t->thread.fpu) { fpu__save(fpu); } else { if (!fpu->fpstate_active) {