From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757920AbcBIQL3 (ORCPT ); Tue, 9 Feb 2016 11:11:29 -0500 Received: from terminus.zytor.com ([198.137.202.10]:38525 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757740AbcBIQL0 (ORCPT ); Tue, 9 Feb 2016 11:11:26 -0500 Date: Tue, 9 Feb 2016 08:10:14 -0800 From: tip-bot for Andy Lutomirski Message-ID: Cc: mingo@kernel.org, peterz@infradead.org, sai.praneeth.prakhya@intel.com, fenghua.yu@intel.com, bp@alien8.de, yu-cheng.yu@intel.com, luto@kernel.org, riel@redhat.com, linux-kernel@vger.kernel.org, luto@amacapital.net, dave.hansen@linux.intel.com, hpa@zytor.com, quentin.casasnovas@oracle.com, torvalds@linux-foundation.org, oleg@redhat.com, tglx@linutronix.de Reply-To: luto@amacapital.net, hpa@zytor.com, dave.hansen@linux.intel.com, oleg@redhat.com, torvalds@linux-foundation.org, quentin.casasnovas@oracle.com, tglx@linutronix.de, sai.praneeth.prakhya@intel.com, fenghua.yu@intel.com, peterz@infradead.org, mingo@kernel.org, luto@kernel.org, yu-cheng.yu@intel.com, bp@alien8.de, riel@redhat.com, linux-kernel@vger.kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Fix math emulation in eager fpu mode Git-Commit-ID: 4ecd16ec7059390b430af34bd8bc3ca2b5dcef9a 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: 4ecd16ec7059390b430af34bd8bc3ca2b5dcef9a Gitweb: http://git.kernel.org/tip/4ecd16ec7059390b430af34bd8bc3ca2b5dcef9a Author: Andy Lutomirski AuthorDate: Sun, 24 Jan 2016 14:38:06 -0800 Committer: Ingo Molnar CommitDate: Tue, 9 Feb 2016 15:42:55 +0100 x86/fpu: Fix math emulation in eager fpu mode 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 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Quentin Casasnovas Cc: Rik van Riel Cc: Sai Praneeth Prakhya Cc: Thomas Gleixner Cc: yu-cheng yu Link: http://lkml.kernel.org/r/b4b8d112436bd6fab866e1b4011131507e8d7fbe.1453675014.git.luto@kernel.org Signed-off-by: Ingo Molnar --- 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 0fd440d..a1f78a9 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); if (old_fpu->fpregs_active) { diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index d25097c..08e1e11 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -423,7 +423,7 @@ void fpu__clear(struct fpu *fpu) { WARN_ON_FPU(fpu != ¤t->thread.fpu); /* Almost certainly an anomaly */ - if (!use_eager_fpu()) { + if (!use_eager_fpu() || !static_cpu_has(X86_FEATURE_FPU)) { /* FPU state will be reallocated lazily at the first use. */ fpu__drop(fpu); } else { diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index ade185a..87f80fe 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -750,7 +750,6 @@ dotraplinkage void do_device_not_available(struct pt_regs *regs, long error_code) { RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU"); - BUG_ON(use_eager_fpu()); #ifdef CONFIG_MATH_EMULATION if (read_cr0() & X86_CR0_EM) {