Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932561AbcKJAx0 (ORCPT ); Wed, 9 Nov 2016 19:53:26 -0500 Received: from mail-bl2nam02on0052.outbound.protection.outlook.com ([104.47.38.52]:27072 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932295AbcKJAxR (ORCPT ); Wed, 9 Nov 2016 19:53:17 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; From: Tom Lendacky Subject: [RFC PATCH v3 18/20] x86: Access the setup data through debugfs un-encrypted To: , , , , , , , , CC: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Joerg Roedel , Konrad Rzeszutek Wilk , "Paolo Bonzini" , Larry Woodman , "Ingo Molnar" , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , "Thomas Gleixner" , Dmitry Vyukov Date: Wed, 9 Nov 2016 18:38:15 -0600 Message-ID: <20161110003814.3280.56548.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> References: <20161110003426.3280.2999.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: CY4PR13CA0022.namprd13.prod.outlook.com (10.168.161.160) To CY4PR12MB1142.namprd12.prod.outlook.com (10.168.163.150) X-MS-Office365-Filtering-Correlation-Id: 7be0dd64-b267-440d-4dc9-08d40901de23 X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;2:SDXCxkiRwmUDS+8Iu8V0EbzOYeOWgOEnHmLLF7DHPXLz1LsD7UffqLgd8ms4BPozCmtX1TFAOhGGh9EJNKOPp/D/8NJbbpdEXv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GN4Qg== X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;31:65wBHFmOTxREyxIPNYGnUJWPguVfmAQYG7C3F6obFlkElsiHaLf8ZPstXUENMpWzg3UvWJKREradkKNJuzUuxV4nPkry1QpgnO1qPx4rBvbzHAnBgwQ5ZqN5H+MC28V21EfwXhzTg8StOVpINrM8z6nFzPJix4/COfsji8Agjg24S8aEsBa4I7BOQkefGs9PT2Zf/88CQbnye2vc0LwMmdGlWBuiyYg4J436yyclfZeJ3Qnwplm243zvX05OK4Tf;20:PcJMnRtPKGIAzkaMADkPUyNRe4XpHKqvPJJCllXOvEwkD2rFAQl7C9hUK0K5MjFbZJWFIx1WXhF3S/gRUe0ddtQhndbl7VdTk5F4WGhhG5XKpWwiIJGVv9JgtBexBjto6OQoQ/s5NKNpCVgMYQRSwpB324mus8AkcCSerwvx//AuVB5IrBzUCxhV8Dk1xUnW4pM/jmoY6iD4Fmi9hBJ8DUOjH25gq9vzKz5saZdnV6e43vLqagXaXG7cTmywPqj3HLFLgymEwZUeCeF9tIsB07Tko4VNkXlOGmoOJx8++UsLjpYlXCuLDS1Ma2oGKpHa7/vM+xIajSjvbojcEk7KlAxty1zBT+xmhzQIklHMXeFoY/RmGV3yPnyYQzJydcF1Qltg4AoGmx4t60bB09MF9ZymNcQfSPfzXrfxIlMfse8upCbZfcXrJBdYquimpvODQUm3oQ1UuFNXJ/FJcvojBbz2nHsDByV+N42JRPHNNqtYRUjGBtOfBXzLW5Wcx6ac X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:CY4PR12MB1142;BCL:0;PCL:0;RULEID:;SRVR:CY4PR12MB1142; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1142;4:j8iyXgTFMlYZHqwoUaIRNFtcW5afYf3cLPNYVRrbLBhDrp503BOg4FgrWYNh6bSXtDFqpFEco4TXgJHWWfXkEQ0uv4k6AjppXiWfJBZsLsKmSlyOfq6cb2VFZl6HqN16M9wPBr7bfCUpiD0d48v4bhzNlc8RRD2CpBBRtjb6C/NYgS/1tPv2HiYpIyJJmAgiUmQh+3/CvY1+1Ccr8uZ/Lhxq2X80DKPg1AzfOXnhXz36u0jXOIwx415lD3mhnRTXnpdo0W7J13dh6D9hXa5SgKUWGgLuxP749m26EYNYK+EC6HQeWPIBdsx+/USSbaL5jeORXR/DklUORrjEtIOJhHXn0wI9rrA0vLX5YFJyICpXP394ObaVam/fJAaoIMHrldlsReRt1YQi1Cb2AmZL19Wk7oJn1MdgLj6KeVgEdx0SLgI+ziPGnBVBo9oQRKxb3cEB4aavQdAksl2b+hDxKg== X-Forefront-PRVS: 01221E3973 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(7846002)(97746001)(23676002)(7736002)(5001770100001)(305945005)(101416001)(6666003)(33646002)(69596002)(230700001)(92566002)(2950100002)(103116003)(4001350100001)(66066001)(47776003)(77096005)(97736004)(54356999)(50986999)(76176999)(83506001)(2906002)(6116002)(105586002)(586003)(4326007)(189998001)(7416002)(1076002)(3846002)(81156014)(5660300001)(8676002)(53416004)(86362001)(68736007)(81166006)(50466002)(42186005)(106356001)(2201001)(9686002)(71626007)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1142;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQyOzIzOlV1Q2k5MXUvSmltUGc2QU5uOCs4ODJDOStM?= =?utf-8?B?KzR2MzdVSG43SlprTVdEQmFwdVU0M05adVJ4MWlmUzZ4K3N2K1ZEampQUkwv?= =?utf-8?B?ZVBGdFNyK0RMYnVzQ2Fjd2wrUkROQjdOb2NacW5RN2Z6c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eG03JrY0aSGl X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2016 00:38:18.3648 (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: 1805 Lines: 67 Since the setup data is in memory in the clear, it must be accessed as un-encrypted. Always use ioremap (similar to sysfs setup data support) to map the data. Signed-off-by: Tom Lendacky --- arch/x86/kernel/kdebugfs.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c index bdb83e4..a58a82e 100644 --- a/arch/x86/kernel/kdebugfs.c +++ b/arch/x86/kernel/kdebugfs.c @@ -48,17 +48,13 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf, pa = node->paddr + sizeof(struct setup_data) + pos; pg = pfn_to_page((pa + count - 1) >> PAGE_SHIFT); - if (PageHighMem(pg)) { - p = ioremap_cache(pa, count); - if (!p) - return -ENXIO; - } else - p = __va(pa); + p = ioremap_cache(pa, count); + if (!p) + return -ENXIO; remain = copy_to_user(user_buf, p, count); - if (PageHighMem(pg)) - iounmap(p); + iounmap(p); if (remain) return -EFAULT; @@ -127,15 +123,12 @@ static int __init create_setup_data_nodes(struct dentry *parent) } pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT); - if (PageHighMem(pg)) { - data = ioremap_cache(pa_data, sizeof(*data)); - if (!data) { - kfree(node); - error = -ENXIO; - goto err_dir; - } - } else - data = __va(pa_data); + data = ioremap_cache(pa_data, sizeof(*data)); + if (!data) { + kfree(node); + error = -ENXIO; + goto err_dir; + } node->paddr = pa_data; node->type = data->type; @@ -143,8 +136,7 @@ static int __init create_setup_data_nodes(struct dentry *parent) error = create_setup_data_node(d, no, node); pa_data = data->next; - if (PageHighMem(pg)) - iounmap(data); + iounmap(data); if (error) goto err_dir; no++;