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
143static atomic_t mbochs_avail_mbytes;143static atomic_t mbochs_avail_mbytes;
144static const struct vfio_device_ops mbochs_dev_ops;144static const struct vfio_device_ops mbochs_dev_ops;
145 145
146struct vfio_region_info_ext {
147 struct vfio_region_info base;
148 struct vfio_region_info_cap_type type;
149};
150
151struct mbochs_mode {146struct mbochs_mode {
152 u32 drm_format;147 u32 drm_format;
153 u32 bytepp;148 u32 bytepp;
@@ -1033,10 +1028,12 @@ static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf) · 879 unmodified lines
1033 return 0;1028 return 0;
1034}1029}
1035 1030
1036static int mbochs_get_region_info(struct mdev_state *mdev_state,1031static int mbochs_ioctl_get_region_info(struct vfio_device *vdev,
1037 struct vfio_region_info_ext *ext)1032 struct vfio_region_info *region_info,
1033 struct vfio_info_cap *caps)
1038{1034{
1039 struct vfio_region_info *region_info = &ext->base;1035 struct mdev_state *mdev_state =
1036 container_of(vdev, struct mdev_state, vdev);
1040 1037
1041 if (region_info->index >= MBOCHS_NUM_REGIONS)1038 if (region_info->index >= MBOCHS_NUM_REGIONS)
1042 return -EINVAL;1039 return -EINVAL;
@@ -1061,20 +1058,23 @@ static int mbochs_get_region_info(struct mdev_state *mdev_state, · 18 unmodified lines
1061 region_info->flags = (VFIO_REGION_INFO_FLAG_READ |1058 region_info->flags = (VFIO_REGION_INFO_FLAG_READ |
1062 VFIO_REGION_INFO_FLAG_WRITE);1059 VFIO_REGION_INFO_FLAG_WRITE);
1063 break;1060 break;
1064 case MBOCHS_EDID_REGION_INDEX:1061 case MBOCHS_EDID_REGION_INDEX: {
1065 ext->base.argsz = sizeof(*ext);1062 struct vfio_region_info_cap_type cap_type = {
1066 ext->base.offset = MBOCHS_EDID_OFFSET;1063 .header.id = VFIO_REGION_INFO_CAP_TYPE,
1067 ext->base.size = MBOCHS_EDID_SIZE;1064 .header.version = 1,
1068 ext->base.flags = (VFIO_REGION_INFO_FLAG_READ |1065 .type = VFIO_REGION_TYPE_GFX,
1069 VFIO_REGION_INFO_FLAG_WRITE |1066 .subtype = VFIO_REGION_SUBTYPE_GFX_EDID,
1070 VFIO_REGION_INFO_FLAG_CAPS);1067 };
1071 ext->base.cap_offset = offsetof(typeof(*ext), type);1068
1072 ext->type.header.id = VFIO_REGION_INFO_CAP_TYPE;1069 region_info->offset = MBOCHS_EDID_OFFSET;
1073 ext->type.header.version = 1;1070 region_info->size = MBOCHS_EDID_SIZE;
1074 ext->type.header.next = 0;1071 region_info->flags = (VFIO_REGION_INFO_FLAG_READ |
1075 ext->type.type = VFIO_REGION_TYPE_GFX;1072 VFIO_REGION_INFO_FLAG_WRITE |
1076 ext->type.subtype = VFIO_REGION_SUBTYPE_GFX_EDID;1073 VFIO_REGION_INFO_FLAG_CAPS);
1077 break;1074
1075 return vfio_info_add_capability(caps, &cap_type.header,
1076 sizeof(cap_type));
1077 }
1078 default:1078 default:
1079 region_info->size = 0;1079 region_info->size = 0;
1080 region_info->offset = 0;1080 region_info->offset = 0;
@@ -1191,7 +1191,7 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd, · 110 unmodified lines
1191 struct mdev_state *mdev_state =1191 struct mdev_state *mdev_state =
1192 container_of(vdev, struct mdev_state, vdev);1192 container_of(vdev, struct mdev_state, vdev);
1193 int ret = 0;1193 int ret = 0;
1194 unsigned long minsz, outsz;1194 unsigned long minsz;
1195 1195
1196 switch (cmd) {1196 switch (cmd) {
1197 case VFIO_DEVICE_GET_INFO:1197 case VFIO_DEVICE_GET_INFO:
@@ -1215,30 +1215,6 @@ static long mbochs_ioctl(struct vfio_device *vdev, unsigned int cmd, · 17 unmodified lines
1215 1215
1216 return 0;1216 return 0;
1217 }1217 }
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 }
1242 1218
1243 case VFIO_DEVICE_GET_IRQ_INFO:1219 case VFIO_DEVICE_GET_IRQ_INFO:
1244 {1220 {
@@ -1376,6 +1352,7 @@ static const struct vfio_device_ops mbochs_dev_ops = { · 131 unmodified lines
1376 .read = mbochs_read,1352 .read = mbochs_read,
1377 .write = mbochs_write,1353 .write = mbochs_write,
1378 .ioctl = mbochs_ioctl,1354 .ioctl = mbochs_ioctl,
1355 .get_region_info_caps = mbochs_ioctl_get_region_info,
1379 .mmap = mbochs_mmap,1356 .mmap = mbochs_mmap,
1380 .bind_iommufd = vfio_iommufd_emulated_bind,1357 .bind_iommufd = vfio_iommufd_emulated_bind,
1381 .unbind_iommufd = vfio_iommufd_emulated_unbind,1358 .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
435 return remap_vmalloc_range(vma, mdev_state->memblk, 0);435 return remap_vmalloc_range(vma, mdev_state->memblk, 0);
436}436}
437 437
438static int mdpy_get_region_info(struct mdev_state *mdev_state,438static int mdpy_ioctl_get_region_info(struct vfio_device *vdev,
439 struct vfio_region_info *region_info,439 struct vfio_region_info *region_info,
440 u16 *cap_type_id, void **cap_type)440 struct vfio_info_cap *caps)
441{441{
442 struct mdev_state *mdev_state =
443 container_of(vdev, struct mdev_state, vdev);
444
442 if (region_info->index >= VFIO_PCI_NUM_REGIONS &&445 if (region_info->index >= VFIO_PCI_NUM_REGIONS &&
443 region_info->index != MDPY_DISPLAY_REGION)446 region_info->index != MDPY_DISPLAY_REGION)
444 return -EINVAL;447 return -EINVAL;
@@ -544,30 +547,6 @@ static long mdpy_ioctl(struct vfio_device *vdev, unsigned int cmd, · 99 unmodified lines
544 547
545 return 0;548 return 0;
546 }549 }
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 }
571 550
572 case VFIO_DEVICE_GET_IRQ_INFO:551 case VFIO_DEVICE_GET_IRQ_INFO:
573 {552 {
@@ -665,6 +644,7 @@ static const struct vfio_device_ops mdpy_dev_ops = { · 91 unmodified lines
665 .read = mdpy_read,644 .read = mdpy_read,
666 .write = mdpy_write,645 .write = mdpy_write,
667 .ioctl = mdpy_ioctl,646 .ioctl = mdpy_ioctl,
647 .get_region_info_caps = mdpy_ioctl_get_region_info,
668 .mmap = mdpy_mmap,648 .mmap = mdpy_mmap,
669 .bind_iommufd = vfio_iommufd_emulated_bind,649 .bind_iommufd = vfio_iommufd_emulated_bind,
670 .unbind_iommufd = vfio_iommufd_emulated_unbind,650 .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
624 u8 lsr = 0;624 u8 lsr = 0;
625 625
626 mutex_lock(&mdev_state->rxtx_lock);626 mutex_lock(&mdev_state->rxtx_lock);
627 /* atleast one char in FIFO */627 /* at least one char in FIFO */
628 if (mdev_state->s[index].rxtx.head !=628 if (mdev_state->s[index].rxtx.head !=
629 mdev_state->s[index].rxtx.tail)629 mdev_state->s[index].rxtx.tail)
630 lsr |= UART_LSR_DR;630 lsr |= UART_LSR_DR;
@@ -1717,10 +1717,12 @@ static int mtty_set_irqs(struct mdev_state *mdev_state, uint32_t flags, · 1086 unmodified lines
1717 return ret;1717 return ret;
1718}1718}
1719 1719
1720static int mtty_get_region_info(struct mdev_state *mdev_state,1720static int mtty_ioctl_get_region_info(struct vfio_device *vdev,
1721 struct vfio_region_info *region_info,1721 struct vfio_region_info *region_info,
1722 u16 *cap_type_id, void **cap_type)1722 struct vfio_info_cap *caps)
1723{1723{
1724 struct mdev_state *mdev_state =
1725 container_of(vdev, struct mdev_state, vdev);
1724 unsigned int size = 0;1726 unsigned int size = 0;
1725 u32 bar_index;1727 u32 bar_index;
1726 1728
@@ -1817,30 +1819,6 @@ static long mtty_ioctl(struct vfio_device *vdev, unsigned int cmd, · 90 unmodified lines
1817 1819
1818 return 0;1820 return 0;
1819 }1821 }
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 }
1844 1822
1845 case VFIO_DEVICE_GET_IRQ_INFO:1823 case VFIO_DEVICE_GET_IRQ_INFO:
1846 {1824 {
@@ -1949,6 +1927,7 @@ static const struct vfio_device_ops mtty_dev_ops = { · 102 unmodified lines
1949 .read = mtty_read,1927 .read = mtty_read,
1950 .write = mtty_write,1928 .write = mtty_write,
1951 .ioctl = mtty_ioctl,1929 .ioctl = mtty_ioctl,
1930 .get_region_info_caps = mtty_ioctl_get_region_info,
1952 .bind_iommufd = vfio_iommufd_emulated_bind,1931 .bind_iommufd = vfio_iommufd_emulated_bind,
1953 .unbind_iommufd = vfio_iommufd_emulated_unbind,1932 .unbind_iommufd = vfio_iommufd_emulated_unbind,
1954 .attach_ioas = vfio_iommufd_emulated_attach_ioas,1933 .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