Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2001409imm; Thu, 14 Jun 2018 07:17:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIEjvyDvgiFcufnYbgdklwY+XgJ8Xy2yHf00kX1dXPGqJi+F4UZJ/w2k/gVsjVVQM/l2iZ9 X-Received: by 2002:a17:902:112b:: with SMTP id d40-v6mr3297196pla.123.1528985823120; Thu, 14 Jun 2018 07:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528985823; cv=none; d=google.com; s=arc-20160816; b=GzYwroH1lXr+BMT3MWdikNTSAbIq8tcE8IYtgF2ihGataVa37MA00zvMYmoo0WLwLD XMJu7jnBs1OvSvFVybOFbOzpGvnQOCYYz77KjdLNa9ZyM6rgGCXk7ItAgB3aeJ8GtUmv KCKf6xknc5RYMtBZkDqQWZic6Jk5BhQvRy22euFHUCDvtAYPG7g7BkkHU6tcNNTOJNbw NuFltVdarw1/KpEuFMWgznRYvbNERVJi2p14C3r9kPBuYFBwzOAUasyuO5JkYqpjxAK3 B+4ZMKqzFyxoRV6uQOBJIjat2FBXGs+4KlFthqKdfYEDEWSiqUEZakXRJt+mzdONBdS5 wweg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=pOYw7aWvySHPXQTPLZktsREDhQAmzbmKw9Z6i3nj2CE=; b=Ech0PmW9Lb8jGqBEuHvPumAYJgJsJSwU5DHstQc5IyhXRQFJfV9Us3zz4HF9zTdcLL AR10QDUndWAfmhnynREoN90aVQErhU9UfE9NGYMEgJWYoSK5uEZ9YDARNYV7Pb6nMQPE ewxMrapyIotRD/GZMN3Sr85fvERd705rio7lSxNFPdjpCBFwa9lHO+Zc6pfG0059Hf5Y E/af3VC2jXKYUFL5umryUqxOEtt/ZvXbklQJjk+1jd20ZjVgqP2WX19XYRnIPLG7cd7V SX/awntXrxhRlHCvpHcrpYK9PxqP+x0TIO9rZzexk9R4p3w+SBg7EYwYojrlBFcKI2LY 7QdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p9/4nOpN"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4-v6si6348876plm.181.2018.06.14.07.16.49; Thu, 14 Jun 2018 07:17:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p9/4nOpN"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965668AbeFNOPk (ORCPT + 99 others); Thu, 14 Jun 2018 10:15:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:55362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965614AbeFNONs (ORCPT ); Thu, 14 Jun 2018 10:13:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AE44208DD; Thu, 14 Jun 2018 14:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528985628; bh=Cs/gu1tPblBOfW3B7HRknhvrWico/fmmclweIH8H/wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p9/4nOpNmsxItpV1j4JZac/9oA6T7DCjHOkDhLjAzy2nnUac8G7+cTyt5CdUAe5Ii kmAQb0shrsu8HoXEwj36/6TxUU1O9zgtGjf10zSD2VPEJtXy0k6Cyk/qCMTrEBjkR2 0jiLR0flKbzECp1gOAS08WeBqGs2k1VKxRDOlU1w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Borislav Petkov , Linus Torvalds , Andrew Morton , Andy Lutomirski , Borislav Petkov , Brian Gerst , Dave Hansen , Denys Vlasenko , Fenghua Yu , "H. Peter Anvin" , Oleg Nesterov , Peter Zijlstra , Quentin Casasnovas , Thomas Gleixner , Yu-cheng , Ingo Molnar Subject: [PATCH 4.4 09/24] x86/fpu: Fix eager-FPU handling on legacy FPU machines Date: Thu, 14 Jun 2018 16:05:04 +0200 Message-Id: <20180614132724.861855858@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180614132724.483802160@linuxfoundation.org> References: <20180614132724.483802160@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit 6e6867093de35141f0a76b66ac13f9f2e2c8e77a upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/fpu/core.c | 4 +++- arch/x86/kernel/fpu/init.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) --- 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_ { 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); } /* --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -135,7 +135,7 @@ static void __init fpu__init_system_gene * 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(); }