From patchwork Tue Jun 27 15:08:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9812457 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 3D7D360351 for ; Tue, 27 Jun 2017 15:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3041F27FAD for ; Tue, 27 Jun 2017 15:14:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23E08286CA; Tue, 27 Jun 2017 15:14:24 +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 48D3E27FAD for ; Tue, 27 Jun 2017 15:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbdF0POV (ORCPT ); Tue, 27 Jun 2017 11:14:21 -0400 Received: from mail-dm3nam03on0068.outbound.protection.outlook.com ([104.47.41.68]:3830 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751513AbdF0PIc (ORCPT ); Tue, 27 Jun 2017 11:08:32 -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=5KdJxKL+w6r2KAuqTqr9kxwekL5aj4U8wWEp9DorKWw=; b=SYT26ulaGY1DoYzr48VxVBLEKwI4p1E+SV2BVoibciEqHQhl9rnlGdW8MTmR1B8fQWMEghpE/N/bM5w4luGeXoNMhVoBEHKZKMNz69JPpPZvGlfh8pKw3GbVb8um179ik4EPLzKSzILDTQbDXihrQ0ale8/R1Auj8WZz0nzFQts= 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.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.1199.15; Tue, 27 Jun 2017 15:08:29 +0000 From: Tom Lendacky Subject: [PATCH v8 RESEND 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: Tue, 27 Jun 2017 10:08:24 -0500 Message-ID: <20170627150824.17428.98358.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: DM3PR12CA0053.namprd12.prod.outlook.com (10.161.151.21) To CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92b9f764-2292-4256-8dea-08d4bd6e5ef8 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:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 3:1JeJKXqub3tXvI0fMWpjuvatUa34e7af+NdDobmRvMXASBZEDTJ1F9zkF4cTLXfNWrC2JNvLgU26jcACIEpwsDy0gGomwfw1lLiPVKYH3cs7nOEF3J92eYZyIOENUjWYm6AK6ryAr21RMeVKV5BX3PaOYigNwUGcfJmYpBHRlz1IsarJvizCHvMK4dTxrdRQeC13HfJD8mfBcPpu4e2AiwLpikhBUPU2yPyDg5U8mDzWPZtPcQRx18imvk+8bnIqYmngR5LPxUfcdg8Lm8hsbNMpZqAazy0NM5t1JvbdLsHfXougRUz79JkGI5qO/Zi+Sm24S/4z90wlTelsUAXuxRdGjce2pcB+6kddKSKMpsBVKI+rIhooiECzQuEkO4BwYDCOt66+jzU/u+NmCKjvhY4+2xoP7UUDTxNa7N4cNMWwMfQFZ1Tr573toBD9CqCgNbnwuFNLuXyJV7R25b5rkO9ambQ1V3l6a0Q8NBB6Hsu/Eai1aCrdItNvB41SpEqn6+Y3WmeFI1bJds0SMjpXuXVxjHbTccsztiPcWsi7IQtytBcNHjj+VI/NUVt1UmUDQJ1qB3QBHbW2qvihRWI3KfmjxG1ovsFWciea9n/6exs9F7Ef3ZbwX4w6+ij77JwtkoRio0yS0ZPJKo0rwaN5Ulh5TA/XXBRGE7q0b8/bITCaJA66o8z6+v1jrQ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Awo9foasbb/8hlG3eiddUv2OKvEy+vxkw97JNJRdJXbxFUEbIOXAXu0QxinCi9ni5hB2nXExyqzcm75uKqH+J8zvjpr1gFfjw54mrF7mswoifHkbUqPyspjsUrsxYamhZDn76UokRo21nT3zohWh8bZu 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)(8121501046)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(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?MTtDWTRQUjEyTUIxMTQxOzQ6MW42M2FmNFlrR1ZCRDBNb25lam9jWDNUNmVa?= =?utf-8?B?dHk5RkdTeXRFNmdKbmIybDBvekRaRHR6THlHdWxwUHR3K1ZMS0I0c1JkSjFR?= =?utf-8?B?UCtIVHA2UkZoNG05Zy9xbTQxRk80N1NodERYYk1ld1JKWkVlVU9Ob21qeHVq?= =?utf-8?B?ZHZJRmxBR05nQ1d6L3dvTDVIR2JMRnIwclBCNkcwQTlWcnl0VUpZbTdIMWs2?= =?utf-8?B?ZXZSVFJjYzcwSU5sclcwWm9EMFhsbk9rNW5aVGlYR1Vuam1Cb09VU0dKNHRo?= =?utf-8?B?UVp3VDd5YUNRTWUrVEovUjJqU2pkN3hKZ2ZYOWVIMXVjSnBrbFpkWGlQdTFO?= =?utf-8?B?NlRBcGN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?utf-8?B?VGo0L2ViMklYK0ZYMHh4SDNxdGlSQnd4Q2plMEZ3L3ZQbklYRWI1SUliTUxn?= =?utf-8?B?VUVVM3d4K1ZYK1MyM3NYbGNlcklITitTbnFtYXJBRnRYOHBONkNMRmZxLzVh?= =?utf-8?B?RUttaTUvZHcySUk2SEhMMXFQNGg5clhzbi9VRnFaVEwzOEgyV1JOc3NMdWFC?= =?utf-8?B?QkpuSXcvdmViMWkvWjlnVkljTzNnYTdITlJqdEUrR2ZuY2UrSTEzdzNBK2tl?= =?utf-8?B?LzZmOUo0amFTdjhnZFUxZTB6WFBvTlUrVVdGbDFtNWRwK0JQWTQyRVBuRFRi?= =?utf-8?B?OC9WVVJTV05PM0g1S0duSVFIRUFGOU5OSEZYZmVnZ2hyYU5BYkx1SjZwMUFp?= =?utf-8?B?N1BkZDFldERzVWlMVXZwbFZoMU9kMFV4czM1OUFDZUk4dThrMmp2TzAxTUtC?= =?utf-8?B?cFFBejdLOVpMRXZYZnYrbVlEdXU3RjdiWlBUWGhocXRmZW43MVlyWUdOb0o3?= =?utf-8?B?cXdzdzF3RG9hTGEwdW1GWm1uNExlaEZZV1VoSUJRdDh2dnlZdTdZQWxvaGRN?= =?utf-8?Q?Vqy3ll23gyzT?= X-Forefront-PRVS: 0351D213B3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39400400002)(39450400003)(39410400002)(39850400002)(39860400002)(103116003)(53416004)(97746001)(47776003)(42186005)(66066001)(50466002)(72206003)(81166006)(33646002)(7736002)(86362001)(7416002)(7406005)(6506006)(5660300001)(305945005)(23676002)(8676002)(53936002)(9686003)(55016002)(2950100002)(6116002)(54906002)(6666003)(110136004)(38730400002)(76176999)(2906002)(54356999)(83506001)(3846002)(50986999)(4326008)(1076002)(25786009)(189998001)(230700001)(4001350100001)(478600001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1141; H:tlendack-t1.amdoffice.net; FPR:; S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7dgQTp6pvENY= X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 20:KeAHpbxSh5C1sz0JvmIlV8X92pYSDCCccvKjz7JvHX25+ckB4fAWTyiiO7/92b2bbIcHocgks/vi4cBMaYNUOc/TIsHSvYE85v/bTBXnk+mKPEybqn76w6H1O3v00pMbaTU9rhS+qz2p6ZZrxEVNXQqV/4qctqG7CXAA/0Su6PwavvYKjzDvU/UQACrrxULjoTHh37szMWyWfbU2vUaCYy0zZ2Kdd8rF+nBxxcNAsNtdytJQD3JvL5aFgubxreaJ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2017 15:08:29.0044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 72028a1..3a59e9c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1409,6 +1409,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__ */