From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756207AbbCCL2W (ORCPT ); Tue, 3 Mar 2015 06:28:22 -0500 Received: from terminus.zytor.com ([198.137.202.10]:51690 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754021AbbCCL2T (ORCPT ); Tue, 3 Mar 2015 06:28:19 -0500 Date: Tue, 3 Mar 2015 03:27:42 -0800 From: tip-bot for Oleg Nesterov Message-ID: Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, bp@suse.de, luto@amacapital.net, priikone@iki.fi, riel@redhat.com, sbsiddha@gmail.com, oleg@redhat.com, hpa@zytor.com Reply-To: tglx@linutronix.de, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, riel@redhat.com, hpa@zytor.com, sbsiddha@gmail.com, oleg@redhat.com, priikone@iki.fi, luto@amacapital.net, bp@suse.de, mingo@kernel.org In-Reply-To: <20150119185132.GB16427@redhat.com> References: <20150119185132.GB16427@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: __kernel_fpu_begin() should clear fpu_owner_task even if use_eager_fpu() Git-Commit-ID: 7aeccb83e76316b365e4b44a1dd982ee22a7d8b2 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: 7aeccb83e76316b365e4b44a1dd982ee22a7d8b2 Gitweb: http://git.kernel.org/tip/7aeccb83e76316b365e4b44a1dd982ee22a7d8b2 Author: Oleg Nesterov AuthorDate: Mon, 19 Jan 2015 19:51:32 +0100 Committer: Borislav Petkov CommitDate: Mon, 23 Feb 2015 15:50:28 +0100 x86/fpu: __kernel_fpu_begin() should clear fpu_owner_task even if use_eager_fpu() __kernel_fpu_begin() does nothing if !__thread_has_fpu() && use_eager_fpu(), perhaps it assumes that this case is simply impossible. This is certainly not possible if in_interrupt() == T; interrupted_user_mode() should have FPU, and interrupted_kernel_fpu_idle() should fail if !__thread_has_fpu(). However, even if use_eager_fpu() == T a task can do drop_fpu(), then switch to another thread which becomes fpu_owner_task, then resume and call some function which does kernel_fpu_begin(). Say, an exiting task does a lot of things after exit_thread(), it is not safe to assume that it can't use FPU in these paths. Signed-off-by: Oleg Nesterov Reviewed-by: Rik van Riel Cc: Linus Torvalds Cc: Suresh Siddha Cc: Andy Lutomirski Cc: Pekka Riikonen Link: http://lkml.kernel.org/r/20150119185132.GB16427@redhat.com Signed-off-by: Borislav Petkov --- arch/x86/kernel/i387.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c index f59d806..ad3a2a2 100644 --- a/arch/x86/kernel/i387.c +++ b/arch/x86/kernel/i387.c @@ -93,9 +93,10 @@ void __kernel_fpu_begin(void) if (__thread_has_fpu(me)) { __save_init_fpu(me); - } else if (!use_eager_fpu()) { + } else { this_cpu_write(fpu_owner_task, NULL); - clts(); + if (!use_eager_fpu()) + clts(); } } EXPORT_SYMBOL(__kernel_fpu_begin);