From patchwork Tue Apr 18 21:18:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9686355 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 01C2F602C2 for ; Tue, 18 Apr 2017 21:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E641826E4D for ; Tue, 18 Apr 2017 21:18:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAC7027816; Tue, 18 Apr 2017 21:18:32 +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 5DEDC26E4D for ; Tue, 18 Apr 2017 21:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756219AbdDRVSa (ORCPT ); Tue, 18 Apr 2017 17:18:30 -0400 Received: from mail-bn3nam01on0079.outbound.protection.outlook.com ([104.47.33.79]:6720 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752866AbdDRVSU (ORCPT ); Tue, 18 Apr 2017 17:18:20 -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=ZjpaCbvg4lN97KcMwh83iSVdoAQNiN2aPzaEKAFSxWY=; b=FXQuxJ/t7OFgUBJqE4X1hH8cDp9bOJ2QZqEs4Gymi9kDpEoYqtC3GDwX3nUA2iqE7sRnS2MVo9X1QP30y2y+6fT/t9oHEDJsOkzGM5MLHV9Y5xEHH24y6sy9YcEc4mwz/FrOPX95VHud6sfPT5ZJ1PcpnEP4dd+V2v2QcbwnLws= 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 DM5PR12MB1146.namprd12.prod.outlook.com (10.168.236.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 21:18:16 +0000 From: Tom Lendacky Subject: [PATCH v5 11/32] x86/mm: Add support for early encrypt/decrypt of memory To: , , , , , , , , , CC: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Date: Tue, 18 Apr 2017 16:18:14 -0500 Message-ID: <20170418211814.10190.45922.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> References: <20170418211612.10190.82788.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: DM5PR19CA0022.namprd19.prod.outlook.com (10.175.226.160) To DM5PR12MB1146.namprd12.prod.outlook.com (10.168.236.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee21200b-2dab-4454-b003-08d486a06e72 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:DM5PR12MB1146; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1146; 3:57Xv2nj6z0alXTjhVcjEoY0NLIoDZBzk6TZG8leGZWLfXMTziPKPbgBjNdN5J4oVuWE/K1BrRDw3BXTOk6bW4hjOhNeB65NAUWpefMlr97rMfXVA42Ka7Nn3VNPmK1Io6jks1E4aB9+72VErB0qhoxIoEhl7YWHvR4RCmWtr8SyLzuzCdJoBIIZYjEMK5Ekiz0vQyBUYxONtdDP295cTQzfy5rnVczX4ghho8gmbqUhY33QedtVxxFq+t849aZ/OT/1WVaX1+46GZlvKPnppgmKf8iS4fOFVjEErsL7pBdm0kOoQc+RSLUOLu+uaMyyjwKUnIPPyxx9VITufgBjBEluQvI3Iq8efWahVepc09b4=; 25:6G5kPbaPdcKz3Q9mA/UYvivuwqApCXeCyf1J+jIykeh6wziEIkKGXqK2ZazcMKu3dzQEcJLUgi7H0I7MqbURpOzElcGsaI5Ans504iCAMVJHTjG4UkF6W6l9TpQFt4LqeaYyt42a7gavcIJdXMKG3zWaYXwL5Xaz+/WVelbNQweAkVabEiN5BJQMwYKX8XFSjVaXd1TPizSitFV3vMDhdpH8mfKFae2hdvcE3bKoBRYvBIn5tH+SgO4MGE+4a4ZVQopzQOgKWwAoUG1VbEDMsM5BSTZWz+EF9uX7XMLzMq1eHTpXbOuHJovln1Fbhb2hc1lTcwNzEgraRrRKG55fdqjaWk6AOzuoBD8LbmC2uKjMNzT+LNF0IX7qI6DYjjO7jIVvkkfZXY4IDZNbRjutPzRRkkMJuq9xkGMLkkMmxKIZMqDIUzyVudBphEub0WxrjIGvtYRKRLaFcev3p8HIVA== X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1146; 31:Id0+ZBtMFlvP7KG5Vfudd2IJbEHYG9xvzZ+enLM6GLZ1Tbv53nivu3CtaISjXD2RxxsNumiquktLMyxjgmL4m5sttq7e8z65o71dl2hrtKBfMtlm/R69vIe9OVfrSjTZJsyRKC1pQ70M7mzyv5ym29drlfrrkuuwUTdqy7t/4xLsouPEqBIX1ggPrrREsAoUPo9ciFaLmWucWAX+zJXDBxsuMiYJ3/Srcs30aWydGjU=; 20:ld/XUye2tNE9jn0HdwI++W4qywCc5K+dUtQD5/d9trS1fNa2ez8kgHtQBAEoTpKlFRoYsbcaYpHXzeLEH2UB6SeeQmzWKbn/qyN4ESnshMmdqS6AIZZ26CGy+da827APtUE8u9MnQ8cYtHIusfIzRmdRnAUkAPnSjoUxPe656TO91CTWdqy47ARhrShU3atyYF+NXCJPxyGlwoTW6e07uPr+UoDN+wWi17t0tpqB99xOdtprB+Hkl+Nbj3DEyRiPpqKb/oUsPMV4FhuH3Gjm7/7CD9kpy8rqEp0t8xsIiLfu9YXDlWEOlERz1ijrBZUNZOi5QUx69NuPcvQ9W1AsKPWkIUDdh3wtdXmosaZMbj0yJ26cmZYykxy84tkeALbz0qgjsXlkHTHs2k1hU1cNo+VRTlLdWOcajRAJmS2kdF5XC3jAbCCtjLZdi5g7iGoUefSusW48WqAtQDJM5u5EqX0LcUogzA8oOMdCjxc/VfvWoW8vlJ7DhZJRyqiEsa6t X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(20161123562025)(6072148); SRVR:DM5PR12MB1146; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1146; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1146; 4:+p9DzFrsXYTxV7LAG2a7sBHtz41igqC24FJZ/9Lx5kdKX0uCu7hFyKLepcl9BpU1Jv3JowVyrNuS88ZQZMYKAK1pHlYUJV2uA3sWGn+XP9rQZK+sd5Y7uza2C/Hd0tVbwPAICB0nCugjt2qy4AstyZo0tGYwVZKUf7F+3sSjs+zrxbzDV0MlbIPwSMFA9O5RWioVFgIf7EMgapqcHDEdLh968mdIKR2cwIz50eJZnmpMFhecFKuAtYdo40c49y7i+VVb35khD5Agc6kemutnx03LDNG4rGarIi9ogWrhnB7jrVy20fN0dBmYvnm/jH3rwPhtneUaHrjZ8s0y1Zkzu+kb4+1F3u9bD6hEohgzCUh948rD/2ooQInKQv1Dp0EJ9RQ/7pHEbA9bw0RKZcSzlXBn9Ix0WvnMJzNdBE9eHL64LCvxa5anabcZ+uyqwm7tnG1DcbryDLnFAchC8uYQjjtq0dZ3Vd8bCjYsxpndqFYRQqSmCP/kTl2wY9aV7HDoT8owO7kx96rs1ymoRGa/nwX7xzTB1ukxC6JEIwLxhztRkOw0qsaWTpmK/c+P65wpOEOqsk+te7KfQJeDpMykobkAaILmfcBqmvkox8ni8/lDYTjEPVyaBbmAiJ3Y8qcP536D6OzlGkHukBH+KARRszUywbvu1iil1eZDVqqm9Xss26w7xYonAsQPzU5wyb8vcS5ED3yrRzTPWUrWJfhGQLAmfMtldrr0n/w7UkOC1kWFrHr1xnmbccio/W/wyaxkhykBOvA0wII4nTr0jPcP2g== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39410400002)(39450400003)(39860400002)(39400400002)(39840400002)(39850400002)(97746001)(23676002)(47776003)(2906002)(1076002)(7416002)(189998001)(9686003)(54906002)(6506006)(7736002)(305945005)(76176999)(2201001)(54356999)(55016002)(4001350100001)(53936002)(50986999)(86362001)(7406005)(66066001)(8676002)(3846002)(25786009)(50466002)(5660300001)(4326008)(6116002)(83506001)(230700001)(2950100002)(81166006)(53416004)(103116003)(38730400002)(33646002)(42186005)(921003)(71626007)(1121003)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1146; H:tlendack-t1.amdoffice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e/2ZirS5s3iCxUUuAXBFiPhBLp3uFHU8WngFRwfPgjjgUaxLlVLRdhp6p51qPlQvOzSi1i9OvI+Wn51NTJ2DrgPcfkvF2ONGO3C57VFMxJDP17iQUgWeEw+mUCEeIrSEr67NGlSb//WKQTMO2DCn6g==; 20:lW+11Xq3yHBO0MfmNWySi3kBdCwq0D3zGRBYK8bmRRTPrZKNu3SwJppW5MXZVSKVOALZFwJVfEulPh4wQDFMV8R6et9rooEDwGd08Rw41Td+l+AsCzXRXYUJzB1uqAi/LP4HD4nOOIuvwhEuTZ3qzVP+tPo6+3u3ZRoz2VRu7qPI2rCEpUqdszH7hN5nMst93vICLd1Jr081MNKeun093ICSbnsY8DUlfc7QrhaaVogsiqX8V2vNr12/RIYzh2Na X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 21:18:16.4615 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1146 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 to be able to either encrypt or decrypt data in place during the early stages of booting the kernel. This does not change the memory encryption attribute - it is used for ensuring that data present in either an encrypted or decrypted memory area is in the proper state (for example the initrd will have been loaded by the boot loader and will not be encrypted, but the memory that it resides in is marked as encrypted). Signed-off-by: Tom Lendacky --- arch/x86/include/asm/mem_encrypt.h | 15 +++++++ arch/x86/mm/mem_encrypt.c | 76 ++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index 9fdbc53..4021203 100644 --- a/arch/x86/include/asm/mem_encrypt.h +++ b/arch/x86/include/asm/mem_encrypt.h @@ -26,6 +26,11 @@ static inline bool sme_active(void) return !!sme_me_mask; } +void __init sme_early_encrypt(resource_size_t paddr, + unsigned long size); +void __init sme_early_decrypt(resource_size_t paddr, + unsigned long size); + void __init sme_early_init(void); #else /* !CONFIG_AMD_MEM_ENCRYPT */ @@ -39,6 +44,16 @@ static inline bool sme_active(void) } #endif +static inline void __init sme_early_encrypt(resource_size_t paddr, + unsigned long size) +{ +} + +static inline void __init sme_early_decrypt(resource_size_t paddr, + unsigned long size) +{ +} + static inline void __init sme_early_init(void) { } diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 8ca93e5..18c0887 100644 --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -17,6 +17,9 @@ #include +#include +#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 @@ -25,6 +28,79 @@ unsigned long sme_me_mask __section(.data) = 0; EXPORT_SYMBOL_GPL(sme_me_mask); +/* Buffer used for early in-place encryption by BSP, no locking needed */ +static char sme_early_buffer[PAGE_SIZE] __aligned(PAGE_SIZE); + +/* + * This routine does not change the underlying encryption setting of the + * page(s) that map this memory. It assumes that eventually the memory is + * meant to be accessed as either encrypted or decrypted but the contents + * are currently not in the desired state. + * + * This routine follows the steps outlined in the AMD64 Architecture + * Programmer's Manual Volume 2, Section 7.10.8 Encrypt-in-Place. + */ +static void __init __sme_early_enc_dec(resource_size_t paddr, + unsigned long size, bool enc) +{ + void *src, *dst; + size_t len; + + if (!sme_me_mask) + return; + + local_flush_tlb(); + wbinvd(); + + /* + * There are limited number of early mapping slots, so map (at most) + * one page at time. + */ + while (size) { + len = min_t(size_t, sizeof(sme_early_buffer), size); + + /* + * Create mappings for the current and desired format of + * the memory. Use a write-protected mapping for the source. + */ + src = enc ? early_memremap_decrypted_wp(paddr, len) : + early_memremap_encrypted_wp(paddr, len); + + dst = enc ? early_memremap_encrypted(paddr, len) : + early_memremap_decrypted(paddr, len); + + /* + * If a mapping can't be obtained to perform the operation, + * then eventual access of that area in the desired mode + * will cause a crash. + */ + BUG_ON(!src || !dst); + + /* + * Use a temporary buffer, of cache-line multiple size, to + * avoid data corruption as documented in the APM. + */ + memcpy(sme_early_buffer, src, len); + memcpy(dst, sme_early_buffer, len); + + early_memunmap(dst, len); + early_memunmap(src, len); + + paddr += len; + size -= len; + } +} + +void __init sme_early_encrypt(resource_size_t paddr, unsigned long size) +{ + __sme_early_enc_dec(paddr, size, true); +} + +void __init sme_early_decrypt(resource_size_t paddr, unsigned long size) +{ + __sme_early_enc_dec(paddr, size, false); +} + void __init sme_early_init(void) { unsigned int i;