Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753919AbeAJT0S (ORCPT + 1 other); Wed, 10 Jan 2018 14:26:18 -0500 Received: from mail-sn1nam01on0082.outbound.protection.outlook.com ([104.47.32.82]:32576 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753881AbeAJT0O (ORCPT ); Wed, 10 Jan 2018 14:26:14 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v3 2/5] x86/mm: Use a struct to reduce parameters for SME PGD mapping To: x86@kernel.org Cc: Brijesh Singh , linux-kernel@vger.kernel.org, Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Thomas Gleixner Date: Wed, 10 Jan 2018 13:26:05 -0600 Message-ID: <20180110192605.6026.96206.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20180110192544.6026.17285.stgit@tlendack-t1.amdoffice.net> References: <20180110192544.6026.17285.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: CO1PR15CA0105.namprd15.prod.outlook.com (10.175.177.25) To CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 715e32b3-8cb9-4ff4-c6cb-08d55860016d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;3:DryvmgHf7bB66+jDIwUe4tfD4DA1wL8/fjhT6XZdptogRJ2/tZPi4LEv9OpQAalf+UnRY/YYQ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AecGSbiPzW7DwZD6VRosjkL14Dd2FatfrNiTgB3n78BOm6455FJyfXe5Ndq8vp5V9ONz3saS/JMNTd4QTPsVWbPXFu8qtzXnkxaAZUgLXQCj95UvW1zSCk7pTkv27GFefORjCJQlpXSAy2uO5FKTB+rwKMInNgy6+Tw/MH6uZIrZ5Qxy4pege6dtiRX0UE3uLZ68X+Bz8QzJqJXYlvYhp4qXP1TjH5kRSneP0OYYxdf2jBJv+1lYEyoBMiLsMlsW/m5ijr7;4:ImLuS4H/iGg1XHFzqpqv6qZeP2XPW/HTz4fjLScD2ujHevOZ2qCXVySKq3KKAXWkw1QxfkYFK/t4ZUvdw37sy5uI24ECbEq07mWcGiHkMstfnupxMI/B+57a0GxPzLmiiC020tkdyMuz7+r5At9Gj4cTTOfi90ya64J96K9ehsY71o2JUt3TGasL89iSPdHDJgTzlY/EhlGC8NatKi/URYubAazrNe3/pLg09Yy8PPKTTZdLvAdqdas0hCoTw5IU1Nw8SEMn6ugc50CRGR4UVVqeKtoSPSbqgpbhhnV020LXmCLz1cSq2CaP5QlLb4Ar X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041268)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011);SRVR:CY4PR12MB1141;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR12MB1141; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(39380400002)(366004)(396003)(376002)(346002)(199004)(189003)(106356001)(2361001)(2351001)(478600001)(7696005)(97746001)(72206003)(2486003)(8676002)(23676004)(16526018)(52116002)(66066001)(5660300001)(76176011)(6506007)(386003)(2906002)(230700001)(81156014)(83506002)(4326008)(103116003)(8936002)(81166006)(305945005)(3846002)(25786009)(9686003)(316002)(6666003)(97736004)(50466002)(6116002)(47776003)(68736007)(2950100002)(86362001)(7736002)(53936002)(54906003)(69596002)(53416004)(6916009)(105586002)(1076002)(55016002)(58126008)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1141;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzIzOnhLTHVyY2pCaGw1R2xVbUx4UTgySXVpaGFq?= =?utf-8?B?VEVjMnVtdjlGT0gyWUFWa2NrTDRLcENqR1pvWUE4M3RxZHNVakNPZ01Sbitv?= =?utf-8?B?aFRoZFlDVVBKTGVyZGtnR0toODhtblRxS25TbkNYZDdBRGh0UUkraWxrN1Ba?= =?utf-8?B?UUdNVi96VHJvS3NEazhGMDVzUC9GUnc4VXJNR0EvWE1qbkp6M2dRcFE5RW1J?= =?utf-8?B?MDVhN1pFV0ZCRVdMZVZzblN0dTlOR0RiV2I2SFVhcVI5QzlBQXNPdU9OWnVB?= =?utf-8?B?bzlnMVJqVFRvbythdWZqMllpWjZoV1VheFlhaE0rN2JJOU8zQklaci9VdUF0?= =?utf-8?B?Y0EyZ1J3V2c5TnRubkxHc3R5b0tGQTVzTEZTWWt0OElkUVNVL1REQ1QyQkJ3?= =?utf-8?B?dDV1cVB1dHp6KzVObnFQWGZSbGxDNitoNWpPS1hoRitRTkNsWHJQQXg0MGJr?= =?utf-8?B?c3hjQjZwaWhLZ01nQ0lYUDN0Y2hzNWlFU2dUc0w1NkQyLzZPejNiNjd0QURq?= =?utf-8?B?VGJKQnFvRE82cmxkVTM5aC9oL01UbmwwaHRKdThLeWRzOGMvMmVMWHlZK0xW?= =?utf-8?B?K2k3dEMveklIVzVqV0UySDZwT21hZitkVCtQMTQ3QmQ4TDRZbTlaQjJMQ1R6?= =?utf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AT9/1j+mreU12i6OX9riFwvKtUeABoqpM15eavsfnJ/0SM5MM5ES/cJrAsoj4LgpgBp2hHuSw2Q5LtsEL8HYQ5l/5ExS1n5LlL1Hi5nEakUTispPv8p/02d+NfxniAnw+Sz0PsR3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1141;20:+U4khT+AhnOx09XqFTQyDsVYUkJF3ePug+Mhc0KBHxqTpFJ7q/3ZBjDwPq6rhKaT2Jyvc3boJ8lmyww+EdEHzXkI7FWYrBxhR/Ro77LHydfs+V9dmxcHyTYtiUbTPR6amkf2fLcYJUHJGZgRvQa9AJSQROErFDTTbSmVJMZhKL+LJPZo5HzFUKCva0y4cu8OlgoJ1KYxD2lyS9m783h+6C1QQAbawTC2JsKI2gh9ia88WFmVyWF4F/I8ZhI/ViQh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 19:26:09.9369 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 715e32b3-8cb9-4ff4-c6cb-08d55860016d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: In preparation for follow-on patches, combine the PGD mapping parameters into a struct to reduce the number of function arguments and allow for direct updating of the next pagetable mapping area pointer. Signed-off-by: Tom Lendacky --- arch/x86/mm/mem_encrypt.c | 90 +++++++++++++++++++++++---------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 391b134..5a20696 100644 --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -464,6 +464,14 @@ void swiotlb_set_mem_attributes(void *vaddr, unsigned long size) set_memory_decrypted((unsigned long)vaddr, size >> PAGE_SHIFT); } +struct sme_populate_pgd_data { + void *pgtable_area; + pgd_t *pgd; + + pmdval_t pmd_val; + unsigned long vaddr; +}; + static void __init sme_clear_pgd(pgd_t *pgd_base, unsigned long start, unsigned long end) { @@ -486,15 +494,14 @@ static void __init sme_clear_pgd(pgd_t *pgd_base, unsigned long start, #define PUD_FLAGS _KERNPG_TABLE_NOENC #define PMD_FLAGS (__PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL) -static void __init *sme_populate_pgd(pgd_t *pgd_base, void *pgtable_area, - unsigned long vaddr, pmdval_t pmd_val) +static void __init sme_populate_pgd_large(struct sme_populate_pgd_data *ppd) { pgd_t *pgd_p; p4d_t *p4d_p; pud_t *pud_p; pmd_t *pmd_p; - pgd_p = pgd_base + pgd_index(vaddr); + pgd_p = ppd->pgd + pgd_index(ppd->vaddr); if (native_pgd_val(*pgd_p)) { if (IS_ENABLED(CONFIG_X86_5LEVEL)) p4d_p = (p4d_t *)(native_pgd_val(*pgd_p) & ~PTE_FLAGS_MASK); @@ -504,15 +511,15 @@ static void __init *sme_populate_pgd(pgd_t *pgd_base, void *pgtable_area, pgd_t pgd; if (IS_ENABLED(CONFIG_X86_5LEVEL)) { - p4d_p = pgtable_area; + p4d_p = ppd->pgtable_area; memset(p4d_p, 0, sizeof(*p4d_p) * PTRS_PER_P4D); - pgtable_area += sizeof(*p4d_p) * PTRS_PER_P4D; + ppd->pgtable_area += sizeof(*p4d_p) * PTRS_PER_P4D; pgd = native_make_pgd((pgdval_t)p4d_p + PGD_FLAGS); } else { - pud_p = pgtable_area; + pud_p = ppd->pgtable_area; memset(pud_p, 0, sizeof(*pud_p) * PTRS_PER_PUD); - pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD; + ppd->pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD; pgd = native_make_pgd((pgdval_t)pud_p + PGD_FLAGS); } @@ -520,44 +527,41 @@ static void __init *sme_populate_pgd(pgd_t *pgd_base, void *pgtable_area, } if (IS_ENABLED(CONFIG_X86_5LEVEL)) { - p4d_p += p4d_index(vaddr); + p4d_p += p4d_index(ppd->vaddr); if (native_p4d_val(*p4d_p)) { pud_p = (pud_t *)(native_p4d_val(*p4d_p) & ~PTE_FLAGS_MASK); } else { p4d_t p4d; - pud_p = pgtable_area; + pud_p = ppd->pgtable_area; memset(pud_p, 0, sizeof(*pud_p) * PTRS_PER_PUD); - pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD; + ppd->pgtable_area += sizeof(*pud_p) * PTRS_PER_PUD; p4d = native_make_p4d((pudval_t)pud_p + P4D_FLAGS); native_set_p4d(p4d_p, p4d); } } - pud_p += pud_index(vaddr); + pud_p += pud_index(ppd->vaddr); if (native_pud_val(*pud_p)) { if (native_pud_val(*pud_p) & _PAGE_PSE) - goto out; + return; pmd_p = (pmd_t *)(native_pud_val(*pud_p) & ~PTE_FLAGS_MASK); } else { pud_t pud; - pmd_p = pgtable_area; + pmd_p = ppd->pgtable_area; memset(pmd_p, 0, sizeof(*pmd_p) * PTRS_PER_PMD); - pgtable_area += sizeof(*pmd_p) * PTRS_PER_PMD; + ppd->pgtable_area += sizeof(*pmd_p) * PTRS_PER_PMD; pud = native_make_pud((pmdval_t)pmd_p + PUD_FLAGS); native_set_pud(pud_p, pud); } - pmd_p += pmd_index(vaddr); + pmd_p += pmd_index(ppd->vaddr); if (!native_pmd_val(*pmd_p) || !(native_pmd_val(*pmd_p) & _PAGE_PSE)) - native_set_pmd(pmd_p, native_make_pmd(pmd_val)); - -out: - return pgtable_area; + native_set_pmd(pmd_p, native_make_pmd(ppd->pmd_val)); } static unsigned long __init sme_pgtable_calc(unsigned long len) @@ -615,11 +619,10 @@ void __init sme_encrypt_kernel(void) unsigned long workarea_start, workarea_end, workarea_len; unsigned long execute_start, execute_end, execute_len; unsigned long kernel_start, kernel_end, kernel_len; + struct sme_populate_pgd_data ppd; unsigned long pgtable_area_len; unsigned long paddr, pmd_flags; unsigned long decrypted_base; - void *pgtable_area; - pgd_t *pgd; if (!sme_active()) return; @@ -683,18 +686,18 @@ void __init sme_encrypt_kernel(void) * pagetables and when the new encrypted and decrypted kernel * mappings are populated. */ - pgtable_area = (void *)execute_end; + ppd.pgtable_area = (void *)execute_end; /* * Make sure the current pagetable structure has entries for * addressing the workarea. */ - pgd = (pgd_t *)native_read_cr3_pa(); + ppd.pgd = (pgd_t *)native_read_cr3_pa(); paddr = workarea_start; while (paddr < workarea_end) { - pgtable_area = sme_populate_pgd(pgd, pgtable_area, - paddr, - paddr + PMD_FLAGS); + ppd.pmd_val = paddr + PMD_FLAGS; + ppd.vaddr = paddr; + sme_populate_pgd_large(&ppd); paddr += PMD_PAGE_SIZE; } @@ -708,17 +711,17 @@ void __init sme_encrypt_kernel(void) * populated with new PUDs and PMDs as the encrypted and decrypted * kernel mappings are created. */ - pgd = pgtable_area; - memset(pgd, 0, sizeof(*pgd) * PTRS_PER_PGD); - pgtable_area += sizeof(*pgd) * PTRS_PER_PGD; + ppd.pgd = ppd.pgtable_area; + memset(ppd.pgd, 0, sizeof(pgd_t) * PTRS_PER_PGD); + ppd.pgtable_area += sizeof(pgd_t) * PTRS_PER_PGD; /* Add encrypted kernel (identity) mappings */ pmd_flags = PMD_FLAGS | _PAGE_ENC; paddr = kernel_start; while (paddr < kernel_end) { - pgtable_area = sme_populate_pgd(pgd, pgtable_area, - paddr, - paddr + pmd_flags); + ppd.pmd_val = paddr + pmd_flags; + ppd.vaddr = paddr; + sme_populate_pgd_large(&ppd); paddr += PMD_PAGE_SIZE; } @@ -736,9 +739,9 @@ void __init sme_encrypt_kernel(void) pmd_flags = (PMD_FLAGS & ~_PAGE_CACHE_MASK) | (_PAGE_PAT | _PAGE_PWT); paddr = kernel_start; while (paddr < kernel_end) { - pgtable_area = sme_populate_pgd(pgd, pgtable_area, - paddr + decrypted_base, - paddr + pmd_flags); + ppd.pmd_val = paddr + pmd_flags; + ppd.vaddr = paddr + decrypted_base; + sme_populate_pgd_large(&ppd); paddr += PMD_PAGE_SIZE; } @@ -746,30 +749,29 @@ void __init sme_encrypt_kernel(void) /* Add decrypted workarea mappings to both kernel mappings */ paddr = workarea_start; while (paddr < workarea_end) { - pgtable_area = sme_populate_pgd(pgd, pgtable_area, - paddr, - paddr + PMD_FLAGS); + ppd.pmd_val = paddr + PMD_FLAGS; + ppd.vaddr = paddr; + sme_populate_pgd_large(&ppd); - pgtable_area = sme_populate_pgd(pgd, pgtable_area, - paddr + decrypted_base, - paddr + PMD_FLAGS); + ppd.vaddr = paddr + decrypted_base; + sme_populate_pgd_large(&ppd); paddr += PMD_PAGE_SIZE; } /* Perform the encryption */ sme_encrypt_execute(kernel_start, kernel_start + decrypted_base, - kernel_len, workarea_start, (unsigned long)pgd); + kernel_len, workarea_start, (unsigned long)ppd.pgd); /* * At this point we are running encrypted. Remove the mappings for * the decrypted areas - all that is needed for this is to remove * the PGD entry/entries. */ - sme_clear_pgd(pgd, kernel_start + decrypted_base, + sme_clear_pgd(ppd.pgd, kernel_start + decrypted_base, kernel_end + decrypted_base); - sme_clear_pgd(pgd, workarea_start + decrypted_base, + sme_clear_pgd(ppd.pgd, workarea_start + decrypted_base, workarea_end + decrypted_base); /* Flush the TLB - no globals so cr3 is enough */