Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933566AbeAHXUY (ORCPT + 1 other); Mon, 8 Jan 2018 18:20:24 -0500 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81]:52688 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933462AbeAHXUV (ORCPT ); Mon, 8 Jan 2018 18:20:21 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Subject: Re: [PATCH v2 4/5] 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: <20171221220242.30632.5031.stgit@tlendack-t1.amdoffice.net> <20171221220321.30632.70405.stgit@tlendack-t1.amdoffice.net> <20180107182513.3bvw3xgrzaxi23m3@pd.tnic> From: Tom Lendacky Message-ID: Date: Mon, 8 Jan 2018 17:20:15 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180107182513.3bvw3xgrzaxi23m3@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: CY4PR1801CA0016.namprd18.prod.outlook.com (10.171.252.29) To CY4PR12MB1143.namprd12.prod.outlook.com (10.168.164.135) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ae9f4223-f386-49fc-b1d8-08d556ee6239 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:CY4PR12MB1143; X-Microsoft-Exchange-Diagnostics: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YWIZCKp3McOHCE1zEnqEjWTKtZWzLx/j/PFlAtw1LfHFAk7vZHTuSMOslymUvnmAStwgpw+v4HA3gYzXLazXtguSnxtSGTOYRiEOjzILvS6xckM5VKgAOsv1djfABnvYst1o8A0jPqYqJhB3qyVnoqjS4jdTiZ5IlygQw2/ZtyPWwarw3HW+p51H0TUsQYFsxvWrwEjgnFu+qugSQYSCLHBOUE8liLj/wN1vu+ZKprjkI2Ck7GptE41f+ryEs12ni8cvSu/sHSyAON/WryqmK3ff1t2bzXFyp1LJBfnoQ/8dENIsySUpOK4GBd9epAx94kMxxZeTQychjuVy83K+nXeFw3N61KeN3assHh+kOTeIOLTL;4:uNHlRA3+R9GpHy+YXQwqfNqvfmc0tNg9QuNogM7GbWTjc477omHtAAJUUDbf1kJsT8eo/viUvx6UDvoVinBePj65UM5QZZVaHnr3EEO0B7LASZgPJ1F1g98im5qEi7Weal8wx3wXvAxpdI1ctKdca0PctMHlYd3I61ZQG1+SDHgmJOeIGnpYP+rHVsIHd0Ti8aywF0Liy7BMSQwA/tmK7VKM6wp7FJdgu8Mg/S3eobVonDP856OCLye51FEPnQL/UMt00ivtuqBteRItJBslcA== 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)(93006095)(93001095)(10201501046)(3002001)(3231023)(944501075)(6055026)(6041268)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:CY4PR12MB1143;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR12MB1143; X-Forefront-PRVS: 054642504A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(396003)(366004)(39380400002)(376002)(39860400002)(346002)(189003)(199004)(24454002)(316002)(4326008)(229853002)(2906002)(7736002)(5660300001)(16576012)(52116002)(2486003)(52146003)(23676004)(54906003)(3260700006)(36756003)(478600001)(83506002)(106356001)(58126008)(25786009)(65826007)(105586002)(6116002)(66066001)(65806001)(65956001)(47776003)(72206003)(76176011)(3846002)(16526018)(386003)(53546011)(31696002)(6246003)(86362001)(90366009)(31686004)(50466002)(53936002)(64126003)(97736004)(305945005)(230700001)(8936002)(6916009)(68736007)(8676002)(2950100002)(77096006)(6666003)(81166006)(81156014)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1143;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQzOzIzOmdmdkJJakltTG1helhjdGVteEZmNjhoTmlN?= =?utf-8?B?aFNld25IL29QcU1UbFB5Y0hLUG1GZlpMSmtCZGl3ZE1yNElrQll0dWNVbUNJ?= =?utf-8?B?dGQraFIxbndxQ1VXamJVZEFwMmVRekRqdUFOSkN1elQxTFNZWXNuTU1FYzls?= =?utf-8?B?RGJXUkc5cnI1U0J6UlRnaWFkN3VnWTVvZ25iRWozOGVzSk9NNXJnc2dxZWRy?= =?utf-8?B?TkNKOUdrWUhkUVEydEpKbjZvTWgxYStRc1l5bW9QcnBZMEFiL0FXUm5BS2VV?= =?utf-8?B?MlRueEd0MVZtZ0oxcUNIVUQxUTgrVDBqUEhRUlovZzVER2luOEZqUUVYMGZz?= =?utf-8?B?R0tnY0VXcUJqekprUnV0MTdaUHRDRjdHaXlyMGNkK1c2NVNVd09hWC82Wm52?= =?utf-8?B?bUppT2N3K2lmN2NFQmhIOXIreEl3cVZUc05jWVpmcTF4RFFrMThWQmkxTnBp?= =?utf-8?B?c1VLK2ZoQmRXZWhwb0N3MHpQdWZwMXVEZkdSUUtUay93SmIwRlV0K3YzYTk4?= =?utf-8?B?bFgwT0VlN01INk1hOHZJNGVwY01GTW9oSG5FMWZtMUpvU3pzd1VOWmxnTzVO?= =?utf-8?B?MmpXMC9qNyt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jrTjV9ikzkPEkXnmzx19A4s128Cf60JZdzI5ArLaBo=;24:Z7wtRPdsAZ3y5PUtA5z8Rgwchjl555UB98sYMBOkbZJ4azqwLMJjFhjOu2wfiK23saGhdcj7oLH+rXxKpLW8sv19d6mIMUAO+O68lGVbbxs=;7:rodg7Wj1MWsPX8WR6YqBJ25MJKGuUjNhVx4Cnb7AAZzMXxVKZF4hGVkurQd/quieuk0Oz6x9vyGVTRCUPEuybum9uNRzIVzMnDcUxdUNx+JRQ6GeOQI9zqBNov0vdaGy2fiy54nS1t5hrEcv1xWiMZIAPzvAHKE/Vva8aUollhlHHmUTI1Za9FWj8GlaXHkMhTwS95epQ7kEJCXhL72UfZwL4wJZCPZBWn8+B9DLdO6iOLviQVZ0oYpoJsVzuObM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1143;20:UOipmEAodfffwQSEq3SltOnLD03zK0CjuGJDeqDfKbmLW5yzhiFnDiJXP1sbixBZ59L+HzUcfXX6DdCQLiufFlvj2OeyIxfZ805+JUw7KwjWYaoWAaYGzNsgdzrs28mPGdNfO/n30IEchGuxILFKIisGqqvk1pwvbr+dBqmroS2OArEo58fIgv8C/z9dEM3koodz7HTq4kj/xGwHx+zlhPexw+Y6uPlELRS+fTmuYtdDrkUq7wzoDYJTQpzF7Ikj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2018 23:20:18.8571 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae9f4223-f386-49fc-b1d8-08d556ee6239 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1143 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 1/7/2018 12:25 PM, Borislav Petkov wrote: > On Thu, Dec 21, 2017 at 04:03:21PM -0600, Tom Lendacky wrote: >> @@ -568,17 +578,57 @@ static void __init sme_populate_pgd_large(struct sme_populate_pgd_data *ppd) >> native_set_pud(pud_p, pud); >> } >> >> + return pmd_p; >> +} >> + >> +static void __init sme_populate_pgd_large(struct sme_populate_pgd_data *ppd) >> +{ >> + pmd_t *pmd_p; >> + >> + pmd_p = sme_prepare_pgd(ppd); >> + if (!pmd_p) >> + return; >> + >> 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(ppd->paddr | ppd->pmd_flags)); > > Ugly linebreak. That one will be fixed in the previous patch. > >> } >> >> -static void __init __sme_map_range(struct sme_populate_pgd_data *ppd, >> - pmdval_t pmd_flags) >> +static void __init sme_populate_pgd(struct sme_populate_pgd_data *ppd) >> { >> - ppd->pmd_flags = pmd_flags; >> + pmd_t *pmd_p; >> + pte_t *pte_p; >> + >> + pmd_p = sme_prepare_pgd(ppd); >> + if (!pmd_p) >> + return; >> + >> + pmd_p += pmd_index(ppd->vaddr); >> + if (native_pmd_val(*pmd_p)) { >> + if (native_pmd_val(*pmd_p) & _PAGE_PSE) >> + return; >> + >> + pte_p = (pte_t *)(native_pmd_val(*pmd_p) & ~PTE_FLAGS_MASK); >> + } else { >> + pmd_t pmd; >> >> + pte_p = ppd->pgtable_area; >> + memset(pte_p, 0, sizeof(*pte_p) * PTRS_PER_PTE); >> + ppd->pgtable_area += sizeof(*pte_p) * PTRS_PER_PTE; >> + >> + pmd = native_make_pmd((pteval_t)pte_p + PMD_FLAGS); >> + native_set_pmd(pmd_p, pmd); >> + } >> + >> + pte_p += pte_index(ppd->vaddr); >> + if (!native_pte_val(*pte_p)) >> + native_set_pte(pte_p, >> + native_make_pte(ppd->paddr | ppd->pte_flags)); > > Ditto. And this one will be fixed here. Thanks, Tom >