Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4758116imm; Tue, 7 Aug 2018 06:57:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcV04P9eauM5V5KQ2o7PQW6tUqgUuCp+3DhaaExfJZMwsLFfhldJo21+qDbeyF4/IPYyD/X X-Received: by 2002:a62:1314:: with SMTP id b20-v6mr22041162pfj.230.1533650243659; Tue, 07 Aug 2018 06:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533650243; cv=none; d=google.com; s=arc-20160816; b=hIPIkBXrdzNLXiIc/EO8Z0gNX89bAcG6Vq96yvQyDY9sXKGDDse2LHYJfyYyw0+19k 2hyeF/v5VLOca/jL4dtuhIIXgwy9npoHpfFFkf2FQdIrk0YvWQQvY0AOGxcYGnWUaCB+ GqExk/6LzeAg1AM++9C2i56ntlYI1Q9x3gjL6r63C1AiymE6M5BVdkbYwX0f/F20eWQl 3+x4Ql0W2JV6sQfznSpLF1JLIPW45MDCe0i0nLLMTeA64dz2XM64lBr+n9C4wG0iMAwr RXMtLmgyO4jcjAtAOWfjsC/+kpPMYM7TEG2nQbdjPYlfWQMYv7surw7I7SZ4Tne8soAv DvBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=sjc6qVLlnS7MNzp4S2oiRbv92h0kueFo92fuyJ8QGeg=; b=c5cGRyl741wed0LCXGzXlTMoiKF2n8hrKQP4mMCSkPTGrNf17IeY5T2IDVIIwv00gC TzQzOOdKGrdBE0Aocdi0ulcH2t7X2u3gBGBYY7OPlqSqmsrKd9V2Uwkf7Pg1+HDRtkGl MzYLpYIUqB0znJjc11ruV9dyv2X3T1uc8VF5S0DoO5SjmfOqJ+tlFRnIzKyEMlQ62+qC HRMlo07R23MWMT8kSGEzxaroSd5oz++BSLbnOWYS/vbkYW7QlQkKKNpopLarVMKOUuff I5zsy9rDTvpiKICuzHGzPKPqjCEe6HJwwJ91FGBLujxSFEoSXHzYQa5sTjTESuHG4rWk ByrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QL3nJ9jV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c125-v6si1286595pga.534.2018.08.07.06.57.08; Tue, 07 Aug 2018 06:57:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QL3nJ9jV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389356AbeHGQJm (ORCPT + 99 others); Tue, 7 Aug 2018 12:09:42 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:56556 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732141AbeHGQJm (ORCPT ); Tue, 7 Aug 2018 12:09:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sjc6qVLlnS7MNzp4S2oiRbv92h0kueFo92fuyJ8QGeg=; b=QL3nJ9jV0qjzlhC1av8lYnoxs A3ATxoB56BRe5kTmeTt/BSuXDQkeoofmFZOXGR/MDdnG4zm/wKpyRisbG+AHRK7gR4zpFgsSKM4qw t7Aeq/ozeL+yTvpnFkAOc9kgf1+Pg3mvJ4nHmyXm+bsGVrhcX4XtelSeLrcWR+7M6paKEnJXERp9J IxxcbQ2jtUzq5AVeqUDyTQ5pOp8pW/hS9bX7UsWuyyhY0MVYYL0N/DuVdXHartJfOFjq4ymbexjf5 oMJsp7zbdEAZsBNZ7rVrY1PbcDoIwklPHIsgQMk1acllIbx2asWOGOeo1oQi7ajLQTixyltE7IDdA FB4i9gpWQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fn2S2-0008J0-38; Tue, 07 Aug 2018 13:55:06 +0000 Date: Tue, 7 Aug 2018 06:55:05 -0700 From: Christoph Hellwig To: Benjamin Herrenschmidt Cc: Christoph Hellwig , "Michael S. Tsirkin" , Will Deacon , Anshuman Khandual , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, aik@ozlabs.ru, robh@kernel.org, joe@perches.com, elfring@users.sourceforge.net, david@gibson.dropbear.id.au, jasowang@redhat.com, mpe@ellerman.id.au, linuxram@us.ibm.com, haren@linux.vnet.ibm.com, paulus@samba.org, srikar@linux.vnet.ibm.com, robin.murphy@arm.com, jean-philippe.brucker@arm.com, marc.zyngier@arm.com Subject: Re: [RFC 0/4] Virtio uses DMA API for all devices Message-ID: <20180807135505.GA29034@infradead.org> References: <20180803160246.GA13794@infradead.org> <22310f58605169fe9de83abf78b59f593ff7fbb7.camel@kernel.crashing.org> <20180804082120.GB4421@infradead.org> <20180805072930.GB23288@infradead.org> <20180806094243.GA16032@infradead.org> <6c707d6d33ac25a42265c2e9b521c2416d72c739.camel@kernel.crashing.org> <20180807062117.GD32709@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 07, 2018 at 04:42:44PM +1000, Benjamin Herrenschmidt wrote: > Note that I can make it so that the same DMA ops (basically standard > swiotlb ops without arch hacks) work for both "direct virtio" and > "normal PCI" devices. > > The trick is simply in the arch to setup the iommu to map the swiotlb > bounce buffer pool 1:1 in the iommu, so the iommu essentially can be > ignored without affecting the physical addresses. > > If I do that, *all* I need is a way, from the guest itself (again, the > other side dosn't know anything about it), to force virtio to use the > DMA ops as if there was an iommu, that is, use whatever dma ops were > setup by the platform for the pci device. In that case just setting VIRTIO_F_IOMMU_PLATFORM in the flags should do the work (even if that isn't strictly what the current definition of the flag actually means). On the qemu side you'll need to make sure you have a way to set VIRTIO_F_IOMMU_PLATFORM without emulating an iommu, but with code to take dma offsets into account if your plaform has any (various power plaforms seem to have them, not sure if it affects your config).