Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753436AbcCLPSB (ORCPT ); Sat, 12 Mar 2016 10:18:01 -0500 Received: from torg.zytor.com ([198.137.202.12]:36030 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750734AbcCLPRy (ORCPT ); Sat, 12 Mar 2016 10:17:54 -0500 Date: Sat, 12 Mar 2016 07:16:25 -0800 From: tip-bot for Borislav Petkov Message-ID: Cc: oleg@redhat.com, fenghua.yu@intel.com, andy.shevchenko@gmail.com, quentin.casasnovas@oracle.com, peterz@infradead.org, brgerst@gmail.com, torvalds@linux-foundation.org, bp@suse.de, tglx@linutronix.de, hpa@zytor.com, akpm@linux-foundation.org, mingo@kernel.org, dvlasenk@redhat.com, luto@amacapital.net, linux-kernel@vger.kernel.org, pure.logic@nexus-software.ie, yu-cheng.yu@intel.com, bp@alien8.de, dave.hansen@linux.intel.com Reply-To: linux-kernel@vger.kernel.org, yu-cheng.yu@intel.com, pure.logic@nexus-software.ie, dave.hansen@linux.intel.com, bp@alien8.de, akpm@linux-foundation.org, hpa@zytor.com, dvlasenk@redhat.com, mingo@kernel.org, luto@amacapital.net, brgerst@gmail.com, tglx@linutronix.de, torvalds@linux-foundation.org, bp@suse.de, fenghua.yu@intel.com, oleg@redhat.com, andy.shevchenko@gmail.com, peterz@infradead.org, quentin.casasnovas@oracle.com In-Reply-To: <20160311113206.GD4312@pd.tnic> References: <20160311113206.GD4312@pd.tnic> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/fpu: Fix eager-FPU handling on legacy FPU machines Git-Commit-ID: 6e6867093de35141f0a76b66ac13f9f2e2c8e77a 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 Content-Length: 3092 Lines: 84 Commit-ID: 6e6867093de35141f0a76b66ac13f9f2e2c8e77a Gitweb: http://git.kernel.org/tip/6e6867093de35141f0a76b66ac13f9f2e2c8e77a Author: Borislav Petkov AuthorDate: Fri, 11 Mar 2016 12:32:06 +0100 Committer: Ingo Molnar CommitDate: Sat, 12 Mar 2016 16:13:55 +0100 x86/fpu: Fix eager-FPU handling on legacy FPU machines i486 derived cores like Intel Quark support only the very old, legacy x87 FPU (FSAVE/FRSTOR, CPUID bit FXSR is not set), and our FPU code wasn't handling the saving and restoring there properly in the 'eagerfpu' case. So after we made eagerfpu the default for all CPU types: 58122bf1d856 x86/fpu: Default eagerfpu=on on all CPUs these old FPU designs broke. First, Andy Shevchenko reported a splat: WARNING: CPU: 0 PID: 823 at arch/x86/include/asm/fpu/internal.h:163 fpu__clear+0x8c/0x160 which was us trying to execute FXRSTOR on those machines even though they don't support it. After taking care of that, Bryan O'Donoghue reported that a simple FPU test still failed because we weren't initializing the FPU state properly on those machines. Take care of all that. Reported-and-tested-by: Bryan O'Donoghue Reported-by: Andy Shevchenko Signed-off-by: Borislav Petkov Acked-by: Linus Torvalds Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Denys Vlasenko Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Quentin Casasnovas Cc: Thomas Gleixner Cc: Yu-cheng Link: http://lkml.kernel.org/r/20160311113206.GD4312@pd.tnic Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/core.c | 4 +++- arch/x86/kernel/fpu/init.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index d25097c..d5804ad 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -409,8 +409,10 @@ static inline void copy_init_fpstate_to_fpregs(void) { if (use_xsave()) copy_kernel_to_xregs(&init_fpstate.xsave, -1); - else + else if (static_cpu_has(X86_FEATURE_FXSR)) copy_kernel_to_fxregs(&init_fpstate.fxsave); + else + copy_kernel_to_fregs(&init_fpstate.fsave); } /* diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c index 9ee7e30..bd08fb7 100644 --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -134,7 +134,7 @@ static void __init fpu__init_system_generic(void) * Set up the legacy init FPU context. (xstate init might overwrite this * with a more modern format, if the CPU supports it.) */ - fpstate_init_fxstate(&init_fpstate.fxsave); + fpstate_init(&init_fpstate); fpu__init_system_mxcsr(); }