From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbeDEPKi (ORCPT ); Thu, 5 Apr 2018 11:10:38 -0400 Received: from gate.crashing.org ([63.228.1.57]:50236 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeDEPKh (ORCPT ); Thu, 5 Apr 2018 11:10:37 -0400 Message-ID: <1522940983.21446.205.camel@kernel.crashing.org> Subject: Re: [RFC] virtio: Use DMA MAP API for devices without an IOMMU From: Benjamin Herrenschmidt To: "Michael S. Tsirkin" , Anshuman Khandual Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, robh@kernel.org, aik@ozlabs.ru, jasowang@redhat.com, joe@perches.com, linuxppc-dev@lists.ozlabs.org, elfring@users.sourceforge.net, david@gibson.dropbear.id.au Date: Fri, 06 Apr 2018 01:09:43 +1000 In-Reply-To: <20180405175326-mutt-send-email-mst@kernel.org> References: <20180405105631.9514-1-khandual@linux.vnet.ibm.com> <3e1b113b-79ca-b700-5be9-10c66d74aabe@linux.vnet.ibm.com> <20180405175326-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-04-05 at 17:54 +0300, Michael S. Tsirkin wrote: > On Thu, Apr 05, 2018 at 08:09:30PM +0530, Anshuman Khandual wrote: > > On 04/05/2018 04:26 PM, Anshuman Khandual wrote: > > > There are certian platforms which would like to use SWIOTLB based DMA API > > > for bouncing purpose without actually requiring an IOMMU back end. But the > > > virtio core does not allow such mechanism. Right now DMA MAP API is only > > > selected for devices which have an IOMMU and then the QEMU/host back end > > > will process all incoming SG buffer addresses as IOVA instead of simple > > > GPA which is the case for simple bounce buffers after being processed with > > > SWIOTLB API. To enable this usage, it introduces an architecture specific > > > function which will just make virtio core front end select DMA operations > > > structure. > > > > > > Signed-off-by: Anshuman Khandual > > > > + "Michael S. Tsirkin" > > I'm confused by this. > > static bool vring_use_dma_api(struct virtio_device *vdev) > { > if (!virtio_has_iommu_quirk(vdev)) > return true; > > > Why doesn't setting VIRTIO_F_IOMMU_PLATFORM on the > hypervisor side sufficient? In this specific case, because that would make qemu expect an iommu, and there isn't one. Anshuman, you need to provide more background here. I don't have time right now it's late, but explain about the fact that this is for a specific type of secure VM which has only a limited pool of (insecure) memory that can be shared with qemu, so all IOs need to bounce via that pool, which can be achieved by using swiotlb. Note: this isn't urgent, we can discuss alternative approaches, this is just to start the conversation. Cheers, Ben.