Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752973AbcDZW4T (ORCPT ); Tue, 26 Apr 2016 18:56:19 -0400 Received: from mail-bn1on0057.outbound.protection.outlook.com ([157.56.110.57]:12448 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752249AbcDZW4O (ORCPT ); Tue, 26 Apr 2016 18:56:14 -0400 X-Greylist: delayed 631 seconds by postgrey-1.27 at vger.kernel.org; Tue, 26 Apr 2016 18:56:13 EDT Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; From: Tom Lendacky Subject: [RFC PATCH v1 01/18] x86: Set the write-protect cache mode for AMD processors To: , , , , , , , , CC: Radim =?utf-8?b?S3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Joerg Roedel , "Konrad Rzeszutek Wilk" , Paolo Bonzini , "Ingo Molnar" , Borislav Petkov , "H. Peter Anvin" , Andrey Ryabinin , "Alexander Potapenko" , Thomas Gleixner , "Dmitry Vyukov" Date: Tue, 26 Apr 2016 17:56:04 -0500 Message-ID: <20160426225604.13567.55443.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20160426225553.13567.19459.stgit@tlendack-t1.amdoffice.net> References: <20160426225553.13567.19459.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY1PR13CA0014.namprd13.prod.outlook.com (10.162.30.152) To DM3PR1201MB1120.namprd12.prod.outlook.com (10.164.198.20) X-MS-Office365-Filtering-Correlation-Id: 07f82a1c-3068-49e5-42c1-08d36e25f509 X-Microsoft-Exchange-Diagnostics: 1;DM3PR1201MB1120;2:Bzqvq8J/iBzyQUDMatV88eiM8NgYx8cPEXLuwiYXrrIsIvUgY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nsqlRbV3pgFS6VpQXZNK1pmtTxLyfNsuBHeNLH0j2buDOscjHoL/XMwyfjb/P3SBxZsulLnrfMIvuYljJVhru1sEAEQNqqLP1x2X5lVev2gP9HXsKpe9nSv+pg+a7+DF+dMtGKwOXSA6yk;4:BvhH6bLYiQegSiToSkVpc8N4mqy2CXHUmGdtWIxr0L70BdWKSwhUkjQoNgsEYayogIKRKO2sNTEDnDDIv7iyHxsAGTLgbYCPs6CFlGzBHVOdCRcJnghadn+L26Ze2OEh9wv/UMPMVGFnC9vo0yaro5nsJ0D0IWPrj6VhVEXxWOwkS3YPab6Xv7WOkx03Nvtakt46T+IP4qlBTRasGhDRdkdTvu5E7AERJgLY0FOVy6CvowSxjWDx359vZUs8OCQ0ZkRZ8VYaBWdX6ynGccpG/DxQd8GA4hX7a9YzrJeHvXiG5fyn8rEf7RwZGJNbHOZj0LfaoygX/0Cj69YgVAGsWo7alKIoBcCEFcjG4o1ftzlEKcAwYsoo3DfcZcz+RMc3X1wO30URS76DgYi6B8qUS+2arE+mP9Dx+hjI5weBrDc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521072)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:DM3PR1201MB1120;BCL:0;PCL:0;RULEID:;SRVR:DM3PR1201MB1120; X-Forefront-PRVS: 0924C6A0D5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(42186005)(97746001)(81166005)(5008740100001)(5004730100002)(66066001)(47776003)(2201001)(2950100001)(92566002)(103116003)(53416004)(19580395003)(77096005)(19580405001)(50466002)(86362001)(5001770100001)(4326007)(4001350100001)(23676002)(33646002)(230700001)(9686002)(76176999)(50986999)(189998001)(2906002)(1096002)(1076002)(6116002)(586003)(54356999)(229853001)(71626007)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR1201MB1120;H:tlendack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bmRqstA1HZsUF2bZIohJ+ln/56cCwUxiyN2Ew6cKdFF9coOuq4r+pPW5+/B0NDxGdmI14mTvBbZopCte0t1jRObShEcjfxzoiDGvdKr87k0Ygn7hMVTZzqkC3Q1EFHXljBg=;20:5d8rFuK1dCIs7g94ksuNjxDYtjid8H5cPEWjJl5MrvDsPG+WX0dvtFm2+xqc4IMvMKt3GA3mvWPhRbJjuJMBVoONqy2dsBZDI6uKt5MmzakwdP86Hl91g3ko6qOSf3QvoMhep4piiP1QK7NbALh8Q5B3kOSVxAbrmhdzSBXzOcsOWDr21ZU/1ZQL2hW3owAH/GXjnIsoesCR2qtzDllhSVRvSYN4kD5LsgbLv8HQmeMWU6ra1Hhvmhhk+m6eQxG4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2016 22:56:07.9803 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR1201MB1120 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1566 Lines: 44 For AMD processors that support PAT, set the write-protect cache mode (_PAGE_CACHE_MODE_WP) entry to the actual write-protect value (x05). Signed-off-by: Tom Lendacky --- arch/x86/mm/pat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index fb0604f..dda78ed 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -345,6 +345,8 @@ void pat_init(void) * we lose performance without causing a correctness issue. * Pentium 4 erratum N46 is an example for such an erratum, * although we try not to use PAT at all on affected CPUs. + * AMD processors support write-protect so initialize the + * PAT slot 5 appropriately. * * PTE encoding: * PAT @@ -356,7 +358,7 @@ void pat_init(void) * 010 2 UC-: _PAGE_CACHE_MODE_UC_MINUS * 011 3 UC : _PAGE_CACHE_MODE_UC * 100 4 WB : Reserved - * 101 5 WC : Reserved + * 101 5 WC : Reserved (AMD: _PAGE_CACHE_MODE_WP) * 110 6 UC-: Reserved * 111 7 WT : _PAGE_CACHE_MODE_WT * @@ -364,7 +366,12 @@ void pat_init(void) * corresponding types in the presence of PAT errata. */ pat = PAT(0, WB) | PAT(1, WC) | PAT(2, UC_MINUS) | PAT(3, UC) | - PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, WT); + PAT(4, WB) | PAT(6, UC_MINUS) | PAT(7, WT); + + if (c->x86_vendor == X86_VENDOR_AMD) + pat |= PAT(5, WP); + else + pat |= PAT(5, WC); } if (!boot_cpu_done) {