Hi Linus, Late this time due to some travel and a bunch of linux-next issues last week. I think it is quiet now. There is a shared branch with Joerg's tree that has already been merged by you. That branch contained a fix for a long standing issue with how interrupts on ARM interwork with iommufd, and it should bring full functionality to ARM systems now too. Despite the shared branch there was still a merge conflict (take both but drop mutex and sw_msi): diff --cc drivers/iommu/dma-iommu.c index 8cc5397d7dfc1a,0832998eca389a..6054d0ab802321 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@@ -54,31 -59,34 +54,30 @@@ struct iommu_dma_options }; struct iommu_dma_cookie { - enum iommu_dma_cookie_type type; + struct iova_domain iovad; + struct list_head msi_page_list; + /* Flush queue */ union { - /* Full allocator for IOMMU_DMA_IOVA_COOKIE */ - struct { - struct iova_domain iovad; - /* Flush queue */ - union { - struct iova_fq *single_fq; - struct iova_fq __percpu *percpu_fq; - }; - /* Number of TLB flushes that have been started */ - atomic64_t fq_flush_start_cnt; - /* Number of TLB flushes that have been finished */ - atomic64_t fq_flush_finish_cnt; - /* Timer to regularily empty the flush queues */ - struct timer_list fq_timer; - /* 1 when timer is active, 0 when not */ - atomic_t fq_timer_on; - }; - /* Trivial linear page allocator for IOMMU_DMA_MSI_COOKIE */ - dma_addr_t msi_iova; + struct iova_fq *single_fq; + struct iova_fq __percpu *percpu_fq; }; - struct list_head msi_page_list; - + /* Number of TLB flushes that have been started */ + atomic64_t fq_flush_start_cnt; + /* Number of TLB flushes that have been finished */ + atomic64_t fq_flush_finish_cnt; + /* Timer to regularily empty the flush queues */ + struct timer_list fq_timer; + /* 1 when timer is active, 0 when not */ + atomic_t fq_timer_on; /* Domain for flush queue callback; NULL if flush queue not in use */ - struct iommu_domain *fq_domain; + struct iommu_domain *fq_domain; /* Options for dma-iommu use */ - struct iommu_dma_options options; + struct iommu_dma_options options; - struct mutex mutex; +}; + +struct iommu_dma_msi_cookie { + dma_addr_t msi_iova; + struct list_head msi_page_list; }; static DEFINE_STATIC_KEY_FALSE(iommu_deferred_attach_enabled); @@@ -363,19 -393,14 +362,18 @@@ int iommu_dma_init_fq(struct iommu_doma */ int iommu_get_dma_cookie(struct iommu_domain *domain) { - if (domain->iova_cookie) + struct iommu_dma_cookie *cookie; + + if (domain->cookie_type != IOMMU_COOKIE_NONE) return -EEXIST; - domain->iova_cookie = cookie_alloc(IOMMU_DMA_IOVA_COOKIE); - if (!domain->iova_cookie) + cookie = kzalloc(sizeof(*cookie), GFP_KERNEL); + if (!cookie) return -ENOMEM; - mutex_init(&cookie->mutex); - iommu_domain_set_sw_msi(domain, iommu_dma_sw_msi); + INIT_LIST_HEAD(&cookie->msi_page_list); + domain->cookie_type = IOMMU_COOKIE_DMA_IOVA; + domain->iova_cookie = cookie; return 0; } The tag for-linus-iommufd-merged with my merge resolution to your tree is also available to pull. The following changes since commit 5e9f822c9c683ae884fa5e71df41d1647b2876c6: iommu: Swap the order of setting group->pasid_array and calling attach op of iommu drivers (2025-02-28 10:07:14 -0400) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd.git tags/for-linus-iommufd for you to fetch changes up to 7be11d34f660bfa6583f3d6e2032d5dcbff56081: iommufd: Test attach before detaching pasid (2025-03-28 11:40:41 -0300) ---------------------------------------------------------------- iommufd 6.15 merge window pull Two significant new items: - Allow reporting IOMMU HW events to userspace when the events are clearly linked to a device. This is linked to the VIOMMU object and is intended to be used by a VMM to forward HW events to the virtual machine as part of emulating a vIOMMU. ARM SMMUv3 is the first driver to use this mechanism. Like the existing fault events the data is delivered through a simple FD returning event records on read(). - PASID support in VFIO. "Process Address Space ID" is a PCI feature that allows the device to tag all PCI DMA operations with an ID. The IOMMU will then use the ID to select a unique translation for those DMAs. This is part of Intel's vIOMMU support as VT-D HW requires the hypervisor to manage each PASID entry. The support is generic so any VFIO user could attach any translation to a PASID, and the support should work on ARM SMMUv3 as well. AMD requires additional driver work. Some minor updates, along with fixes: - Prevent using nested parents with fault's, no driver support today - Put a single "cookie_type" value in the iommu_domain to indicate what owns the various opaque owner fields ---------------------------------------------------------------- Bagas Sanjaya (1): iommufd: Fix iommu_vevent_header tables markup Josh Poimboeuf (1): iommu: Convert unreachable() to BUG() Nicolin Chen (18): iommufd: Fix uninitialized rc in iommufd_access_rw() iommufd: Set domain->iommufd_hwpt in all hwpt->domain allocators 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 iommufd: Move iommufd_sw_msi and related functions to driver.c iommu: Drop sw_msi from iommu_domain Robin Murphy (1): iommu: Sort out domain user data Yi Liu (28): iommufd: Disallow allocating nested parent domain with fault ID iommufd: Fail replace if device has not been attached iommu: Require passing new handles to APIs supporting handle iommu: Introduce a replace API for device pasid iommufd: Pass @pasid through the device attach/replace path iommufd/device: Only add reserved_iova in non-pasid path iommufd/device: Replace idev->igroup with local variable iommufd/device: Add helper to detect the first attach of a group iommufd/device: Wrap igroup->hwpt and igroup->device_list into attach struct iommufd/device: Replace device_list with device_array iommufd/device: Add pasid_attach array to track per-PASID attach iommufd: Enforce PASID-compatible domain in PASID path iommufd: Support pasid attach/replace iommufd: Enforce PASID-compatible domain for RID iommu/vt-d: Add IOMMU_HWPT_ALLOC_PASID support iommufd: Allow allocating PASID-compatible domain iommufd/selftest: Add set_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 ida: Add ida_find_first_range() vfio-iommufd: Support pasid [at|de]tach for physical VFIO devices vfio: VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT support pasid iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability iommufd/selftest: Add coverage for reporting max_pasid_log2 via IOMMU_HW_INFO iommufd: Initialize the flags of vevent in iommufd_viommu_report_event() iommufd: Balance veventq->num_events inc/dec iommufd: Test attach before detaching pasid Documentation/userspace-api/iommufd.rst | 17 + .../iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 60 +++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 80 ++- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 36 ++ drivers/iommu/dma-iommu.c | 204 +++---- drivers/iommu/dma-iommu.h | 14 + drivers/iommu/intel/iommu.c | 3 +- drivers/iommu/intel/nested.c | 2 +- drivers/iommu/iommu-priv.h | 16 + drivers/iommu/iommu-sva.c | 1 + drivers/iommu/iommu.c | 160 +++++- drivers/iommu/iommufd/Kconfig | 2 +- drivers/iommu/iommufd/Makefile | 2 +- drivers/iommu/iommufd/device.c | 499 ++++++++++------- drivers/iommu/iommufd/driver.c | 198 +++++++ drivers/iommu/iommufd/eventq.c | 598 +++++++++++++++++++++ drivers/iommu/iommufd/fault.c | 342 ------------ drivers/iommu/iommufd/hw_pagetable.c | 42 +- drivers/iommu/iommufd/iommufd_private.h | 156 ++++-- drivers/iommu/iommufd/iommufd_test.h | 40 ++ drivers/iommu/iommufd/main.c | 7 + drivers/iommu/iommufd/selftest.c | 297 +++++++++- drivers/iommu/iommufd/viommu.c | 2 + drivers/pci/ats.c | 33 ++ drivers/vfio/device_cdev.c | 60 ++- drivers/vfio/iommufd.c | 60 ++- drivers/vfio/pci/vfio_pci.c | 2 + include/linux/idr.h | 11 + include/linux/iommu.h | 35 +- include/linux/iommufd.h | 32 +- include/linux/pci-ats.h | 3 + include/linux/vfio.h | 14 + include/uapi/linux/iommufd.h | 129 ++++- include/uapi/linux/vfio.h | 29 +- lib/idr.c | 67 +++ lib/test_ida.c | 70 +++ tools/testing/selftests/iommu/iommufd.c | 365 +++++++++++++ tools/testing/selftests/iommu/iommufd_fail_nth.c | 59 +- tools/testing/selftests/iommu/iommufd_utils.h | 229 +++++++- 39 files changed, 3147 insertions(+), 829 deletions(-) (diffstat from tag for-linus-iommufd-merged)
Attachment:
signature.asc
Description: PGP signature