From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751707AbbBPVK2 (ORCPT ); Mon, 16 Feb 2015 16:10:28 -0500 Received: from mail.skyhub.de ([78.46.96.112]:58010 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751572AbbBPVK1 (ORCPT ); Mon, 16 Feb 2015 16:10:27 -0500 Date: Mon, 16 Feb 2015 22:09:38 +0100 From: Borislav Petkov To: riel@redhat.com, oleg@redhat.com Cc: dave.hansen@linux.intel.com, sbsiddha@gmail.com, luto@amacapital.net, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/8] x86, fpu: kill save_init_fpu(), change math_error() to use unlazy_fpu() Message-ID: <20150216210938.GN4458@pd.tnic> References: <1423252925-14451-1-git-send-email-riel@redhat.com> <1423252925-14451-4-git-send-email-riel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1423252925-14451-4-git-send-email-riel@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 06, 2015 at 03:02:00PM -0500, riel@redhat.com wrote: > From: Oleg Nesterov > > math_error() calls save_init_fpu() after conditional_sti(), this means > that the caller can be preempted. If !use_eager_fpu() we can hit the > WARN_ON_ONCE(!__thread_has_fpu(tsk)) and/or save the wrong FPU state. > > Change math_error() to use unlazy_fpu() and kill save_init_fpu(). > > Signed-off-by: Oleg Nesterov > Signed-off-by: Rik van Riel > --- > arch/x86/include/asm/fpu-internal.h | 18 ------------------ > arch/x86/kernel/traps.c | 2 +- > 2 files changed, 1 insertion(+), 19 deletions(-) > > diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h > index 0dbc08282291..27d00e04f911 100644 > --- a/arch/x86/include/asm/fpu-internal.h > +++ b/arch/x86/include/asm/fpu-internal.h > @@ -520,24 +520,6 @@ static inline void __save_fpu(struct task_struct *tsk) > } > > /* > - * These disable preemption on their own and are safe > - */ > -static inline void save_init_fpu(struct task_struct *tsk) > -{ > - WARN_ON_ONCE(!__thread_has_fpu(tsk)); > - > - if (use_eager_fpu()) { > - __save_fpu(tsk); > - return; > - } > - > - preempt_disable(); > - __save_init_fpu(tsk); > - __thread_fpu_end(tsk); > - preempt_enable(); > -} > - > -/* > * i387 state interaction > */ > static inline unsigned short get_fpu_cwd(struct task_struct *tsk) > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > index fb4cb6adf225..51c465846f06 100644 > --- a/arch/x86/kernel/traps.c > +++ b/arch/x86/kernel/traps.c > @@ -663,7 +663,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr) > /* > * Save the info for the exception handler and clear the error. > */ > - save_init_fpu(task); > + unlazy_fpu(task); Do I see it correctly that even with this there's a not-so-small hole *after* conditional_sti() and *before* unlazy_fpu() where caller can still get preempted? Thanks. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --