Received: by 10.192.165.148 with SMTP id m20csp5134081imm; Tue, 1 May 2018 09:36:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZonbfyJ+50eJ6ejO0wmQ7wpv0i7X8jYrYvPbeKpLl5WHbOeBXIwMSktkPMxtdkI+0gXTnUm X-Received: by 10.98.69.68 with SMTP id s65mr16422706pfa.150.1525192572365; Tue, 01 May 2018 09:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525192572; cv=none; d=google.com; s=arc-20160816; b=wahw+cZcILxDyxjxgDc3eVx5VAhLiVr8wEAicny2pKcZFBO9BdvyCsJxscPttPgvw1 puxraAcra1PEIsMbcSQX5wnnKlJLCpI/8kycQQymYNGc0ZkImga+sI3lHQii0QWK1Di0 2BSADefgZw+zmBD5GYAXoFMi2KkfL94XKPXsH+MOAVp21J6b86f28bnA2O2Kt5az/lL6 73Fupz/6yUoPnfgsvjp4NF3PPPnayt10ndXDagCFrlGEIbvcNAYnYM5aHQ1wKOC7MWKB uNJL9gVhL7X/RT7IurqDgnG4fAJ9siwM5m3Oaa5bPMr0cnGS7P5WICyQuVSAF/8kegLS UMag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=krf6khcSPnr0gbODOsWJR/RiqhSpir6cUErlDaCPKiw=; b=uMv2Rkgb3YQITboU/6fo3fz4aKMborv7m5e2kh5Qsqbo9QwNB0lrrv3orZMmfIH/4n aIkBn9IBPah1e6DTBwBQTOyJvAaoBzvL0jEnhmne9I0sc9XAsIQ45zcoUGOIEy62jq8S HDlwT62P6LVFtYAeIN0yfVYPWjmOxfgGUs3rVV332dD7qqa7Dh5Z0/MyVY3gHTq1T7TW xULsE5FVjQoERtG8vaCLDDvDin7tXSPueWMjoLgks1oPLVIfzSBC9cBJfDAm1dm1B1rt n4IFNAMDWTLwLqNOXizGC+IMnUUlTKMk4YCsxxJtQcDlJNaijHxx9tArbjdau8RzGpsg f8oQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si3996366plc.14.2018.05.01.09.35.58; Tue, 01 May 2018 09:36:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756115AbeEAQeV (ORCPT + 99 others); Tue, 1 May 2018 12:34:21 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36238 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754727AbeEAQeT (ORCPT ); Tue, 1 May 2018 12:34:19 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w41GTmL3010455 for ; Tue, 1 May 2018 12:34:18 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hpp3u56sc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 01 May 2018 12:34:18 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 May 2018 17:34:16 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 1 May 2018 17:34:13 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w41GYCNH9568718; Tue, 1 May 2018 16:34:12 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9E1B44C044; Tue, 1 May 2018 17:26:23 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C6BA4C04E; Tue, 1 May 2018 17:26:21 +0100 (BST) Received: from ram.oc3035372033.ibm.com (unknown [9.85.147.55]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 1 May 2018 17:26:21 +0100 (BST) Date: Tue, 1 May 2018 09:34:07 -0700 From: Ram Pai To: "Michael S. Tsirkin" Cc: Anshuman Khandual , robh@kernel.org, aik@ozlabs.ru, jasowang@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Christoph Hellwig , joe@perches.com, linuxppc-dev@lists.ozlabs.org, elfring@users.sourceforge.net, david@gibson.dropbear.id.au Subject: Re: [RFC] virtio: Use DMA MAP API for devices without an IOMMU Reply-To: Ram Pai References: <20180405175326-mutt-send-email-mst@kernel.org> <1522940983.21446.205.camel@kernel.crashing.org> <20180405213042-mutt-send-email-mst@kernel.org> <1522963113.21446.211.camel@kernel.crashing.org> <70cb433f-a8f7-5199-3c96-a760c7624804@linux.vnet.ibm.com> <20180406071634.GA31108@infradead.org> <1523003838.21446.238.camel@kernel.crashing.org> <20180415121157.GA17726@infradead.org> <002f153f-452d-f64b-4fc7-7f3383b39162@linux.vnet.ibm.com> <20180418191722-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180418191722-mutt-send-email-mst@kernel.org> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18050116-0012-0000-0000-000005D0D367 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050116-0013-0000-0000-0000194DEF97 Message-Id: <20180501163407.GA6450@ram.oc3035372033.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-01_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805010161 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 07:20:10PM +0300, Michael S. Tsirkin wrote: > On Wed, Apr 18, 2018 at 08:47:10AM +0530, Anshuman Khandual wrote: > > On 04/15/2018 05:41 PM, Christoph Hellwig wrote: > > > On Fri, Apr 06, 2018 at 06:37:18PM +1000, Benjamin Herrenschmidt wrote: > > >>>> implemented as DMA API which the virtio core understands. There is no > > >>>> need for an IOMMU to be involved for the device representation in this > > >>>> case IMHO. > > >>> > > >>> This whole virtio translation issue is a mess. I think we need to > > >>> switch it to the dma API, and then quirk the legacy case to always > > >>> use the direct mapping inside the dma API. > > >> > > >> Fine with using a dma API always on the Linux side, but we do want to > > >> special case virtio still at the arch and qemu side to have a "direct > > >> mapping" mode. Not sure how (special flags on PCI devices) to avoid > > >> actually going through an emulated IOMMU on the qemu side, because that > > >> slows things down, esp. with vhost. > > >> > > >> IE, we can't I think just treat it the same as a physical device. > > > > > > We should have treated it like a physical device from the start, but > > > that device has unfortunately sailed. > > > > > > But yes, we'll need a per-device quirk that says 'don't attach an > > > iommu'. > > > > How about doing it per platform basis as suggested in this RFC through > > an arch specific callback. Because all the virtio devices in the given > > platform would require and exercise this option (to avail bounce buffer > > mechanism for secure guests as an example). So the flag basically is a > > platform specific one not a device specific one. > > That's not the case. A single platform can have a mix of virtio and > non-virtio devices. Same applies even within virtio, e.g. the balloon > device always bypasses an iommu. Further, QEMU supports out of process > devices some of which might bypass the IOMMU. Given that each virtio device has to behave differently depending on (a) what it does? (balloon, block, net etc ) (b) what platform it is on? (pseries, x86, ....) (c) what environment it is on? (secure, insecure...) I think, we should let the virtio device decide what it wants, instead of forcing it to NOT use dma_ops when VIRTIO_F_IOMMU_PLATFORM is NOT enabled. Currently, virtio generic code, has an assumption that a device must NOT use dma operations if the hypervisor has NOT enabled VIRTIO_F_IOMMU_PLATFORM. This assumption is baked into vring_use_dma_api(); though there is a special exception for xen_domain(). This assumption is restricting us from using the dma_ops abstraction for virtio devices on secure VM. BTW: VIRTIO_F_IOMMU_PLATFORM may or may not be set on this platform. On our secure VM, virtio devices; by default, do not share pages with hypervisor. In other words, hypervisor cannot access the secure VM pages. The secure VM with the help of the hardware enables some pages to be shared with the hypervisor. Secure VM then uses these pages to bounce virtio data with the hypervisor. One elegant way to impliment this functionality is to abstract it under our special dma_ops and wire it to the virtio devices. However the restriction imposed by the generic virtio code, contrains us from doing so. If we can enrich vring_use_dma_api() to take multiple factors into consideration and not just VIRTIO_F_IOMMU_PLATFORM; perferrably by consulting a arch-dependent function, we could seemlessly integrate into the existing virtio infrastructure. RP > > -- > MST -- Ram Pai