From patchwork Fri Jul 7 13:39:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9830347 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 B6FAB60352 for ; Fri, 7 Jul 2017 13:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC340286A3 for ; Fri, 7 Jul 2017 13:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0AD02868B; Fri, 7 Jul 2017 13:42:29 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 5564728697 for ; Fri, 7 Jul 2017 13:42:28 +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 1dTTUR-0003NG-6c; Fri, 07 Jul 2017 13:40:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dTTUP-0003Lr-Hs for xen-devel@lists.xen.org; Fri, 07 Jul 2017 13:40:09 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id DC/D1-02962-83F8F595; Fri, 07 Jul 2017 13:40:08 +0000 X-Brightmail-Tracker: H4sIAAA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messagelabs.com!1499434805!65553597!1 X-Originating-IP: [104.47.42.55] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49813 invoked from network); 7 Jul 2017 13:40:07 -0000 Received: from mail-by2nam03on0055.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) (104.47.42.55) by server-10.tower-21.messagelabs.com with AES256-SHA256 encrypted SMTP; 7 Jul 2017 13:40:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Bi52B/idbOGO5O/OiAZXx8UAFoQ61dAiZiRN83d/Cmk=; b=QSsqQMYgaGaiTIyPOl/0dfadPbagBO9XkPulEY3ek/UVUPID0jRZFKiHcPl2bia5UU/gqroUB3kCjYj4Hd8z5i1GRyqa2WCIAifcnQ/28BF6ZdnKlwPcuoLXTYCZkHB/pjqkJ1Q45iAFpQ8N6u4O1ncI3dWfSQe3U7jWz+hlL0E= Received: from tlendack-t1.amdoffice.net (165.204.77.1) by CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1220.11; Fri, 7 Jul 2017 13:40:00 +0000 From: Tom Lendacky To: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Date: Fri, 07 Jul 2017 08:39:57 -0500 Message-ID: <20170707133957.29711.61760.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> References: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR16CA0025.namprd16.prod.outlook.com (10.172.42.139) To CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 327a269f-ada4-4e99-ccda-08d4c53daad1 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 3:CenJoIJF8VTHSdT7aDXH1JA3OjsHpUMw0Ri6paGkoOD+Np3SwuV20uJTARZtejBtDKT/fZ5V17Qgtf1LpWXafCvh4G3yAyNqkdGlEDh5VlaXdAciQCoRSnsUCbE/aPWr70EzeXYvmEl3n75jsmNDYHoK5hnxNok5BWOxPVyjyLphD1AJvNZ5/ZdzXUqyNbf+hkJQMHUMlKmZma2x3KuKRRRnurQ0RadsvHOlxLnH47/EILRIMGzsh8k37N7mnvfeqQjC2O7Sr7bOWPxexgkyqNdyWCVMAYkGIS3GVPhA5u0+j64uGRlyH5zVlwaoxr+ctZzaKpbHq13IUjvJyQgWGmXV8Nt912hS8+6yiYft8Dt+L1UXc2wpO+hHZLiprNtl7VNujKhM/u/EwWtqLhmWuRYLNGF8BUoUw7SdRiMBkNiEIKjorJMLF/7ouINmQztiT+gxjo6W37gzIL1XlnA2jOVnpE1aF0y/4sUj+z3mLzyr9b/B58yDJD7DxpViCd8+qYGY4LND0OznRcAXLns+hRE7UhKc0Ah6LgokmNEPl5wLfs3hiceWSG2ZDrQUkVLtG5cmMuQqZLnmP2Juv13EuOPv6TA6+rge2mZY1JPeNcU99NaUpbcgliWoz201tD0WNRU7Xh4hjpbmiBOiVk6+XNGdm5AyzQGAhkhHaH0QIi74cIzuUn529cxTd1yQrQKmVPwOpfpyI39NIN9rty4WHjdqBtKV9TO1fvidNj8OIWIurqms/wJeTRRUqiElDvPqsL7c2CSaDw1YLWIiCnl8Pw== X-MS-TrafficTypeDiagnostic: CY4PR12MB1141: X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 25:wFk2cZ7O7kw09+e58vTSarsZG4Av0iGECHsAlknRV0Krxvt6Rt9REXMUXYVHKLnbDC78pxHGnrGBJROFtLTkjEjKRjSSR9GSCRoog5GjCsJyu/LyLERntYxKvBAlDmdmHK1FzofJMdds6BaAPnRnXtkV26OywXRAU2nL9kI1Lv+K0qddRI8JjpXqhvFGN/KUJ5wNMwIzQaCWeJ83LA/35AB9/gNJwBBPK8doK34YyipddCRI/QOIOV51/bvq2lltr6qXhmSYMEV3N9YxE41wjre3NwaGhPQx76+21lPW5G0EAAHowilu//EpZzHWf6qzYriby3nwOcxhoXZBPJ5BY+k4bXInt2W3Yj2S27Zd2E+DKbRgFajIo+6r/LadtNwYbSzJmqKVy5KtGa1z4MHuB9QctcZEm6XSaDoF6SfAaMs92mpKdCDM4DXPiJgJrea32448KVc5EwXUST1Igb9MOIO7QEbtXh0+A/vs9BBlokkA4eTvP+uO2vi7buaRRxQydQXDorZr+z0MkGHPisugzS05dxLoDKJXZ3ldLArgQOKQhH0wJMb+6cya0CPJTZt2ewilyInqViInguCoOzOaZjSfFJZ/KH4zLCzFQiBP7EhER1t3THMYM42N71OMMcb9tHyLLauaWweOB2HVGzCYBPv5cmkgBA/CdcijsMiOnyJrGK7ImnG8nc2nPCuuvD8UQnCCcf03FZwtAAjIC7Pg2UxYqajfaRPGBwa3BrjGKKuUcyygb9y0PyuQbSu7XFYajLzdjBGZUgQNDyl7nABQuGRGuvgOlgZfsPOipTrlZr7rURSjOjAMHvoSV1wS60U/glEQmZYjbW9feCLtcNIcwF7Ui+0R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QpI/upBn1BFjZ1SFeP+WrHtquxuZV95PlMSk0iKBWqI3Zta5tY9E/ACmIwJ0O0w7ofyz07hJTHraRdfA5lOjHxK1lsaJXz4n40UvcVAXM37eUxgXAkZm58lWz3rSWX/ONg0GJzfgp7g05lvwzCGkdpXMwaDAJZrD7bmA5nluZnvGFWJWs79POzqXRhNnBc64G2RMobVFF0I6UFzjatbaoRsVffvXatVQjRvK5RNHgAToQdIQ0jGOdh93JSjLEdbFUmLFbuM+ACvdR/+EQgJUu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(236129657087228)(767451399110)(148574349560750)(167848164394848); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(2017060910064)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(20161123558100)(20161123555025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR12MB1141; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzQ6Z0dERkFobitlaFBuYlc0eWNwT3dJN3kvODlP?= =?utf-8?B?Q3BzNFprNTVSc0w3QVVxcWRodzc0NVNJSEV3dnc1MkE4bHo0am1ad05NMnFz?= =?utf-8?B?V0JtY0g0VHNQMituc0dKOE1TUjVja3dLY0hUWnRaOU5zT1BDSVh1aU1CNFNR?= =?utf-8?B?SEVFRVRQMXhHNFVrY2p5N1pmL1RWeGJFQThjQjRpTk9LbERXM2p5T1d3N241?= =?utf-8?B?R3VneDgvY05IUGVCYWVmMjVpMX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mVvQ0Z4M004Z044eWZWd3I1TUxsc1FQZlBHSzdWUE1Cc1Zx?= =?utf-8?B?b3BSM1VTaFBIcTRIZExaYUdTS1dFeWowS1BUbUE1UDJuRkljYjU1MUE4NGd6?= =?utf-8?B?akRYOStGSDM4NkZkNXE3YUxyZzNjd01TZkQxNUNLOVY3d0VmQi8yNUhrb0ln?= =?utf-8?B?enkrVFlyUVZrNDZoeHh5YU0vT3VUWURrUVVoOHVYSENWMERXSXhCTFZia0Vq?= =?utf-8?B?RWdnaTFwaHFUVDNJTjZEVXhTMmYyYkVtck9Hb09xVmlxQ3BGMEYvcC9STGxk?= =?utf-8?B?Y3NuL0ppeGR5RnRxSUIxTmtqYURxL0JjeFQyMXh2STk3REI5WndhM0dsN3pj?= =?utf-8?B?MUdock43NVExSU1ZRTlxN09rODVFNkJ3QUJxM2hGNHhSTlJIZ1VHMXhvTzFl?= =?utf-8?B?ZlFxTVo0T0lVK2RCa0RESmtkRDVDUFpxQXFjb2MrNFp4dHpqblp5MURVS0Ez?= =?utf-8?B?ZWNNY2FpWXRicnRmTXk5YWJ5TnJFNmliY3NOdFFTQURXcEc5d2tnNTN1Wkl0?= =?utf-8?B?Uk50SjZJdXkwTWEzaWVpOVJ3MmYxcTRVZmY4Y1pJTUlITlRtUHk4SU1XTk9G?= =?utf-8?B?SUZXMjdTbGFIeTRvRDdOUGpYTW5XOXdMaUo5QjNrSFc2Q24vbVVuV0ZYVCt1?= =?utf-8?B?MEtKbVlLUmNEbGtNN3pZZUhNVjZTZDdVZUtKd3hFd0FSRWxseHdYMVdyOTNU?= =?utf-8?Q?epr4kjDcUQ=3D?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39860400002)(39450400003)(39850400002)(39400400002)(39410400002)(5660300001)(50466002)(23676002)(230700001)(305945005)(7406005)(66066001)(81166006)(7736002)(478600001)(8676002)(2906002)(47776003)(7416002)(83506001)(97746001)(53416004)(6666003)(575784001)(54356999)(2950100002)(42186005)(103116003)(4326008)(6116002)(6506006)(25786009)(55016002)(1076002)(50986999)(189998001)(3846002)(54906002)(86362001)(72206003)(9686003)(33646002)(53936002)(76176999)(38730400002)(110136004)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1141; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzIzOnNyNGVCRW1HN01rT28rd1pGT3lWbkhHYzFZ?= =?utf-8?B?SWUvdGNsd3Y0QzNBbVZkMDZDMWpxb3E3Ujl0aVdPVUdKNElaeXlObkhhdnJp?= =?utf-8?B?NUI4ak9aM0VFSFY5TXFoZU5CQ2ZtdGhyQlhQQ2kyTGxMU2hxVVNkLzFoSkw3?= =?utf-8?B?bzdQUDlTUVNnemhQNDBsdWNLblc4eGc5YnVnOVNkbFErb1NpK0JrNFNBdTJw?= =?utf-8?B?Sk9rNDNmOCt5NjdpQjl2T1ZJb1NWMksvR1ZHTkV6NExSc1d0dFNONzNBbVFH?= =?utf-8?B?TXVnUlRDVVkwMU5RTGM4L3dMOGZCOGYzSEdGNmpMOWR6TEJxU2pRLzh5K0dw?= =?utf-8?B?eUdmVUIyUk9IZ05LMFJ5ZDBPVHNRZGM2MloyNUpRay80NU8wVWdhekVWVXpu?= =?utf-8?B?OW5JTEV0cy9VRDE4c0U0Z2pyYjFSTzlzOU9oUmNkWXYwRTZKT0l2eHlUUHNG?= =?utf-8?B?d0oxV3IwSno3ZUtpbFNKRVJzSHVzV3UrVndjQXQyNDBuUFRscXV6eTBuaEt4?= =?utf-8?B?S0x6a0E2eUVMeHJmak1sMmlZMmViMU5yOVRYYlpxSlhUcGxrMFIvaDlva2tB?= =?utf-8?B?VFBCK21pQ1VETlBxaFpKVXNmekRpdVRCVnJxcEpBU09TQ0NiWmRJZldseW1s?= =?utf-8?B?Vk5UK0tiN2Z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778RM7tHbvrr2zq8zB3G2aNzJHyzwlyBYBiu5DaWeNIPprVNzNa2mymxY5yPF8kBPdCubiAUJX1KXFdGCOc7RGLnxr4S91OPYl49v3Tp7OK/Kr9WP2V1HWV7CnYDdf/uEwP2Xs3KBpirsfxn5461zjHvK5VS08IMItp/DVFhQkBIz304RZ17mz9lHtMcX0iGWBjf28Md/Hhqi5836xFUCk= X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 20:uxBKNrGHpeZ8Iwd9VcrHcEJEVcns8VQyETGTjXC7g7TZn9m0LXhOUzdNGqqUaILAMDdHcf9RJb9nxxKQ8vY8iKSqzR3QNJ6spm0gRUZUt4XcsAq4Jz28/3qF2q75GaXL3x58pAM8Cl/jJGDdCYbhbj6l0pk9qsHy3IqfV+pUPyXUZuddShn/CxLb/Y1vPjPLGuCQJLPFH/8JsFzgOFkLoLDEJ56f44GnbUeItCl2OAQj6+Q0kc/Bxa5wzQWLk4+T X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:40:00.2041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Cc: Brijesh Singh , Toshimitsu Kani , "Michael S. Tsirkin" , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Boris Ostrovsky , Jonathan Corbet , Joerg Roedel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Larry Woodman , Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , Dmitry Vyukov , Juergen Gross , Paolo Bonzini Subject: [Xen-devel] [PATCH v9 10/38] x86/mm: Provide general kernel support for memory encryption 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 Changes to the existing page table macros will allow the SME support to be enabled in a simple fashion with minimal changes to files that use these macros. Since the memory encryption mask will now be part of the regular pagetable macros, we introduce two new macros (_PAGE_TABLE_NOENC and _KERNPG_TABLE_NOENC) to allow for early pagetable creation/initialization without the encryption mask before SME becomes active. Two new pgprot() macros are defined to allow setting or clearing the page encryption mask. The FIXMAP_PAGE_NOCACHE define is introduced for use with MMIO. SME does not support encryption for MMIO areas so this define removes the encryption mask from the page attribute. Two new macros are introduced (__sme_pa() / __sme_pa_nodebug()) to allow creating a physical address with the encryption mask. These are used when working with the cr3 register so that the PGD can be encrypted. The current __va() macro is updated so that the virtual address is generated based off of the physical address without the encryption mask thus allowing the same virtual address to be generated regardless of whether encryption is enabled for that physical location or not. Also, an early initialization function is added for SME. If SME is active, this function: - Updates the early_pmd_flags so that early page faults create mappings with the encryption mask. - Updates the __supported_pte_mask to include the encryption mask. - Updates the protection_map entries to include the encryption mask so that user-space allocations will automatically have the encryption mask applied. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/boot/compressed/pagetable.c | 7 +++++ arch/x86/include/asm/fixmap.h | 7 +++++ arch/x86/include/asm/mem_encrypt.h | 13 ++++++++++ arch/x86/include/asm/page_types.h | 3 ++ arch/x86/include/asm/pgtable.h | 9 +++++++ arch/x86/include/asm/pgtable_types.h | 45 ++++++++++++++++++++++------------ arch/x86/include/asm/processor.h | 3 ++ arch/x86/kernel/espfix_64.c | 2 +- arch/x86/kernel/head64.c | 11 +++++++- arch/x86/kernel/head_64.S | 20 ++++++++------- arch/x86/mm/kasan_init_64.c | 4 ++- arch/x86/mm/mem_encrypt.c | 17 +++++++++++++ arch/x86/mm/pageattr.c | 3 ++ arch/x86/mm/tlb.c | 4 ++- include/asm-generic/pgtable.h | 12 +++++++++ include/linux/mem_encrypt.h | 8 ++++++ 16 files changed, 133 insertions(+), 35 deletions(-) diff --git a/arch/x86/boot/compressed/pagetable.c b/arch/x86/boot/compressed/pagetable.c index 28029be..f1aa438 100644 --- a/arch/x86/boot/compressed/pagetable.c +++ b/arch/x86/boot/compressed/pagetable.c @@ -15,6 +15,13 @@ #define __pa(x) ((unsigned long)(x)) #define __va(x) ((void *)((unsigned long)(x))) +/* + * The pgtable.h and mm/ident_map.c includes make use of the SME related + * information which is not used in the compressed image support. Un-define + * the SME support to avoid any compile and link errors. + */ +#undef CONFIG_AMD_MEM_ENCRYPT + #include "misc.h" /* These actually do the work of building the kernel identity maps. */ diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index b65155c..d9ff226 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -157,6 +157,13 @@ static inline void __set_fixmap(enum fixed_addresses idx, } #endif +/* + * FIXMAP_PAGE_NOCACHE is used for MMIO. Memory encryption is not + * supported for MMIO addresses, so make sure that the memory encryption + * mask is not part of the page attributes. + */ +#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE + #include #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index 475e34f..dbae7a5 100644 --- a/arch/x86/include/asm/mem_encrypt.h +++ b/arch/x86/include/asm/mem_encrypt.h @@ -21,6 +21,8 @@ extern unsigned long sme_me_mask; +void __init sme_early_init(void); + void __init sme_encrypt_kernel(void); void __init sme_enable(void); @@ -28,11 +30,22 @@ #define sme_me_mask 0UL +static inline void __init sme_early_init(void) { } + static inline void __init sme_encrypt_kernel(void) { } static inline void __init sme_enable(void) { } #endif /* CONFIG_AMD_MEM_ENCRYPT */ +/* + * The __sme_pa() and __sme_pa_nodebug() macros are meant for use when + * writing to or comparing values from the cr3 register. Having the + * encryption mask set in cr3 enables the PGD entry to be encrypted and + * avoid special case handling of PGD allocations. + */ +#define __sme_pa(x) (__pa(x) | sme_me_mask) +#define __sme_pa_nodebug(x) (__pa_nodebug(x) | sme_me_mask) + #endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */ diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h index 7bd0099..b98ed9d 100644 --- a/arch/x86/include/asm/page_types.h +++ b/arch/x86/include/asm/page_types.h @@ -3,6 +3,7 @@ #include #include +#include /* PAGE_SHIFT determines the page size */ #define PAGE_SHIFT 12 @@ -15,7 +16,7 @@ #define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT) #define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1)) -#define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1)) +#define __PHYSICAL_MASK ((phys_addr_t)(__sme_clr((1ULL << __PHYSICAL_MASK_SHIFT) - 1))) #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1) /* Cast *PAGE_MASK to a signed type so that it is sign-extended if diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index b64ea52..c6452cb 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1,6 +1,7 @@ #ifndef _ASM_X86_PGTABLE_H #define _ASM_X86_PGTABLE_H +#include #include #include @@ -13,6 +14,12 @@ cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS))) \ : (prot)) +/* + * Macros to add or remove encryption attribute + */ +#define pgprot_encrypted(prot) __pgprot(__sme_set(pgprot_val(prot))) +#define pgprot_decrypted(prot) __pgprot(__sme_clr(pgprot_val(prot))) + #ifndef __ASSEMBLY__ #include @@ -38,6 +45,8 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page); +extern pmdval_t early_pmd_flags; + #ifdef CONFIG_PARAVIRT #include #else /* !CONFIG_PARAVIRT */ diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index bf9638e..de32ca3 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -2,6 +2,8 @@ #define _ASM_X86_PGTABLE_DEFS_H #include +#include + #include #define FIRST_USER_ADDRESS 0UL @@ -121,10 +123,10 @@ #define _PAGE_PROTNONE (_AT(pteval_t, 1) << _PAGE_BIT_PROTNONE) -#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ - _PAGE_ACCESSED | _PAGE_DIRTY) -#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ - _PAGE_DIRTY) +#define _PAGE_TABLE_NOENC (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER |\ + _PAGE_ACCESSED | _PAGE_DIRTY) +#define _KERNPG_TABLE_NOENC (_PAGE_PRESENT | _PAGE_RW | \ + _PAGE_ACCESSED | _PAGE_DIRTY) /* * Set of bits not changed in pte_modify. The pte's @@ -191,18 +193,29 @@ enum page_cache_mode { #define __PAGE_KERNEL_IO (__PAGE_KERNEL) #define __PAGE_KERNEL_IO_NOCACHE (__PAGE_KERNEL_NOCACHE) -#define PAGE_KERNEL __pgprot(__PAGE_KERNEL) -#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO) -#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC) -#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX) -#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE) -#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE) -#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC) -#define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL) -#define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR) - -#define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) -#define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) +#ifndef __ASSEMBLY__ + +#define _PAGE_ENC (_AT(pteval_t, sme_me_mask)) + +#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ + _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_ENC) +#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ + _PAGE_DIRTY | _PAGE_ENC) + +#define PAGE_KERNEL __pgprot(__PAGE_KERNEL | _PAGE_ENC) +#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO | _PAGE_ENC) +#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC | _PAGE_ENC) +#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX | _PAGE_ENC) +#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE | _PAGE_ENC) +#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE | _PAGE_ENC) +#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC | _PAGE_ENC) +#define PAGE_KERNEL_VSYSCALL __pgprot(__PAGE_KERNEL_VSYSCALL | _PAGE_ENC) +#define PAGE_KERNEL_VVAR __pgprot(__PAGE_KERNEL_VVAR | _PAGE_ENC) + +#define PAGE_KERNEL_IO __pgprot(__PAGE_KERNEL_IO) +#define PAGE_KERNEL_IO_NOCACHE __pgprot(__PAGE_KERNEL_IO_NOCACHE) + +#endif /* __ASSEMBLY__ */ /* xwr */ #define __P000 PAGE_NONE diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 6a79547..a68f70c 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -29,6 +29,7 @@ #include #include #include +#include /* * We handle most unaligned accesses in hardware. On the other hand @@ -241,7 +242,7 @@ static inline unsigned long read_cr3_pa(void) static inline void load_cr3(pgd_t *pgdir) { - write_cr3(__pa(pgdir)); + write_cr3(__sme_pa(pgdir)); } #ifdef CONFIG_X86_32 diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c index 6b91e2e..9c4e7ba 100644 --- a/arch/x86/kernel/espfix_64.c +++ b/arch/x86/kernel/espfix_64.c @@ -195,7 +195,7 @@ void init_espfix_ap(int cpu) pte_p = pte_offset_kernel(&pmd, addr); stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0)); - pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); + pte = __pte(__pa(stack_page) | ((__PAGE_KERNEL_RO | _PAGE_ENC) & ptemask)); for (n = 0; n < ESPFIX_PTE_CLONES; n++) set_pte(&pte_p[n*PTE_STRIDE], pte); diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 1f0ddcc..5cd0b72 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -102,7 +102,7 @@ unsigned long __head __startup_64(unsigned long physaddr) pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); - pgtable_flags = _KERNPG_TABLE + sme_get_me_mask(); + pgtable_flags = _KERNPG_TABLE_NOENC + sme_get_me_mask(); if (IS_ENABLED(CONFIG_X86_5LEVEL)) { p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); @@ -177,7 +177,7 @@ static void __init reset_early_page_tables(void) { memset(early_top_pgt, 0, sizeof(pgd_t)*(PTRS_PER_PGD-1)); next_early_pgt = 0; - write_cr3(__pa_nodebug(early_top_pgt)); + write_cr3(__sme_pa_nodebug(early_top_pgt)); } /* Create a new PMD entry */ @@ -310,6 +310,13 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) clear_page(init_top_pgt); + /* + * SME support may update early_pmd_flags to include the memory + * encryption mask, so it needs to be called before anything + * that may generate a page fault. + */ + sme_early_init(); + kasan_early_init(); for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index ec5d5e9..513cbb0 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -351,9 +351,9 @@ GLOBAL(name) NEXT_PAGE(early_top_pgt) .fill 511,8,0 #ifdef CONFIG_X86_5LEVEL - .quad level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC #else - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC #endif NEXT_PAGE(early_dynamic_pgts) @@ -366,15 +366,15 @@ NEXT_PAGE(init_top_pgt) .fill 512,8,0 #else NEXT_PAGE(init_top_pgt) - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC .org init_top_pgt + PGD_PAGE_OFFSET*8, 0 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC .org init_top_pgt + PGD_START_KERNEL*8, 0 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */ - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC NEXT_PAGE(level3_ident_pgt) - .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE + .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC .fill 511, 8, 0 NEXT_PAGE(level2_ident_pgt) /* Since I easily can, map the first 1G. @@ -386,14 +386,14 @@ NEXT_PAGE(level2_ident_pgt) #ifdef CONFIG_X86_5LEVEL NEXT_PAGE(level4_kernel_pgt) .fill 511,8,0 - .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC #endif NEXT_PAGE(level3_kernel_pgt) .fill L3_START_KERNEL,8,0 /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */ - .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE - .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC + .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC NEXT_PAGE(level2_kernel_pgt) /* @@ -411,7 +411,7 @@ NEXT_PAGE(level2_kernel_pgt) NEXT_PAGE(level2_fixmap_pgt) .fill 506,8,0 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE + .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */ .fill 5,8,0 diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 88215ac..d7cc830 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c @@ -92,7 +92,7 @@ static int kasan_die_handler(struct notifier_block *self, void __init kasan_early_init(void) { int i; - pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL; + pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL | _PAGE_ENC; pmdval_t pmd_val = __pa_nodebug(kasan_zero_pte) | _KERNPG_TABLE; pudval_t pud_val = __pa_nodebug(kasan_zero_pmd) | _KERNPG_TABLE; p4dval_t p4d_val = __pa_nodebug(kasan_zero_pud) | _KERNPG_TABLE; @@ -158,7 +158,7 @@ void __init kasan_init(void) */ memset(kasan_zero_page, 0, PAGE_SIZE); for (i = 0; i < PTRS_PER_PTE; i++) { - pte_t pte = __pte(__pa(kasan_zero_page) | __PAGE_KERNEL_RO); + pte_t pte = __pte(__pa(kasan_zero_page) | __PAGE_KERNEL_RO | _PAGE_ENC); set_pte(&kasan_zero_pte[i], pte); } /* Flush TLBs again to be sure that write protection applied. */ diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 3ac6f99..f973d3d 100644 --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -12,6 +12,7 @@ #include #include +#include /* * Since SME related variables are set early in the boot process they must @@ -21,6 +22,22 @@ unsigned long sme_me_mask __section(.data) = 0; EXPORT_SYMBOL_GPL(sme_me_mask); +void __init sme_early_init(void) +{ + unsigned int i; + + if (!sme_me_mask) + return; + + early_pmd_flags = __sme_set(early_pmd_flags); + + __supported_pte_mask = __sme_set(__supported_pte_mask); + + /* Update the protection map with memory encryption mask */ + for (i = 0; i < ARRAY_SIZE(protection_map); i++) + protection_map[i] = pgprot_encrypted(protection_map[i]); +} + void __init sme_encrypt_kernel(void) { } diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index c8520b2..e7d3866 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -2014,6 +2014,9 @@ int kernel_map_pages_in_pgd(pgd_t *pgd, u64 pfn, unsigned long address, if (!(page_flags & _PAGE_RW)) cpa.mask_clr = __pgprot(_PAGE_RW); + if (!(page_flags & _PAGE_ENC)) + cpa.mask_clr = pgprot_encrypted(cpa.mask_clr); + cpa.mask_set = __pgprot(_PAGE_PRESENT | page_flags); retval = __change_page_attr_set_clr(&cpa, 0); diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 2c1b888..593d2f7 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -115,7 +115,7 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, */ this_cpu_write(cpu_tlbstate.ctxs[0].tlb_gen, next_tlb_gen); - write_cr3(__pa(next->pgd)); + write_cr3(__sme_pa(next->pgd)); trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL); } @@ -157,7 +157,7 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, this_cpu_write(cpu_tlbstate.ctxs[0].ctx_id, next->context.ctx_id); this_cpu_write(cpu_tlbstate.ctxs[0].tlb_gen, next_tlb_gen); this_cpu_write(cpu_tlbstate.loaded_mm, next); - write_cr3(__pa(next->pgd)); + write_cr3(__sme_pa(next->pgd)); trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL); } diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 7dfa767..4d7bb98 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -583,6 +583,18 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm, #endif /* CONFIG_MMU */ /* + * No-op macros that just return the current protection value. Defined here + * because these macros can be used used even if CONFIG_MMU is not defined. + */ +#ifndef pgprot_encrypted +#define pgprot_encrypted(prot) (prot) +#endif + +#ifndef pgprot_decrypted +#define pgprot_decrypted(prot) (prot) +#endif + +/* * A facility to provide lazy MMU batching. This allows PTE updates and * page invalidations to be delayed until a call to leave lazy MMU mode * is issued. Some architectures may benefit from doing this, and it is diff --git a/include/linux/mem_encrypt.h b/include/linux/mem_encrypt.h index 570f4fc..1255f09 100644 --- a/include/linux/mem_encrypt.h +++ b/include/linux/mem_encrypt.h @@ -35,6 +35,14 @@ static inline unsigned long sme_get_me_mask(void) return sme_me_mask; } +/* + * The __sme_set() and __sme_clr() macros are useful for adding or removing + * the encryption mask from a value (e.g. when dealing with pagetable + * entries). + */ +#define __sme_set(x) ((unsigned long)(x) | sme_me_mask) +#define __sme_clr(x) ((unsigned long)(x) & ~sme_me_mask) + #endif /* __ASSEMBLY__ */ #endif /* __MEM_ENCRYPT_H__ */