Skip to content

iommufd support pasid attach/replace

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 Latest8 patches 27 repliesIn review

Changes in v1 from the cover letter

- Implemnet iommu_replace_device_pasid() to fall back to the original domain if this replacement failed (Kevin)
- Add check in do_attach() to check corressponding attach_fn per the pasid value.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8iommu: Introduce a replace API for device pasiddrivers/iommu/iommu-priv.h drivers/iommu/iommu.c+70 -1413 replies
2/8iommufd: replace attach_fn with a structuredrivers/iommu/iommufd/device.c drivers/iommu/iommufd/iommufd_private.h+30 -130 replies
3/8iommufd: Support attach/replace hwpt per pasiddrivers/iommu/iommufd/Makefile drivers/iommu/iommufd/device.c drivers/iommu/iommufd/iommufd_private.h +2 more+176 -19 replies
4/8iommufd/selftest: Add set_dev_pasid and remove_dev_pasid in mock iommudrivers/iommu/iommufd/selftest.c+28 -00 replies
5/8iommufd/selftest: Add a helper to get test devicedrivers/iommu/iommufd/selftest.c+21 -110 replies
6/8iommufd/selftest: Add test ops to test pasid attach/detachdrivers/iommu/iommufd/iommufd_test.h drivers/iommu/iommufd/selftest.c+140 -00 replies
7/8iommufd/selftest: Add coverage for iommufd pasid attach/detachtools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_fail_nth.c tools/testing/selftests/iommu/iommufd_utils.h+274 -40 replies
8/8iommu/vt-d: Add set_dev_pasid callback for nested domaindrivers/iommu/intel/nested.c+47 -05 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/8] iommufd support pasid attach/replace

PASID (Process Address Space ID) is a PCIe extension to tag the DMA transactions out of a physical device, and most modern IOMMU hardware have supported PASID granular address translation. So a PASID-capable device can be attached to multiple hwpts (a.k.a. domains), each attachment is tagged with a pasid.

This series first adds a missing iommu API to replace domain for a pasid, then adds iommufd APIs for device drivers to attach/replace/detach pasid to/from hwpt per userspace's request, and adds selftest to validate the iommufd APIs.

pasid attach/replace is mandatory on Intel VT-d given the PASID table locates in the physical address space hence must be managed by the kernel, both for supporting vSVA and coming SIOV. But it's optional on ARM/AMD which allow configuring the PASID/CD table either in host physical address space or nested on top of an GPA address space. This series only add VT-d support as the minimal requirement.

Complete code can be found in below link:

https://github.com/yiliu1765/iommufd/tree/iommufd_pasid

Change log:

v1:
- Implemnet iommu_replace_device_pasid() to fall back to the original domain if this replacement failed (Kevin)
- Add check in do_attach() to check corressponding attach_fn per the pasid value.

rfc: https://lore.kernel.org/linux-iommu/[email protected]/

Regards,
Yi Liu

Kevin Tian (1):
iommufd: Support attach/replace hwpt per pasid

Lu Baolu (2):
iommu: Introduce a replace API for device pasid iommu/vt-d: Add set_dev_pasid callback for nested domain

Yi Liu (5):
iommufd: replace attach_fn with a structure iommufd/selftest: Add set_dev_pasid and remove_dev_pasid in mock iommu iommufd/selftest: Add a helper to get test device iommufd/selftest: Add test ops to test pasid attach/detach iommufd/selftest: Add coverage for iommufd pasid attach/detach

 drivers/iommu/intel/nested.c                  |  47 +++++
 drivers/iommu/iommu-priv.h                    |   2 +
 drivers/iommu/iommu.c                         |  82 ++++++--
 drivers/iommu/iommufd/Makefile                |   1 +
 drivers/iommu/iommufd/device.c                |  50 +++--
 drivers/iommu/iommufd/iommufd_private.h       |  23 +++
 drivers/iommu/iommufd/iommufd_test.h          |  24 +++
 drivers/iommu/iommufd/pasid.c                 | 138 ++++++++++++++
 drivers/iommu/iommufd/selftest.c              | 176 ++++++++++++++++--
 include/linux/iommufd.h                       |   6 +
 tools/testing/selftests/iommu/iommufd.c       | 172 +++++++++++++++++
 .../selftests/iommu/iommufd_fail_nth.c        |  28 ++-
 tools/testing/selftests/iommu/iommufd_utils.h |  78 ++++++++
 13 files changed, 785 insertions(+), 42 deletions(-)
 create mode 100644 drivers/iommu/iommufd/pasid.c
Signature · 1 line
2.34.1