]> Gentwo Git Trees - linux/.git/commitdiff
Merge tag 'vfio-v6.19-rc1' of https://github.com/awilliam/linux-vfio
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Dec 2025 02:42:48 +0000 (18:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Dec 2025 02:42:48 +0000 (18:42 -0800)
Pull VFIO updates from Alex Williamson:

 - Move libvfio selftest artifacts in preparation of more tightly
   coupled integration with KVM selftests (David Matlack)

 - Fix comment typo in mtty driver (Chu Guangqing)

 - Support for new hardware revision in the hisi_acc vfio-pci variant
   driver where the migration registers can now be accessed via the PF.
   When enabled for this support, the full BAR can be exposed to the
   user (Longfang Liu)

 - Fix vfio cdev support for VF token passing, using the correct size
   for the kernel structure, thereby actually allowing userspace to
   provide a non-zero UUID token. Also set the match token callback for
   the hisi_acc, fixing VF token support for this this vfio-pci variant
   driver (Raghavendra Rao Ananta)

 - Introduce internal callbacks on vfio devices to simplify and
   consolidate duplicate code for generating VFIO_DEVICE_GET_REGION_INFO
   data, removing various ioctl intercepts with a more structured
   solution (Jason Gunthorpe)

 - Introduce dma-buf support for vfio-pci devices, allowing MMIO regions
   to be exposed through dma-buf objects with lifecycle managed through
   move operations. This enables low-level interactions such as a
   vfio-pci based SPDK drivers interacting directly with dma-buf capable
   RDMA devices to enable peer-to-peer operations. IOMMUFD is also now
   able to build upon this support to fill a long standing feature gap
   versus the legacy vfio type1 IOMMU backend with an implementation of
   P2P support for VM use cases that better manages the lifecycle of the
   P2P mapping (Leon Romanovsky, Jason Gunthorpe, Vivek Kasireddy)

 - Convert eventfd triggering for error and request signals to use RCU
   mechanisms in order to avoid a 3-way lockdep reported deadlock issue
   (Alex Williamson)

 - Fix a 32-bit overflow introduced via dma-buf support manifesting with
   large DMA buffers (Alex Mastro)

 - Convert nvgrace-gpu vfio-pci variant driver to insert mappings on
   fault rather than at mmap time. This conversion serves both to make
   use of huge PFNMAPs but also to both avoid corrected RAS events
   during reset by now being subject to vfio-pci-core's use of
   unmap_mapping_range(), and to enable a device readiness test after
   reset (Ankit Agrawal)

 - Refactoring of vfio selftests to support multi-device tests and split
   code to provide better separation between IOMMU and device objects.
   This work also enables a new test suite addition to measure parallel
   device initialization latency (David Matlack)

* tag 'vfio-v6.19-rc1' of https://github.com/awilliam/linux-vfio: (65 commits)
  vfio: selftests: Add vfio_pci_device_init_perf_test
  vfio: selftests: Eliminate INVALID_IOVA
  vfio: selftests: Split libvfio.h into separate header files
  vfio: selftests: Move vfio_selftests_*() helpers into libvfio.c
  vfio: selftests: Rename vfio_util.h to libvfio.h
  vfio: selftests: Stop passing device for IOMMU operations
  vfio: selftests: Move IOVA allocator into iova_allocator.c
  vfio: selftests: Move IOMMU library code into iommu.c
  vfio: selftests: Rename struct vfio_dma_region to dma_region
  vfio: selftests: Upgrade driver logging to dev_err()
  vfio: selftests: Prefix logs with device BDF where relevant
  vfio: selftests: Eliminate overly chatty logging
  vfio: selftests: Support multiple devices in the same container/iommufd
  vfio: selftests: Introduce struct iommu
  vfio: selftests: Rename struct vfio_iommu_mode to iommu_mode
  vfio: selftests: Allow passing multiple BDFs on the command line
  vfio: selftests: Split run.sh into separate scripts
  vfio: selftests: Move run.sh into scripts directory
  vfio/nvgrace-gpu: wait for the GPU mem to be ready
  vfio/nvgrace-gpu: Inform devmem unmapped after reset
  ...

1  2 
block/blk-mq-dma.c
drivers/crypto/hisilicon/qm.c
drivers/gpu/drm/i915/gvt/kvmgt.c
drivers/iommu/dma-iommu.c
kernel/dma/direct.c

Simple merge
Simple merge
index bbeba0d3fca8428eda359dee18ed8ec8c92129d9,96d23717684f7ecf291240484bbac2a50992a11b..3abc9206f1a8a78804b0bcdc2022132307de0545
@@@ -1141,6 -1140,126 +1141,122 @@@ static int intel_vgpu_set_irqs(struct i
        return func(vgpu, index, start, count, flags, data);
  }
  
 -              switch (cap_type_id) {
 -              case VFIO_REGION_INFO_CAP_SPARSE_MMAP:
+ static int intel_vgpu_ioctl_get_region_info(struct vfio_device *vfio_dev,
+                                           struct vfio_region_info *info,
+                                           struct vfio_info_cap *caps)
+ {
+       struct vfio_region_info_cap_sparse_mmap *sparse = NULL;
+       struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev);
+       int nr_areas = 1;
+       int cap_type_id;
+       unsigned int i;
+       int ret;
+       switch (info->index) {
+       case VFIO_PCI_CONFIG_REGION_INDEX:
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->size = vgpu->gvt->device_info.cfg_space_size;
+               info->flags = VFIO_REGION_INFO_FLAG_READ |
+                             VFIO_REGION_INFO_FLAG_WRITE;
+               break;
+       case VFIO_PCI_BAR0_REGION_INDEX:
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->size = vgpu->cfg_space.bar[info->index].size;
+               if (!info->size) {
+                       info->flags = 0;
+                       break;
+               }
+               info->flags = VFIO_REGION_INFO_FLAG_READ |
+                             VFIO_REGION_INFO_FLAG_WRITE;
+               break;
+       case VFIO_PCI_BAR1_REGION_INDEX:
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->size = 0;
+               info->flags = 0;
+               break;
+       case VFIO_PCI_BAR2_REGION_INDEX:
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->flags = VFIO_REGION_INFO_FLAG_CAPS |
+                             VFIO_REGION_INFO_FLAG_MMAP |
+                             VFIO_REGION_INFO_FLAG_READ |
+                             VFIO_REGION_INFO_FLAG_WRITE;
+               info->size = gvt_aperture_sz(vgpu->gvt);
+               sparse = kzalloc(struct_size(sparse, areas, nr_areas),
+                                GFP_KERNEL);
+               if (!sparse)
+                       return -ENOMEM;
+               sparse->header.id = VFIO_REGION_INFO_CAP_SPARSE_MMAP;
+               sparse->header.version = 1;
+               sparse->nr_areas = nr_areas;
+               cap_type_id = VFIO_REGION_INFO_CAP_SPARSE_MMAP;
+               sparse->areas[0].offset =
+                       PAGE_ALIGN(vgpu_aperture_offset(vgpu));
+               sparse->areas[0].size = vgpu_aperture_sz(vgpu);
+               break;
+       case VFIO_PCI_BAR3_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX:
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->size = 0;
+               info->flags = 0;
+               gvt_dbg_core("get region info bar:%d\n", info->index);
+               break;
+       case VFIO_PCI_ROM_REGION_INDEX:
+       case VFIO_PCI_VGA_REGION_INDEX:
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->size = 0;
+               info->flags = 0;
+               gvt_dbg_core("get region info index:%d\n", info->index);
+               break;
+       default: {
+               struct vfio_region_info_cap_type cap_type = {
+                       .header.id = VFIO_REGION_INFO_CAP_TYPE,
+                       .header.version = 1
+               };
+               if (info->index >= VFIO_PCI_NUM_REGIONS + vgpu->num_regions)
+                       return -EINVAL;
+               info->index = array_index_nospec(
+                       info->index, VFIO_PCI_NUM_REGIONS + vgpu->num_regions);
+               i = info->index - VFIO_PCI_NUM_REGIONS;
+               info->offset = VFIO_PCI_INDEX_TO_OFFSET(info->index);
+               info->size = vgpu->region[i].size;
+               info->flags = vgpu->region[i].flags;
+               cap_type.type = vgpu->region[i].type;
+               cap_type.subtype = vgpu->region[i].subtype;
+               ret = vfio_info_add_capability(caps, &cap_type.header,
+                                              sizeof(cap_type));
+               if (ret)
+                       return ret;
+       }
+       }
+       if ((info->flags & VFIO_REGION_INFO_FLAG_CAPS) && sparse) {
 -                      if (ret) {
 -                              kfree(sparse);
 -                              return ret;
 -                      }
 -                      break;
 -              default:
++              ret = -EINVAL;
++              if (cap_type_id == VFIO_REGION_INFO_CAP_SPARSE_MMAP) {
+                       ret = vfio_info_add_capability(
+                               caps, &sparse->header,
+                               struct_size(sparse, areas, sparse->nr_areas));
 -                      return -EINVAL;
++              }
++              if (ret) {
+                       kfree(sparse);
++                      return ret;
+               }
+       }
+       kfree(sparse);
+       return 0;
+ }
  static long intel_vgpu_ioctl(struct vfio_device *vfio_dev, unsigned int cmd,
                             unsigned long arg)
  {
Simple merge
index f973e7e73c90bb04d4f0ba394f2c1bb20bece955,d8b3dfc598b22ab699e30d0310bd4eb32703a135..50c3fe2a1d550d95290914fd640de45a46a9d2e4
@@@ -479,9 -479,8 +479,9 @@@ int dma_direct_map_sg(struct device *de
                        }
                        break;
                case PCI_P2PDMA_MAP_BUS_ADDR:
-                       sg->dma_address = pci_p2pdma_bus_addr_map(&p2pdma_state,
-                                       sg_phys(sg));
+                       sg->dma_address = pci_p2pdma_bus_addr_map(
+                               p2pdma_state.mem, sg_phys(sg));
 +                      sg_dma_len(sg) = sg->length;
                        sg_dma_mark_bus_address(sg);
                        continue;
                default: