Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755113AbdLUWDP (ORCPT ); Thu, 21 Dec 2017 17:03:15 -0500 Received: from mail-sn1nam01on0075.outbound.protection.outlook.com ([104.47.32.75]:31048 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750920AbdLUWDJ (ORCPT ); Thu, 21 Dec 2017 17:03:09 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [PATCH v2 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: Thu, 21 Dec 2017 16:03:02 -0600 Message-ID: <20171221220302.30632.72365.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20171221220242.30632.5031.stgit@tlendack-t1.amdoffice.net> References: <20171221220242.30632.5031.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: MWHPR10CA0061.namprd10.prod.outlook.com (10.169.238.23) To CY4PR12MB1144.namprd12.prod.outlook.com (10.168.164.136) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b2c127eb-cbf4-4dfd-e9f6-08d548be9de6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060);SRVR:CY4PR12MB1144; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1144;3:6P3d6DiwxJdKe5Qr+DYogCb/DGIwQ+7onrA4hD5A3LykV8YsM9Lv2W7EYJ68HzodXd0PArl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nPjLX/jYugsc0Djn4KsxyHFUatjzfsbMX/FrgVs8FweBvlHGzrsblBCWwuziSIJCEz3yB/LG/e0D2/h9rQBgIPT6PBbmYwLk0uqUd4N8DpaszTIvBJJ36D2R58vH9iiT9BUjpfUxNWtDwUmvXKwPnVAqm/0JeX082clc+89GNOhiaFK7ts4R5J8pj76tOs4k/kV1D8XOITL3HlkHug/utU+9woou0meKDwb0eDoJCZa0oF1+hfsUzsSECbLOHHbyx+KA6sgyMaWgm9yORbCdfpK5eQz+R;4:0bSm93lN6V4YQdNPsIXfs7/zqU3RW9zGW/ckmDO+rYpDDQaCnuJ9AJqjb/Rr+HExY2SlAUrmorgXbR0NrCpp43cwY1yM/M+pdiNHpODQzm9dRonUVLbEtdCustGlExNS8PzVC1siZUYrwGEGee81HFJvHu5GFzAByWqzX40floo9mTVh0OBoJvKRL4rfX+osBpQqRcSZCSvgHHgOFCWkLh9MR/IYcLBLRThqQEDSxLp5Sxsv6gBGuZurezDMilI33MDS5FDz8AUqMP5wdmRb79k/8U8XKiQ+lEKS7pJCxf9xyngYiBdP7HQFibJ1U5UX X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231023)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:CY4PR12MB1144;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR12MB1144; X-Forefront-PRVS: 0528942FD8 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(39860400002)(39380400002)(366004)(376002)(346002)(189003)(199004)(69596002)(86362001)(23676004)(72206003)(52116002)(7696005)(478600001)(2486003)(76176011)(47776003)(6116002)(97746001)(1076002)(3846002)(5660300001)(230700001)(66066001)(2950100002)(81156014)(6666003)(68736007)(8676002)(81166006)(6916009)(2906002)(50466002)(53936002)(83506002)(25786009)(2361001)(7736002)(305945005)(106356001)(53416004)(105586002)(4326008)(2351001)(316002)(58126008)(16526018)(54906003)(55016002)(6506007)(9686003)(386003)(97736004)(8936002)(103116003)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1144;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQ0OzIzOk1tcVNhZFJUdXpKU1dKSWIwajVyemlzL0ZD?= =?utf-8?B?SlQ3bXZCWDNPSndUbzBoc2IxNW05di9HUTdyN09CZjFuNzVXanpKMUpjWk96?= =?utf-8?B?MUQ1dXkrbzNOZWw5dkVoYWJLdWtxekYvT3JvZVErMC9XcTExSkJBMEpsRnJj?= =?utf-8?B?ejJCZnNmRWZReDVTMUxCbkZVMlJFMnRMVFZoSjVObEFXMXp0ZVNrS2pTRjRr?= =?utf-8?B?V3gxOEZ3c3J1YnBDd1Bxa0dvTGM2UXRpVmJReHZpUDBScWxnaGE5WGJoOEF5?= =?utf-8?B?YTJlZlFBdnY1UjZpMUZ2SkN2alY0K2VDOWlpM2xtZFgrK1FhNXp3c05zejlY?= =?utf-8?B?VmM3ZHBYOGFLS0dBNEcyMEMvVDZFQlNaSzJRUENveWoveU5KNzNEZ2kvSmFv?= =?utf-8?B?YU1UT2hkdTkvVVVkVHZNMmw2VHU4V25FU1lhVVVxV3gwUkw1Uk9PYUd3OFY5?= =?utf-8?B?OGhLTFVZVkdUT3RPd3BSU29qbUs2NW1ZcFZjS3ZXS3NzejhpWVVUUEFacDNm?= =?utf-8?B?WW92Umk5YWFMNTE5bS95bGlWTHplSmpmY09nVDRKc05Tcnd6U1VjUks4NTU2?= =?utf-8?B?S1pJdjZvdmtoU1NQT09LcFRDTytzdzFBbTNkdElSOTI3d0dUb01pN3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ApLrVBwbSuVnnfK8dy3R+83ifBFNnapfIf4CzcnVHU+K+8iEclfMde6UYPKMMMbLGGWKii1vJfvfUvIVwKWx1Rqxb5IQt3B8DLQnfW2/E/lyFEte1RgCMR1qSzT1erQ4VtvqYf9/7SYJJ25Y/bbr9ExN/o SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1144;20:HU91aO0EHirEgxBYfyYSx32DAcK0u2iUciT42cbuXSdPjrWT4zvgsl614bPsGrj0GL1ACe8mKRModk6FSSKJWiaECQlZrncoIpAkdVCeod6l932qKln7L6AKDTT25FkfxXEsiUwzPE/P3GBpKOQNmKv0Ezc0eaIzHNAW41B8afEhCZlT4X/2lmasQNu7Ze8Xe7uAJubDGACJtn9r2iuXTuw1msApzxWvb1GlK2mlAldfXLfNQ5NsKf3UJ1W1LR0B X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 22:03:06.5509 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2c127eb-cbf4-4dfd-e9f6-08d548be9de6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1144 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7593 Lines: 233 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 */