From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH v1 2/2] dma-mapping-common: add DMA attribute - DMA_ATTR_IOMMU_BYPASS Date: Fri, 30 Oct 2015 11:32:06 +0100 Message-ID: <3880193.j0XDKyhAXH@wuerfel> References: <1445789224-28032-1-git-send-email-shamir.rabinovitch@oracle.com> <1446079332.3405.273.camel@infradead.org> <1446081046.1856.55.camel@kernel.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: In-Reply-To: <1446081046.1856.55.camel@kernel.crashing.org> Sender: kvm-owner@vger.kernel.org To: Benjamin Herrenschmidt Cc: David Woodhouse , Shamir Rabinovitch , corbet@lwn.net, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, Andy Lutomirski , Joerg Roedel , Christian Borntraeger , Cornelia Huck , Sebastian Ott , Paolo Bonzini , Christoph Hellwig , KVM , Martin Schwidefsky , linux-s390 List-Id: linux-arch.vger.kernel.org On Thursday 29 October 2015 10:10:46 Benjamin Herrenschmidt wrote: > > > Maybe we should at least coordinate IOMMU 'paranoid/fast' modes across > > architectures, and then the DMA_ATTR_IOMMU_BYPASS flag would have a > > sane meaning in the paranoid mode (and perhaps we'd want an ultra > > -paranoid mode where it's not honoured). > > Possibly, though ideally that would be a user policy but of course by > the time you get to userspace it's generally too late. IIRC, we have an 'iommu=force' command line switch for this, to ensure that no device can use a linear mapping and everything goes through the page tables. This is often useful for both debugging and as a security measure when dealing with unpriviledged DMA access (virtual machines, vfio, ...). If we add a DMA_ATTR_IOMMU_BYPASS attribute, we should clearly document which of the two we expect to take priority in cases where we have a choice. I wonder if the 'iommu=force' attribute is too coarse-grained though, and if we should perhaps allow a per-device setting on architectures that allow this. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de ([212.227.126.187]:54490 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758792AbbJ3Kce (ORCPT ); Fri, 30 Oct 2015 06:32:34 -0400 From: Arnd Bergmann Subject: Re: [PATCH v1 2/2] dma-mapping-common: add DMA attribute - DMA_ATTR_IOMMU_BYPASS Date: Fri, 30 Oct 2015 11:32:06 +0100 Message-ID: <3880193.j0XDKyhAXH@wuerfel> In-Reply-To: <1446081046.1856.55.camel@kernel.crashing.org> References: <1445789224-28032-1-git-send-email-shamir.rabinovitch@oracle.com> <1446079332.3405.273.camel@infradead.org> <1446081046.1856.55.camel@kernel.crashing.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-arch-owner@vger.kernel.org List-ID: To: Benjamin Herrenschmidt Cc: David Woodhouse , Shamir Rabinovitch , corbet@lwn.net, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, Andy Lutomirski , Joerg Roedel , Christian Borntraeger , Cornelia Huck , Sebastian Ott , Paolo Bonzini , Christoph Hellwig , KVM , Martin Schwidefsky , linux-s390 Message-ID: <20151030103206.Gv0n2nba5L32SJRdeaudLi2EVYGf3QQN6e8GNCWxFsw@z> On Thursday 29 October 2015 10:10:46 Benjamin Herrenschmidt wrote: > > > Maybe we should at least coordinate IOMMU 'paranoid/fast' modes across > > architectures, and then the DMA_ATTR_IOMMU_BYPASS flag would have a > > sane meaning in the paranoid mode (and perhaps we'd want an ultra > > -paranoid mode where it's not honoured). > > Possibly, though ideally that would be a user policy but of course by > the time you get to userspace it's generally too late. IIRC, we have an 'iommu=force' command line switch for this, to ensure that no device can use a linear mapping and everything goes through the page tables. This is often useful for both debugging and as a security measure when dealing with unpriviledged DMA access (virtual machines, vfio, ...). If we add a DMA_ATTR_IOMMU_BYPASS attribute, we should clearly document which of the two we expect to take priority in cases where we have a choice. I wonder if the 'iommu=force' attribute is too coarse-grained though, and if we should perhaps allow a per-device setting on architectures that allow this. Arnd