Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2001267imm; Thu, 14 Jun 2018 07:16:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJYXpgAhU23LzWjeUbVJFlBcpmmP5OOWMAU/oFML/OdRNp+7OTu8Z/hPu2cgd87tIkiuRUb X-Received: by 2002:a63:b609:: with SMTP id j9-v6mr2496550pgf.335.1528985815964; Thu, 14 Jun 2018 07:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528985815; cv=none; d=google.com; s=arc-20160816; b=ZwmdRT1OQhp0QzqE5eYJq1IakVCo7WBnUW8OYNERDQ2SSatNCa89GA36XfN9JjHWRz rIZP3onSlFTB0Pk3ujefVyoreLVp1E4nVXHPpB1aQWnaQNf2VzksC2NWZ9pAgUBNlonD B1fh2ctxN4HI4FOsmpL/nawT76lY2cBDdupChXkl7RSGLSeqc+oNBGWxzLbHE1loc3Fv ONK9bzMU6QD8FpOjSuKmB7IADl2haQV4VAmzqBKLZqSkywVM0J05Gvt7yPn8hGY8869O brr0JiVX11qSRNP6QQwpKLOLzfPnlOAGA9iKEk38UFT1pBhJpyhNm1Ps1jTX7pfyNjmN Ghiw== 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=2t0lbZfIUOjrPdWdL3xG0ng9dnHfd8ShF/OiZMKVFtU=; b=Q62i8Pcf0dyhv3PH99+KxE0vSX1/S6r25kkFe4IvBgoubG8RScj3Tg0oIbUcJMIeeP oV9XzIXMaRTO1/fOA56r+Z2OwA0XBpu1nF9rSW1GHVrRvEgdxCxTck5wqhZAarOVdiuh H58MsKPioPTPr33Rlq5QGhya/kY9JgmBhYge+u1XHt969g2Il313x6lP9bqS6GB+kKkS hqv7P2E3Md7TK06WqFfB/PSONSHvqD3ItBM7FEazvBAB5YiSNJzLFpkm0RSCgLuSB8nB /QZJb/xVGaPyiCCBF3Wqor0YyOfMEnJkbpYnlIDxrQ0YC6l5Y2qwCgg5KNjhg2IPNzbZ ljHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y7tHMUFr; 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 q72-v6si5340197pfi.183.2018.06.14.07.16.41; Thu, 14 Jun 2018 07:16:55 -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=Y7tHMUFr; 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 S966310AbeFNONt (ORCPT + 99 others); Thu, 14 Jun 2018 10:13:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:55292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966300AbeFNONp (ORCPT ); Thu, 14 Jun 2018 10:13:45 -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 CEC68208DA; Thu, 14 Jun 2018 14:13:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528985625; bh=3lTcSw9S5+HadAzaN7KDhOr9ETr3TIUQHdg/wSlyQYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y7tHMUFrAHUi6hfb+1TLd+VGgY/9uZ1XuTDe6MRwlpJtosfCqwMiy/UieDmLdmaVE jcAQ8UKFiyd0dK467tsT0Kpdv0tWfU/tK939weEdHgCrObvUHfBounWowPcnFNayH8 DNz10Xr6njTmlYgIzFTtZRkHEIyQEDqdOt7YUc/4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leonid Shatz , Yu-cheng Yu , Andy Lutomirski , Borislav Petkov , Dave Hansen , Fenghua Yu , Linus Torvalds , Peter Zijlstra , "Ravi V. Shankar" , Sai Praneeth Prakhya , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.4 08/24] x86/fpu: Revert ("x86/fpu: Disable AVX when eagerfpu is off") Date: Thu, 14 Jun 2018 16:05:03 +0200 Message-Id: <20180614132724.824634808@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: Yu-cheng Yu commit a65050c6f17e52442716138d48d0a47301a8344b upstream. Leonid Shatz noticed that the SDM interpretation of the following recent commit: 394db20ca240741 ("x86/fpu: Disable AVX when eagerfpu is off") ... is incorrect and that the original behavior of the FPU code was correct. Because AVX is not stated in CR0 TS bit description, it was mistakenly believed to be not supported for lazy context switch. This turns out to be false: Intel Software Developer's Manual Vol. 3A, Sec. 2.5 Control Registers: 'TS Task Switched bit (bit 3 of CR0) -- Allows the saving of the x87 FPU/ MMX/SSE/SSE2/SSE3/SSSE3/SSE4 context on a task switch to be delayed until an x87 FPU/MMX/SSE/SSE2/SSE3/SSSE3/SSE4 instruction is actually executed by the new task.' Intel Software Developer's Manual Vol. 2A, Sec. 2.4 Instruction Exception Specification: 'AVX instructions refer to exceptions by classes that include #NM "Device Not Available" exception for lazy context switch.' So revert the commit. Reported-by: Leonid Shatz Signed-off-by: Yu-cheng Yu Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Fenghua Yu Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Ravi V. Shankar Cc: Sai Praneeth Prakhya Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1457569734-3785-1-git-send-email-yu-cheng.yu@intel.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/fpu/xstate.h | 9 ++++----- arch/x86/kernel/fpu/init.c | 6 ------ 2 files changed, 4 insertions(+), 11 deletions(-) --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -20,16 +20,15 @@ /* Supported features which support lazy state saving */ #define XFEATURE_MASK_LAZY (XFEATURE_MASK_FP | \ - XFEATURE_MASK_SSE) - -/* Supported features which require eager state saving */ -#define XFEATURE_MASK_EAGER (XFEATURE_MASK_BNDREGS | \ - XFEATURE_MASK_BNDCSR | \ + XFEATURE_MASK_SSE | \ XFEATURE_MASK_YMM | \ XFEATURE_MASK_OPMASK | \ XFEATURE_MASK_ZMM_Hi256 | \ XFEATURE_MASK_Hi16_ZMM) +/* Supported features which require eager state saving */ +#define XFEATURE_MASK_EAGER (XFEATURE_MASK_BNDREGS | XFEATURE_MASK_BNDCSR) + /* All currently supported features */ #define XCNTXT_MASK (XFEATURE_MASK_LAZY | XFEATURE_MASK_EAGER) --- a/arch/x86/kernel/fpu/init.c +++ b/arch/x86/kernel/fpu/init.c @@ -297,12 +297,6 @@ u64 __init fpu__get_supported_xfeatures_ static void __init fpu__clear_eager_fpu_features(void) { setup_clear_cpu_cap(X86_FEATURE_MPX); - setup_clear_cpu_cap(X86_FEATURE_AVX); - setup_clear_cpu_cap(X86_FEATURE_AVX2); - setup_clear_cpu_cap(X86_FEATURE_AVX512F); - setup_clear_cpu_cap(X86_FEATURE_AVX512PF); - setup_clear_cpu_cap(X86_FEATURE_AVX512ER); - setup_clear_cpu_cap(X86_FEATURE_AVX512CD); } /*