From patchwork Sun Aug 14 20:23:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 9279927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1775760839 for ; Sun, 14 Aug 2016 20:28:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08567289F3 for ; Sun, 14 Aug 2016 20:28:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F03C728A1A; Sun, 14 Aug 2016 20:28:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73084289F3 for ; Sun, 14 Aug 2016 20:28:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ1zU-0006UJ-Dm; Sun, 14 Aug 2016 20:26:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ1zT-0006Tr-FJ for xen-devel@lists.xenproject.org; Sun, 14 Aug 2016 20:26:39 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id AD/C1-05361-EF3D0B75; Sun, 14 Aug 2016 20:26:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeJIrShJLcpLzFFi42LpubySR/ff5Q3 hBruO81t83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmftx9iLfggWvGj5R17A+N7oS5GLg4hgW2M EosOTWDqYuTgYBMwlZjxX6WLkZNDREBBYnPvM1aQGmaBb6wSlw+8ZwVJCAs4STx73MMCYrMIq EqcWnGRGaSXV8BK4uxLQ5CwhICcxKVtX5hBbE4Ba4nOX2uYQGwhoJLT01vAxogKiElsbtsFZv MKCEqcnPmEBWQMs4C6xPp5QhMYeWchycxCyCxgZFrFqF6cWlSWWqRrqpdUlJmeUZKbmJmja2h gppebWlycmJ6ak5hUrJecn7uJERg2DECwg3H6Zf9DjJIcTEqivDrm68KF+JLyUyozEosz4otK c1KLDzHKcHAoSfBOuLQhXEiwKDU9tSItMwcYwDBpCQ4eJRHeNSBp3uKCxNzizHSI1ClGRSlxX lOQhABIIqM0D64NFjWXGGWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMzbCDKFJzOvBG76K6DFTE CL9aXBFpckIqSkGhiZs7IsGa5LODgyX4zQUXJynvks9ZGoX8bznaE+qxccZrxpJZzx8x3T05C 2fQWnsuX/OqqwOs3dPNv9rchvLuHLn35JmGd6/dpavFD9ZX3mlqqALedSy4+IZv79d8i0/PN+ LfFrYsf2Bte2pDw3W2Af9G/WpL9tqipmgmLOq73Dy89Zq/9IOK7EUpyRaKjFXFScCAAL5l5vl QIAAA== X-Env-Sender: gregkh@linuxfoundation.org X-Msg-Ref: server-14.tower-21.messagelabs.com!1471206396!28370725!1 X-Originating-IP: [140.211.169.12] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49932 invoked from network); 14 Aug 2016 20:26:37 -0000 Received: from mail.linuxfoundation.org (HELO mail.linuxfoundation.org) (140.211.169.12) by server-14.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Aug 2016 20:26:37 -0000 Received: from localhost (pes75-3-78-192-101-3.fbxo.proxad.net [78.192.101.3]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6D6E18DC; Sun, 14 Aug 2016 20:26:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Date: Sun, 14 Aug 2016 22:23:24 +0200 Message-Id: <20160814202303.816870130@linuxfoundation.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160814202302.493206349@linuxfoundation.org> References: <20160814202302.493206349@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Cc: Juergen Gross , Denys Vlasenko , xen-devel@lists.xenproject.org, Toshi Kani , Peter Zijlstra , Greg Kroah-Hartman , "Luis R. Rodriguez" , "H. Peter Anvin" , stable@vger.kernel.org, Andy Lutomirski , paul.gortmaker@windriver.com, Ingo Molnar , Borislav Petkov , Brian Gerst , Toshi Kani , Andrew Morton , Borislav Petkov , Linus Torvalds , Thomas Gleixner , Robert Elliott Subject: [Xen-devel] [PATCH 4.4 24/49] x86/mm/pat: Add pat_disable() interface X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Toshi Kani commit 224bb1e5d67ba0f2872c98002d6a6f991ac6fd4a upstream. In preparation for fixing a regression caused by: 9cd25aac1f44 ("x86/mm/pat: Emulate PAT when it is disabled") ... PAT needs to provide an interface that prevents the OS from initializing the PAT MSR. PAT MSR initialization must be done on all CPUs using the specific sequence of operations defined in the Intel SDM. This requires MTRRs to be enabled since pat_init() is called as part of MTRR init from mtrr_rendezvous_handler(). Make pat_disable() as the interface that prevents the OS from initializing the PAT MSR. MTRR will call this interface when it cannot provide the SDM-defined sequence to initialize PAT. This also assures that pat_disable() called from pat_bsp_init() will set the PAT table properly when CPU does not support PAT. Signed-off-by: Toshi Kani Reviewed-by: Thomas Gleixner Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Juergen Gross Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Robert Elliott Cc: Toshi Kani Cc: konrad.wilk@oracle.com Cc: paul.gortmaker@windriver.com Cc: xen-devel@lists.xenproject.org Link: http://lkml.kernel.org/r/1458769323-24491-3-git-send-email-toshi.kani@hpe.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/pat.h | 1 + arch/x86/mm/pat.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/pat.h +++ b/arch/x86/include/asm/pat.h @@ -5,6 +5,7 @@ #include bool pat_enabled(void); +void pat_disable(const char *reason); extern void pat_init(void); void __init_cache_modes(u64); --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -39,11 +39,22 @@ static bool boot_cpu_done; static int __read_mostly __pat_enabled = IS_ENABLED(CONFIG_X86_PAT); +static void init_cache_modes(void); -static inline void pat_disable(const char *reason) +void pat_disable(const char *reason) { + if (!__pat_enabled) + return; + + if (boot_cpu_done) { + WARN_ONCE(1, "x86/PAT: PAT cannot be disabled after initialization\n"); + return; + } + __pat_enabled = 0; pr_info("x86/PAT: %s\n", reason); + + init_cache_modes(); } static int __init nopat(char *str)