Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752635AbdFGT1U (ORCPT ); Wed, 7 Jun 2017 15:27:20 -0400 Received: from mail-sn1nam01on0072.outbound.protection.outlook.com ([104.47.32.72]:60283 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752241AbdFGTOe (ORCPT ); Wed, 7 Jun 2017 15:14:34 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; From: Tom Lendacky Subject: [PATCH v6 07/34] x86/mm: Don't use phys_to_virt in ioremap() if SME is active To: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Date: Wed, 07 Jun 2017 14:14:23 -0500 Message-ID: <20170607191423.28645.14413.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170607191309.28645.15241.stgit@tlendack-t1.amdoffice.net> References: <20170607191309.28645.15241.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: BN6PR03CA0057.namprd03.prod.outlook.com (10.173.137.19) To MWHPR12MB1149.namprd12.prod.outlook.com (10.169.204.13) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR12MB1149: X-MS-Office365-Filtering-Correlation-Id: 4ca35eed-b7ba-4ec5-e4f3-08d4add96c8a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;3:8r7F4SjgJKdx8D6AsWJdFKaXfsqB3E4pOMUYj7elsaIzykENtsDLtjxmWcPMBtu4RvoqxA+wB/0fLaf/sZrfPmoN116Xsyug7NPXdLh6HroSuUqQt3ybBuOddar73tvdQxY53Od1RrZxlf/O9ppHTsyFMPWVuPWBmXVJF19ic4qLobuJ2SsHNQOVAEVqG29Aptz5deg/WycJ/5T71dxzrkIZq6HcoQhkZ7IVdIFG5X9Itl4gfh6FM1qIfeWO7adyLioGpUhViwAopE9zEemYqlkqFWYnMVGKLkjwUAkwN8CyJAXJfKILk/Dulocz+82YP5LSKM/rkUO261PkdFjFgeTpg0FK9lpjOIgSJ2o364k=;25:u6Py4vTc5s4j1bXUeLALH8oFOaoDT1BdBqJtSkkCrLVpkGJLWwmPOzUmHNF9IUrWG6IlDVBOuDv0yBzAN3OCctextLBHnV45DxlGR6JghOGrCJiBpcriPZwMNClIgI7mk/6adktr+nZQwvLcVOatDSo7NybY7JKXUDtd9hDqGx9lhgpJIj3cmVtN1fQqaW7QGeuKv95UE2BXhH8iiFRSosSsjYdI0DbdDhGbW9dHB9MrdwxsP1o2G5P4PsHX/s8LEjUYQn9TzzOpB6I1sZXkladV/Chlgi/hm5KWWo0LnD8bG6ydE+WB5UDEtpoVmjlxrqdSLI/v3lBgrmq59cGJsQ5j+LTHxIHjYi/nE6wIfCe8H05RFwRm56qq9qvAhgmQr3oiHQiXIXmLwdmxrpOvGneaDnCYYZhdSt4rU6+lw+CiSEL3PROloE2w9/nU/VB3UE2lBFAdFnByv5TU4Tny1keqtfS1vWBJKm+uTNGlxI8= X-Microsoft-Exchange-Diagnostics: 1;MWHPR12MB1149;31:xUrnHSfn267b0dTjwr9yUIgOSdqzBdUEVo2fDUUrPPvMC3x51aom1Y0lIqhhFhLBeJfvvcaqSXPx+4wnv0JTqan2OH0IpAXIqXhSxpp8FYzk4B/Z623hewxidxFMZDHYMKi9+C7rVn08rQkkpEiYWiBeim6oBzCSrMSYwGThjBvoJyRcu0ELsdrUkR3PMGynoA7b+EUtNxiq+TuHxz0ofpRFr08DFJoXiujWA9lp5NI=;20:AL9GM99/LtfW4BxnyEXkrMctd9lQRQLJhJBRI4ao7ia9+APe84RWFSyRpf1tZaG46HcSWDMyrka5BdGSQAvOMibNQQrINVas+tQcQW0TLPgGpMNFoQEezgpTEJzzcOvu/f6PzdwjJHMtoCSAyDaOxlc4MGNekUgrhzIA0EVCp1l+GJnOgIE8RoxkIKLcMsqGSOlKJggMZJhkbthmX4sYB6mkDilwLiGjCIW4ArBoGmL3i6aTXMA6/GnB70MoUo4MkRCRffhJNrB/pi1G10eFZTSLBPTJ6N9xtt/564vO2q4eqhvH5/embKf2/LQGDs9Pj9xQm9A6II4suawt6loIWbXWn7Fr0DbfKdBQDEai8n7jD/yysxzxs0KI5sWr+K3sPzk7FyUfCD7TpiGZzgZXXnx8BjVeVB5di5AnF2G/kS0Ifi6v5bew1Cl456bWdOjtt1HJM9GqPmr/DUbvnL5QB6TUjhaJ3A12blXPR6gGXgwvrAV5LShC6zHplfkpG1Ft X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123555025)(20161123558100)(20161123564025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR12MB1149;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR12MB1149; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzQ6bDJrTjVKSlhSak1yYmRycEJ2eTVKMVNVcjhT?= =?utf-8?B?cng1YmI3eDNGVExWc3Fud1JRdmtKcTZRN1RJSHpjbldvTVZoVVFoV2hUKy9Q?= =?utf-8?B?QVFNRGU3U05nTmJ2U3QrOHVEMjRBeEJJVW0wKzN1TWx2VjRCV2ZLTHFVaEM1?= =?utf-8?B?UDB0ekdHUjMyUzBpdERDMHl0dGhSdHhYY2w0c3hEQVZsNEdRS2FFNHpCNGJI?= =?utf-8?B?TExReFJHemh1cFhQZkk5ZGV6TVRZREtla0FhamhaaUxTRzYydlRiTGVlclY3?= =?utf-8?B?citBQVBCdlo0bEJUR09ZV21LRCswRkRvV3BCdUw0aVRWSCtkU09oT1p5WEwr?= =?utf-8?B?MEtZV04yeFlnak1SWmtqUnZZS2xoQXplbU1FK0JsSU5zUXNMMmFaOG52SURh?= =?utf-8?B?Z3NiS0RJOUtyYm42MG4rSWFDcjV4ak92dWw3ZXVLa3ZJOFdoK3czRnIrUFRI?= =?utf-8?B?RFg0WHpTNVVSOXdCM0l6Z21mRE1LMlhFSlZYN0F1UmNvaXFPSU4wV3FNejZT?= =?utf-8?B?SW5CWkc2S29VQ2R3aE90elNmREdLNEMwSWg0SGNob3Q0dlR1OFdwTGxUQ1Yr?= =?utf-8?B?VmJRb0dyTzZBNGhORmtpKy8vZitETmFsSmF2NU1xbEtSaU52OEI1cU1QaWRz?= =?utf-8?B?VXBTMWJJZXI1NitmSlhUeWoveURISUgwY0g0ZmJjcmhMUGMzNERiUW50bWNO?= =?utf-8?B?SGQ1ejlEZHNFZmNwNk8wY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ZbHx6uC6Ful9?= X-Forefront-PRVS: 03319F6FEF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39860400002)(39400400002)(39410400002)(39850400002)(39450400003)(39840400002)(6506006)(38730400002)(53416004)(478600001)(72206003)(54906002)(53936002)(66066001)(3846002)(9686003)(110136004)(6116002)(81166006)(54356999)(76176999)(50986999)(4001350100001)(4326008)(86362001)(1076002)(42186005)(97746001)(6666003)(575784001)(2950100002)(189998001)(47776003)(83506001)(23676002)(33646002)(2906002)(7416002)(230700001)(305945005)(7406005)(50466002)(25786009)(5660300001)(8676002)(55016002)(7736002)(103116003)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR12MB1149;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxMTQ5OzIzOlZ1RTZCVU5taFRReHc1K05CUTIyM2Y0aXla?= =?utf-8?B?dDNpVGpGQkhQWGZzQlM3RjJpdDU5WEpkelVwRk9IQktDYmZORDNyMWhXT294?= =?utf-8?B?WE8yRFlZeFM0NUJVdXZvck1FRjU4S2d3YmFHWXp1N2xiZWsrU1lKWlJpNHhG?= =?utf-8?B?SjNBV0RrQVNUcm9pN2M5NDhqdGkwbkxjdkhZNjRKVmtJV2RkSWFjSjVPbGE1?= =?utf-8?B?UXJoUGJpYVpQV0kwZGdEamYwN3UzbW5CQktISzBnVU9nTWF6SmJJR0d4b2hy?= =?utf-8?B?UksyQ0kreXVSUS9QREU0SWJOWDBtZmZnN2lWNHFTcmR3UFpCa3VkZUVWaFZq?= =?utf-8?B?ay9rTzh4ZkJ6anVTU1Q4Qlk0RXJheEh6d01aMi9VVFkyaE84R3ZjQzZuS1Bv?= =?utf-8?B?Z2x6QlhYUUQrSTdNTjNMYjM3SS9KZG1vcWtLbDZIeFNZdkkxWlNhYVVWbStL?= =?utf-8?B?R25rNzJMQXBVc3F5K080an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IVTtrD2sVjA==;20:uL2iTsdq3z/8NOT5Zt9ocYDMxV/f/1yoN4X7KdLEWISX76t2NTkyyjS3maFeEhF8LKsvSDOm6YPWt2p69YMr8hwyuCBqQOVyIM2wCmaTeyhqc1J/xBQx8L9szgjwJqdWFnLRnLWo17XfCb8ra27lKPnb6wsI6R18lCkNCpyX8h/Ly/qG4sgzaE77KH8n1ynaapxQqyuW1mwNms5uX3yIkuXXX/vuGILp0HwIxL0na6ClwZ2Z3FNC4m1VONuDQK7Z X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2017 19:14:26.9712 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1149 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1310 Lines: 38 Currently there is a check if the address being mapped is in the ISA range (is_ISA_range()), and if it is then phys_to_virt() is used to perform the mapping. When SME is active, however, this will result in the mapping having the encryption bit set when it is expected that an ioremap() should not have the encryption bit set. So only use the phys_to_virt() function if SME is not active Signed-off-by: Tom Lendacky --- arch/x86/mm/ioremap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index bbc558b..2a0fa89 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "physaddr.h" @@ -106,9 +107,11 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr, } /* - * Don't remap the low PCI/ISA area, it's always mapped.. + * Don't remap the low PCI/ISA area, it's always mapped. + * But if SME is active, skip this so that the encryption bit + * doesn't get set. */ - if (is_ISA_range(phys_addr, last_addr)) + if (is_ISA_range(phys_addr, last_addr) && !sme_active()) return (__force void __iomem *)phys_to_virt(phys_addr); /*