Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753120AbdGGNsu (ORCPT ); Fri, 7 Jul 2017 09:48:50 -0400 Received: from mail-by2nam01on0070.outbound.protection.outlook.com ([104.47.34.70]:19040 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753021AbdGGNmY (ORCPT ); Fri, 7 Jul 2017 09:42:24 -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 22/38] x86/mm: Add support for changing the memory encryption attribute 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:42:09 -0500 Message-ID: <20170707134209.29711.14421.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: CO1PR15CA0055.namprd15.prod.outlook.com (10.175.176.23) To BN6PR12MB1137.namprd12.prod.outlook.com (10.168.226.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b997ad0-78e8-4361-24e2-08d4c53dfcbc 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:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1137;3:kjgb6V4P6FJqcef9tZFPlDVOqdfQOGT+RZZEst1n21yjDwDjOAkoDcV6SRbs9g0j7/X4H2C3Cbn76SXUH5fK/Fi57eKzFmY49FYRKpsBmUhdgVMYm9mYL08KxgrZVlqN9fUVdsGhLjj9VLd06aHlvyFp7AhcooU7vSkjHJs27JoBhc2FgRqyVC2YqC9j7fkfi+ltAyDNySpb2eJUEX77vSm+bdErtVKUz3ardTjQ4juF9eN+mb8XXW5Av9faIQdk7NiFlZcsVrcWbj2YjablCeNiUYKsErqT8xBWCsJUG2mw/FsZLwU/Cq5TfwAJb+VAC2WrKlgdblx799W9LN9JPUicp27dgtpgEwRE4Q4dMwRF9Pec//zUk9jGFf6MtYEko8tkCPjGGQmYOUjkvbXRdAW+CB+jIICBMPyDYwQfsC388jVku3FWiQJl0Xv6oM1eBGWp9i4s/DKXyswT/AGqSlmL9kyrCPcs7IPLm9MktxCybLyD820UJ7L9S0v4LHSEDw4Qmfd3wtqxY/FH9jX3yKfrlr5JSz4LhDrjq5zSMzHGZfk82zIo/2l3qNMZrkUdi3+jCuJVHvSK9+UIlenEcA8EDr2MinYPgh/2co9bWCY8zcTWfC5NWS+ciGPKp+eZ5TWpmHi7pUb3LvyCYwTlvJzuH7TggOnAndTA5udJZooqFKSE4o1wJC8pQWNx9dNz911FZb3qfZX6u8hrCU5t8mR1RxL7fWj6dA8XjIiOen5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uHM/7Eu9kLfHckvmtKlNdmF+O8d5Bezu7Ip6CKChH0fI1BggWSFHYPuIxbyM0tXHnh0yZPwNIAdic2ZuMcY6DvPddLQlVsUj6RUamVKJ8jF6LVh7n870xULV+uEDoG5AaOeTK4W+jK6b2TJD6Jd19O2I X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(133145235818549)(236129657087228)(767451399110)(247924648384137); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(2017060910064)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR12MB1137;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR12MB1137; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTM3OzQ6dVpPdTZqeUtwb0xYV1RoQTFUWEh5d21oM2h6?= =?utf-8?B?cjdTbXJrRzZyWFFsV3BlbUdZVnBBUFFrancyZU02bjN1bnFUbnFMdjdSOERl?= =?utf-8?B?SUFSMVJrY3JRbGdtSVdIdEg3STltVDVPeE80YUozUGJVT1FUdmNXNnV3Vlgr?= =?utf-8?B?NWRVRVpVdlg2WFcwV1F6UmlFYXQ1QXVSNXlKdGMyc0lZNzlubmRtazcrdkM2?= =?utf-8?B?UW1pWjV5M1VDQllHamZaZkxnb3BVclRmK2RTNldhbzNvZDA0KzVBdnd2d2tZ?= =?utf-8?B?TFhLUXdEUy9qSFRkc2I3eTN6WTlGbTZwdVk0VHZJSDRiTWJRcVR4S3FXVXVj?= =?utf-8?B?VT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DMXNZZlVoV0dZ?= =?utf-8?B?b1dnTEdlbnJqMGpFRm8rSE1lVUZWSllFU0s3dHM4eDBjWlJVU0dSZ1Z5Znhl?= =?utf-8?B?K1VNTG8rR1NBekFqaHlpV2I2blVlYTdyT2lFWVg3Y1VsNWRYUkVuejRQV0hT?= =?utf-8?B?RUt5a080WUY2UVIydE5PS1BZV1h0OGEyYWcwZHowWE9WN0NzZXBEU3BZa2ZP?= =?utf-8?B?a3lIV2laMnNqUjdaT29GcUlPZUpqNk5QVWt0STM3WHA4RzBFNENOaUJnNEMx?= =?utf-8?B?d3hQa0IxMkJnTEFJNC9yQ0VxZ0lsQ2RIVS9lS01WTFZHU2wwRmZGQVN5dnda?= =?utf-8?B?NXNqc21OVHZnMS93OXM4QmlLRXA3TTV2R2w1UzhsM3VwVnVManR4RWZoQnJw?= =?utf-8?B?T2s4aUE0akN6ZVJjdTlJSmNmMEVJNGZEYTN5dVU0L1MrbGQ0VC9LVFJhd3NX?= =?utf-8?B?enVnWmZDUnBxMkFSdi9VVXhqSGh2RVlmazJuNm9SbktuN1NYWDk2M2pYVzkv?= =?utf-8?B?cUd6eUxucFBTUFlOS1I4MU9FczVrcUV0aFpxanVOZ1NIa0NtUkwvd1V5d0hj?= =?utf-8?Q?6xu7U8Y1g+Ms?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39860400002)(39450400003)(39840400002)(39410400002)(39400400002)(39850400002)(2906002)(97746001)(66066001)(7736002)(47776003)(81166006)(8676002)(103116003)(86362001)(50466002)(189998001)(42186005)(4326008)(53936002)(2950100002)(55016002)(6666003)(9686003)(38730400002)(110136004)(23676002)(53416004)(33646002)(6506006)(54906002)(25786009)(6116002)(7406005)(478600001)(72206003)(3846002)(230700001)(54356999)(1076002)(305945005)(76176999)(83506001)(50986999)(7416002)(5660300001)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1137;H:tlendack-t1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= X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1137;20:z2vUSdvVNALL4rmGyeZD5SK9tO7qamhZXrRL0jWYPj9EEWYRXHMxT//coWtZPBazujE2/kn+n1lY9IOqBWx1BUqLgaWLZ1ZHIhvXktOXMlT9ikAUE1tIjuTPjVSG/IFXhiMyrmvqls6w9YeroOxsNbYMfZKHn2h/XC5KmlyjrhnxR29qc/juLIoRSmlEtzdI+sKBPVLCDXtpvncZl8SqN44vrMn7mKFldP81CJwOlOWwkHuz+GJtNhek3kkANVHq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:42:14.2760 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1137 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3466 Lines: 107 Add support for changing the memory encryption attribute for one or more memory pages. This will be useful when we have to change the AP trampoline area to not be encrypted. Or when we need to change the SWIOTLB area to not be encrypted in support of devices that can't support the encryption mask range. Reviewed-by: Borislav Petkov Signed-off-by: Tom Lendacky --- arch/x86/include/asm/set_memory.h | 3 ++ arch/x86/mm/pageattr.c | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h index eaec6c3..cd71273 100644 --- a/arch/x86/include/asm/set_memory.h +++ b/arch/x86/include/asm/set_memory.h @@ -11,6 +11,7 @@ * Executability : eXeutable, NoteXecutable * Read/Write : ReadOnly, ReadWrite * Presence : NotPresent + * Encryption : Encrypted, Decrypted * * Within a category, the attributes are mutually exclusive. * @@ -42,6 +43,8 @@ int set_memory_wb(unsigned long addr, int numpages); int set_memory_np(unsigned long addr, int numpages); int set_memory_4k(unsigned long addr, int numpages); +int set_memory_encrypted(unsigned long addr, int numpages); +int set_memory_decrypted(unsigned long addr, int numpages); int set_memory_array_uc(unsigned long *addr, int addrinarray); int set_memory_array_wc(unsigned long *addr, int addrinarray); diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index e7d3866..d9e09fb 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -1769,6 +1769,68 @@ int set_memory_4k(unsigned long addr, int numpages) __pgprot(0), 1, 0, NULL); } +static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc) +{ + struct cpa_data cpa; + unsigned long start; + int ret; + + /* Nothing to do if the SME is not active */ + if (!sme_active()) + return 0; + + /* Should not be working on unaligned addresses */ + if (WARN_ONCE(addr & ~PAGE_MASK, "misaligned address: %#lx\n", addr)) + addr &= PAGE_MASK; + + start = addr; + + memset(&cpa, 0, sizeof(cpa)); + cpa.vaddr = &addr; + cpa.numpages = numpages; + cpa.mask_set = enc ? __pgprot(_PAGE_ENC) : __pgprot(0); + cpa.mask_clr = enc ? __pgprot(0) : __pgprot(_PAGE_ENC); + cpa.pgd = init_mm.pgd; + + /* Must avoid aliasing mappings in the highmem code */ + kmap_flush_unused(); + vm_unmap_aliases(); + + /* + * Before changing the encryption attribute, we need to flush caches. + */ + if (static_cpu_has(X86_FEATURE_CLFLUSH)) + cpa_flush_range(start, numpages, 1); + else + cpa_flush_all(1); + + ret = __change_page_attr_set_clr(&cpa, 1); + + /* + * After changing the encryption attribute, we need to flush TLBs + * again in case any speculative TLB caching occurred (but no need + * to flush caches again). We could just use cpa_flush_all(), but + * in case TLB flushing gets optimized in the cpa_flush_range() + * path use the same logic as above. + */ + if (static_cpu_has(X86_FEATURE_CLFLUSH)) + cpa_flush_range(start, numpages, 0); + else + cpa_flush_all(0); + + return ret; +} + +int set_memory_encrypted(unsigned long addr, int numpages) +{ + return __set_memory_enc_dec(addr, numpages, true); +} + +int set_memory_decrypted(unsigned long addr, int numpages) +{ + return __set_memory_enc_dec(addr, numpages, false); +} + int set_pages_uc(struct page *page, int numpages) { unsigned long addr = (unsigned long)page_address(page);