Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1584518imp; Fri, 22 Feb 2019 06:36:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IagTb782BRZPfCe4HqAMAOOHDeFAikt/AN1wEFkbhEAj8hkR36/IpEM66OV3PoMLEcvLSs8 X-Received: by 2002:a62:cf81:: with SMTP id b123mr4624142pfg.29.1550846212871; Fri, 22 Feb 2019 06:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550846212; cv=none; d=google.com; s=arc-20160816; b=YCPfh4KA2AlBZ6kopVfKfsbfISGs3KroGOgqp27IM+CvZDJtaQvkMQXGME/37/gD92 m3SpS5VlCZEl6DWIcc32mcBOgz7x+ex3T+Ct8rH3sBcUn4hcKZ9nmPMJYm8b0cyJUBs0 lYV9WLl4pi7BpTpxXS5IVykUB/WTLXXog4a9exD5EZtL5OA4f0zpAZq04kDAdOwJuKUW cj/4zbPj13MoQppJwLR4UvJz11POtz3sLU/ukCBSL5UBKeyHpNM4/EO+pJPvGP3fHZ5r ztt2pg4KeX5TTaJEaUx1pmYR7anFrvhGLnwoy5T7znGDIboPLM5PJEJfveUek4pES2WD XPQg== 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; bh=nJdkNYi/qi4NG5QxXzDCAGS+dYvtcSmIKJb7xje0Fh8=; b=v9grC+bJxiSmZ7xDAjw0a3xp5LBE997nVUxFIB1CT6J0c/Qt+fIxDNgDTiEYT2ICAO OrSpALpWg4Itl17F37Ply9I/RFnY0xNiuTlPPYHp52iRR8lLh/O/0pMjL7zz/InS6Y9U nNntnU5sLnreQgP9agTqTwr3DhZWvRyxkVonkWIciADNfhp+jxvg1wrL+5shAtCpIazp D6wQK0PemYJvPS9lAUcoPe4FHFJxrIK3EKOKOzD35eNHp/K1/m2YrOPvfcJKzaU4NsQ8 EYLmL6h6arV7lBVMmIiGMLcAC/JzkxUVXmMjaGGB1Jo7AuvuAUKVofCjQimenpeQ5PY5 DRFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=XgCPuXO6; 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 z88si1569747pfl.65.2019.02.22.06.36.37; Fri, 22 Feb 2019 06:36:52 -0800 (PST) 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=XgCPuXO6; 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 S1726574AbfBVOer (ORCPT + 99 others); Fri, 22 Feb 2019 09:34:47 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:57898 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbfBVOeq (ORCPT ); Fri, 22 Feb 2019 09:34:46 -0500 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=nJdkNYi/qi4NG5QxXzDCAGS+dYvtcSmIKJb7xje0Fh8=; b=XgCPuXO6IkJQjjOL7Zi4MWgHm qdRdfTwIwWz3x4Ihgyn+9Rl0a3kv/fMrXf8Ru9ndgDNvhuxZA32ctG3t8EQNRezrcDD1tWLydcKP6 So2964wk8UogUlMoXv87IJ8gi3z6HZffNpsHb9IfDqZO7alWjIpzXyHPpGWkAiezSZ0WFoeWXcy3i aBK2nzrocpCZVAj75S0lrQvSCuiMVvO8tmSpaU0gzAqeXFMYosQhHXpWooB+Ufsv2Q76m16n8uiFn ok3Xv+oUNwwF0NWAb/Ppv4MXgPTMUwiutAKBjFd64ChiH902XZaFqzW/68Mh3LQqzoU8ayOFqWkQe eip+th8LA==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxBuQ-0000VA-HQ; Fri, 22 Feb 2019 14:34:38 +0000 Date: Fri, 22 Feb 2019 06:34:38 -0800 From: Christoph Hellwig To: Lu Baolu Cc: Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede , kevin.tian@intel.com, ashok.raj@intel.com, tiwei.bie@intel.com, Jean-Philippe Brucker , sanjay.k.kumar@intel.com, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, yi.y.sun@intel.com, jacob.jun.pan@intel.com, kvm@vger.kernel.org Subject: Re: [PATCH v7 7/9] vfio/mdev: Add iommu related member in mdev_device Message-ID: <20190222143438.GA31016@infradead.org> References: <20190222021927.13132-1-baolu.lu@linux.intel.com> <20190222021927.13132-8-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190222021927.13132-8-baolu.lu@linux.intel.com> 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 Fri, Feb 22, 2019 at 10:19:25AM +0800, Lu Baolu wrote: > A parent device might create different types of mediated > devices. For example, a mediated device could be created > by the parent device with full isolation and protection > provided by the IOMMU. One usage case could be found on > Intel platforms where a mediated device is an assignable > subset of a PCI, the DMA requests on behalf of it are all > tagged with a PASID. Since IOMMU supports PASID-granular > translations (scalable mode in VT-d 3.0), this mediated > device could be individually protected and isolated by an > IOMMU. > > This patch adds a new member in the struct mdev_device to > indicate that the mediated device represented by mdev could > be isolated and protected by attaching a domain to a device > represented by mdev->iommu_device. It also adds a helper to > add or set the iommu device. > > * mdev_device->iommu_device > - This, if set, indicates that the mediated device could > be fully isolated and protected by IOMMU via attaching > an iommu domain to this device. If empty, it indicates > using vendor defined isolation, hence bypass IOMMU. > > * mdev_set/get_iommu_device(dev, iommu_device) > - Set or get the iommu device which represents this mdev > in IOMMU's device scope. Drivers don't need to set the > iommu device if it uses vendor defined isolation. > > Cc: Ashok Raj > Cc: Jacob Pan > Cc: Kevin Tian > Cc: Liu Yi L > Suggested-by: Kevin Tian > Suggested-by: Alex Williamson > Signed-off-by: Lu Baolu > Reviewed-by: Jean-Philippe Brucker > --- > drivers/vfio/mdev/mdev_core.c | 18 ++++++++++++++++++ > drivers/vfio/mdev/mdev_private.h | 1 + > include/linux/mdev.h | 14 ++++++++++++++ > 3 files changed, 33 insertions(+) > > diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c > index 0212f0ee8aea..9be58d392d2b 100644 > --- a/drivers/vfio/mdev/mdev_core.c > +++ b/drivers/vfio/mdev/mdev_core.c > @@ -390,6 +390,24 @@ int mdev_device_remove(struct device *dev, bool force_remove) > return 0; > } > > +int mdev_set_iommu_device(struct device *dev, struct device *iommu_device) > +{ > + struct mdev_device *mdev = to_mdev_device(dev); > + > + mdev->iommu_device = iommu_device; > + > + return 0; > +} > +EXPORT_SYMBOL(mdev_set_iommu_device); As said before, please make all new mdev/vfio exports EXPORT_SYMBOL_GPL to fit the other exports in vfio.