]> www.infradead.org Git - users/hch/misc.git/commitdiff
Merge tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Apr 2025 01:03:46 +0000 (18:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 2 Apr 2025 01:03:46 +0000 (18:03 -0700)
Pull iommufd updates from Jason Gunthorpe:
 "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.

     The "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"

* tag 'for-linus-iommufd' of git://git.kernel.org/pub/scm/linux/kernel/git/jgg/iommufd: (49 commits)
  iommufd: Test attach before detaching pasid
  iommufd: Fix iommu_vevent_header tables markup
  iommu: Convert unreachable() to BUG()
  iommufd: Balance veventq->num_events inc/dec
  iommufd: Initialize the flags of vevent in iommufd_viommu_report_event()
  iommufd/selftest: Add coverage for reporting max_pasid_log2 via IOMMU_HW_INFO
  iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability
  vfio: VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT support pasid
  vfio-iommufd: Support pasid [at|de]tach for physical VFIO devices
  ida: Add ida_find_first_range()
  iommufd/selftest: Add coverage for iommufd pasid attach/detach
  iommufd/selftest: Add test ops to test pasid attach/detach
  iommufd/selftest: Add a helper to get test device
  iommufd/selftest: Add set_dev_pasid in mock iommu
  iommufd: Allow allocating PASID-compatible domain
  iommu/vt-d: Add IOMMU_HWPT_ALLOC_PASID support
  iommufd: Enforce PASID-compatible domain for RID
  iommufd: Support pasid attach/replace
  iommufd: Enforce PASID-compatible domain in PASID path
  iommufd/device: Add pasid_attach array to track per-PASID attach
  ...

1  2 
drivers/iommu/dma-iommu.c
drivers/iommu/intel/iommu.c
drivers/iommu/iommu-priv.h
drivers/iommu/iommu.c
include/linux/idr.h
include/linux/iommu.h
include/uapi/linux/vfio.h

index 0832998eca389af4b371978962deeb0ade1bf0fe,8cc5397d7dfc1a254aba073e6e182c64ebadbb2d..6054d0ab80232102c4a9e39ab47f4877ce4e8774
@@@ -59,34 -54,31 +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);
@@@ -393,14 -363,19 +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;
  
-       iommu_domain_set_sw_msi(domain, iommu_dma_sw_msi);
 -      mutex_init(&cookie->mutex);
+       INIT_LIST_HEAD(&cookie->msi_page_list);
+       domain->cookie_type = IOMMU_COOKIE_DMA_IOVA;
+       domain->iova_cookie = cookie;
        return 0;
  }
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge