From patchwork Sun Aug 14 20:37:28 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: 9280055 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 079C760231 for ; Sun, 14 Aug 2016 20:45:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED3A5289A7 for ; Sun, 14 Aug 2016 20:45:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E14A828A1A; Sun, 14 Aug 2016 20:45:48 +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 446B7289A7 for ; Sun, 14 Aug 2016 20:45:48 +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 1bZ2Ew-000882-Oi; Sun, 14 Aug 2016 20:42:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZ2Ev-00087w-5g for xen-devel@lists.xenproject.org; Sun, 14 Aug 2016 20:42:37 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id FB/03-28857-CB7D0B75; Sun, 14 Aug 2016 20:42:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeJIrShJLcpLzFFi42LpubySR3f39Q3 hBlc36lt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmbJsgVfBCteNL/mb2B8b1QFyMXh5DANkaJ vsXrGLsYOTjYBEwlZvxX6WLk5BARUJDY3PuMFaSGWeAbq8TlA+9ZQRLCAk4Sj77uYwexWQRUJ f48WsIMYvMKWEksWrGSDcSWEJCTuLTtC1icU8BaYua9ViYQWwio5urhPrC4qICYxOa2XawQvY ISJ2c+YQG5gVlAXWL9PKEJjLyzkGRmIWQWMDKtYtQoTi0qSy3SNTTUSyrKTM8oyU3MzNE1NDD Ty00tLk5MT81JTCrWS87P3cQIDBwGINjB+GlZwCFGSQ4mJVFeHfN14UJ8SfkplRmJxRnxRaU5 qcWHGGU4OJQkeO2BgSgkWJSanlqRlpkDDGGYtAQHj5II7/NrQGne4oLE3OLMdIjUKUZFKXHeR yAJAZBERmkeXBssbi4xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmPcdyBSezLwSuOmvgBYzAS 3WlwZbXJKIkJJqYIzwninQ2W51KfyUYujh6OMKM+RPujcddfnjI3Hw/KMb5nqO+5l1FQTnuEX 5HS1pVO1QaWsVlfv4buFGfodb/552MCzfrVO7ztZiWsdyrZYDx9ZaNHIEV3pFHTN63KlkG+bq Hxl8XzK1U/2974K7z60XScV3H+yVO/45rvzNg5ValrpTRH2ylFiKMxINtZiLihMBWW4s/5YCA AA= X-Env-Sender: gregkh@linuxfoundation.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1471207354!53523437!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 54469 invoked from network); 14 Aug 2016 20:42:35 -0000 Received: from mail.linuxfoundation.org (HELO mail.linuxfoundation.org) (140.211.169.12) by server-12.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 14 Aug 2016 20:42:35 -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 82E5978D; Sun, 14 Aug 2016 20:42:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Date: Sun, 14 Aug 2016 22:37:28 +0200 Message-Id: <20160814202505.917424759@linuxfoundation.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160814202504.908694181@linuxfoundation.org> References: <20160814202504.908694181@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.6 24/56] 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.6-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 @@ -40,11 +40,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)