From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752586AbcAWKD3 (ORCPT ); Sat, 23 Jan 2016 05:03:29 -0500 Received: from mail.skyhub.de ([78.46.96.112]:42541 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbcAWKDZ (ORCPT ); Sat, 23 Jan 2016 05:03:25 -0500 Date: Sat, 23 Jan 2016 11:02:54 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Fenghua Yu , Oleg Nesterov , Peter Zijlstra , Sai Praneeth Prakhya , yu-cheng yu , Dave Hansen , Rik van Riel , Linus Torvalds Subject: Re: [PATCH 1/5] x86/fpu: Fix math emulation in eager fpu mode Message-ID: <20160123100253.GA16329@pd.tnic> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 22, 2016 at 04:56:02PM -0800, Andy Lutomirski wrote: > Systems without an FPU are generally old and therefore use lazy FPU > switching. Unsurprisingly, math emulation in eager FPU mode is a > bit buggy. Fix it. > > There were two bugs involving kernel code trying to use the FPU > registers in eager mode even if they didn't exist and one BUG_ON > that was incorrect. > > Signed-off-by: Andy Lutomirski > --- > arch/x86/include/asm/fpu/internal.h | 3 ++- > arch/x86/kernel/fpu/core.c | 2 +- > arch/x86/kernel/traps.c | 1 - > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h > index 0fd440df63f1..a1f78a9fbf41 100644 > --- a/arch/x86/include/asm/fpu/internal.h > +++ b/arch/x86/include/asm/fpu/internal.h > @@ -589,7 +589,8 @@ switch_fpu_prepare(struct fpu *old_fpu, struct fpu *new_fpu, int cpu) > * If the task has used the math, pre-load the FPU on xsave processors > * or if the past 5 consecutive context-switches used math. > */ > - fpu.preload = new_fpu->fpstate_active && > + fpu.preload = static_cpu_has(X86_FEATURE_FPU) && > + new_fpu->fpstate_active && > (use_eager_fpu() || new_fpu->counter > 5); Should we move that static_cpu_has(X86_FEATURE_FPU) check in use_eager_fpu()? I mean, when !X86_FEATURE_FPU, then we most certainly aren't doing eager FPU anyway. Looking at the call sites briefly says we should be covered but I might be missing out some detail. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.