Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753703AbdLUQfp (ORCPT ); Thu, 21 Dec 2017 11:35:45 -0500 Received: from mail-by2nam01on0057.outbound.protection.outlook.com ([104.47.34.57]:56033 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751418AbdLUQfn (ORCPT ); Thu, 21 Dec 2017 11:35:43 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Subject: Re: [PATCH v1 2/3] x86/mm: Prepare sme_encrypt_kernel() for PAGE aligned encryption To: Borislav Petkov Cc: x86@kernel.org, Brijesh Singh , linux-kernel@vger.kernel.org, Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner References: <20171207233342.29646.12858.stgit@tlendack-t1.amdoffice.net> <20171207233402.29646.77306.stgit@tlendack-t1.amdoffice.net> <20171221125800.wb5747hq4vbp5yhf@pd.tnic> From: Tom Lendacky Message-ID: <4ff5706f-367d-2204-d753-63e78931fd66@amd.com> Date: Thu, 21 Dec 2017 10:35:37 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171221125800.wb5747hq4vbp5yhf@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR1201CA0014.namprd12.prod.outlook.com (10.174.238.24) 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: a58bce13-fe58-47e5-4667-08d54890e041 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:JjJWMH84fMFXfOUHJMcTBgcoCj4PdlqFCbkFetZbSt21cyaWQdumpFjHXFHOjIRAmyZf6eSpWZ8mIBCNZWPxG7jtKxvHo23ki8z2k18LL7A8ccmmNtp8LY0dj9cvsl1oh1Fmu8Tqu/wMEft33Zhw1oPbWhoaKITk2iXYK/l7MNsxVeCGLjxWeDfBHJ3nbyV2CXkqWA1sFZGsyLtglh5kFtDqU1mHfVJzmDDrLsh7JgsNx/RO70jACLY3wet53667;25:8uHqzXP8wZOP3NYS1HbQ6YHH4RHo9zTXvo819tZSY7z2iKfaEiBYInH+j0I/TbPtq6Qm7rqIUPGLORKgFdIhwW4ME73uwt60Zy5Ub+ytfGwPJV3xCTCiPTzkbV7j5OSIMeonMQgiEQ1d4Sj1J3KHuHOu71EAK7uexd5pk3tCGS5wUpVBbdftTug7fNZvp3ByNiQsx0ZaHL9fQPnaaA22+kuwhrETo06N7GGmW9Rp/LXfi5JhrIKIS9ZHSTdhpBUH3s0Y0odHyBoq92k7WnNAWb0ctcQk+CKUj+VYLgDYYnLlcQKgSMGOP+q8DNEhQ/aomq3ewmB24QL8u16t62KJFg==;31:hvf+gtHOI0exsQWtUP3jjpxSj5Y39e+Bncj6cDsvXp8jHxplCabtMGhRvN6wXPmNcwtDwtloQHfg+R8h3Fy/JQk4ZVYtSEyoPlGCVJzYY7Znog0oXR7h7LsXvYlsNbq3lbUZch56phI5UL7ye6ZHkHLu22gByOo/omp69EOApIPURf5bCtNoyEmOINufzOkm3og9PfScBXiVe0WLsoBCycVILcdkE6grfjadR9yzioo= X-MS-TrafficTypeDiagnostic: CY4PR12MB1144: X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1144;20:P92DfxOimv53ni8vjH7us04BswkKHEJ6huqnUHVGmTqAXSQcZeahOZj22n26WVW5w/HvjsRzZlgyEIh5nk45a2dGM9mW/jdTHBPT1utoMk5klxiMc5j0r+LgAAv4w/DguPqgAGpolVlAg6rRKCvDGWW+JKPrwb6QuG76W0JXfAiHgrK/nxMx7kpCnLUBchRvETEByShcXOX/yN4e3rDvikW7dQzF4qRhARab2z1kMdwvdBo9vQA1d2dQAYMPDUdGG6MXZV6GJg4y1OxjnYUmOrweM3sjK89jMUFSbsN6vJFAGZi3bNP3Uxb0fWUZrK4Radst7+mjQLQ+rgBo6zp+7d9KiEQhQBuDBgum9mufrtAMbeXyG/Kp2oeebh7+W/xsBqbikZ2/lgZrx/li7AkjuTja6LN4riONKST5NVcnDRPgaD+CAP4utc4rpnQQBIWn4+Ymzt/rlvnyTGNKEu5OHnnnIIPTFvjUoeq+IMd2kSzPLS072mNxeEm3/QCCg2Aw;4:CBcfr4TvBzjkCQTt/9TO7lUUCSNkMbwgVpDA5J6SWmZI7ITLCZPXJY55FQ5TNCGx0Nge+D18tTL8309CpdrKUCcrILx1Z/WCT7fP+W1MrhbDmaUbCN7vR6ZXcoB+jxY0l/POqQ5unQMkaz2iaamb1FiH6D5cz2FNjhVUikznSSKsOGwTwMVXmvoueqIgBZkQh/yWMdZwpReT84xf4gUAGSvh7zW+Gmfdbsd9amqJIWTRG3QjQ2WY3Ay020E1/PkYrzsyRXcf35uSwt6wbiJF/A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231023)(10201501046)(6055026)(6041268)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(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)(6049001)(39860400002)(396003)(376002)(346002)(366004)(39380400002)(43544003)(24454002)(189003)(199004)(72206003)(86362001)(23676004)(64126003)(31696002)(52116002)(478600001)(76176011)(2486003)(52146003)(59450400001)(68736007)(47776003)(3846002)(6116002)(5660300001)(65956001)(66066001)(65806001)(230700001)(2950100002)(6666003)(6916009)(8676002)(65826007)(81166006)(81156014)(2906002)(50466002)(53936002)(83506002)(31686004)(3260700006)(25786009)(7736002)(305945005)(106356001)(6246003)(105586002)(4326008)(58126008)(16576012)(316002)(16526018)(54906003)(386003)(97736004)(8936002)(77096006)(53546011)(36756003)(229853002)(6486002)(90366009);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1144;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQ0OzIzOkIwT0MxMXkwVEp4djAySWlvQ014em1ldzJ0?= =?utf-8?B?Qm0ydTY0WWVXdWdwUnZjWUFyMVFXaER4NnRKL1VHcGhOU3lqSkdGWTFXNWZI?= =?utf-8?B?SXFVZVRyZ2JrdjdNZ1h0eFJIQnA5RlRyUkNHbmlTdTF4V0ZPMlJ6d3pJQW5y?= =?utf-8?B?bGVPVFZnZDhjZkRqS0F1MzFma25MNlhzUUNIWERsN2JuOE9Zbkx6dlZKZVpn?= =?utf-8?B?R0J5RXRONkoxRExOdHBjWk9hNzN3NGM5OUpCOVE3end1enBocm5UOTBUVlh0?= =?utf-8?B?amVkU2NjL2Q4c3d3TzdVMlo2bkR6UlJTODhWRHQyOS9tUDVMdkN5RlNUUk9r?= =?utf-8?B?MU1semhQOEM4eXV4ZitUYVpyVmpuTDBRZzA4enNpQkFoa1l3NkUxUHpqbzBy?= =?utf-8?B?T1dtamcxam55ekZPa1VlSHRWczBlRE5KWVNNdHRzVHFxVzBhWkJ1THpIcWpF?= =?utf-8?B?RGZuOUFzY0prNWNPcnRQQmNUbVJCSjBHcDlGRlFFZmFpL2ZhcmMxYmRlVTE1?= =?utf-8?B?STNVM2NsWlNvejNCMm41NlZjZF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rNYegTY=;5:VFWCxYqJh2ocrRuSLvZPxF3Onzv9cAftHkrhW4oXVeQ7XMRXGAKZ2W7yUc5eiFuYETvWF86/IKfrdKZIs3rVcJhz5YdigkZXxsc5Vco03YHY4bW1BXHinFexwkoM1CORMa5gP3uKiFdsUiyJZGVg+ypMJT99e+pKs0BgmU/uan0=;24:XBlFJrZnP2v0MaeOjaH0WMbuz2drQoJzIX+QZrU4XIE9Dp59Cz/pkYFvZ9mV+pNWM6hrF/GtKP8mVXXJx71fH0NKxYV94G6Jzjh5OQf+Mlo=;7:M7xMrGKx+B84tEmgO5suA4FKWZGVDs9rhC5dBF4upM0QuBk9gsJ4SEPIGIswjkW3QaZcOz0Ie5Ui7OvKavdGPwZI01mFXK4h1gbvkcR9t3yPfq1GLkkXylqt6bXn5ivbh4f5fT1LyCo73SiEqfbMyF7EbgXgBOAkWPkQIYRkXVYw6FxgqXi9Sca4151peFEUSD+OyPFSTyUobkDD429jYq2RbM9zGcHsEumaokLwqAd1gC9Ny41CMGJ6Ndjv9PZL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1144;20:4LGmQ6SPoxfyZbUwCwR4pCj7r3guXzD2RrmvJXUes+eEWCPSIo2FyPVkZDVRpa6jjJlgAGmpulJCTIecsl7cpjsrBjFKGKY3tAA0TxHxWI58vnk2NVb3szxSbF4KON/lZQDHaCGivvuRk2v8I67HYLC1tChkYLa1RR1AsNSZZozH3RXkulDNZdezqVDoCssEhPhW5lL48jEHDFeDwcrjyDDU8uTPpd+fiM+yE4HNJAjKVsyrGQru07ppSCf2/SWj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 16:35:40.8282 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a58bce13-fe58-47e5-4667-08d54890e041 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: 6793 Lines: 211 On 12/21/2017 6:58 AM, Borislav Petkov wrote: > On Thu, Dec 07, 2017 at 05:34:02PM -0600, Tom Lendacky wrote: >> In preparation for encrypting more than just the kernel, the encryption >> support in sme_encrypt_kernel() needs to support 4KB page aligned >> encryption instead of just 2MB large page aligned encryption. > > ... > >> static void __init __sme_map_range(pgd_t *pgd, unsigned long vaddr, >> unsigned long vaddr_end, >> - unsigned long paddr, pmdval_t pmd_flags) >> + unsigned long paddr, >> + pmdval_t pmd_flags, pteval_t pte_flags) >> { >> - while (vaddr < vaddr_end) { >> - sme_populate_pgd(pgd, vaddr, paddr, pmd_flags); >> + if (vaddr & ~PMD_PAGE_MASK) { >> + /* Start is not 2MB aligned, create PTE entries */ >> + unsigned long pmd_start = ALIGN(vaddr, PMD_PAGE_SIZE); >> + >> + while (vaddr < pmd_start) { >> + sme_populate_pgd(pgd, vaddr, paddr, pte_flags); >> + >> + vaddr += PAGE_SIZE; >> + paddr += PAGE_SIZE; >> + } >> + } > > This chunk... > >> + >> + while (vaddr < (vaddr_end & PMD_PAGE_MASK)) { >> + sme_populate_pgd_large(pgd, vaddr, paddr, pmd_flags); >> >> vaddr += PMD_PAGE_SIZE; >> paddr += PMD_PAGE_SIZE; >> } >> + >> + if (vaddr_end & ~PMD_PAGE_MASK) { >> + /* End is not 2MB aligned, create PTE entries */ >> + while (vaddr < vaddr_end) { >> + sme_populate_pgd(pgd, vaddr, paddr, pte_flags); >> + >> + vaddr += PAGE_SIZE; >> + paddr += PAGE_SIZE; >> + } >> + } > > ... and this chunk look like could be extracted in a wrapper as they're > pretty similar. > Should be doable, I'll take care of it. >> static void __init sme_map_range_encrypted(pgd_t *pgd, >> @@ -582,7 +658,8 @@ static void __init sme_map_range_encrypted(pgd_t *pgd, >> unsigned long vaddr_end, >> unsigned long paddr) >> { >> - __sme_map_range(pgd, vaddr, vaddr_end, paddr, PMD_FLAGS_ENC); >> + __sme_map_range(pgd, vaddr, vaddr_end, paddr, >> + PMD_FLAGS_ENC, PTE_FLAGS_ENC); >> } >> >> static void __init sme_map_range_decrypted(pgd_t *pgd, >> @@ -590,7 +667,8 @@ static void __init sme_map_range_decrypted(pgd_t *pgd, >> unsigned long vaddr_end, >> unsigned long paddr) >> { >> - __sme_map_range(pgd, vaddr, vaddr_end, paddr, PMD_FLAGS_DEC); >> + __sme_map_range(pgd, vaddr, vaddr_end, paddr, >> + PMD_FLAGS_DEC, PTE_FLAGS_DEC); >> } >> >> static void __init sme_map_range_decrypted_wp(pgd_t *pgd, >> @@ -598,19 +676,20 @@ static void __init sme_map_range_decrypted_wp(pgd_t *pgd, >> unsigned long vaddr_end, >> unsigned long paddr) >> { >> - __sme_map_range(pgd, vaddr, vaddr_end, paddr, PMD_FLAGS_DEC_WP); >> + __sme_map_range(pgd, vaddr, vaddr_end, paddr, >> + PMD_FLAGS_DEC_WP, PTE_FLAGS_DEC_WP); >> } >> >> static unsigned long __init sme_pgtable_calc(unsigned long len) >> { >> - unsigned long p4d_size, pud_size, pmd_size; >> + unsigned long p4d_size, pud_size, pmd_size, pte_size; >> unsigned long total; >> >> /* >> * Perform a relatively simplistic calculation of the pagetable >> - * entries that are needed. That mappings will be covered by 2MB >> - * PMD entries so we can conservatively calculate the required >> - * number of P4D, PUD and PMD structures needed to perform the >> + * entries that are needed. That mappings will be covered mostly > > Those > Got it. >> + * by 2MB PMD entries so we can conservatively calculate the required >> + * number of P4D, PUD, PMD and PTE structures needed to perform the >> * mappings. Incrementing the count for each covers the case where >> * the addresses cross entries. >> */ >> @@ -626,8 +705,9 @@ static unsigned long __init sme_pgtable_calc(unsigned long len) >> } >> pmd_size = (ALIGN(len, PUD_SIZE) / PUD_SIZE) + 1; >> pmd_size *= sizeof(pmd_t) * PTRS_PER_PMD; >> + pte_size = 2 * sizeof(pte_t) * PTRS_PER_PTE; > > This needs the explanation from the commit message about the 2 extra > pages, as a comment above it. Yup, I'll include the info about the (possible) extra PTE entries. > >> - total = p4d_size + pud_size + pmd_size; >> + total = p4d_size + pud_size + pmd_size + pte_size; >> >> /* >> * Now calculate the added pagetable structures needed to populate >> @@ -710,10 +790,13 @@ void __init sme_encrypt_kernel(void) >> >> /* >> * The total workarea includes the executable encryption area and >> - * the pagetable area. >> + * the pagetable area. The start of the workarea is already 2MB >> + * aligned, align the end of the workarea on a 2MB boundary so that >> + * we don't try to create/allocate PTE entries from the workarea >> + * before it is mapped. >> */ >> workarea_len = execute_len + pgtable_area_len; >> - workarea_end = workarea_start + workarea_len; >> + workarea_end = ALIGN(workarea_start + workarea_len, PMD_PAGE_SIZE); >> >> /* >> * Set the address to the start of where newly created pagetable >> diff --git a/arch/x86/mm/mem_encrypt_boot.S b/arch/x86/mm/mem_encrypt_boot.S >> index 730e6d5..20cca86 100644 >> --- a/arch/x86/mm/mem_encrypt_boot.S >> +++ b/arch/x86/mm/mem_encrypt_boot.S >> @@ -120,23 +120,33 @@ ENTRY(__enc_copy) >> >> wbinvd /* Invalidate any cache entries */ >> >> + push %r12 >> + >> /* Copy/encrypt 2MB at a time */ >> + movq $PMD_PAGE_SIZE, %r12 >> 1: >> + cmpq %r12, %r9 >> + jnb 2f >> + movq %r9, %r12 >> + >> +2: >> movq %r11, %rsi /* Source - decrypted kernel */ >> movq %r8, %rdi /* Dest - intermediate copy buffer */ >> - movq $PMD_PAGE_SIZE, %rcx /* 2MB length */ >> + movq %r12, %rcx >> rep movsb >> >> movq %r8, %rsi /* Source - intermediate copy buffer */ >> movq %r10, %rdi /* Dest - encrypted kernel */ >> - movq $PMD_PAGE_SIZE, %rcx /* 2MB length */ >> + movq %r12, %rcx >> rep movsb >> >> - addq $PMD_PAGE_SIZE, %r11 >> - addq $PMD_PAGE_SIZE, %r10 >> - subq $PMD_PAGE_SIZE, %r9 /* Kernel length decrement */ >> + addq %r12, %r11 >> + addq %r12, %r10 >> + subq %r12, %r9 /* Kernel length decrement */ >> jnz 1b /* Kernel length not zero? */ >> >> + pop %r12 >> + >> /* Restore PAT register */ >> push %rdx /* Save original PAT value */ >> movl $MSR_IA32_CR_PAT, %ecx > > Right, for this here can you pls do a cleanup pre-patch which does > > push > push > push > > /* meat of the function */ > > pop > pop > pop > > as now those pushes and pops are interspersed with the rest of the insns > and that makes following through it harder. F17h has a stack engine so > those streams of pushes and pops won't hurt perf and besides, this is > not even perf-sensitive. > Ok, I'll clean that up to move any pushes/pops to the beginning/end of the function, as well as moving some register saving earlier which may eliminate some push/pop instructions. Thanks, Tom > Thx. >