From patchwork Tue Jun 27 15:09:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9812441 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 4EBBF60351 for ; Tue, 27 Jun 2017 15:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7551827FAD for ; Tue, 27 Jun 2017 15:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6942D28589; Tue, 27 Jun 2017 15:13:38 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3E9127FAD for ; Tue, 27 Jun 2017 15:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753250AbdF0PNe (ORCPT ); Tue, 27 Jun 2017 11:13:34 -0400 Received: from mail-sn1nam01on0047.outbound.protection.outlook.com ([104.47.32.47]:41712 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751541AbdF0PJo (ORCPT ); Tue, 27 Jun 2017 11:09:44 -0400 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=ZdBosiV9qxJe2azi1DD6Jmr4pVvxbVFcw8/JCFkNaE0=; b=Gu+VV1G2jn+R94hW52phw1S0/TtGiukyX4lbUukNGdjbjQgxn2Zp8OYEaO+NTaPMvWB8LWmFaJ9N8cqtaB1HBGKNH61DdT5L+Xa3i4fzcKP4PuanbUGhPLRW+Rt+24aYZ4Dx2Y6qNmGTFH7vBRUvMbWRchdGidXBvWBGQomzcRg= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.78.1) by BN6PR12MB1138.namprd12.prod.outlook.com (10.168.226.140) 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:31 +0000 From: Tom Lendacky Subject: [PATCH v8 RESEND 12/38] x86/mm: Extend early_memremap() support with additional attrs 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 Cc: Brijesh Singh , Toshimitsu Kani , Radim =?utf-8?b?S3LEjW3DocWZ?= , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Konrad Rzeszutek Wilk , Borislav Petkov , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , Thomas Gleixner , Paolo Bonzini Date: Tue, 27 Jun 2017 10:09:29 -0500 Message-ID: <20170627150929.17428.31589.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.78.1] X-ClientProxiedBy: DM3PR12CA0063.namprd12.prod.outlook.com (10.161.151.31) To BN6PR12MB1138.namprd12.prod.outlook.com (10.168.226.140) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 859ae3c0-7ddf-4264-ab9b-08d4bd6e849a 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); SRVR:BN6PR12MB1138; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1138; 3:7LZadyXxsC7hFWpgvER9HC7ROMwwO39cTu7B7trhHey3LXJuKvJwalqaCem5hk4RVge11WdcdY8pHTyMN1mcMWPBz01c1+/NBDcCcWi8FVytQBPrxTcKTcebd+JwvjZ4hGXOvxZ+FstGplCdb1YZINCBfoh4qkhZwLr+tNSgq9SfTq3hOAJ3Dov9lLppIPJhxo63lqEU2v0SBtDuemh56Q2qsCqdISxTieHBZHijZH5meQUHvkPZgVmYygjIp+areEXkRiXDOEwN4XBFSprqpFw2sJnWHNAI1YD845ofFfG0n9F37ujBDrXikE5Qkjl3xTNc5qPXU8eP7Jewk1r1DDpOfXPHCxvu9QMnhBVB+Q003rEhVDZf1f/uLHcGc7BA67KR33633jzIyHfDF7NzMW/ZegvG6WbejDim+RMbIZAZqnKohxn3oY9Dy9NHh8fYs7RkTXWH+zq+NVv4APSFxJAUqUv+4scDa4EZ8HpLzp8FgCmIg8UI8PDzWtAjPc6mXSIEdb+Dr76bhxEHT9p2YHlpR9jmg+hSkycZsr7LOnguOBf1BTtTaBGf92JWR9hXkO/ZbaCH8iEdJfFgHzfRbn4WSlHZdg/czIcMMp4YPomPjA6uMjrpyi0m4tjdjhH3+UbAbxsA/NfpCsE6XfqgeJKe251YN6ndodG3Q7UdEwmQ52/r1dd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aBjOyOopfuG60/e0kmy52SWEs4lorrxHBzx1DTZ32RMTXhfsBVZytIjgtxEUuWn+5k/E6VpZvhYTd3z07hyHstRDZPF/9dGsulHWxLnFePqSKxwYQ3PD5RF7tzHTvzC0oBcj5RXZKgMD8SfTTT0lHTGHoW3RifaRdeuTVFnSxzLeh X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(236129657087228)(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR12MB1138; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR12MB1138; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTM4OzQ6OGYzMUNvYXZucVZFcnFTRjNiemxpQWRMWHZV?= =?utf-8?B?bDZQWGtKcTZmY2pPeGhJWWM1TmV2MGYyZHlGYWNEeDJjOWRFTlNJdURVNTQx?= =?utf-8?B?YkJUUjN1ZXZ3Wi9DRkNrR1JOQTJ6NVBFVWh5ek9SdSsvR2NVcXpHWGVZZldU?= =?utf-8?B?Z3lsQkdaOVFQeXZlTjBwQnJpeFVhZU5QWjg0QVV1U3IxdndLVVhKdFB1eE16?= =?utf-8?B?M2d2WDNieW1yOGVlam9LR3ZJRjRVVTZjMkJrdldwaEUraENmZGpGQ3cyV2NS?= =?utf-8?B?Q1dVNlRGTy95RXVnOVhrNnJhV0VJalNXKzF1QkhEaTJYUTd2ekpQRm80aFF1?= =?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aemIwUkpi?= =?utf-8?B?MTFFVFpqSG9Fd3JEUE9ZcndlY2loeEpabWJiWUV4TlE3Z1JpcEFsTzZjZTI0?= =?utf-8?B?ZUE0WldiSXZ2THdNcEZpUjBjNnFJd3BXdnA1NWI3eDJFanMvZ0pYbnBNRkFs?= =?utf-8?B?TENLTVBlS0dOTXZ1Ry8rdHB3ZXJwN2FOZ2I2bzVIUVlVWlo2VXRrZDBBNDJw?= =?utf-8?B?cytDc0hGNUpKMFREaXlHeU9uMkRmZkdZU25QWTBZNS8ra29XM2o4OHRQU1FF?= =?utf-8?B?ZjVHVXl5U2R0RWd5cEVWWGZrYXoyeVc3UXpEL0gwQ3pyWXVvdmZjQWFlVVc3?= =?utf-8?B?bkJjK0orQ1BrUkYwMXdWVlk4SWo5Y1JiWjFUUEpaRHU1NW1HczVIOHBkUWRa?= =?utf-8?B?a1BUNFBtRFBkdDUyWHk1S0F5U2RucjI0VW1jSGJrcVAzMzRlN3BISXFxdzA5?= =?utf-8?Q?tr1pRFgslcTLytvigC/qJeUnrCH82gaTTN2Ysb?= X-Forefront-PRVS: 0351D213B3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39850400002)(39400400002)(39410400002)(39860400002)(39450400003)(39840400002)(189998001)(47776003)(66066001)(53936002)(33646002)(50466002)(42186005)(110136004)(103116003)(38730400002)(53416004)(1076002)(478600001)(54906002)(6116002)(3846002)(7736002)(6506006)(72206003)(9686003)(55016002)(4326008)(25786009)(305945005)(230700001)(5660300001)(81166006)(7416002)(7406005)(2906002)(2950100002)(54356999)(23676002)(50986999)(4001350100001)(76176999)(83506001)(8676002)(97746001)(86362001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1138; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTM4OzIzOmFtVlBFZEdJSW5SR08vYkIxT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jGDeS1l+LfhVQQF6sYt+AipZdVvYKPWrIWO6HkEvsL1fql0K89HS48WUPt8eSK/yj6anU5xMKUbHEc/Xa8gf9h71KYNdl77GMMiQBaD9Cw69B/cSZ6l64J81NyhprA/Ffgf9nNg7X6I9dldNuadcrM41Cob3UzZThl8MgBa2i/vfKU6tGZHf8KOS7K4LOXJF2M785dj4wJKAfDh7s X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2017 15:09:31.3144 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1138 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add early_memremap() support to be able to specify encrypted and decrypted mappings with and without write-protection. The use of write-protection is necessary when encrypting data "in place". The write-protect attribute is considered cacheable for loads, but not stores. This implies that the hardware will never give the core a dirty line with this memtype. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/Kconfig | 4 +++ arch/x86/include/asm/fixmap.h | 13 ++++++++++ arch/x86/include/asm/pgtable_types.h | 8 ++++++ arch/x86/mm/ioremap.c | 44 ++++++++++++++++++++++++++++++++++ include/asm-generic/early_ioremap.h | 2 ++ mm/early_ioremap.c | 10 ++++++++ 6 files changed, 81 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3a59e9c..a04081ce 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1434,6 +1434,10 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT If set to N, then the encryption of system memory can be activated with the mem_encrypt=on command line option. +config ARCH_USE_MEMREMAP_PROT + def_bool y + depends on AMD_MEM_ENCRYPT + # Common NUMA Features config NUMA bool "Numa Memory Allocation and Scheduler Support" diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index d9ff226..dcd9fb5 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h @@ -164,6 +164,19 @@ static inline void __set_fixmap(enum fixed_addresses idx, */ #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_IO_NOCACHE +/* + * Early memremap routines used for in-place encryption. The mappings created + * by these routines are intended to be used as temporary mappings. + */ +void __init *early_memremap_encrypted(resource_size_t phys_addr, + unsigned long size); +void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, + unsigned long size); +void __init *early_memremap_decrypted(resource_size_t phys_addr, + unsigned long size); +void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, + unsigned long size); + #include #define __late_set_fixmap(idx, phys, flags) __set_fixmap(idx, phys, flags) diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index de32ca3..32095af 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -161,6 +161,7 @@ enum page_cache_mode { #define _PAGE_CACHE_MASK (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT) #define _PAGE_NOCACHE (cachemode2protval(_PAGE_CACHE_MODE_UC)) +#define _PAGE_CACHE_WP (cachemode2protval(_PAGE_CACHE_MODE_WP)) #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ @@ -189,6 +190,7 @@ enum page_cache_mode { #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER) #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) +#define __PAGE_KERNEL_WP (__PAGE_KERNEL | _PAGE_CACHE_WP) #define __PAGE_KERNEL_IO (__PAGE_KERNEL) #define __PAGE_KERNEL_IO_NOCACHE (__PAGE_KERNEL_NOCACHE) @@ -202,6 +204,12 @@ enum page_cache_mode { #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ _PAGE_DIRTY | _PAGE_ENC) +#define __PAGE_KERNEL_ENC (__PAGE_KERNEL | _PAGE_ENC) +#define __PAGE_KERNEL_ENC_WP (__PAGE_KERNEL_WP | _PAGE_ENC) + +#define __PAGE_KERNEL_NOENC (__PAGE_KERNEL) +#define __PAGE_KERNEL_NOENC_WP (__PAGE_KERNEL_WP) + #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) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index bfc3e2d..26db273 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -414,6 +414,50 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK)); } +#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT +/* Remap memory with encryption */ +void __init *early_memremap_encrypted(resource_size_t phys_addr, + unsigned long size) +{ + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC); +} + +/* + * Remap memory with encryption and write-protected - cannot be called + * before pat_init() is called + */ +void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, + unsigned long size) +{ + /* Be sure the write-protect PAT entry is set for write-protect */ + if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) + return NULL; + + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC_WP); +} + +/* Remap memory without encryption */ +void __init *early_memremap_decrypted(resource_size_t phys_addr, + unsigned long size) +{ + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC); +} + +/* + * Remap memory without encryption and write-protected - cannot be called + * before pat_init() is called + */ +void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, + unsigned long size) +{ + /* Be sure the write-protect PAT entry is set for write-protect */ + if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) + return NULL; + + return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); +} +#endif /* CONFIG_ARCH_USE_MEMREMAP_PROT */ + static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; static inline pmd_t * __init early_ioremap_pmd(unsigned long addr) diff --git a/include/asm-generic/early_ioremap.h b/include/asm-generic/early_ioremap.h index 734ad4d..2edef8d 100644 --- a/include/asm-generic/early_ioremap.h +++ b/include/asm-generic/early_ioremap.h @@ -13,6 +13,8 @@ extern void *early_memremap(resource_size_t phys_addr, unsigned long size); extern void *early_memremap_ro(resource_size_t phys_addr, unsigned long size); +extern void *early_memremap_prot(resource_size_t phys_addr, + unsigned long size, unsigned long prot_val); extern void early_iounmap(void __iomem *addr, unsigned long size); extern void early_memunmap(void *addr, unsigned long size); diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c index 6d5717b..d7d30da 100644 --- a/mm/early_ioremap.c +++ b/mm/early_ioremap.c @@ -226,6 +226,16 @@ void __init early_iounmap(void __iomem *addr, unsigned long size) } #endif +#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT +void __init * +early_memremap_prot(resource_size_t phys_addr, unsigned long size, + unsigned long prot_val) +{ + return (__force void *)__early_ioremap(phys_addr, size, + __pgprot(prot_val)); +} +#endif + #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT) void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size)