Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1631827imp; Fri, 22 Feb 2019 07:32:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IYP+et1EMyFAHrnK2cyZoefOOl5valtxRINmK1D/iT6KAWKpXlL07dpWILL3eTQlR/AfN3+ X-Received: by 2002:a65:6151:: with SMTP id o17mr4505316pgv.285.1550849531114; Fri, 22 Feb 2019 07:32:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550849531; cv=none; d=google.com; s=arc-20160816; b=1D2nyfZNDGyffNZZEr5psnWxQmIDfm4BlhzDqjRoyY5fXdJWDAybwMZMVZ93QxL+L4 l5cZzCWPQh5JgTS8KvnKU3MzTEDW0eGKEOs2kB17mJF58qp2VoAV99x2oR5GaKT6WFsu CWRyU+1/xZag9cib0u3ygKqewraXXLb5oGuIU5fco9B49CNKW9L1VWWOG5k2f7/Nn1ky 7QzrMRjti4qvELJ3QRt0gmTkp+nElyOUEBkDtnh2a5jK1IcqoeD0hGrSiJ88OprC4TIJ 4niVBvfbmKFtnT10bDvs+t9mCnxjpP5zyL7x5LwfhNMkfgk7AzoHP0uwBBGRGcj6J/CC TDpA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=IU1sKJrC+Lf02AbzgRiBgIWquezKbEDuyoE2us3ej8U=; b=gd90+E5CXsxGE+Fjco9IB/2e8ipph8O/w8GgjaxrE+1eEyrGWfq3kXA/UhNe1YBzFy pCsinukpXpFvK+i2KIlQoKe3HndO2uI7Bahc7P/JLSgz8Okh4jqYOmrQqZpAihsDdQLD 8kxsXaCZEhHIaIpbDQfc0vkFJ0CBzG5D7BaP6/ImmOV5euNn/R60RKdrt8/5QQSOGil7 LU2oc6JurqdEzGZQdroF4ehCz+ycceJi0gXGQ0mgSigtU37eE001PZEp/b+x/oF1fuwj igCAuRVvsSB6PkQNFK1fPQEi7M6WtRyqvY/7jq/F2MIL94QPBCTBRItH6AOmKtdiJ5Xx WrLQ== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a129si1619506pfa.273.2019.02.22.07.31.55; Fri, 22 Feb 2019 07:32:11 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727274AbfBVPbG (ORCPT + 99 others); Fri, 22 Feb 2019 10:31:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48968 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbfBVPbF (ORCPT ); Fri, 22 Feb 2019 10:31:05 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 986A13003C4F; Fri, 22 Feb 2019 15:31:04 +0000 (UTC) Received: from x1.home (ovpn-116-24.phx2.redhat.com [10.3.116.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 079185D719; Fri, 22 Feb 2019 15:31:02 +0000 (UTC) Date: Fri, 22 Feb 2019 08:31:01 -0700 From: Alex Williamson To: Christoph Hellwig Cc: Lu Baolu , Joerg Roedel , David Woodhouse , 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: <20190222083101.089ffadf@x1.home> In-Reply-To: <20190222143438.GA31016@infradead.org> References: <20190222021927.13132-1-baolu.lu@linux.intel.com> <20190222021927.13132-8-baolu.lu@linux.intel.com> <20190222143438.GA31016@infradead.org> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 22 Feb 2019 15:31:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Feb 2019 06:34:38 -0800 Christoph Hellwig wrote: > 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. Well... $ grep EXPORT_SYMBOL drivers/vfio/mdev/* drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_parent_dev); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_get_drvdata); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_set_drvdata); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_dev); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_from_dev); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_uuid); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_register_device); drivers/vfio/mdev/mdev_core.c:EXPORT_SYMBOL(mdev_unregister_device); drivers/vfio/mdev/mdev_driver.c:EXPORT_SYMBOL_GPL(mdev_bus_type); drivers/vfio/mdev/mdev_driver.c:EXPORT_SYMBOL(mdev_register_driver); drivers/vfio/mdev/mdev_driver.c:EXPORT_SYMBOL(mdev_unregister_driver); For better or worse, the mdev interface does allow non-GPL vendor drivers. This export seems consistent with that, it's a simple association allowing the vendor driver to define an IOMMU API backing device for an mdev device. I don't think this association implies sufficient operational knowledge to require a GPL symbol and it's been requested for use by one of those non-GPL mdev vendor drivers, therefore I support this definition. Thanks, Alex