Skip to content

iommufd: Add vIOMMU infrastructure (Part-3: vEVENTQ)

Nicolin Chen linux-arm-kernel linux-doc linux-iommu linux-kselftest linux-patches lkml 17 versions – Applied

Status from this message: Applied, thanks

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest14 patches 1 replyApplied
  2. v814 patches 18 repliesSuperseded
  3. v7 posting 3/314 patches 19 repliesSuperseded
Earlier versions · 14
VersionPostedPatchesRepliesStatus
v6 posting 3/314 patches45 repliesSuperseded
v5 posting 3/314 patches61 repliesApplied
v4 posting 2/214 patches16 repliesSuperseded
v3 posting 2/214 patches13 repliesSuperseded
v213 patches18 repliesSuperseded
v7 posting 2/310 patches4 repliesApplied
v7 posting 1/313 patches15 repliesApplied
v6 posting 2/310 patches15 repliesSuperseded
v6 posting 1/313 patches10 repliesSuperseded
v5 posting 2/313 patches30 repliesSuperseded
v5 posting 1/313 patches39 repliesSuperseded
v4 posting 1/214 patches14 repliesSuperseded
v3 posting 1/216 patches19 repliesSuperseded
v110 patches6 repliesSuperseded

Patches in v9 Applied

#Subject and filesSizeRepliesApplied
1/14iommufd/fault: Move two fault functions out of the headerdrivers/iommu/iommufd/fault.c drivers/iommu/iommufd/iommufd_private.h+25 -250 replies
2/14iommufd/fault: Add an iommufd_fault_init() helperdrivers/iommu/iommufd/fault.c+42 -280 replies
3/14iommufd: Abstract an iommufd_eventq from iommufd_faultdrivers/iommu/iommufd/fault.c drivers/iommu/iommufd/hw_pagetable.c drivers/iommu/iommufd/iommufd_private.h+82 -630 replies
4/14iommufd: Rename fault.c to eventq.cdrivers/iommu/iommufd/Makefile drivers/iommu/iommufd/eventq.c+1 -10 replies
5/14iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOCdrivers/iommu/iommufd/eventq.c drivers/iommu/iommufd/iommufd_private.h drivers/iommu/iommufd/main.c +3 more+384 -10 replies
6/14iommufd/viommu: Add iommufd_viommu_get_vdev_id helperdrivers/iommu/iommufd/driver.c include/linux/iommufd.h+33 -00 replies
7/14iommufd/viommu: Add iommufd_viommu_report_event helperdrivers/iommu/iommufd/driver.c include/linux/iommufd.h+59 -00 replies
8/14iommufd/selftest: Require vdev_id when attaching to a nested domaindrivers/iommu/iommufd/selftest.c tools/testing/selftests/iommu/iommufd.c+29 -00 replies
9/14iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VEVENT for vEVENTQ coveragedrivers/iommu/iommufd/iommufd_test.h drivers/iommu/iommufd/selftest.c+40 -00 replies
10/14iommufd/selftest: Add IOMMU_VEVENTQ_ALLOC test coveragetools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_fail_nth.c tools/testing/selftests/iommu/iommufd_utils.h+153 -00 replies
11/14Documentation: userspace-api: iommufd: Update FAULT and VEVENTQDocumentation/userspace-api/iommufd.rst+17 -00 replies
12/14iommu/arm-smmu-v3: Introduce struct arm_smmu_vmasterdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h+86 -10 replies
13/14iommu/arm-smmu-v3: Report events that belong to devices attached to vIOMMUdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +1 more+80 -250 replies
14/14iommu/arm-smmu-v3: Set MEV bit in nested STE for DoS mitigationsdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h+5 -20 replies

Reviews trailers per patch

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

PatchJason GunthorpeKevin TianLu BaoluBagas SanjayaPranjal ShrivastavaWill Deacon
1/14R-b R-b
2/14R-b R-b R-b
3/14R-b R-b R-b
4/14R-b R-b R-b
5/14R-b R-b R-b
6/14R-b R-b R-b
7/14R-b R-b R-b
8/14R-b
9/14R-b
10/14R-b
11/14R-b R-b R-b R-b
12/14R-b R-b A-b
13/14R-b R-b R-b A-b
14/14R-b R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v9 thread

Cover letter [PATCH v9 00/14] iommufd: Add vIOMMU infrastructure (Part-3: vEVENTQ)

As the vIOMMU infrastructure series part-3, this introduces a new vEVENTQ object. The existing FAULT object provides a nice notification pathway to the user space with a queue already, so let vEVENTQ reuse that.

Mimicing the HWPT structure, add a common EVENTQ structure to support its
derivatives: IOMMUFD_OBJ_FAULT (existing) and IOMMUFD_OBJ_VEVENTQ (new).

An IOMMUFD_CMD_VEVENTQ_ALLOC is introduced to allocate vEVENTQ object for vIOMMUs. One vIOMMU can have multiple vEVENTQs in different types but can not support multiple vEVENTQs in the same type.

The forwarding part is fairly simple but might need to replace a physical device ID with a virtual device ID in a driver-level event data structure. So, this also adds some helpers for drivers to use.

As usual, this series comes with the selftest coverage for this new ioctl and with a real world use case in the ARM SMMUv3 driver.

This is on Github:
https://github.com/nicolinc/iommufd/commits/iommufd_veventq-v9
Paring QEMU branch for testing:
https://github.com/nicolinc/qemu/commits/wip/for_iommufd_veventq-v9

Changelog
v9
* Add Acked-by from Will
* Fix typo in commit logs and reviewer name
* Allow invaid nested STE for C_BAD_STE report
* Drop extra indentation in arm_smmu_handle_event()
* Drop comments in arm_smmu_attach_prepare_vmaster()
v8
https://lore.kernel.org/all/[email protected]/
* Add Reviewed-by from Jason and Pranjal
* Fix errno returned in arm_smmu_handle_event()
* Validate domain->type outside of arm_smmu_attach_prepare_vmaster()
* Drop unnecessary vmaster comparison in arm_smmu_attach_commit_vmaster()
v7
https://lore.kernel.org/all/[email protected]/
* Rebase on Jason's for-next tree for latest fault.c
* Add Reviewed-by
* Update commit logs
* Add __reserved field sanity
* Skip kfree() on the static header
* Replace "bool on_list" with list_is_last()
* Use u32 for flags in iommufd_vevent_header
* Drop casting in iommufd_viommu_get_vdev_id()
* Update the bounding logic to veventq->sequence
* Add missing cpu_to_le64() around STRTAB_STE_1_MEV
* Reuse veventq->common.lock to fence sequence and num_events
* Rename overflow to lost_events and log it in upon kmalloc failure
* Correct the error handling part in iommufd_veventq_deliver_fetch()
* Add an arm_smmu_clear_vmaster() to simplify identity/blocked domain attach ops
* Add additional four event records to forward to user space VM, and update the uAPI doc
* Reuse the existing smmu->streams_mutex lock to fence master->vmaster pointer, instead of adding a new rwsem
v6
https://lore.kernel.org/all/[email protected]/
* Drop supports_veventq viommu op
* Split bug/cosmetics fixes out of the series
* Drop the blocking mutex around copy_to_user()
* Add veventq_depth in uAPI to limit vEVENTQ size
* Revise the documentation for a clear description
* Fix sparse warnings in arm_vmaster_report_event()
* Rework iommufd_viommu_get_vdev_id() to return -ENOENT v.s. 0
* Allow Abort/Bypass STEs to allocate vEVENTQ and set STE.MEV for DoS mitigations
v5
https://lore.kernel.org/all/[email protected]/
* Add Reviewed-by from Baolu
* Reorder the OBJ list as well
* Fix alphabetical order after renaming in v4
* Add supports_veventq viommu op for vEVENTQ type validation
v4
https://lore.kernel.org/all/[email protected]/
* Rename "vIRQ" to "vEVENTQ"
* Use flexible array in struct iommufd_vevent
* Add the new ioctl command to union ucmd_buffer
* Fix the alphabetical order in union ucmd_buffer too
* Rename _TYPE_NONE to _TYPE_DEFAULT aligning with vIOMMU naming
v3
https://lore.kernel.org/all/[email protected]/
* Rebase on Will's for-joerg/arm-smmu/updates for arm_smmu_event series
* Add "Reviewed-by" lines from Kevin
* Fix typos in comments, kdocs, and jump tags
* Add a patch to sort struct iommufd_ioctl_op
* Update iommufd's userpsace-api documentation
* Update uAPI kdoc to quote SMMUv3 offical spec
* Drop the unused workqueue in struct iommufd_virq
* Drop might_sleep() in iommufd_viommu_report_irq() helper
* Add missing "break" in iommufd_viommu_get_vdev_id() helper
* Shrink the scope of the vmaster's read lock in SMMUv3 driver
* Pass in two arguments to iommufd_eventq_virq_handler() helper
* Move "!ops || !ops->read" validation into iommufd_eventq_init()
* Move "fault->ictx = ictx" closer to iommufd_ctx_get(fault->ictx)
* Update commit message for arm_smmu_attach_prepare/commit_vmaster()
* Keep "iommufd_fault" as-is and rename "iommufd_eventq_virq" to just "iommufd_virq"
v2
https://lore.kernel.org/all/[email protected]/
* Rebase on v6.13-rc1
* Add IOPF and vIRQ in iommufd.rst (userspace-api)
* Add a proper locking in iommufd_event_virq_destroy
* Add iommufd_event_virq_abort with a lockdep_assert_held
* Rename "EVENT_*" to "EVENTQ_*" to describe the objects better
* Reorganize flows in iommufd_eventq_virq_alloc for abort() to work
* Adde struct arm_smmu_vmaster to store vSID upon attaching to a nested domain, calling a newly added iommufd_viommu_get_vdev_id helper
* Adde an arm_vmaster_report_event helper in arm-smmu-v3-iommufd file to simplify the routine in arm_smmu_handle_evt() of the main driver
v1
https://lore.kernel.org/all/[email protected]/

Thanks!
Nicolin

Nicolin Chen (14):
iommufd/fault: Move two fault functions out of the header iommufd/fault: Add an iommufd_fault_init() helper
iommufd: Abstract an iommufd_eventq from iommufd_fault
iommufd: Rename fault.c to eventq.c
iommufd: Add IOMMUFD_OBJ_VEVENTQ and IOMMUFD_CMD_VEVENTQ_ALLOC iommufd/viommu: Add iommufd_viommu_get_vdev_id helper iommufd/viommu: Add iommufd_viommu_report_event helper iommufd/selftest: Require vdev_id when attaching to a nested domain iommufd/selftest: Add IOMMU_TEST_OP_TRIGGER_VEVENT for vEVENTQ
coverage
iommufd/selftest: Add IOMMU_VEVENTQ_ALLOC test coverage
Documentation: userspace-api: iommufd: Update FAULT and VEVENTQ iommu/arm-smmu-v3: Introduce struct arm_smmu_vmaster iommu/arm-smmu-v3: Report events that belong to devices attached to
vIOMMU
iommu/arm-smmu-v3: Set MEV bit in nested STE for DoS mitigations

 drivers/iommu/iommufd/Makefile                |   2 +-
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  36 ++
 drivers/iommu/iommufd/iommufd_private.h       | 135 +++-
 drivers/iommu/iommufd/iommufd_test.h          |  10 +
 include/linux/iommufd.h                       |  23 +
 include/uapi/linux/iommufd.h                  | 105 +++
 tools/testing/selftests/iommu/iommufd_utils.h | 115 ++++
 .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c     |  60 ++
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   |  80 ++-
 drivers/iommu/iommufd/driver.c                |  72 +++
 drivers/iommu/iommufd/eventq.c                | 597 ++++++++++++++++++
 drivers/iommu/iommufd/fault.c                 | 342 ----------
 drivers/iommu/iommufd/hw_pagetable.c          |   6 +-
 drivers/iommu/iommufd/main.c                  |   7 +
 drivers/iommu/iommufd/selftest.c              |  54 ++
 drivers/iommu/iommufd/viommu.c                |   2 +
 tools/testing/selftests/iommu/iommufd.c       |  36 ++
 .../selftests/iommu/iommufd_fail_nth.c        |   7 +
 Documentation/userspace-api/iommufd.rst       |  17 +
 19 files changed, 1298 insertions(+), 408 deletions(-)
 create mode 100644 drivers/iommu/iommufd/eventq.c
 delete mode 100644 drivers/iommu/iommufd/fault.c

base-commit: a05df03a88bc1088be8e9d958f208d6484691e43

Signature · 1 line
2.43.0