History

Merge tag 'vfio-v6.19-rc1' of https://github.com/awilliam/linux-vfio

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 ...

Linus Torvalds committed 11 months ago

Commit a3ebb592 parents ce5cfb0 d721f5272 files · +3426 −1899Browse files

Showing the changes to samples (3 of 72 files). Show all

Unified · Split

3 files
  1. samples/vfio-mdev/mbochs.c +24 −47
  2. samples/vfio-mdev/mdpy.c +7 −27
  3. samples/vfio-mdev/mtty.c +7 −28
samples/vfio-mdev/mbochs.c+24−47
@@ -143,11 +143,6 @@ static struct mdev_parent mbochs_parent; · 142 unmodified lines
143143 static atomic_t mbochs_avail_mbytes;
144144 static const struct vfio_device_ops mbochs_dev_ops;
145145
146−struct vfio_region_info_ext {
147− struct vfio_region_info base;
148− struct vfio_region_info_cap_type type;
149−};
150−
151146 struct mbochs_mode {
152147 u32 drm_format;
153148 u32 bytepp;
@@ -1033,10 +1028,12 @@ static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) · 879 unmodified lines
10331028 return 0;
10341029 }
10351030
1036−static int mbochs_get_region_info(struct mdev_state *mdev_state,
1037− struct vfio_region_info_ext *ext)
1031+static int mbochs_ioctl_get_region_info(struct vfio_device *vdev,
1032+ struct vfio_region_info *region_info,
1033+ struct vfio_info_cap *caps)
10381034 {
1039− struct vfio_region_info *region_info = &ext->base;
1035+ struct mdev_state *mdev_state =
1036+ container_of(vdev, struct mdev_state, vdev);
10401037
10411038 if (region_info->index >= MBOCHS_NUM_REGIONS)
10421039 return -EINVAL;
@@ -1061,20 +1058,23 @@ static int mbochs_get_region_info(struct mdev_state *mdev_state, · 18 unmodified lines
10611058 region_info->flags = (VFIO_REGION_INFO_FLAG_READ |
10621059 VFIO_REGION_INFO_FLAG_WRITE);
10631060 break;
1064− case MBOCHS_EDID_REGION_INDEX:
1065− ext->base.argsz = sizeof(*ext);
1066− ext->base.offset = MBOCHS_EDID_OFFSET;
1067− ext->base.size = MBOCHS_EDID_SIZE;
1068− ext->base.flags = (VFIO_REGION_INFO_FLAG_READ |
1069− VFIO_REGION_INFO_FLAG_WRITE |
1070− VFIO_REGION_INFO_FLAG_CAPS);
1071− ext->base.cap_offset = offsetof(typeof(*ext), type);
1072− ext->type.header.id = VFIO_REGION_INFO_CAP_TYPE;
1073− ext->type.header.version = 1;
1074− ext->type.header.next = 0;
1075− ext->type.type = VFIO_REGION_TYPE_GFX;
1076− ext->type.subtype = VFIO_REGION_SUBTYPE_GFX_EDID;
1077− break;
1061+ case MBOCHS_EDID_REGION_INDEX: {
1062+ struct vfio_region_info_cap_type cap_type = {
1063+ .header.id = VFIO_REGION_INFO_CAP_TYPE,
1064+ .header.version = 1,
1065+ .type = VFIO_REGION_TYPE_GFX,
1066+ .subtype = VFIO_REGION_SUBTYPE_GFX_EDID,
1067+ };
1068+
1069+ region_info->offset = MBOCHS_EDID_OFFSET;
1070+ region_info->size = MBOCHS_EDID_SIZE;
1071+ region_info->flags = (VFIO_REGION_INFO_FLAG_READ |
1072+ VFIO_REGION_INFO_FLAG_WRITE |
1073+ VFIO_REGION_INFO_FLAG_CAPS);
1074+
1075+ return vfio_info_add_capability(caps, &cap_type.header,
1076+ sizeof(cap_type));
1077+ }
10781078 default:
10791079 region_info->size = 0;
10801080 region_info->offset = 0;
@@ -1191,7 +1191,7 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd, · 110 unmodified lines
11911191 struct mdev_state *mdev_state =
11921192 container_of(vdev, struct mdev_state, vdev);
11931193 int ret = 0;
1194− unsigned long minsz, outsz;
1194+ unsigned long minsz;
11951195
11961196 switch (cmd) {
11971197 case VFIO_DEVICE_GET_INFO:
@@ -1215,30 +1215,6 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd, · 17 unmodified lines
12151215
12161216 return 0;
12171217 }
1218− case VFIO_DEVICE_GET_REGION_INFO:
1219− {
1220− struct vfio_region_info_ext info;
1221−
1222− minsz = offsetofend(typeof(info), base.offset);
1223−
1224− if (copy_from_user(&info, (void __user *)arg, minsz))
1225− return -EFAULT;
1226−
1227− outsz = info.base.argsz;
1228− if (outsz < minsz)
1229− return -EINVAL;
1230− if (outsz > sizeof(info))
1231− return -EINVAL;
1232−
1233− ret = mbochs_get_region_info(mdev_state, &info);
1234− if (ret)
1235− return ret;
1236−
1237− if (copy_to_user((void __user *)arg, &info, outsz))
1238− return -EFAULT;
1239−
1240− return 0;
1241− }
12421218
12431219 case VFIO_DEVICE_GET_IRQ_INFO:
12441220 {
@@ -1376,6 +1352,7 @@ static const struct vfio_device_ops mbochs_dev_ops = { · 131 unmodified lines
13761352 .read = mbochs_read,
13771353 .write = mbochs_write,
13781354 .ioctl = mbochs_ioctl,
1355+ .get_region_info_caps = mbochs_ioctl_get_region_info,
13791356 .mmap = mbochs_mmap,
13801357 .bind_iommufd = vfio_iommufd_emulated_bind,
13811358 .unbind_iommufd = vfio_iommufd_emulated_unbind,
samples/vfio-mdev/mdpy.c+7−27
@@ -435,10 +435,13 @@ static int mdpy_mmap(struct vfio_device *vdev, struct vm_area_struct *vma) · 434 unmodified lines
435435 return remap_vmalloc_range(vma, mdev_state->memblk, 0);
436436 }
437437
438−static int mdpy_get_region_info(struct mdev_state *mdev_state,
439− struct vfio_region_info *region_info,
440− u16 *cap_type_id, void **cap_type)
438+static int mdpy_ioctl_get_region_info(struct vfio_device *vdev,
439+ struct vfio_region_info *region_info,
440+ struct vfio_info_cap *caps)
441441 {
442+ struct mdev_state *mdev_state =
443+ container_of(vdev, struct mdev_state, vdev);
444+
442445 if (region_info->index >= VFIO_PCI_NUM_REGIONS &&
443446 region_info->index != MDPY_DISPLAY_REGION)
444447 return -EINVAL;
@@ -544,30 +547,6 @@ static long mdpy_ioctl(struct vfio_device *vdev, unsigned int cmd, · 99 unmodified lines
544547
545548 return 0;
546549 }
547− case VFIO_DEVICE_GET_REGION_INFO:
548− {
549− struct vfio_region_info info;
550− u16 cap_type_id = 0;
551− void *cap_type = NULL;
552−
553− minsz = offsetofend(struct vfio_region_info, offset);
554−
555− if (copy_from_user(&info, (void __user *)arg, minsz))
556− return -EFAULT;
557−
558− if (info.argsz < minsz)
559− return -EINVAL;
560−
561− ret = mdpy_get_region_info(mdev_state, &info, &cap_type_id,
562− &cap_type);
563− if (ret)
564− return ret;
565−
566− if (copy_to_user((void __user *)arg, &info, minsz))
567− return -EFAULT;
568−
569− return 0;
570− }
571550
572551 case VFIO_DEVICE_GET_IRQ_INFO:
573552 {
@@ -665,6 +644,7 @@ static const struct vfio_device_ops mdpy_dev_ops = { · 91 unmodified lines
665644 .read = mdpy_read,
666645 .write = mdpy_write,
667646 .ioctl = mdpy_ioctl,
647+ .get_region_info_caps = mdpy_ioctl_get_region_info,
668648 .mmap = mdpy_mmap,
669649 .bind_iommufd = vfio_iommufd_emulated_bind,
670650 .unbind_iommufd = vfio_iommufd_emulated_unbind,
samples/vfio-mdev/mtty.c+7−28
@@ -624,7 +624,7 @@ static void handle_bar_read(unsigned int index, struct mdev_state *mdev_state, · 623 unmodified lines
624624 u8 lsr = 0;
625625
626626 mutex_lock(&mdev_state->rxtx_lock);
627− /* atleast one char in FIFO */
627+ /* at least one char in FIFO */
628628 if (mdev_state->s[index].rxtx.head !=
629629 mdev_state->s[index].rxtx.tail)
630630 lsr |= UART_LSR_DR;
@@ -1717,10 +1717,12 @@ static int mtty_set_irqs(struct mdev_state *mdev_state, uint32_t flags, · 1086 unmodified lines
17171717 return ret;
17181718 }
17191719
1720−static int mtty_get_region_info(struct mdev_state *mdev_state,
1721− struct vfio_region_info *region_info,
1722− u16 *cap_type_id, void **cap_type)
1720+static int mtty_ioctl_get_region_info(struct vfio_device *vdev,
1721+ struct vfio_region_info *region_info,
1722+ struct vfio_info_cap *caps)
17231723 {
1724+ struct mdev_state *mdev_state =
1725+ container_of(vdev, struct mdev_state, vdev);
17241726 unsigned int size = 0;
17251727 u32 bar_index;
17261728
@@ -1817,30 +1819,6 @@ static long mtty_ioctl(struct vfio_device *vdev, unsigned int cmd, · 90 unmodified lines
18171819
18181820 return 0;
18191821 }
1820− case VFIO_DEVICE_GET_REGION_INFO:
1821− {
1822− struct vfio_region_info info;
1823− u16 cap_type_id = 0;
1824− void *cap_type = NULL;
1825−
1826− minsz = offsetofend(struct vfio_region_info, offset);
1827−
1828− if (copy_from_user(&info, (void __user *)arg, minsz))
1829− return -EFAULT;
1830−
1831− if (info.argsz < minsz)
1832− return -EINVAL;
1833−
1834− ret = mtty_get_region_info(mdev_state, &info, &cap_type_id,
1835− &cap_type);
1836− if (ret)
1837− return ret;
1838−
1839− if (copy_to_user((void __user *)arg, &info, minsz))
1840− return -EFAULT;
1841−
1842− return 0;
1843− }
18441822
18451823 case VFIO_DEVICE_GET_IRQ_INFO:
18461824 {
@@ -1949,6 +1927,7 @@ static const struct vfio_device_ops mtty_dev_ops = { · 102 unmodified lines
19491927 .read = mtty_read,
19501928 .write = mtty_write,
19511929 .ioctl = mtty_ioctl,
1930+ .get_region_info_caps = mtty_ioctl_get_region_info,
19521931 .bind_iommufd = vfio_iommufd_emulated_bind,
19531932 .unbind_iommufd = vfio_iommufd_emulated_unbind,
19541933 .attach_ioas = vfio_iommufd_emulated_attach_ioas,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t