Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754593AbcKNQj4 (ORCPT ); Mon, 14 Nov 2016 11:39:56 -0500 Received: from mail-cys01nam02on0075.outbound.protection.outlook.com ([104.47.37.75]:55559 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752253AbcKNQjw (ORCPT ); Mon, 14 Nov 2016 11:39:52 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Subject: Re: [RFC PATCH v3 10/20] Add support to access boot related data in the clear To: "Kani, Toshimitsu" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "kasan-dev@googlegroups.com" , "x86@kernel.org" , "iommu@lists.linux-foundation.org" , "linux-efi@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-doc@vger.kernel.org" References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003631.3280.73292.stgit@tlendack-t1.amdoffice.net> <1478880929.20881.148.camel@hpe.com> CC: "matt@codeblueprint.co.uk" , "corbet@lwn.net" , "tglx@linutronix.de" , "konrad.wilk@oracle.com" , "joro@8bytes.org" , "dvyukov@google.com" , "aryabinin@virtuozzo.com" , "riel@redhat.com" , "lwoodman@redhat.com" , "mingo@redhat.com" , "hpa@zytor.com" , "luto@kernel.org" , "pbonzini@redhat.com" , "bp@alien8.de" , "glider@google.com" , "rkrcmar@redhat.com" , "arnd@arndb.de" From: Tom Lendacky Message-ID: Date: Mon, 14 Nov 2016 10:24:14 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1478880929.20881.148.camel@hpe.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR07CA0013.namprd07.prod.outlook.com (10.172.94.23) To CY4PR12MB1142.namprd12.prod.outlook.com (10.168.163.150) X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;2:JcyLntUAdJroC7zH8XmkRV7akhliSWot/SjHB0x7UQDxddLw4nSuAgdJRyCUKJGst5Jboi31u6ByFWms48qiawYTrycPAQFiNLFYRsMG5QSkaPkfnyLRQQarnD01+VcgEdY8u7e3METh6kiYYctN9H3P+rowEUMRKaT/gTIZGrQ=;3:ISI0aBDUUDwkkUFcFx12i8Z21IqHEefGYnGi5Aw27SJ4D9wWPG6RhlbwPNcvfR6WZqbkbEeNp/aQS6HGViVZF6ppxBIt/czWjHZ37bVZbUV6CsSUlW9BpWfiv2WYZcKIra3cuqApvA/cpEwdTkEgcwED6+INrgeb5HJg/YWHtHc=;25:aJGlpy3KY2BFAmO3cNE9OX/8mvuSSzK0VCPMh0Zvs0dN3ryeByPMRXiP4lNVwMHWiifAwJukpQQcbK7+RTLUBuLFxZ4DkghV5Vc6ie/ptyIuU6aUkcMIe6PF8+sx3aDgQ7Dzps84Stq1IGdKvTfiEtUg2Bn4tqOVC2IFTwXydnqDY++fQhZmYd0XM1ZOKl0CeqjQTN9kaC6SQBy8LnqlikYLlUEoQhOBV2tzxZxNM1IlqmrJuP85JOSRutPesok4yD729nFX0UDUIJ0YRv2UDHCNovSt/1OEleOUm764FOJb82bVyi9a7NpgLBpEc7aeCH5STx+2D3dyYcNt3N6vVF5aCNKqmlF9Vx+m9tpL+quzn+wO/XvG/r2xIIsfW2v0OuxEbfTG8w7j9G4SQWT8PLw6P1cl7NZ4PCSznqo0hGlAN+Pn0R7r289aBABRTtnQ X-MS-Office365-Filtering-Correlation-Id: 8580b580-8e00-4412-8530-08d40caab03c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;31:zA7Ut3gc3ESyB/crg+Z6vLGkyqb6wqtGrMDbepCfE/5nuviiQKQM43QpGptroul/R/SqQDoOZxNFzSXTfZh4L3u3utJxQfxaRAzqbnfVGduIp438OPC2HG31fulHPUokWazf+Y1dayNCHNSfoviW2xPxFqtp0E65ccamMIUKJN6+tXKfoCjE1lXB7HAJNuSaryQwtYf1HRB1jdrVY2ziC/170fIQH2ME3V1qqpsQqsXbGnKUr5IvYzesFdph7awg;20:Jr727nXRbhk6q/tFxr5PODGQQ92eLwCOXjvzJubZzAB6SbRqwQDI9dmXN8A5aONGsXW8UMO3LL76ug2Rqu/2KOFuZr+VAU+BU9kznYQ5Ur6ntDcHKA/L21xJ0CutJUEZPlj9TO2WvfwHsl0qD+JEKmhQT5LnYg9tI//GlJk41Vy0GIFG62tsAo9z6H0xS2NiXSXTg61uqli8ly2cr+V877Hvtf75K1bO0FNDDoj7Nm6DWZDfi5O+tiJuSyh/7CQt3Cff8G/sbL0PqoVWGuWSlUpdD+GPrgLRoXZOtxL5rQAOhPic2C7PYJkEKGro0uycH6kFVwCtS/vldO1uH4Ug3tHo/XtSBcgI8wRpoTQw8kJXlSBBIix50zmaSWs6A043lkJFFvsOfM7/GICqtaDE6SgCO4swhKJ9HFxMmZtA2vIzc57LuhHsJiRH8I4K9UbcGtz0iiZa+GHAU4kwONWFHKBUeMb306AzGqIRmrbyMTSWqThfzagOsfxhClCLtVcF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6061321);SRVR:CY4PR12MB1142;BCL:0;PCL:0;RULEID:;SRVR:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;4:nvePYi57GxGYgrYwsImD0QtM5CoAzllFfFacN79kZ6n3XlF3aNFVwwRzPaWeZQI3Utx+PyS7bCeKeMkVqqubroye/06r5V18KHex7A7Ra4ECAxQws2ol7+CnU8DdPMj4RbTNDrT8w2Cuk9C/jOAXPw2BwwQPzo7l86k481I9IAdjA6/t1w2OJaRCBzdy3Rcq2Cin4ahgvXpq6UuggvDfDZV/QYwWRIJ7UFOkh9pS+Ner2ec1H4JTNYujqzJ9EMs1r8Ug9r4a1OnKYUL8yEdffLNNKOzs8WUMaaAKdDg3A13UDTT2DqrJGp0EiIHLolTy90MDeszews4zOVe9q8/RvLo1SzHtWtutIM+ZuYyCbCkMo/Et6Twj/buf65bggC41uKnbG9H6JhvOl8jOLZkJwUR1NZ/E0J9Sy66/rpLvqn7cE8gWv+a/D9coe0Hd8Bwo X-Forefront-PRVS: 0126A32F74 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(24454002)(189002)(199003)(377454003)(377424004)(105586002)(106356001)(36756003)(230700001)(7416002)(42186005)(2950100002)(50466002)(3846002)(6116002)(76176999)(4001350100001)(189998001)(50986999)(5001770100001)(54356999)(101416001)(586003)(33646002)(65826007)(5660300001)(4326007)(86362001)(31696002)(2201001)(229853002)(64126003)(2906002)(81166006)(77096005)(81156014)(65806001)(7846002)(47776003)(7736002)(8676002)(23676002)(65956001)(92566002)(66066001)(2501003)(83506001)(31686004)(305945005)(97736004)(68736007)(6666003)(921003)(1121003)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1142;H:[10.236.18.82];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQyOzIzOjVqVE5reVMrVGFETkNIOHhscnBQcitBSU90?= =?utf-8?B?Qk5HNWpYUHRHZ3ZxYlYzdGRDeGZCQ3cya3BUeDltYjBSaUxuOC9hVEp1dXNl?= =?utf-8?B?Um1nUkRQZDdpeWtMV2V5SE1pM0wyWUM4Vm1XTFB5cS8rVE91QXgzYURBeC90?= =?utf-8?B?QktiWGlNY3FDRUFiWG93Z0toeTVlOGtGeEh2ZWlwcHJ0M2ovSUl2NlRPREVx?=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elHqaPXPgCgUNbcD8PGW6j5lcIIz2ckLd+GWVTq3B3rtG17WUEJnvufJUAf9ASIEcyITkMx4fhm+6yA6kfUFtpVxgQ5amNLcqsxMgMGVyMW3S56j1BuFRmZlCaKJairx29A0xVWplG1Uu2JEejt8lQvXrbOV5/AzbmWOSt0dbUVqJD+T5TFSQLA4PV0gW/bwBAWls5tSi+6F+W1W4Ut5pyktLTojGXgDFUuFbl23rvixSBpKRwYAQmP/V3p X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2016 16:24:18.3963 (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: 1657 Lines: 54 On 11/11/2016 10:17 AM, Kani, Toshimitsu wrote: > On Wed, 2016-11-09 at 18:36 -0600, Tom Lendacky wrote: >> Boot data (such as EFI related data) is not encrypted when the system >> is booted and needs to be accessed unencrypted. Add support to apply >> the proper attributes to the EFI page tables and to the >> early_memremap and memremap APIs to identify the type of data being >> accessed so that the proper encryption attribute can be applied. > : >> +static bool memremap_apply_encryption(resource_size_t phys_addr, >> + unsigned long size) >> +{ >> + /* SME is not active, just return true */ >> + if (!sme_me_mask) >> + return true; >> + >> + /* Check if the address is part of the setup data */ >> + if (memremap_setup_data(phys_addr, size)) >> + return false; >> + >> + /* Check if the address is part of EFI boot/runtime data */ >> + switch (efi_mem_type(phys_addr)) { >> + case EFI_BOOT_SERVICES_DATA: >> + case EFI_RUNTIME_SERVICES_DATA: >> + return false; >> + } >> + >> + /* Check if the address is outside kernel usable area */ >> + switch (e820_get_entry_type(phys_addr, phys_addr + size - >> 1)) { >> + case E820_RESERVED: >> + case E820_ACPI: >> + case E820_NVS: >> + case E820_UNUSABLE: >> + return false; >> + } >> + >> + return true; >> +} > > Are you supporting encryption for E820_PMEM ranges? If so, this > encryption will persist across a reboot and does not need to be > encrypted again, right? Also, how do you keep a same key across a > reboot? The key will change across a reboot... so I need to look into this more for memory that isn't used as traditional system ram. Thanks, Tom > > Thanks, > -Toshi >