Skip to content

RFC Add SIOV virtual device support

Yi Liu kvm linux-iommu linux-kselftest lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest7 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7iommufd: Handle unsafe interrupts in a separate functiondrivers/iommu/iommufd/device.c+21 -150 replies
2/7iommufd: Introduce iommufd_alloc_device()drivers/iommu/iommufd/device.c+23 -110 replies
3/7iommufd: Add iommufd_device_bind_pasid()drivers/iommu/iommufd/device.c drivers/iommu/iommufd/iommufd_private.h include/linux/iommufd.h+80 -24 replies
4/7iommufd: Support attach/replace for SIOV virtual device {dev, pasid}drivers/iommu/iommufd/device.c+17 -42 replies
5/7iommufd/selftest: Extend IOMMU_TEST_OP_MOCK_DOMAIN to pass in pasiddrivers/iommu/iommufd/iommufd_test.h drivers/iommu/iommufd/selftest.c tools/testing/selftests/iommu/iommufd.c +2 more+42 -311 reply
6/7iommufd/selftest: Add test coverage for SIOV virtual devicetools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_fail_nth.c+77 -22 replies
7/7vfio: Add vfio_register_pasid_iommu_dev()drivers/vfio/group.c drivers/vfio/vfio.h drivers/vfio/vfio_main.c +1 more+37 -05 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC 0/7] Add SIOV virtual device support

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/[email protected]/
[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(-)
Signature · 1 line
2.34.1