Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752687AbdGGNjh (ORCPT ); Fri, 7 Jul 2017 09:39:37 -0400 Received: from mail-dm3nam03on0084.outbound.protection.outlook.com ([104.47.41.84]:43968 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752633AbdGGNj2 (ORCPT ); Fri, 7 Jul 2017 09:39:28 -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 06/38] x86/mm: Add Secure Memory Encryption (SME) support 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:39:13 -0500 Message-ID: <20170707133913.29711.72455.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: MWHPR13CA0007.namprd13.prod.outlook.com (10.169.208.17) To DM5PR12MB1146.namprd12.prod.outlook.com (10.168.236.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cad733cf-3ea2-46e7-3d2f-08d4c53d926a 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:DM5PR12MB1146; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1146;3:3HUG8AeufF1eDY7uSqVLbRovfcV158uU8wKClbC1ryg40Rp4GT/cbkrnRtEgNCXZvUI338ExsjaeP5ew2Gl0yUjxRvWVcs0c9ewS/VRcQ/t3kJb0gkXG5sx29GqpKaaitdMGqQeiFrL32BVlp8y1TeMellrUvr2SNC1NZH/fw/mrSzrGzrYZlwI3dHIha5LbS/O8cx4hk6/pK3tKZ0f4w0j/ZDWiIwGIFBLWW94z6BWoMj1dFKO6Bt3GGO94Ck+4nAVcY5rSFvvMOiBRUMbAWH1HatJz4/HaxSQcGuJJ4GxQGEXG+ZEs8NAtbL0Fgkewq3MaMgqKCpRMhktsNN7HtnSOW9THyizKPuLKFlZnrwBdLfCrRgYJZ9GXXu7i9OS0QsBCWzKwDJsMHviSeWCAA4LCtwWH1DwKsEckxhGLwzp5EmEVRLqpnfbYdpd6k/Ge4j/jQLclBP6pydyKfmbCSMpuQUgX4d7FBnpBU9/bH+dXXhYK+bb5b74zTRcsaGHz6zqpi7zkJtE9f1CsxcEXurEhHZpIo4xKwAMqhrtR0yRCHCqcVKCcyI8C7kNrStW3pMPWQCE1jWYfqpiw9bVFWCLJ6SuRoJ/gANpWPDltQZI+o4MicxnFuQOhhFrMB75y5BxuruN8xAsdi8TBSA+SwTFEGIrwdt/gTEED3ix7r4j/pWM3e8/wTEEc1pFwgmPc+rt48cLCMZMPy2aOQO7M0ESV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XUE8Gt8BzE0b1UlKeta9X5VZzzFdlZfDRXJcwyfQikSHKVw6o6Gx32qEXChowY02ETpqNI+J5m99se27+ybhNhpMkRQHH67M1mT6dfZeXkjxBcPHA3JjJU2zDs78QfaLxa2+unZ23E7IxDaZGgPpDKl+F3tu1qh9fCb36niVO4De8kYh5sYR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(125551606395959)(133145235818549)(236129657087228)(767451399110)(148574349560750); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(2017060910064)(8121501046)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR12MB1146;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR12MB1146; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyTUIxMTQ2OzQ6cjhWeTVnSVJicXg5UTJKMlBrbk9oOVd2UitE?= =?utf-8?B?WUUvZkpXMGc3SHJTWFB2K2pvTWlPVWkrcFN4c3BJKy9ZbmU4WmQxUVBTcXF4?= =?utf-8?B?eDMxK3JPWTVRb3g1NUxJYUF3ZUl2Z2pCZ2xQWEx4Y0c4Rk5JUitGbnZNdnA0?= =?utf-8?B?U0o1MDlSaHYrcDhZc09OSnRKTElpeGdSeWd3OGZnZzFKTmJQSlkyRXpnOGRq?= =?utf-8?B?UGVKSUFNblF6S3EwOHovSjgyenBkMklScWxFVmlTWk04MmQ0d3NTZ3hMQ2xz?= =?utf-8?B?b2NWR01DMm5EMXd5ZE1hWUsvamFwNkdoTURycjF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g2bS9rWWpGNzI5WTRMSzlLMGgxclB4eHd2S2NFYStv?= =?utf-8?B?a3VPQWt0Z1ZTU0NhUXVERUptL0RRMUsxUUlDUWM0MmNJVGhSek05YVZ5cmZM?= =?utf-8?B?bHdKVW1YU2p3Nk8wME5OYjRiT05MN1l0Y1phb2hEd3AzTlJPU2J4emVmZGlE?= =?utf-8?B?UHdrb3FCWmxJd0UyN25RZ1RGOGYrMU11Z28zcUx5LzhhWVZyV1gxbVBsN2Jr?= =?utf-8?B?WnVIYkxoOEpXWmlQRFlQYWVMSHlOMnZKTzJHTWY1YTJMdUIzZ0h1aXdBVDFw?= =?utf-8?B?UXl0OURLdVVMMER1bTlKUTdCQlN1SHErMFhrVDdaeGJIWk15TEpNbmhuVnEv?= =?utf-8?B?SEYwaHFZT3ZWeHYvVC9pbWlUbUhrSXNNbGE4TVE2WmJDV08yQlpTRzd4YUxz?= =?utf-8?B?bTBOUWxON2hQS0xHbGhISFdTa0VCaHpCUlpZWkxRenFUODJCbFdncEtBbEU3?= =?utf-8?B?VUxMS3JkMysrNmFwZGw0Ni9wWHFsVk9OcmdVRG5meFhKV3VyUDVvOG9JaFdF?= =?utf-8?B?U09RekZvdWRQMXVJZ2tjY0FLbnlZYWEvRmMzdCtYMVgwMFRPRG8rcHNkUVov?= =?utf-8?B?b0YwcUp2TTc5aklZRHJxSHZGdFgwcnBmbTB2R0tpRjNrZmRsVG9BSStPVnJ2?= =?utf-8?Q?5JbsS3K4Nc=3D?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39400400002)(39410400002)(39860400002)(39850400002)(39840400002)(39450400003)(2906002)(81166006)(42186005)(83506001)(189998001)(8676002)(38730400002)(305945005)(2950100002)(103116003)(53416004)(6666003)(4326008)(110136004)(33646002)(25786009)(6506006)(86362001)(53936002)(47776003)(97746001)(50986999)(23676002)(9686003)(66066001)(7736002)(76176999)(72206003)(478600001)(230700001)(6116002)(7406005)(5660300001)(7416002)(50466002)(55016002)(54906002)(1076002)(54356999)(3846002)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1146;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyTUIxMTQ2OzIzOjNGZmVZejMwWGhzWVl1OXJySUtzWlZpZTlI?= =?utf-8?B?azY5RWQ4bUNJV1IwSEtvM25YVGtEOFZUbE0xZWJxV2pPTlh1NlJna0J3Qmh6?= =?utf-8?B?SS9zVmFkeGlYbm0rbE9EYS95QkFBb3FQQUZadkhLN0VLZ3NQd0ZiZjZtRjhT?= =?utf-8?B?d2l1RHcwaW02TDJhbFBFVUpQcmlYMElVSkg2ckhiZ3dlRm1PcG5OTTlKeEk2?= =?utf-8?B?N1hIcTc0M0Q3WmUySVZMWEQ1b2I3UVd2Q2huMzJ0VURGc0l4azBzVmwxaDFa?= =?utf-8?B?WHhIdnVmK3gxU0RVK0drVVNxOW0rUFM1Ni9uL0dVa1VQcEtRdzBHUDBwWDJs?= =?utf-8?B?Y3dhMzVXdXRWbjh2b1lieG1JS2JSaTZWWWR6NkhyUnJ0MG8vUnFzYzlJb29T?= =?utf-8?B?Z1BLaGFEKzRsK1IxZGthV05pR2UrRmJiTVg1bGZwT3FyWjBTdjZvRVNvVVZy?= =?utf-8?B?WXNsT1RHUEtFSHhoZnlqY3Nod29TMjZXWTdlWnhYaXZwOGFtdFNvRlIvOTRt?= =?utf-8?B?VGpkRWhqTlN2ZU12ZGxrYkpad1E4YUUzZHRuZHUvN1Z2MmltZVluNmx0WXlI?= =?utf-8?B?M0pBdWlweERuMStpeFFoOXpBVDZZQ2ZvSkxSdWp6WHdacmVweGx1TW9Qdmow?= =?utf-8?B?bHd1N2pKazMweDZmak8rbzVzc0dyb1RtN0kyZUJ5ME9QUTRjSnU3Z2ZKVFcz?= =?utf-8?B?QUJSeEZvZjF6SUFsakdiOUp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DdkcUIiaBnLW1XVT2TnoUGTwg2OySnnadlS9m70BCiW6A43om9U3sYIeREMnKvIxFhm2JccvewZeqaNldbM5/TtXuMPd2k3uscFoMY5t4vqukEdHJvH2nTNX69fGSU/W3lM6Tw0fT3arxZEBfw/KpVIkZsYkKI/8We3Mlit+7FneDYs55nLlh7wakUz;24:nlmcuQmFEmCBzyyF3B2sX17lLX/umLPQwyAkuSDZ18XaieE/8k62jG82zFBq4IcO6LhKXVqI4T74QrkxzhODw7jZx2cxXGMqNfALrcskYyA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1146;7:0LVRcd2zLqn0Tkxh4Naa3CQiAgsxO0e6AqwQpOG7a2uH0RIpCCoTQdnipFCMP5cInjRI5Pwom2/ax3kbYdlL0d/iDCkVU7ndItx/NJlD+px11lpsVV8PtejyITWOO748mrviM84EGtO/BMBXzSclGSoAdAP6dEfwDPRUnrIqc5KD6x/zsbdh9QrIF5Hu1JCI8hbqMgvP0b228La4T1h0tJndTJW13T7vkdwF1I1BN7BaZpbpM/iutrYjvKC3ntJc1bakkgdDn4iD2b8q7tS2z/9VPTXNTGcUfq2TuBanV9QzOijn6xn3ffqKjVU3UsuOCSewPbwcw/uNZjoYb3pcy72yndCy5uX1gQGK1lfOwtsmQe1VL/V5az91MJXvuI1vBRBZdn70gMRmy6k+sGZCAAyuUQ+TfnnaHypApshHhTtXs3HDx3gi7ByUgHbxll5SUpu/AK6KRhRj2xazRPsh87qkKeReurQWj0z6dxmhw+QnFhdjcdlkcGirBmQ78y9AWrdowHRMUlRbwAfk8qpBcl19mWb5cUuzVNj4VqjX4TvsAwWn8la+CTJX7c44IWFMsirQELNTf0aFi7qaWzf5UskzdHa+IzpXpXGrVH3BiIjL89U/YiI4AgiiILaR4XFxMfBwLXtQ3tZ7HhihBlzTksxvHs0CaTuVuOBZ9HFPdfGew1AkCQ+4f5dpxRdE/UQekL0CjA/13bGP4TD7+G2UV+XqUIf14BQDgH/ICv0ncfi3O4POqTB2/6RWNp9YlsW/qNib1+DJfnrGF7TDz2x5eCaWeOjwhwroO9xBamEYnlc= X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1146;20:8r6CBRszdXwmFmimH/F0Ces7/+dSPajSAvlOncdNwalVj7wDaoFs2ljdMyb4e2EJYyLMdnRH1lVko0OKSMd11ofnto4XxWOSqm8EKlITwfAAtB3fpUG+F+CQLxLW7z0XEoXLwbuurl9M+yayHaGf0HQUhCkhl9eUIuE3AGXZFyPVFhsN+U01Pj9lsIMTlk3wpdmAgpqTxySUAOpUGhxXW0Io+iW/DUe80qU87YIzltyEfrV8yFvjq9WIvig6ufRo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:39:17.3297 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1146 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5060 Lines: 167 Add support for Secure Memory Encryption (SME). This initial support provides a Kconfig entry to build the SME support into the kernel and defines the memory encryption mask that will be used in subsequent patches to mark pages as encrypted. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/Kconfig | 25 +++++++++++++++++++++++++ arch/x86/include/asm/mem_encrypt.h | 30 ++++++++++++++++++++++++++++++ arch/x86/mm/Makefile | 1 + arch/x86/mm/mem_encrypt.c | 21 +++++++++++++++++++++ include/linux/mem_encrypt.h | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 arch/x86/include/asm/mem_encrypt.h create mode 100644 arch/x86/mm/mem_encrypt.c create mode 100644 include/linux/mem_encrypt.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index e767ed2..0f2f8b3 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1410,6 +1410,31 @@ config X86_DIRECT_GBPAGES supports them), so don't confuse the user by printing that we have them enabled. +config ARCH_HAS_MEM_ENCRYPT + def_bool y + +config AMD_MEM_ENCRYPT + bool "AMD Secure Memory Encryption (SME) support" + depends on X86_64 && CPU_SUP_AMD + ---help--- + Say yes to enable support for the encryption of system memory. + This requires an AMD processor that supports Secure Memory + Encryption (SME). + +config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT + bool "Activate AMD Secure Memory Encryption (SME) by default" + default y + depends on AMD_MEM_ENCRYPT + ---help--- + Say yes to have system memory encrypted by default if running on + an AMD processor that supports Secure Memory Encryption (SME). + + If set to Y, then the encryption of system memory can be + deactivated with the mem_encrypt=off command line option. + + If set to N, then the encryption of system memory can be + activated with the mem_encrypt=on command line option. + # Common NUMA Features config NUMA bool "Numa Memory Allocation and Scheduler Support" diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h new file mode 100644 index 0000000..a105796 --- /dev/null +++ b/arch/x86/include/asm/mem_encrypt.h @@ -0,0 +1,30 @@ +/* + * AMD Memory Encryption Support + * + * Copyright (C) 2016 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __X86_MEM_ENCRYPT_H__ +#define __X86_MEM_ENCRYPT_H__ + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_AMD_MEM_ENCRYPT + +extern unsigned long sme_me_mask; + +#else /* !CONFIG_AMD_MEM_ENCRYPT */ + +#define sme_me_mask 0UL + +#endif /* CONFIG_AMD_MEM_ENCRYPT */ + +#endif /* __ASSEMBLY__ */ + +#endif /* __X86_MEM_ENCRYPT_H__ */ diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 0fbdcb6..a94a7b6 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_X86_INTEL_MPX) += mpx.o obj-$(CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) += pkeys.o obj-$(CONFIG_RANDOMIZE_MEMORY) += kaslr.o +obj-$(CONFIG_AMD_MEM_ENCRYPT) += mem_encrypt.o diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c new file mode 100644 index 0000000..b99d469 --- /dev/null +++ b/arch/x86/mm/mem_encrypt.c @@ -0,0 +1,21 @@ +/* + * AMD Memory Encryption Support + * + * Copyright (C) 2016 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include + +/* + * Since SME related variables are set early in the boot process they must + * reside in the .data section so as not to be zeroed out when the .bss + * section is later cleared. + */ +unsigned long sme_me_mask __section(.data) = 0; +EXPORT_SYMBOL_GPL(sme_me_mask); diff --git a/include/linux/mem_encrypt.h b/include/linux/mem_encrypt.h new file mode 100644 index 0000000..59769f7 --- /dev/null +++ b/include/linux/mem_encrypt.h @@ -0,0 +1,35 @@ +/* + * AMD Memory Encryption Support + * + * Copyright (C) 2016 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __MEM_ENCRYPT_H__ +#define __MEM_ENCRYPT_H__ + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_ARCH_HAS_MEM_ENCRYPT + +#include + +#else /* !CONFIG_ARCH_HAS_MEM_ENCRYPT */ + +#define sme_me_mask 0UL + +#endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */ + +static inline bool sme_active(void) +{ + return !!sme_me_mask; +} + +#endif /* __ASSEMBLY__ */ + +#endif /* __MEM_ENCRYPT_H__ */