Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp656595imm; Fri, 3 Aug 2018 09:20:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe9ak617bZyghMi0tjjh+kq/FHnxYdLP7K+/nbI6OHjI6qOyNs7SAyIhfc1dJcOvb22Cu+a X-Received: by 2002:a62:6948:: with SMTP id e69-v6mr5268430pfc.166.1533313257276; Fri, 03 Aug 2018 09:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533313257; cv=none; d=google.com; s=arc-20160816; b=j9F+TbS7X68jMAY6xrpdV00/x+i+kZzhYYHIGJSXOKu/JKDVB84W5iOIeb3MFVGGZL /vlEaWkyK0FxiIeuWU3wfqxTeSxHrimW0yEMnW2G3Ord0jiKR4JEOvGwuDs4PCACwd7q QlbUYrA3xb8y5WqIHSPcqS6HJg2fVC8MnltU1bhMzlhDBqk64zjyiqEVEKrn6uNhMFPu zcORBulWucYu+eRGGUi7Tl8a+qPmUh6teSfV3+Xc8ZOAPAl3+uFnqkZt9ycjoF5puIKk y5OzE6T9yABNeizcJL+OIpZFMj1U8+kw9o1LqlE1PH6szPCQbnRDYy9vaVPkmMX/T/04 iiJA== 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=m3nWn+DiBhx+JSq14Ztm9AZAxzTV5mIBKmWGHXPSup8=; b=LLt8EF8ctDbpWwzHudeezGZxDPJZQeWLB0o1TVhmezgdUm3ogFCih8fp0lu5xvr5r+ qnXa3iB7FZ52LBYFmdcqaiPmCuiDkOFB33K82nOVetDFpCSvalP/CXsl0dvJDa2JIBeN nBejaiq2x+7LxfWk9GJkh1Y49rtaYvOb0uB/Y/TAxg1IZ+rKziqO1X2MIBZIhOchm65+ RT0IL8T3732+mhTtAR+b9bdaOSvZGKXckihr9xhX+MzAjzQ6cV/wDnJ438umqpO1dvn2 ghve301vcjnmJDCMf2u/co1LmEz1GnOIF4FJHJwcGMy4bDf1oc+H+aqbgAJFmlVTQdPY Tvzw== 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 6-v6si4741927pgv.508.2018.08.03.09.20.41; Fri, 03 Aug 2018 09:20:57 -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 S1727540AbeHCSP5 (ORCPT + 99 others); Fri, 3 Aug 2018 14:15:57 -0400 Received: from gate.crashing.org ([63.228.1.57]:55920 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727144AbeHCSP5 (ORCPT ); Fri, 3 Aug 2018 14:15:57 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w73FwaYU029633; Fri, 3 Aug 2018 10:58:38 -0500 Message-ID: Subject: Re: [RFC 0/4] Virtio uses DMA API for all devices From: Benjamin Herrenschmidt To: Christoph Hellwig Cc: "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 Date: Fri, 03 Aug 2018 10:58:36 -0500 In-Reply-To: <20180803070507.GA1344@infradead.org> References: <3d6e81511571260de1c8047aaffa8ac4df093d2e.camel@kernel.crashing.org> <20180801081637.GA14438@arm.com> <20180801083639.GF26378@infradead.org> <26c1d3d50d8e081eed44fe9940fbefed34598cbd.camel@kernel.crashing.org> <20180802182959-mutt-send-email-mst@kernel.org> <82ccef6ec3d95ee43f3990a4a2d0aea87eb45e89.camel@kernel.crashing.org> <20180802200646-mutt-send-email-mst@kernel.org> <20180802225738-mutt-send-email-mst@kernel.org> <20180803070507.GA1344@infradead.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.4 (3.28.4-1.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 Fri, 2018-08-03 at 00:05 -0700, Christoph Hellwig wrote: > > 2- Make virtio use the DMA API with our custom platform-provided > > swiotlb callbacks when needed, that is when not using IOMMU *and* > > running on a secure VM in our case. > > And total NAK the customer platform-provided part of this. We need > a flag passed in from the hypervisor that the device needs all bus > specific dma api treatment, and then just use the normal plaform > dma mapping setup. Christoph, as I have explained already, we do NOT have a way to provide such a flag as neither the hypervisor nor qemu knows anything about this when the VM is created. > To get swiotlb you'll need to then use the DT/ACPI > dma-range property to limit the addressable range, and a swiotlb > capable plaform will use swiotlb automatically. This cannot be done as you describe it. The VM is created as a *normal* VM. The DT stuff is generated by qemu at a point where it has *no idea* that the VM will later become secure and thus will have to restrict which pages can be used for "DMA". The VM will *at runtime* turn itself into a secure VM via interactions with the security HW and the Ultravisor layer (which sits below the HV). This happens way after the DT has been created and consumed, the qemu devices instanciated etc... Only the guest kernel knows because it initates the transition. When that happens, the virtio devices have already been used by the guest firmware, bootloader, possibly another kernel that kexeced the "secure" one, etc... So instead of running around saying NAK NAK NAK, please explain how we can solve that differently. Ben.