From patchwork Sun May 31 09:48:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 6515621 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 24BAE9F1C1 for ; Sun, 31 May 2015 09:48:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7423920705 for ; Sun, 31 May 2015 09:48:23 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A056205FE for ; Sun, 31 May 2015 09:48:13 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AE47A182678; Sun, 31 May 2015 02:48:12 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:120:8448::d00d]) by ml01.01.org (Postfix) with ESMTP id 5BBE918261C for ; Sun, 31 May 2015 02:48:11 -0700 (PDT) X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1433065690; bh=+mHeSPsQ6Rd12/ixY7+gaE4/6l9nITX44e2WAjbkUjM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=tzXN 53rui6cQNTLREOht3FXthUiqb8pCJIGeX4nKIUV0dcJnPQVGRQHsUxLd92Ad2sknH9w NRezRBsy8+9wuQL6Cm2DTknvJOcBDn2vPmtjHaBsqfzcNgM0Sh9JiaDBI17jGDU9QUB lvOL2d9BXoqE6JfkcEfhpVCEw8dPVNS68= Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id edE3kFAeIpx7; Sun, 31 May 2015 11:48:10 +0200 (CEST) Received: from pd.tnic (p54AF42F0.dip0.t-ipconnect.de [84.175.66.240]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 5A3021DA23B; Sun, 31 May 2015 11:48:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alien8.de; s=alien8; t=1433065690; bh=+mHeSPsQ6Rd12/ixY7+gaE4/6l9nITX44e2WAjbkUjM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=tzXN 53rui6cQNTLREOht3FXthUiqb8pCJIGeX4nKIUV0dcJnPQVGRQHsUxLd92Ad2sknH9w NRezRBsy8+9wuQL6Cm2DTknvJOcBDn2vPmtjHaBsqfzcNgM0Sh9JiaDBI17jGDU9QUB lvOL2d9BXoqE6JfkcEfhpVCEw8dPVNS68= Received: by pd.tnic (Postfix, from userid 1000) id DAF2016036A; Sun, 31 May 2015 11:48:06 +0200 (CEST) From: Borislav Petkov To: LKML Subject: [PATCH 2/4] x86/pat: Merge pat_init_cache_modes() into its caller Date: Sun, 31 May 2015 11:48:04 +0200 Message-Id: <1433065686-20922-2-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1433065686-20922-1-git-send-email-bp@alien8.de> References: <20150531094655.GA20440@pd.tnic> <1433065686-20922-1-git-send-email-bp@alien8.de> Cc: jgross@suse.com, x86-ml , arnd@arndb.de, konrad.wilk@oracle.com, "Luis R. Rodriguez" , linux-nvdimm@lists.01.org, stefan.bader@canonical.com, Andy Lutomirski , linux-mm , Ingo Molnar , Thomas Gleixner , hmh@hmh.eng.br, "H. Peter Anvin" , Andrew Morton , hch@lst.de X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Borislav Petkov This way we can pass pat MSR value directly. No functionality change. Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: arnd@arndb.de Cc: Elliott@hp.com Cc: hch@lst.de Cc: hmh@hmh.eng.br Cc: H. Peter Anvin Cc: Ingo Molnar Cc: jgross@suse.com Cc: konrad.wilk@oracle.com Cc: linux-mm Cc: linux-nvdimm@lists.01.org Cc: Luis R. Rodriguez Cc: stefan.bader@canonical.com Cc: Thomas Gleixner Cc: Toshi Kani Cc: x86-ml Cc: yigal@plexistor.com --- arch/x86/mm/pat.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 476d0780560f..4d28759f5a1a 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -172,32 +172,14 @@ static enum page_cache_mode pat_get_cache_mode(unsigned pat_val, char *msg) #undef CM -/* - * Update the cache mode to pgprot translation tables according to PAT - * configuration. - * Using lower indices is preferred, so we start with highest index. - */ -void pat_init_cache_modes(void) -{ - int i; - enum page_cache_mode cache; - char pat_msg[33]; - u64 pat; - - rdmsrl(MSR_IA32_CR_PAT, pat); - pat_msg[32] = 0; - for (i = 7; i >= 0; i--) { - cache = pat_get_cache_mode((pat >> (i * 8)) & 7, - pat_msg + 4 * i); - update_cache_mode_entry(i, cache); - } - pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg); -} - #define PAT(x, y) ((u64)PAT_ ## y << ((x)*8)) static void pat_bsp_init(u64 pat) { + enum page_cache_mode cache; + char pat_msg[33]; + int i; + if (!cpu_has_pat) { pat_disable("PAT not supported by CPU."); return; @@ -211,7 +193,18 @@ static void pat_bsp_init(u64 pat) wrmsrl(MSR_IA32_CR_PAT, pat); - pat_init_cache_modes(); + pat_msg[32] = 0; + + /* + * Update the cache mode to pgprot translation tables according to PAT + * configuration. Using lower indices is preferred, so we start with + * highest index. + */ + for (i = 7; i >= 0; i--) { + cache = pat_get_cache_mode((pat >> (i * 8)) & 7, pat_msg + 4 * i); + update_cache_mode_entry(i, cache); + } + pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg); } static void pat_ap_init(u64 pat)