From patchwork Tue Jun 27 15:09:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9812395 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 6638660351 for ; Tue, 27 Jun 2017 15:11:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5836F28619 for ; Tue, 27 Jun 2017 15:11:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B581286D0; Tue, 27 Jun 2017 15:11:39 +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 F208528619 for ; Tue, 27 Jun 2017 15:11:37 +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 1dPs7E-00082t-H9; Tue, 27 Jun 2017 15:09:20 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPs7D-00081l-2W for xen-devel@lists.xen.org; Tue, 27 Jun 2017 15:09:19 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 71/BE-03620-E1572595; Tue, 27 Jun 2017 15:09:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA1VSa0gUYRTtm5kdJ3Xic9fwtmjZZk9c04qKfkV EWFD0+JM9zLGmnY19MbPGWvReTASxl6IiaVu2qZgVpWFkT6FMRbTWyp6WBekmoimiWDM7qfX9 Oueee879LlyG1GbQeoZ3OXnRxlkMdDAlLDZsMEambU2KP/lu2corfZep1Six/t4IsRnt0Jhtq XZXikaofNJOO0qzkav/zlvyOKpLz0LBDIXdJJyo8NAKQfg8gsr2c6RCtDiDgBctozKZytA4Fn z+AULBOpwMX3/3UQoOxyUEdOZhxUBiPw11zY20IhA4Eko8pQEzhedC98cq2cAwLE6Elz9TlPJ UvB6Kc32BTK1cbhy+H6Tg6XgmlLW5NQpmcRg8L/gasJJ4IVTVLlbKJJ4FNf6iQDrgaKgZGgos ADgTQUuR929mDBT2twSpTVFQ31REqXgjFBQMa5RMwHOgwb1J9T4ioKbrIaWSJhq+vf9CqIZFc NY79jeoMwhqvWvUpk4N5F36pVFJNQV13mJSjbVA/uA2FR4Bd62gtjRqoONaN6mS72HwoKydOI OMhf9sWji5aeE/m5YgshwtkHjxIC8alyyNSxXNJsFp5cwWY0L88jgrL0mcibdwqVLcXrv1FpK PYor87qLR4i2P0QyGMExnK2BrknZaqn1fusBJwh4xzcJLj9F8hsGe+pPb9JTNbuMNwJZLcluY yJt4136zRT6y8U5gQg3hrM8hy6zk4KyS2aRKDWi2PoI9rfiwIghptgnb+Hm2oii9jkXyn7ShD l60mp3/6z9QBIMMOvaSkhJqtjkn0n/Igwl5MHVxszLYyU1K+uPIfupGyL2e9OiumHWZ3kPRu5 3DH1ovrLg+crR1dopn4Pa+izfCrh74/Elny+ET5h2+md/2oemlMSQ3aM4xLrwadW/3+zqe7HI XbIiPkFxnDqI3ibu97FNm2OzbVdyx6tmrnFjHWObrnb1WtDZ7VWRy7Nve0sFKYS4d6fcQWSea e7IMlCRwCYtIUeL+AOyWy0iZAwAA X-Env-Sender: Thomas.Lendacky@amd.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1498576154!75799335!1 X-Originating-IP: [104.47.34.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64152 invoked from network); 27 Jun 2017 15:09:16 -0000 Received: from mail-by2nam01on0074.outbound.protection.outlook.com (HELO NAM01-BY2-obe.outbound.protection.outlook.com) (104.47.34.74) by server-11.tower-21.messagelabs.com with AES256-SHA256 encrypted SMTP; 27 Jun 2017 15:09:16 -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=ftqMCvmg+ce+XxC1oJ9rgy4fNJdKfySZlvBr6/zkVoY=; b=vQ4oy28qOkGAJXfhW01XrgGu5s2WtbHfXQH8JeoVFqpMuATu2rqdn5FFJn0QE+BCg55mRMpSvCDRQ0Ygwy8tbO/3WCXm7hyffywfv7ER74HXUg04E9J6MuWUE+qCPCopiri3n6gpJ8NG57EN9nOkAaeZh5J87uw6JOmLx4R9guo= Received: from tlendack-t1.amdoffice.net (165.204.77.1) by BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1199.15; Tue, 27 Jun 2017 15:09:07 +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: Tue, 27 Jun 2017 10:09:05 -0500 Message-ID: <20170627150905.17428.72579.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170627150718.17428.81813.stgit@tlendack-t1.amdoffice.net> References: <20170627150718.17428.81813.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: DM5PR17CA0048.namprd17.prod.outlook.com (10.173.128.162) To BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b336506-d703-4836-403c-08d4bd6e766c 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)(300000506067)(300135500095); SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 3:a9qA2Wc4r1lvyekLjy2ENGvySidky/2ICu8RwduCyM5z0XpGCENTeeMaGV+cQn7tWWbJ9uIg80xBDL/Rbp6JL1v4hz4KM2/a48DUrY3XuPhJg8+GuVw+GNeCMdsNOet1PIWZOTk7wottufPcWzYJUfrKX5Mz3fmACdjvr1PKmx+H5eX3RNqVdTMddMir7HAsfQiTuUJWvaVIHr9W7MvSitHet4yF9/2BXxpUWvPEquW9GWvbPdlw1yWwK0nl95MxjKwC34A49a4SOG7fIOXPPzQF+hWyCLF0HsiF28GzYSBfj+BtPbv4H6sENffmV9WAmUKxsO3NFd7bkse3v7RqZ0Q+BFLDcWDpLZcaXnfS6zGXNe5CsNgJVXCDlvAMMRL6OwTdd0B6fa47sEOKRaM3zJJ+7TpsrPNCCesQRp9Fn/RW5sSDUqWszFWijpqzoWkoK0FyiQVXSBny8ZHc93DgSvTcJxEUIfCZrF2TQfMkoKD3jCKPuD74xOB57oD/6Sye0G9X4g4QnoBP4xHNRAR1EjBezOEszlioA+MjyK56LaiDNOMDmZ5856RmHnMa2EQgYRLpHvLm17FHj967+V2yQ2lcHVBLuhRFxRlHjaHutZMVBheYEG0g9Y93HovafISU2i5iSveAeXFfmkr9ZL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VJNNQ3tBfBm2OOoBLK0uuH5t5Qo4bkikXnkd2iuNEB5NKh1iBXbvnLRoM9JArc5+oyPbTxRuFbqlivvu9mNNmycCM96LcXk+Vm1s9G0QOr60QsWA4JWK9bHqCxHyIqPQCoFR6Og0AXEhUej35ID7/bhxoNZycJPoGl7uDjTz8DzP/qKbIDDaAj/7z0uFXpI7h4pJQXAulZeAO3ltT9TIA2BVqv8OgkLORKC76qYT6vaR6U3j2JiiWmBDY1k5tGawnidgrwyvb9HwJxzKe9v 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)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR12MB1137; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTM3OzQ6UnBjQXhDYklJenljSkxBRE9IS3BvQlJLSzBU?= =?utf-8?B?NEhJd1pyTW5BV1lUSk9ZcTFOZVZzMUN0SllIQ0oyUzJyK0QyZVhPbHdBY1ZW?= =?utf-8?B?MzVNOEpUVjJUbUJVRGxzS29VMlRqVHJOYXN3TmdQbDBVSmF6Q2xMOWRHM2tR?= =?utf-8?B?QzNqRmppdHRDc2VETGRKY3VtLzExc0F0Q2xUUVdmNFBtcGlVNklCWEtsMXV5?= =?utf-8?B?SUdSOXFGZFR0WWpuQ3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0Z3S1VjSXJFUS93M2tKZzcxelhTd00ybStwa29FVXFvQ05v?= =?utf-8?B?TExzVXJBTW5xYTEzMGJ4WndTVDFUMHBBOS9PZnl0UDFZQktqa3NOOGt5Ry9q?= =?utf-8?B?eWJ1Y3ZyYzVxRkJPcVI0SjFrc1Nqbkl5WDI3eHc0L0pXRTFlbHFOZGtJUEIv?= =?utf-8?B?dUlMaW9vQnVnRkk3eDhmZ04yOEJ1clFKcjBOQU5PaDJFVkkzQ3dqS2E4YTFX?= =?utf-8?B?dC9vTkpGWUYzSWZ2Y1JoWlQxcjlINjJZaHdjd1hidWpPcVlSTW1ZdlF6MjYx?= =?utf-8?B?OUpMalhxNFJCdC9RTXpDN2JSaytDOWpYMGtnbTg0YWVDWktsUW1qTmFpdm03?= =?utf-8?B?Tk5tQWJmeW56d0ordWlLV0cxQmpPTHdrRDNKZVJpcEdJblVleEVWa1ZMaHlM?= =?utf-8?B?RkkxamNwaVo4NWRSd1FZVWtidlpPRUgyczJLK090MG9qQnBXK2NPMWkrS1NI?= =?utf-8?B?MGc2Y05QRERrSjlJeEpJUXRWamhlOUhOYlVPMVpCeFhYTU5Rbm9YVS9IZjl4?= =?utf-8?B?d2NGazFhVlhmRGwrVmZESWsyTzY5dnVYWEFCc1dXODF6bUtzenNUdndYWnVq?= =?utf-8?B?MGtlb2JXZVpjVWxoeFZuM2M1MWw5Sit1ZEhQUDBkRTdhRVJ5Qld0OWE5QjF3?= =?utf-8?Q?l3mZTXocO04b?= X-Forefront-PRVS: 0351D213B3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39410400002)(39450400003)(39850400002)(39860400002)(39400400002)(2906002)(189998001)(110136004)(7416002)(305945005)(4001350100001)(33646002)(8676002)(23676002)(72206003)(38730400002)(25786009)(4326008)(7406005)(55016002)(53936002)(54906002)(6506006)(9686003)(478600001)(50986999)(2950100002)(1076002)(81166006)(76176999)(5660300001)(54356999)(53416004)(83506001)(103116003)(42186005)(66066001)(7736002)(47776003)(50466002)(97746001)(86362001)(575784001)(3846002)(230700001)(6116002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1137; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTM3OzIzOjhJNzAyeGdncC9UMWIyeHY4VWl5bDZOUE84?= =?utf-8?B?U1Z3VktUQVVJcDhHNGRjaW00cU0wSEhFcFRvclBCUmRyaml6NG5YTmpHclA2?= =?utf-8?B?cktvRFF1elhxLzdQT1B3R1ZNZ3ZEcXRNUDVrZkFkZzJjRmRKckI3eU5WZ1Nh?= =?utf-8?B?YlNXZ0R4ME5USWtLNXUwdExXU0IvL0h6NWlSOS9rMDduc3NuaDJEMFdMbWhJ?= =?utf-8?B?dlhyY21LMHVxYVkvWU9xdHZjWElXVWxWYW1laWtacWJiYWtaeS9jZzdYVXp5?= =?utf-8?B?b25GbUtIZzNtY2R4bWZNZHNPZHBFM3ZzcC9FNjVDVy83QVIveHRnaER2TVV4?= =?utf-8?B?NlBZZjRKMkp4Mi9KdUpGWkxINitPd0hJeWZzRVE3R1ZrYUM0dzhQRGNLbzZm?= =?utf-8?B?am9qbGxjdUhrNFdJa3hzOVJDVzJjb0hkSVF6eTNacVZXOGZPSzhjNm5tbUlB?= =?utf-8?B?NFEzb2xBQWllZUtwZHBuaGI1aHcwem5XaCsyeVBLM05pSnNrNVlXN3ZSaUor?= =?utf-8?B?bHhhQXJFSy9wK3l6S252NmxkbEg1T1BYMkUzSFBqQjJsVUVicEhjQVNCYUU0?= =?utf-8?B?dXhLQnRFR0xPbzBJakVzeXhoUk1hcEJxZkFkaHllRURMMXhFaFJaa1phaWF3?= =?utf-8?B?ak1KSXpYMmJOV2dHeHJURklqQVM1Y3NvQ2NOdjJkK3BTNkVIVEZTY05KSTlR?= =?utf-8?B?eUp1V0s2dW5ZeGpIUDlDV1ovY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JGDuAyT9w5qi+o9CKt8yTa8DuS2sbNx8H31YlH2/DcAdOOQEkP5fJT9O0PeqnRW40fbjyMQ5kXIGbvq3vKWlyU6v5+VCEWRxmTeJjTQHQs0pa/1r0NdJuvvtHw6vN9PDeRpdMUkWjVvlR2JAyoZG2FwJdTa0OjpEnqnICQt6es= X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1137; 20:XAWdhm3G0MG9u4RJijKw4VvvtJc6QxeqtAu4i+rWb0vdXiF3Dpzrm2SLb7GIKT6IpjKz1/aLDQnna1F5XgPtjqUybUfgfXh7Y29aWt+/+7Ejd1jtrzmGKqWVJ1RPMVQgimapGYnSyPD9+u98efe4b1778A/Dxryqs28658LQMOdCxVoASy+SPdRpD7I0+biWj4/UzGOKn5cJpfaAlmZJ5eLNv2nWJAQ71Q/0zNaCuBsilxqbK3TnQd8jrQU3xZJk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2017 15:09:07.6315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1137 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 v8 RESEND 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 ++ include/asm-generic/pgtable.h | 12 +++++++++ include/linux/mem_encrypt.h | 8 ++++++ 15 files changed, 131 insertions(+), 33 deletions(-) diff --git a/arch/x86/boot/compressed/pagetable.c b/arch/x86/boot/compressed/pagetable.c index 8e69df9..246bf29 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 f3b1b27..8010c97 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/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__ */