linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/10] vfio/mdev: IOMMU aware mediated device
@ 2018-07-22  6:09 Lu Baolu
  2018-07-22  6:09 ` [RFC PATCH 01/10] iommu/vt-d: Get iommu device for a " Lu Baolu
                   ` (9 more replies)
  0 siblings, 10 replies; 32+ messages in thread
From: Lu Baolu @ 2018-07-22  6:09 UTC (permalink / raw)
  To: Joerg Roedel, David Woodhouse, Alex Williamson, Kirti Wankhede
  Cc: ashok.raj, sanjay.k.kumar, jacob.jun.pan, kevin.tian, yi.l.liu,
	yi.y.sun, peterx, iommu, kvm, linux-kernel, Lu Baolu

Hi,

The Mediate Device is a framework for fine-grained physical device
sharing across the isolated domains. Currently the mdev framework
is designed to be independent of the platform IOMMU support. As the
result, the DMA isolation relies on the mdev parent device in a
vendor specific way.

There are several cases where a mediated device could be protected
and isolated by the platform IOMMU. For example, Intel vt-d rev3.0
[1] introduces a new translation mode called 'scalable mode', which
enables PASID-granular translations. The vt-d scalable mode is the
key ingredient for Scalable I/O Virtualization [2] [3] which allows
sharing a device in minimal possible granularity (ADI - Assignable
Device Interface).

A mediated device backed by an ADI could be protected and isolated
by the IOMMU since 1) the parent device supports tagging an unique
PASID to all DMA traffic out of the mediated device; and 2) the DMA
translation unit (IOMMU) supports the PASID granular translation.
We can apply IOMMU protection and isolation to this kind of devices
just as what we are doing with an assignable PCI device.

In order to distinguish the IOMMU-capable mediated devices from those
which still need to rely on parent devices, this patch set adds a
domain type attribute to each mdev.

enum mdev_domain_type {
       DOMAIN_TYPE_EXTERNAL,   /* Use the external domain and all
                                * IOMMU staff controlled by the
                                * parent device driver.
                                */
       DOMAIN_TYPE_INHERITANCE,/* Use the same domain as the parent device. */
       DOMAIN_TYPE_PRIVATE,    /* Capable of having a private domain. For an
                                * example, the parent device is able to bind
                                * a specific PASID for a mediated device and
                                * transfering data with the asigned PASID.
                                */
};

The mdev parent device driver could opt-in whether an mdev is IOMMU
capable when the device is created by invoking below interface within
its @create callback:

int mdev_set_domain_type(struct device *dev,
                         enum mdev_domain_type type);

In vfio_iommu_type1_attach_group(), a domain will be found and assigned
to the group according to the domain type attributes of mdev devices in
the group.

Besides above, we still need below changes to sport IOMMU-capable mdev
device:
a) The platform specific iommu ops should be set to mdev bus. So that,
   the vfio/mdev framework could call iommu APIs.
b) The iommu driver should be changed to support setting up the translation
   structures for a mediated device.

This patch series extends both IOMMU and vfio components to support
mdev device passing through when it could be isolated and protected
by the IOMMU units. The first part of this series (PATCH 1/10 ~ 5/10)
makes the Intel IOMMU driver to be aware of a mediated device. The
second part (PATCH 6/10 ~ 8/10) sets the iommu ops for the mdev bus.
The last part (PATCH 9/10 ~ 10/10) adds the domain type attribute to
a mdev device and allocates an iommu domain if it is IOMMU-capable.

This patch series depends on a patch set posted here [4] for discussion
which added the support for scalable mode in Intel IOMMU driver.

References:
[1] https://software.intel.com/en-us/download/intel-virtualization-technology-for-directed-io-architecture-specification
[2] https://software.intel.com/en-us/download/intel-scalable-io-virtualization-technical-specification
[3] https://schd.ws/hosted_files/lc32018/00/LC3-SIOV-final.pdf
[4] https://lkml.org/lkml/2018/7/16/62

Best regards,
Lu Baolu

Lu Baolu (10):
  iommu/vt-d: Get iommu device for a mediated device
  iommu/vt-d: Alloc domain for a mediated device
  iommu/vt-d: Allocate groups for mediated devices
  iommu/vt-d: Get pasid table for a mediated device
  iommu/vt-d: Setup DMA remapping for mediated devices
  iommu: Add iommu_set_bus API interface
  iommu/vt-d: Add set_bus iommu ops
  vfio/mdev: Set iommu ops for mdev bus
  vfio/mdev: Add mediated device domain type
  vfio/type1: Allocate domain for mediated device

 drivers/iommu/intel-iommu.c      | 127 ++++++++++++++++++++++++++++++++++++---
 drivers/iommu/intel-pasid.c      |  16 ++++-
 drivers/iommu/intel-pasid.h      |  16 +++++
 drivers/iommu/iommu.c            |  23 +++++++
 drivers/vfio/mdev/mdev_core.c    |  30 ++++++++-
 drivers/vfio/mdev/mdev_driver.c  |  10 +++
 drivers/vfio/mdev/mdev_private.h |   1 +
 drivers/vfio/vfio_iommu_type1.c  |  43 +++++++++----
 include/linux/intel-iommu.h      |   5 ++
 include/linux/iommu.h            |  12 ++++
 include/linux/mdev.h             |  22 +++++++
 11 files changed, 282 insertions(+), 23 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-07-26 15:09 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-22  6:09 [RFC PATCH 00/10] vfio/mdev: IOMMU aware mediated device Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 01/10] iommu/vt-d: Get iommu device for a " Lu Baolu
2018-07-23  4:44   ` Liu, Yi L
2018-07-24  2:06     ` Lu Baolu
2018-07-24 18:50   ` Alex Williamson
2018-07-25  1:18     ` Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 02/10] iommu/vt-d: Alloc domain " Lu Baolu
2018-07-23  4:44   ` Liu, Yi L
2018-07-24  2:09     ` Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 03/10] iommu/vt-d: Allocate groups for mediated devices Lu Baolu
2018-07-23  4:44   ` Liu, Yi L
2018-07-24  2:22     ` Lu Baolu
2018-07-24 11:30       ` Jean-Philippe Brucker
2018-07-24 19:51         ` Alex Williamson
2018-07-25  2:06         ` Lu Baolu
2018-07-25  2:16         ` Tian, Kevin
2018-07-25  2:35         ` Liu, Yi L
     [not found]         ` <AADFC41AFE54684AB9EE6CBC0274A5D19127FB9E@SHSMSX101.ccr.corp.intel.com>
2018-07-25  6:19           ` Tian, Kevin
2018-07-25 19:19             ` Jean-Philippe Brucker
2018-07-26  3:03               ` Tian, Kevin
2018-07-26 15:09                 ` Jean-Philippe Brucker
     [not found]               ` <AADFC41AFE54684AB9EE6CBC0274A5D1912826AE@SHSMSX101.ccr.corp.intel.com>
2018-07-26  3:28                 ` Tian, Kevin
2018-07-26 15:09                   ` Jean-Philippe Brucker
2018-07-22  6:09 ` [RFC PATCH 04/10] iommu/vt-d: Get pasid table for a mediated device Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 05/10] iommu/vt-d: Setup DMA remapping for mediated devices Lu Baolu
2018-07-23  4:44   ` Liu, Yi L
2018-07-24  2:29     ` Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 06/10] iommu: Add iommu_set_bus API interface Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 07/10] iommu/vt-d: Add set_bus iommu ops Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 08/10] vfio/mdev: Set iommu ops for mdev bus Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 09/10] vfio/mdev: Add mediated device domain type Lu Baolu
2018-07-22  6:09 ` [RFC PATCH 10/10] vfio/type1: Allocate domain for mediated device Lu Baolu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).