Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752856AbdGGNk7 (ORCPT ); Fri, 7 Jul 2017 09:40:59 -0400 Received: from mail-dm3nam03on0061.outbound.protection.outlook.com ([104.47.41.61]:25563 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752782AbdGGNkt (ORCPT ); Fri, 7 Jul 2017 09:40:49 -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 14/38] x86/mm: Insure that boot memory areas are mapped properly 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:40 -0500 Message-ID: <20170707134040.29711.20829.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: DM5PR16CA0033.namprd16.prod.outlook.com (10.172.42.147) To CY4PR12MB1142.namprd12.prod.outlook.com (10.168.163.150) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 994f68c5-0e8d-497b-9885-08d4c53dc449 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:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;3:M0j1MUGQlW8g6+EvSN/OxqIZ62527GofD2BWzm6phbrkLXpLc+2dxBTv6uI3hukxBzyDwFRxe8hz4QVY+my/QRD5nIz5XHYAF1tWdIYbn9b6A4K/nAbZBEss76RmbFEi4OcwhwZEjiPUGekMbIlAMDhia5VzvHHi1hNNAPMmct49qCGRLE6ubRATn6cEf1UmKZJrZNW9G3/qHrbCX/mYX522MNaWJn+yqvtx+3c44siGzrQPKzwmaut+wRAXA4WmqAhrcKEnPy8tJxNZDtC0qP5OKB0d9z1ij/sMF1IFagpo8PLMuOxQHU5oSCPB/N+xFr2DfCt5hWsC2Fe4MIHNBwukb8M8vBmLgwUJGogjFvK5EPKEyEiX2xXZ3RbG/B8kH5o6Hvlcoh7FT9qf2GKupUdv6+ub64aLYGbD0VYqys/NV2Q1Fob6UgjpV5bAfplFmhJBGtUC2zJTcdCa+k2qUS1CvYBDyIBfGAe3cfo8PiKtQh87+YRuqXOkzm4DzLaSuKdunZ/BWWlKjmnxAUzSADb6+nKy2BXM5ZjfpZy6m2ZDmkLYjiA8yGpIF2xPzSv1nrns2tErRajRsTS2exm4L8R0J6yt98vFvnYCcHdO+NITehY6C8ZtZbaDcRSi94ZSTMM12p3hyb6l6UJC+HDdWgwqAvnRF6ctsxFAS675+4KKAki4lxBHDLfCXNgs5hjxwaQN/tyQIQ26yXrC4rISSEohCv1gspHVIwBOLOG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i4CSyCggCiOWMAUp+1D2xzWmLOiyvVNrh0OqUqDBWaOam0B0lkAAtXkFHPjVhWK/eMRNCewi3HJTx6kXZk6zj/h/kxR+7c4nkGqcDJxEFxhGY9dlLKyBBU++oniq5YV0cUbtlfjgtADJjVDsIi3Crv+cNuHzslMYcPpiZydPxppE87b6bJiaZV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(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)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123555025)(20161123560025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR12MB1142;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQyOzQ6bHVUY2ZUbGdjUUI1YWQwKzVndzdhS2RBcURR?= =?utf-8?B?SHVQY0NQYVBESnorUjhyd05iK01ybXN5azd3a3BTYW9GdEZwVWJ1NTc5WFNB?= =?utf-8?B?QXBsb1VUQnZsL0o0SzVoMnBWc1FVKzFIQ0czcGEvVmI0dldwdUhIUnhxMWRO?= =?utf-8?B?TDhpb2ZJN3V4WjdIQlVkYmlXR0NaNDRteVJnNVBDWlJycWNBZzVOejNiQmY3?= =?utf-8?B?VnJBZzJabUN6WTNvSGVwSGlhKzEyQmRvK2Fza0JGZzRrWWkwclFwK1M2MFZs?= =?utf-8?B?RDBMbDhmNjN2OTNNczV1Ulp2cENtMzlXN0xJTjB0cWduS20xR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RE5Ja2VsQTZVeHpJWlRyZnAyeHhSN3ZW?= =?utf-8?B?aXJnS01aaDVTdmR0L09yQmpXNmEySlhKMXFqcXRZelRlUlQ3eDU1VnVwY29F?= =?utf-8?B?QkVIYUc2NHFuSWlsbnYvc3hvN2RINUwrdnBMSEdLY3pNLzNkdmlhT1pqa2Fp?= =?utf-8?B?eGhTUElMOVdVYjN3cWdweEdtbXVzRWxTS3lGcnN1alNrcVEyUVE3R3RNMjZy?= =?utf-8?B?Z3laQUtVR0JKa2JCMVZ5dWREZEU2MDlPY20xaUtaZWZ6SkpUN1VidDJkVVZC?= =?utf-8?B?cmVzMXg5bzhocUkzalBYMEJPWTFUbnY3WFJZbmdsZmthcTVWQlREZGlYZTgy?= =?utf-8?B?QVVFNGhQQWMvU1pYZVdCTUFVaVpVanpZdlhZMDhUb2xrb3gvRzg3d0ljT09N?= =?utf-8?B?Y29kS095aTc1dHZUSjIrUFFObFp6R1NOMzdwMUlHOThDblpwWC9Wa1I5LzNU?= =?utf-8?B?akcweGw2aU4zTlpXZnAxSjdrQXUwZzlqNU1XQ1cxb3ljaU9FOVhRK0xtbmhQ?= =?utf-8?B?cmE4dFdsNVpZZ0EyUlNoYlJEWWxLQ1BDdEhjamNRNURsdU9wMWhBeS9NOTFX?= =?utf-8?Q?NBjIekRO54yr?= X-Forefront-PRVS: 0361212EA8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39450400003)(39860400002)(39850400002)(39400400002)(39410400002)(39840400002)(103116003)(23676002)(7406005)(86362001)(2906002)(305945005)(110136004)(6506006)(47776003)(38730400002)(230700001)(33646002)(72206003)(53936002)(25786009)(97746001)(50986999)(54356999)(4326008)(7416002)(189998001)(7736002)(5660300001)(575784001)(54906002)(6116002)(83506001)(81166006)(9686003)(478600001)(2950100002)(53416004)(3846002)(55016002)(1076002)(8676002)(76176999)(66066001)(42186005)(50466002)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12M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Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;20:tidqnaMxFlgPI2TLzh2+vrvwHhw7kKaoVKnt+iVTmsHYtjWefn2xPcba8iYgA49zbWCfYAsINa0HyyYElX7JPx3+1rxoI/d7Ij7LGYkxO/ZI4ZTKxXd2oHyl3/uoqWZnr5lRhJ7OFXyghnlby2oDJ7kEkkGaaCugieqcGV326vGKiEik21++YsTAuCIoR4P3JcoKXFbSLE5h51gAfUI1q38ufQfxTU3em7rOZH+nV1f2d0AOtUdNIRuXdGklIxEc X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2017 13:40:42.9791 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1142 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8587 Lines: 258 The boot data and command line data are present in memory in a decrypted state and are copied early in the boot process. The early page fault support will map these areas as encrypted, so before attempting to copy them, add decrypted mappings so the data is accessed properly when copied. For the initrd, encrypt this data in place. Since the future mapping of the initrd area will be mapped as encrypted the data will be accessed properly. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/mem_encrypt.h | 6 +++ arch/x86/include/asm/pgtable.h | 3 ++ arch/x86/kernel/head64.c | 30 +++++++++++++++-- arch/x86/kernel/setup.c | 9 +++++ arch/x86/mm/kasan_init_64.c | 2 + arch/x86/mm/mem_encrypt.c | 63 ++++++++++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/mem_encrypt.h b/arch/x86/include/asm/mem_encrypt.h index 8baa35b..ab1fe77 100644 --- a/arch/x86/include/asm/mem_encrypt.h +++ b/arch/x86/include/asm/mem_encrypt.h @@ -26,6 +26,9 @@ void __init sme_early_encrypt(resource_size_t paddr, void __init sme_early_decrypt(resource_size_t paddr, unsigned long size); +void __init sme_map_bootdata(char *real_mode_data); +void __init sme_unmap_bootdata(char *real_mode_data); + void __init sme_early_init(void); void __init sme_encrypt_kernel(void); @@ -40,6 +43,9 @@ static inline void __init sme_early_encrypt(resource_size_t paddr, static inline void __init sme_early_decrypt(resource_size_t paddr, unsigned long size) { } +static inline void __init sme_map_bootdata(char *real_mode_data) { } +static inline void __init sme_unmap_bootdata(char *real_mode_data) { } + static inline void __init sme_early_init(void) { } static inline void __init sme_encrypt_kernel(void) { } diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index c6452cb..bbeae4a 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -23,6 +23,9 @@ #ifndef __ASSEMBLY__ #include +extern pgd_t early_top_pgt[PTRS_PER_PGD]; +int __init __early_make_pgtable(unsigned long address, pmdval_t pmd); + void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd); void ptdump_walk_pgd_level_checkwx(void); diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 5cd0b72..0cdb53b 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -34,7 +34,6 @@ /* * Manage page tables very early on. */ -extern pgd_t early_top_pgt[PTRS_PER_PGD]; extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD]; static unsigned int __initdata next_early_pgt; pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); @@ -181,13 +180,13 @@ static void __init reset_early_page_tables(void) } /* Create a new PMD entry */ -int __init early_make_pgtable(unsigned long address) +int __init __early_make_pgtable(unsigned long address, pmdval_t pmd) { unsigned long physaddr = address - __PAGE_OFFSET; pgdval_t pgd, *pgd_p; p4dval_t p4d, *p4d_p; pudval_t pud, *pud_p; - pmdval_t pmd, *pmd_p; + pmdval_t *pmd_p; /* Invalid address or early pgt is done ? */ if (physaddr >= MAXMEM || read_cr3_pa() != __pa_nodebug(early_top_pgt)) @@ -246,12 +245,21 @@ int __init early_make_pgtable(unsigned long address) memset(pmd_p, 0, sizeof(*pmd_p) * PTRS_PER_PMD); *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE; } - pmd = (physaddr & PMD_MASK) + early_pmd_flags; pmd_p[pmd_index(address)] = pmd; return 0; } +int __init early_make_pgtable(unsigned long address) +{ + unsigned long physaddr = address - __PAGE_OFFSET; + pmdval_t pmd; + + pmd = (physaddr & PMD_MASK) + early_pmd_flags; + + return __early_make_pgtable(address, pmd); +} + /* Don't add a printk in there. printk relies on the PDA which is not initialized yet. */ static void __init clear_bss(void) @@ -274,6 +282,12 @@ static void __init copy_bootdata(char *real_mode_data) char * command_line; unsigned long cmd_line_ptr; + /* + * If SME is active, this will create decrypted mappings of the + * boot data in advance of the copy operations. + */ + sme_map_bootdata(real_mode_data); + memcpy(&boot_params, real_mode_data, sizeof boot_params); sanitize_boot_params(&boot_params); cmd_line_ptr = get_cmd_line_ptr(); @@ -281,6 +295,14 @@ static void __init copy_bootdata(char *real_mode_data) command_line = __va(cmd_line_ptr); memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); } + + /* + * The old boot data is no longer needed and won't be reserved, + * freeing up that memory for use by the system. If SME is active, + * we need to remove the mappings that were created so that the + * memory doesn't remain mapped as decrypted. + */ + sme_unmap_bootdata(real_mode_data); } asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 3486d04..0bfe0c1 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include