public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/7] Add SIOV virtual device support
@ 2023-10-09  8:51 Yi Liu
  2023-10-09  8:51 ` [RFC 1/7] iommufd: Handle unsafe interrupts in a separate function Yi Liu
                   ` (7 more replies)
  0 siblings, 8 replies; 25+ messages in thread
From: Yi Liu @ 2023-10-09  8:51 UTC (permalink / raw)
  To: joro, alex.williamson, jgg, kevin.tian, robin.murphy, baolu.lu
  Cc: cohuck, eric.auger, nicolinc, kvm, mjrosato, chao.p.peng,
	yi.l.liu, yi.y.sun, peterx, jasowang, shameerali.kolothum.thodi,
	lulu, suravee.suthikulpanit, iommu, linux-kernel, linux-kselftest,
	zhenzhong.duan, joao.m.martins

Intel SIOV allows creating virtual devices of which the vRID is
represented by a pasid of a physical device. It is called as SIOV
virtual device in this series. Such devices can be bound to an iommufd
as physical device does and then later be attached to an IOAS/hwpt
using that pasid. Such PASIDs are called as default pasid.

iommufd has already supported pasid attach[1]. So a simple way to
support SIOV virtual device attachment is to let device driver call
the iommufd_device_pasid_attach() and pass in the default pasid for
the virtual device. This should work for now, but it may have problem
if iommufd core wants to differentiate the default pasids with other
kind of pasids (e.g. pasid given by userspace). In the later forwarding
page request to userspace, the default pasids are not supposed to send
to userspace as default pasids are mainly used by the SIOV device driver.

With above reason, this series chooses to have a new API to bind the
default pasid to iommufd, and extends the iommufd_device_attach() to
convert the attachment to be pasid attach with the default pasid. Device
drivers (e.g. VFIO) that support SIOV shall call the below APIs to
interact with iommufd:

  - iommufd_device_bind_pasid(): Bind virtual device (a pasid of a device)
				 to iommufd;
  - iommufd_device_attach(): Attach a SIOV virtual device to IOAS/HWPT;
  - iommufd_device_replace(): Replace IOAS/HWPT of a SIOV virtual device;
  - iommufd_device_detach(): Detach IOAS/HWPT of a SIOV virtual device;
  - iommufd_device_unbind(): Unbind virtual device from iommufd;

For vfio devices, the device drivers that support SIOV should:

  - use below API to register vdev for SIOV virtual device
        vfio_register_pasid_iommu_dev()

  - use below API to bind vdev to iommufd in .bind_iommufd() callback
        iommufd_device_bind_pasid()

  - allocate pasid by itself before calling iommufd_device_bind_pasid()

Complete code can be found at[2]

[1] https://lore.kernel.org/linux-iommu/20230926092651.17041-1-yi.l.liu@intel.com/
[2] https://github.com/yiliu1765/iommufd/tree/iommufd_pasid_siov

Regards,
	Yi Liu

Kevin Tian (5):
  iommufd: Handle unsafe interrupts in a separate function
  iommufd: Introduce iommufd_alloc_device()
  iommufd: Add iommufd_device_bind_pasid()
  iommufd: Support attach/replace for SIOV virtual device {dev, pasid}
  vfio: Add vfio_register_pasid_iommu_dev()

Yi Liu (2):
  iommufd/selftest: Extend IOMMU_TEST_OP_MOCK_DOMAIN to pass in pasid
  iommufd/selftest: Add test coverage for SIOV virtual device

 drivers/iommu/iommufd/device.c                | 163 ++++++++++++++----
 drivers/iommu/iommufd/iommufd_private.h       |   7 +
 drivers/iommu/iommufd/iommufd_test.h          |   2 +
 drivers/iommu/iommufd/selftest.c              |  10 +-
 drivers/vfio/group.c                          |  18 ++
 drivers/vfio/vfio.h                           |   8 +
 drivers/vfio/vfio_main.c                      |  10 ++
 include/linux/iommufd.h                       |   3 +
 include/linux/vfio.h                          |   1 +
 tools/testing/selftests/iommu/iommufd.c       |  75 ++++++--
 .../selftests/iommu/iommufd_fail_nth.c        |  42 ++++-
 tools/testing/selftests/iommu/iommufd_utils.h |  21 ++-
 12 files changed, 296 insertions(+), 64 deletions(-)

-- 
2.34.1


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

end of thread, other threads:[~2023-11-22  4:00 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09  8:51 [RFC 0/7] Add SIOV virtual device support Yi Liu
2023-10-09  8:51 ` [RFC 1/7] iommufd: Handle unsafe interrupts in a separate function Yi Liu
2023-10-09  8:51 ` [RFC 2/7] iommufd: Introduce iommufd_alloc_device() Yi Liu
2023-10-09  8:51 ` [RFC 3/7] iommufd: Add iommufd_device_bind_pasid() Yi Liu
2023-10-10  8:19   ` Tian, Kevin
2023-11-08  7:45     ` Yi Liu
2023-11-08  8:46       ` Tian, Kevin
2023-11-08  9:03         ` Yi Liu
2023-10-09  8:51 ` [RFC 4/7] iommufd: Support attach/replace for SIOV virtual device {dev, pasid} Yi Liu
2023-10-10  8:24   ` Tian, Kevin
2023-11-09  8:21     ` Yi Liu
2023-10-09  8:51 ` [RFC 5/7] iommufd/selftest: Extend IOMMU_TEST_OP_MOCK_DOMAIN to pass in pasid Yi Liu
2023-10-10  8:25   ` Tian, Kevin
2023-10-09  8:51 ` [RFC 6/7] iommufd/selftest: Add test coverage for SIOV virtual device Yi Liu
2023-10-10  8:30   ` Tian, Kevin
2023-11-09  7:48     ` Yi Liu
2023-10-09  8:51 ` [RFC 7/7] vfio: Add vfio_register_pasid_iommu_dev() Yi Liu
2023-10-10  8:33   ` Tian, Kevin
2023-11-09  8:20     ` Yi Liu
2023-11-16  5:35   ` Cao, Yahui
2023-11-17  6:31     ` Yi Liu
     [not found]   ` <99115148-d0e3-4920-aed6-669ae45aa2fe@intel.com>
2023-11-17  6:30     ` Yi Liu
2023-10-09 13:21 ` [RFC 0/7] Add SIOV virtual device support Jason Gunthorpe
2023-10-09 23:33   ` Tian, Kevin
2023-11-22  3:59   ` Cao, Yahui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox