From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937016AbdIZIey (ORCPT ); Tue, 26 Sep 2017 04:34:54 -0400 Received: from terminus.zytor.com ([65.50.211.136]:60315 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934122AbdIZIet (ORCPT ); Tue, 26 Sep 2017 04:34:49 -0400 Date: Tue, 26 Sep 2017 01:28:10 -0700 From: tip-bot for Ingo Molnar Message-ID: Cc: mingo@kernel.org, dave.hansen@linux.intel.com, riel@redhat.com, yu-cheng.yu@intel.com, akpm@linux-foundation.org, peterz@infradead.org, luto@kernel.org, torvalds@linux-foundation.org, fenghua.yu@intel.com, ebiggers3@gmail.com, luto@amacapital.net, oleg@redhat.com, tglx@linutronix.de, hpa@zytor.com, bp@alien8.de, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, dave.hansen@linux.intel.com, riel@redhat.com, yu-cheng.yu@intel.com, akpm@linux-foundation.org, peterz@infradead.org, luto@kernel.org, fenghua.yu@intel.com, torvalds@linux-foundation.org, ebiggers3@gmail.com, luto@amacapital.net, oleg@redhat.com, tglx@linutronix.de, hpa@zytor.com, bp@alien8.de, linux-kernel@vger.kernel.org In-Reply-To: <20170923130016.21448-18-mingo@kernel.org> References: <20170923130016.21448-18-mingo@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Split the state handling in fpu__drop() Git-Commit-ID: b6aa85558d7e7b18fc3470d2bc1731d2205dd275 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: b6aa85558d7e7b18fc3470d2bc1731d2205dd275 Gitweb: http://git.kernel.org/tip/b6aa85558d7e7b18fc3470d2bc1731d2205dd275 Author: Ingo Molnar AuthorDate: Sat, 23 Sep 2017 15:00:00 +0200 Committer: Ingo Molnar CommitDate: Sun, 24 Sep 2017 13:04:34 +0200 x86/fpu: Split the state handling in fpu__drop() Prepare fpu__drop() to use fpu->fpregs_active. There are two distinct usecases for fpu__drop() in this context: exit_thread() when called for 'current' in exit(), and when called for another task in fork(). This patch does not change behavior, it only adds a couple of debug checks and structures the code to make the ->fpregs_active change more obviously correct. All the complications will be removed later on. Cc: Andrew Morton Cc: Andy Lutomirski 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-18-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index b7dc383..815dfba 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -414,12 +414,19 @@ void fpu__drop(struct fpu *fpu) { preempt_disable(); - if (fpu->fpregs_active) { - /* Ignore delayed exceptions from user space */ - asm volatile("1: fwait\n" - "2:\n" - _ASM_EXTABLE(1b, 2b)); - fpregs_deactivate(fpu); + if (fpu == ¤t->thread.fpu) { + WARN_ON_FPU(fpu->fpstate_active != fpu->fpregs_active); + + if (fpu->fpregs_active) { + /* Ignore delayed exceptions from user space */ + asm volatile("1: fwait\n" + "2:\n" + _ASM_EXTABLE(1b, 2b)); + if (fpu->fpregs_active) + fpregs_deactivate(fpu); + } + } else { + WARN_ON_FPU(fpu->fpregs_active); } fpu->fpstate_active = 0;