Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935253AbcKOTQl (ORCPT ); Tue, 15 Nov 2016 14:16:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50316 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754359AbcKOTQj (ORCPT ); Tue, 15 Nov 2016 14:16:39 -0500 Date: Tue, 15 Nov 2016 21:16:33 +0200 From: "Michael S. Tsirkin" 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, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, 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 Subject: Re: [RFC PATCH v3 13/20] x86: DMA support for memory encryption Message-ID: <20161115211603-mutt-send-email-mst@kernel.org> References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003723.3280.62636.stgit@tlendack-t1.amdoffice.net> <20161115171443-mutt-send-email-mst@kernel.org> <4d97f998-5835-f4e0-9840-7f7979251275@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4d97f998-5835-f4e0-9840-7f7979251275@amd.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 15 Nov 2016 19:16:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2378 Lines: 57 On Tue, Nov 15, 2016 at 12:29:35PM -0600, Tom Lendacky wrote: > On 11/15/2016 9:16 AM, Michael S. Tsirkin wrote: > > On Wed, Nov 09, 2016 at 06:37:23PM -0600, Tom Lendacky wrote: > >> Since DMA addresses will effectively look like 48-bit addresses when the > >> memory encryption mask is set, SWIOTLB is needed if the DMA mask of the > >> device performing the DMA does not support 48-bits. SWIOTLB will be > >> initialized to create un-encrypted bounce buffers for use by these devices. > >> > >> Signed-off-by: Tom Lendacky > >> --- > >> arch/x86/include/asm/dma-mapping.h | 5 ++- > >> arch/x86/include/asm/mem_encrypt.h | 5 +++ > >> arch/x86/kernel/pci-dma.c | 11 ++++--- > >> arch/x86/kernel/pci-nommu.c | 2 + > >> arch/x86/kernel/pci-swiotlb.c | 8 ++++- > >> arch/x86/mm/mem_encrypt.c | 17 +++++++++++ > >> include/linux/swiotlb.h | 1 + > >> init/main.c | 13 ++++++++ > >> lib/swiotlb.c | 58 +++++++++++++++++++++++++++++++----- > >> 9 files changed, 103 insertions(+), 17 deletions(-) > >> > >> diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h > >> index 4446162..c9cdcae 100644 > >> --- a/arch/x86/include/asm/dma-mapping.h > >> +++ b/arch/x86/include/asm/dma-mapping.h > > ..SNIP... > > >> > >> +/* > >> + * If memory encryption is active, the DMA address for an encrypted page may > >> + * be beyond the range of the device. If bounce buffers are required be sure > >> + * that they are not on an encrypted page. This should be called before the > >> + * iotlb area is used. > > > > Makes sense, but I think at least a dmesg warning here > > might be a good idea. > > Good idea. Should it be a warning when it is first being set up or > a warning the first time the bounce buffers need to be used. Or maybe > both? > > > > > A boot flag that says "don't enable devices that don't support > > encryption" might be a good idea, too, since most people > > don't read dmesg output and won't notice the message. > > I'll look into this. It might be something that can be checked as > part of the device setting its DMA mask or the first time a DMA > API is used if the device doesn't explicitly set its mask. > > Thanks, > Tom > > > I think setup time is nicer if it's possible.