Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752820AbdGGNkq (ORCPT ); Fri, 7 Jul 2017 09:40:46 -0400 Received: from mail-by2nam01on0061.outbound.protection.outlook.com ([104.47.34.61]:14704 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752777AbdGGNkc (ORCPT ); Fri, 7 Jul 2017 09:40:32 -0400 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: [PATCH v9 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: Fri, 07 Jul 2017 08:40:15 -0500 Message-ID: <20170707134015.29711.5885.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR12CA0057.namprd12.prod.outlook.com (10.175.83.147) To MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f52577b-5825-4cde-dc97-08d4c53db803 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:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;3:TW9HwZ3fdQrgrFsyMvFySSZDQ7CLRpu4HnDSSPGJ+Zt/NlemAi9Q6Qff4d5XsFdSmwcgrq+AZp0kW0WkdRXB+6ECRUqed2fghsWBDr9YLuaUVokigRcVIY7l9sKDXO8Av6ugWMMrHGdPdiRduf7lOMSt6Xp32m2U6CLACWIfpZyRm3tdUOlBobY85dYKSpxKgqFsykRXyc0/vLdRa45aw4cJAzfBznNqyTgiNg9UtXPyjC5qmm3SL5/ESRSSvfZSO3qULQobGw3m0uxuGNUp+yt9BuhJE+Wf936fnLe1mdFXzFiUjvrsAEHRZwjyF3EjBXTgzSYYkIH+gwFDBctNpL+sMIY87KXtzjqAYXQISc8QAslSYoUMh6OOBUx1xO/rYWJ7YtIyWMKlwx0ZVSKrHFRWI61U6esiiKd8A6OMWQCEYTzBa1R/8L/PSVMwkAIcf0p2G1E1Eg7rR25sOEMMbQFOVilTjVOXwF0vSiBSQRZQQ4/i2WbFe0H11BQTBUCusu5NG8yjyUKlOVXyjg1KMqsqpBw7IJVtbwuRmiOtIeu9om6Zl4gXQoolhS2+v0UpKp4xSLvvjjD6109NB2gsV/Liw9yMaaaxaKqkI7Aw1yNqNW41wj4Qp+lFgW+YNm+yxPfufqp2IE/jLSZ5kD+i1O5Z7KAsEAirmvQNUvxfQOy5guocM5Xt6c/ZhWFoPD07gNbet5c/Vxcq2ISkMcLFfvWfomEaB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jm9pBt0XJdktaiex7v1vZ+SLvE75nNKv8xrXSW+ItyGHaaEOsN9BX27pSWTEO6VUsFeVzGK1tldW4drDPKyhWUy7UyT1IMsrzMOWsr+roIkd19mRAixGfdT9216Yss/X8naYae9ZY+B5Grhyl/C8/GWFmSEtgW8GTd5Kcb9y+/c+p+2xVokoLqhtOUjj 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)(2017060910064)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR12MB1149;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzQ6WnlVZEZPQzVhVkZML2tpZ1htVWJKTURIc3lY?= =?utf-8?B?dFVZSjVRZlRGSytwVEFaRk11czE1MXRndjJYME9WV0ZabFJlZzlUd2xwOU5N?= =?utf-8?B?NmNSVVk3RHJjeTVRRiszakg0dEo1R3FnVEsxVEgxbk5xRzZ3WDJWankrb0tB?= =?utf-8?B?eUU1cXN1QXNJWDd6UzYzNFJ3aUJPWHg3Nzg0SVZ1Wk51TDdPc3Y1OVJnRDVt?= =?utf-8?B?S3JKanpFdFBJNVIzOEJYd2d6UTlLMTlVT1dwUWhISFM5SlA2dG54NmN2cDRu?= =?utf-8?B?TWhJKzB6d2lJb3Z2dHMrbHZDQ1NkVFd6d1NldnhwQldMcV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KcjUrOVFENEY0U2VhWU1CcHYvc1NZRmwyOWFKN3pK?= =?utf-8?B?dVJrYndkb2k2U1o1NTFGTVdVSXFzbnZtOHIwSjlORE0rWVYreG9nNWVVYm0w?= =?utf-8?B?RjM5YlcxVVFMWENNbGs1TUREZk4vV0J3WStEWUQyRm9HekNhUTVxWnNqcEUv?= =?utf-8?B?eENnTS9xRWhJcGZ4a2FKUXRSMVJoV3hJaXZNVXRZaUgrbzRORzBSN25ZeW1H?= =?utf-8?B?WnFvd014UlJ0MDVKNTByYnZaZ2pUMlVScTRBV2IyNEdzYUlRbm1lYmZZWXZa?= =?utf-8?B?cm9obk9qT24weEhpYkM2UTl6aitrV3JMekUza1pLcEZiRnA4Q2tyRy9tczBH?= =?utf-8?B?cE5rYXBvU3RDN3FlU2Q4dXNUWWZ2U3hXV1lVbDZKMnNGQVZuS0xXYUpITVBT?= =?utf-8?B?OVhNak9hdlZhU3BSMmhIYWtXUXN2SWRHaHU2VlEzU1J3OExrL1VkSmtERi84?= =?utf-8?B?dkZWZUduRlpSSml3dCt1ckZpcVc3bzlUaEluaEZCV1BuejNEZWNaN0lSVXB1?= =?utf-8?Q?w477VKxIxi+vI3gyR9ctKzL8exg6RH3tmLGc=3D?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39400400002)(39850400002)(39410400002)(39450400003)(39840400002)(39860400002)(9686003)(54906002)(53936002)(33646002)(47776003)(103116003)(6116002)(3846002)(25786009)(54356999)(76176999)(110136004)(38730400002)(42186005)(1076002)(53416004)(4326008)(50986999)(230700001)(66066001)(6506006)(86362001)(55016002)(6666003)(2950100002)(2906002)(23676002)(305945005)(189998001)(50466002)(97746001)(478600001)(72206003)(81166006)(8676002)(83506001)(7736002)(7406005)(5660300001)(7416002)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1149;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;MLV:sfv;LANG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MlcG9TpXUynED6fLbjCFjLokqNUMwrxKX7MYbuhGjQlN4Vm+1qS1XJN5aaJ+w3bXuPifmOEi2J3TGN5nT6gc7sgJYFF5XNjRiuN2pSUHwu+QwUO2ohb4c5jrQ8fKyh3VbRBpan1qfW9xW0uaqYHRAUczqq6ZudcNgAMuFCvLAcm1FWT6NM7gu7JCD9s7WvCNi1AA/s9SaL+rEE4udrdmZ9BnOVG/s5kPISc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:40:21.6112 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1149 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6894 Lines: 179 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 0f2f8b3..ad3ddc6 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1435,6 +1435,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)