From mboxrd@z Thu Jan 1 00:00:00 1970 From: Borislav Petkov Subject: Re: [PATCH v7 33/36] x86/mm: Use proper encryption attributes with /dev/mem Date: Fri, 23 Jun 2017 11:32:36 +0200 Message-ID: <20170623093236.ei7z2zmc6vjq5lod@pd.tnic> References: <20170616184947.18967.84890.stgit@tlendack-t1.amdoffice.net> <20170616185607.18967.51412.stgit@tlendack-t1.amdoffice.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Return-path: Received: from mail.skyhub.de ([5.9.137.197]:39608 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753984AbdFWJcx (ORCPT ); Fri, 23 Jun 2017 05:32:53 -0400 Content-Disposition: inline In-Reply-To: <20170616185607.18967.51412.stgit@tlendack-t1.amdoffice.net> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Tom Lendacky 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 , Radim =?utf-8?B?S3LEjW3DocWZ?= , Matt Fleming , Alexander Potapenko , "H. Peter Anvin" , Larry Woodman , Jonathan Corbet , Joerg Roedel , "Michael S. Tsirkin" , Ingo Molnar , Andrey Ryabinin , Dave Young On Fri, Jun 16, 2017 at 01:56:07PM -0500, Tom Lendacky wrote: > When accessing memory using /dev/mem (or /dev/kmem) use the proper > encryption attributes when mapping the memory. > > To insure the proper attributes are applied when reading or writing > /dev/mem, update the xlate_dev_mem_ptr() function to use memremap() > which will essentially perform the same steps of applying __va for > RAM or using ioremap() for if not RAM. > > To insure the proper attributes are applied when mmapping /dev/mem, > update the phys_mem_access_prot() to call phys_mem_access_encrypted(), > a new function which will check if the memory should be mapped encrypted > or not. If it is not to be mapped encrypted then the VMA protection > value is updated to remove the encryption bit. > > Signed-off-by: Tom Lendacky > --- > arch/x86/include/asm/io.h | 3 +++ > arch/x86/mm/ioremap.c | 18 +++++++++--------- > arch/x86/mm/pat.c | 3 +++ > 3 files changed, 15 insertions(+), 9 deletions(-) Reviewed-by: Borislav Petkov -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.skyhub.de ([5.9.137.197]:39608 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753984AbdFWJcx (ORCPT ); Fri, 23 Jun 2017 05:32:53 -0400 Date: Fri, 23 Jun 2017 11:32:36 +0200 From: Borislav Petkov Subject: Re: [PATCH v7 33/36] x86/mm: Use proper encryption attributes with /dev/mem Message-ID: <20170623093236.ei7z2zmc6vjq5lod@pd.tnic> References: <20170616184947.18967.84890.stgit@tlendack-t1.amdoffice.net> <20170616185607.18967.51412.stgit@tlendack-t1.amdoffice.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170616185607.18967.51412.stgit@tlendack-t1.amdoffice.net> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Tom Lendacky 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 , Radim =?utf-8?B?S3LEjW3DocWZ?= , 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 , Andy Lutomirski , Boris Ostrovsky , Dmitry Vyukov , Juergen Gross , Thomas Gleixner , Paolo Bonzini Message-ID: <20170623093236.oUB_l327DmKEITowuzoZEZtaqbYV6rpOfDyuXw0K0dk@z> On Fri, Jun 16, 2017 at 01:56:07PM -0500, Tom Lendacky wrote: > When accessing memory using /dev/mem (or /dev/kmem) use the proper > encryption attributes when mapping the memory. > > To insure the proper attributes are applied when reading or writing > /dev/mem, update the xlate_dev_mem_ptr() function to use memremap() > which will essentially perform the same steps of applying __va for > RAM or using ioremap() for if not RAM. > > To insure the proper attributes are applied when mmapping /dev/mem, > update the phys_mem_access_prot() to call phys_mem_access_encrypted(), > a new function which will check if the memory should be mapped encrypted > or not. If it is not to be mapped encrypted then the VMA protection > value is updated to remove the encryption bit. > > Signed-off-by: Tom Lendacky > --- > arch/x86/include/asm/io.h | 3 +++ > arch/x86/mm/ioremap.c | 18 +++++++++--------- > arch/x86/mm/pat.c | 3 +++ > 3 files changed, 15 insertions(+), 9 deletions(-) Reviewed-by: Borislav Petkov -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.