From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-bn3nam01on0068.outbound.protection.outlook.com ([104.47.33.68] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dUwgQ-0000xD-Ad for kexec@lists.infradead.org; Tue, 11 Jul 2017 15:02:40 +0000 Subject: Re: [PATCH v9 07/38] x86/mm: Remove phys_to_virt() usage in ioremap() References: <20170707133804.29711.1616.stgit@tlendack-t1.amdoffice.net> <20170707133925.29711.39301.stgit@tlendack-t1.amdoffice.net> From: Tom Lendacky Message-ID: <81fbf5db-c42f-cfe6-5d31-d60adbd18f26@amd.com> Date: Tue, 11 Jul 2017 10:02:05 -0500 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Brian Gerst Cc: linux-efi@vger.kernel.org, Brijesh Singh , Toshimitsu Kani , linux-doc@vger.kernel.org, Matt Fleming , the arch/x86 maintainers , Linux-MM , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , linux-arch , kvm@vger.kernel.org, Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , kasan-dev@googlegroups.com, Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Konrad Rzeszutek Wilk , Borislav Petkov , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , kexec@lists.infradead.org, Linux Kernel Mailing List , xen-devel@lists.xen.org, iommu@lists.linux-foundation.org, Thomas Gleixner , Paolo Bonzini On 7/10/2017 11:58 PM, Brian Gerst wrote: > On Mon, Jul 10, 2017 at 3:50 PM, Tom Lendacky wrote: >> On 7/8/2017 7:57 AM, Brian Gerst wrote: >>> >>> On Fri, Jul 7, 2017 at 9:39 AM, Tom Lendacky >>> wrote: >>>> >>>> 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, the default is to add pagetable >>>> mappings with the encryption bit set unless specifically overridden. The >>>> resulting pagetable mapping from phys_to_virt() will result in a mapping >>>> that has the encryption bit set. With SME, the use of ioremap() is >>>> intended to generate pagetable mappings that do not have the encryption >>>> bit set through the use of the PAGE_KERNEL_IO protection value. >>>> >>>> Rather than special case the SME scenario, remove the ISA range check and >>>> usage of phys_to_virt() and have ISA range mappings continue through the >>>> remaining ioremap() path. >>>> >>>> Signed-off-by: Tom Lendacky >>>> --- >>>> arch/x86/mm/ioremap.c | 7 +------ >>>> 1 file changed, 1 insertion(+), 6 deletions(-) >>>> >>>> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c >>>> index 4c1b5fd..bfc3e2d 100644 >>>> --- a/arch/x86/mm/ioremap.c >>>> +++ b/arch/x86/mm/ioremap.c >>>> @@ -13,6 +13,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> >>>> #include >>>> #include >>>> @@ -106,12 +107,6 @@ static void __iomem >>>> *__ioremap_caller(resource_size_t phys_addr, >>>> } >>>> >>>> /* >>>> - * Don't remap the low PCI/ISA area, it's always mapped.. >>>> - */ >>>> - if (is_ISA_range(phys_addr, last_addr)) >>>> - return (__force void __iomem *)phys_to_virt(phys_addr); >>>> - >>>> - /* >>>> * Don't allow anybody to remap normal RAM that we're using.. >>>> */ >>>> pfn = phys_addr >> PAGE_SHIFT; >>>> >>> >>> Removing this also affects 32-bit, which is more likely to access >>> legacy devices in this range. Put in a check for SME instead >> >> >> I originally had a check for SME here in a previous version of the >> patch. Thomas Gleixner recommended removing the check so that the code >> path was always exercised regardless of the state of SME in order to >> better detect issues: >> >> http://marc.info/?l=linux-kernel&m=149803067811436&w=2 >> >> Thanks, >> Tom > > Looking a bit closer, this shortcut doesn't set the caching > attributes. So it's probably best to get rid of it anyways. Also > note, there is a corresponding check in iounmap(). Good catch. I'll update the patch to include the removal of the ISA checks in the iounmap() path as well. Thanks, Tom > > -- > Brian Gerst > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec