Skip to content

iommufd support allocating nested parent domain

Yi Liu kvm linux-iommu linux-kselftest lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 17 repliesIn review
  2. v16 patches 20 repliesSuperseded

Changes in v2 from the cover letter

- Require domain_alloc_user op if IOMMU_HWPT_ALLOC passes non-zero flags (Kevin)
- IOMMUFD core should check kernel known flags while iommu driver needs to check supported flags as well (Jason)
- Minor tweaks per Baolu's comment

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6iommu: Add new iommu op to create domains owned by userspaceinclude/linux/iommu.h include/uapi/linux/iommufd.h+21 -25 replies
2/6iommufd/hw_pagetable: Use domain_alloc_user op for domain allocationdrivers/iommu/iommufd/hw_pagetable.c+15 -42 replies
3/6iommufd/hw_pagetable: Accepts user flags for domain allocationdrivers/iommu/iommufd/device.c drivers/iommu/iommufd/hw_pagetable.c drivers/iommu/iommufd/iommufd_private.h+9 -51 reply
4/6iommufd/hw_pagetable: Support allocating nested parent domaindrivers/iommu/iommufd/hw_pagetable.c+4 -12 replies
5/6iommufd/selftest: Add domain_alloc_user() support in iommu mockdrivers/iommu/iommufd/selftest.c tools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_fail_nth.c +1 more+48 -81 reply
6/6iommu/vt-d: Add domain_alloc_user opdrivers/iommu/intel/iommu.c+28 -04 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchLu BaoluKevin Tian
1/6R-b
2/6R-b R-b
3/6R-b R-b
4/6R-b R-b
5/6R-b
6/6R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/6] iommufd support allocating nested parent domain

IOMMU hardwares that support nested translation would have two stages address translation (normally mentioned as stage-1 and stage-2). The page table formats of the stage-1 and stage-2 can be different. e.g., VT-d has different page table formats for stage-1 and stage-2.

Nested parent domain is the iommu domain used to represent the stage-2 translation. In IOMMUFD, both stage-1 and stage-2 translation are tracked as HWPT (a.k.a. iommu domain). Stage-2 HWPT is parent of stage-1 HWPT as stage-1 cannot work alone in nested translation. In the cases of stage-1 and stage-2 page table format are different, the parent HWPT should use exactly the stage-2 page table format. However, the existing kernel hides the format selection in iommu drivers, so the domain allocated via IOMMU_HWPT_ALLOC can use either stage-1 page table format or stage-2 page table format, there is no guarantees for it.

To enforce the page table format of the nested parent domain, this series introduces a new iommu op (domain_alloc_user) which can accept user flags to allocate domain as userspace requires. It also converts IOMMUFD to use the new domain_alloc_user op for domain allocation if supported, then extends the IOMMU_HWPT_ALLOC ioctl to pass down a NEST_PARENT flag to allocate a HWPT which can be used as parent. This series implements the new op in Intel iommu driver to have a complete picture. It is a preparation for adding nesting support in IOMMUFD/IOMMU.

Complete code can be found:
https://github.com/yiliu1765/iommufd/tree/iommufd_alloc_user_v2

Change log:

v2:
- Require domain_alloc_user op if IOMMU_HWPT_ALLOC passes non-zero flags (Kevin)
- IOMMUFD core should check kernel known flags while iommu driver needs to check supported flags as well (Jason)
- Minor tweaks per Baolu's comment

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

Regards,
Yi Liu

Yi Liu (6):
iommu: Add new iommu op to create domains owned by userspace iommufd/hw_pagetable: Use domain_alloc_user op for domain allocation iommufd/hw_pagetable: Accepts user flags for domain allocation iommufd/hw_pagetable: Support allocating nested parent domain iommufd/selftest: Add domain_alloc_user() support in iommu mock iommu/vt-d: Add domain_alloc_user op

 drivers/iommu/intel/iommu.c                   | 28 +++++++++++++++++
 drivers/iommu/iommufd/device.c                |  2 +-
 drivers/iommu/iommufd/hw_pagetable.c          | 31 ++++++++++++++-----
 drivers/iommu/iommufd/iommufd_private.h       |  3 +-
 drivers/iommu/iommufd/selftest.c              | 19 ++++++++++++
 include/linux/iommu.h                         | 11 ++++++-
 include/uapi/linux/iommufd.h                  | 12 ++++++-
 tools/testing/selftests/iommu/iommufd.c       | 24 +++++++++++---
 .../selftests/iommu/iommufd_fail_nth.c        |  2 +-
 tools/testing/selftests/iommu/iommufd_utils.h | 11 +++++--
 10 files changed, 124 insertions(+), 19 deletions(-)
Signature · 1 line
2.34.1