Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3851876imm; Tue, 29 May 2018 15:15:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJx0RoyYsrtpCoWUS8gV23s34Y6J/wDEW6xhk8dDHwaV5waN8SNvPvP8EzQ7XHJPRSWH0gj X-Received: by 2002:a17:902:9b8a:: with SMTP id y10-v6mr238015plp.124.1527632154859; Tue, 29 May 2018 15:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527632154; cv=none; d=google.com; s=arc-20160816; b=Qlugji3uxBM24EHLVUuhV/NlPiBhWipCYra0/gSc1HCaaNR8jIvylol2lGFIe0dwsI vPLByB2A2TZ2bL0CS3QrJ9dZfWtGz17TbKjg4VX6TyM+qtWe+ZS7WtHf0kx2LSAbd+8Y +UBnN8HCXbKNYhlWA35QtufnkAlyTisxICBIlWGYZXJzPw2Cn4F7lNzCtTLImExUNnCp 5Bf92xJHlM7SrYuJUIj5+rFYT2osj8Lo7VwmT9KxSv8hW4ZT9Hhd6BAvtteXqD/M9JhR 0YSjVm/kYBw0okApI+SOk7+aUzxrr4VQqm/tAClVO5ont4Nv74+Kv3FcfhQN5iwtFOcM ZTew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=mKRrDs2d3gQgSTivnqGq3Vpf0u4Sym7bWHO40eOFfsc=; b=MvdY26ZXQdiJZQaGyv7tsb4EPCFODT48Tgc42N1aPY7kd9aMQQjx4cOPq98TvLMOmG /AQBIiSICTgzWa+VqTW6f63pzeyYexf+vLclarPFxD+HaGkKviXrpS3pzxkyVxexERck cQJKtHXUktLhFi3F0r3lzGvUxwIevYTF+3MT8Gc4vf1YM07GQ6et1r67TWmZmPG3KgkA qUDmiJoXDREW3r1cwmjAdW5iO4uw2QSXLV9zqqc99i43UpQdPi2cjF76vgxVDwV6Ky6J MUMaU7RctQmhLQdBazX8dqksPUBDWYD9jItzfYpqnAoFSgpu8F73Ku7faLYVndAv9mK7 eeuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 r1-v6si8217901pgu.52.2018.05.29.15.15.40; Tue, 29 May 2018 15:15:54 -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; 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 S967731AbeE2WPM (ORCPT + 99 others); Tue, 29 May 2018 18:15:12 -0400 Received: from gate.crashing.org ([63.228.1.57]:45183 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967686AbeE2WPG (ORCPT ); Tue, 29 May 2018 18:15:06 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w4TMDsHU031729; Tue, 29 May 2018 17:13:55 -0500 Message-ID: <230075a7760a9cf878355e2b8abe4cdb967a482a.camel@kernel.crashing.org> Subject: Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices From: Benjamin Herrenschmidt To: Christoph Hellwig Cc: "Michael S. Tsirkin" , 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, luto@kernel.org Date: Wed, 30 May 2018 08:13:54 +1000 In-Reply-To: <20180529140319.GA19972@infradead.org> References: <20180522063317.20956-1-khandual@linux.vnet.ibm.com> <20180523213703-mutt-send-email-mst@kernel.org> <20180525202300-mutt-send-email-mst@kernel.org> <6fff9f5d67361653e6072570a857cf0d1009a123.camel@kernel.crashing.org> <2f1d48cf029c1f0903f3cffea946ae5b85f60ec0.camel@kernel.crashing.org> <20180529140319.GA19972@infradead.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1 (3.28.1-2.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-05-29 at 07:03 -0700, Christoph Hellwig wrote: > On Tue, May 29, 2018 at 09:56:24AM +1000, Benjamin Herrenschmidt wrote: > > I don't think forcing the addition of an emulated iommu in the middle > > just to work around the fact that virtio "cheats" and doesn't use the > > dma API unless there is one, is the right "fix". > > Agreed. > > > The right long term fix is to always use the DMA API, reducing code > > path etc... and just have a single point where virtio can "chose" > > alternate DMA ops (via an arch hook to deal with our case). > > Also agreed. > > When Andi added vring_use_dma_api it was marked as temporary. > > So I'd much rather move to blacklisting platforms that needs this > hack now than adding another exception. > > And then once we have the blacklist move it to a quirk in the arch > code that just forces dma_direct_ops as the per-device dma ops. > > I don't really think this is crazy long term, but something we could > do relatively quickly. Interestingly enough the original commit > mentions PPC64 as a case where this quirk is needed. Not sure why, it's not so much a platform issue today. It's qemu itself who by defaults bypasses any iommu. I suppose ppc64 stood out because unlike x86 we always have an iommu by default. Anyway, Anshuman, I think that's the right approach, first make virtio always use the DMA API with a quirk early to override the ops. Christoph: the overriding of the ops isn't a platform thing. It's a qemu thing, ie, from a Linux perspective, it's a feature of the "device". So it should be done in virtio itself, not the platform code. However, we do want the ability in platform code to force the bounce buffering to solve our secure VM issue. Cheers, Ben.