From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Lendacky Subject: Re: [PATCH v7 07/36] x86/mm: Don't use phys_to_virt in ioremap() if SME is active Date: Wed, 21 Jun 2017 08:52:53 -0500 Message-ID: References: <20170616184947.18967.84890.stgit@tlendack-t1.amdoffice.net> <20170616185104.18967.7867.stgit@tlendack-t1.amdoffice.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Thomas Gleixner Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Brijesh Singh , Toshimitsu Kani , linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Matt Fleming , x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jonathan Corbet , "Michael S. Tsirkin" , kasan-dev-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Borislav Petkov , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , kexe List-Id: linux-arch.vger.kernel.org On 6/20/2017 3:55 PM, Thomas Gleixner wrote: > On Fri, 16 Jun 2017, 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, 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 > > This does not make sense to me. What the heck has phys_to_virt() to do with > the encryption bit. Especially why would the encryption bit be set on that > mapping in the first place? The default is that all entries that get added to the pagetables have the encryption bit set unless specifically overridden. Any __va() or phys_to_virt() calls will result in a pagetable mapping that has the encryption bit set. For ioremap, the PAGE_KERNEL_IO protection is used which will not/does not have the encryption bit set. > > I'm probably missing something, but this want's some coherent explanation > understandable by mere mortals both in the changelog and the code comment. I'll add some additional info to the changelog and code. Thanks, Tom > > Thanks, > > tglx > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-dm3nam03on0089.outbound.protection.outlook.com ([104.47.41.89]:10592 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750999AbdFUNxE (ORCPT ); Wed, 21 Jun 2017 09:53:04 -0400 Subject: Re: [PATCH v7 07/36] x86/mm: Don't use phys_to_virt in ioremap() if SME is active References: <20170616184947.18967.84890.stgit@tlendack-t1.amdoffice.net> <20170616185104.18967.7867.stgit@tlendack-t1.amdoffice.net> From: Tom Lendacky Message-ID: Date: Wed, 21 Jun 2017 08:52:53 -0500 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Thomas Gleixner Cc: 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, xen-devel@lists.xen.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Brijesh Singh , Toshimitsu Kani , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , Ingo Molnar , Andrey Ryabinin , Dave Young , Rik van Riel , Arnd Bergmann , Konrad Rzeszutek Wilk , Borislav Petkov , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , Paolo Bonzini Message-ID: <20170621135253.XpUpiMLa8QkJmd8u3FI1TBUalSH0NSzUXpOet4wOlm0@z> On 6/20/2017 3:55 PM, Thomas Gleixner wrote: > On Fri, 16 Jun 2017, 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, 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 > > This does not make sense to me. What the heck has phys_to_virt() to do with > the encryption bit. Especially why would the encryption bit be set on that > mapping in the first place? The default is that all entries that get added to the pagetables have the encryption bit set unless specifically overridden. Any __va() or phys_to_virt() calls will result in a pagetable mapping that has the encryption bit set. For ioremap, the PAGE_KERNEL_IO protection is used which will not/does not have the encryption bit set. > > I'm probably missing something, but this want's some coherent explanation > understandable by mere mortals both in the changelog and the code comment. I'll add some additional info to the changelog and code. Thanks, Tom > > Thanks, > > tglx >