Skip to content

Commit f0bf3ea

Browse files
committed
Merge tag 'vfio-v7.1-rc1' of https://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - Update QAT vfio-pci variant driver for Gen 5, 420xx devices (Vijay Sundar Selvamani, Suman Kumar Chakraborty, Giovanni Cabiddu) - Fix vfio selftest MMIO DMA mapping selftest (Alex Mastro) - Conversions to const struct class in support of class_create() deprecation (Jori Koolstra) - Improve selftest compiler compatibility by avoiding initializer on variable-length array (Manish Honap) - Define new uAPI for drivers supporting migration to advise user- space of new initial data for reducing target startup latency. Implemented for mlx5 vfio-pci variant driver (Yishai Hadas) - Enable vfio selftests on aarch64, not just cross-compiles reporting arm64 (Ted Logan) - Update vfio selftest driver support to include additional DSA devices (Yi Lai) - Unconditionally include debugfs root pointer in vfio device struct, avoiding a build failure seen in hisi_acc variant driver without debugfs otherwise (Arnd Bergmann) - Add support for the s390 ISM (Internal Shared Memory) device via a new variant driver. The device is unique in the size of its BAR space (256TiB) and lack of mmap support (Julian Ruess) - Enforce that vfio-pci drivers implement a name in their ops structure for use in sequestering SR-IOV VFs (Alex Williamson) - Prune leftover group notifier code (Paolo Bonzini) - Fix Xe vfio-pci variant driver to avoid migration support as a dependency in the reset path and missing release call (Michał Winiarski) * tag 'vfio-v7.1-rc1' of https://github.com/awilliam/linux-vfio: (23 commits) vfio/xe: Add a missing vfio_pci_core_release_dev() vfio/xe: Reorganize the init to decouple migration from reset vfio: remove dead notifier code vfio/pci: Require vfio_device_ops.name MAINTAINERS: add VFIO ISM PCI DRIVER section vfio/ism: Implement vfio_pci driver for ISM devices vfio/pci: Rename vfio_config_do_rw() to vfio_pci_config_rw_single() and export it vfio: unhide vdev->debug_root vfio/qat: add support for Intel QAT 420xx VFs vfio: selftests: Support DMR and GNR-D DSA devices vfio: selftests: Build tests on aarch64 vfio/mlx5: Add REINIT support to VFIO_MIG_GET_PRECOPY_INFO vfio/mlx5: consider inflight SAVE during PRE_COPY net/mlx5: Add IFC bits for migration state vfio: Adapt drivers to use the core helper vfio_check_precopy_ioctl vfio: Add support for VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2 vfio: Define uAPI for re-init initial bytes during the PRE_COPY phase vfio: selftests: Fix VLA initialisation in vfio_pci_irq_set() vfio: uapi: fix comment typo vfio: mdev: replace mtty_dev->vd_class with a const struct class ...
2 parents 1d51b37 + 493c7ef commit f0bf3ea

30 files changed

Lines changed: 738 additions & 165 deletions

File tree

Documentation/arch/s390/vfio-ap.rst

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -431,27 +431,23 @@ matrix device.
431431
* callback interfaces
432432

433433
open_device:
434-
The vfio_ap driver uses this callback to register a
435-
VFIO_GROUP_NOTIFY_SET_KVM notifier callback function for the matrix mdev
436-
devices. The open_device callback is invoked by userspace to connect the
437-
VFIO iommu group for the matrix mdev device to the MDEV bus. Access to the
438-
KVM structure used to configure the KVM guest is provided via this callback.
439-
The KVM structure, is used to configure the guest's access to the AP matrix
440-
defined via the vfio_ap mediated device's sysfs attribute files.
434+
the open_device callback is invoked by userspace to connect the
435+
VFIO iommu group for the matrix mdev device to the MDEV bus. The
436+
callback retrieves the KVM structure used to configure the KVM guest
437+
and configures the guest's access to the AP matrix defined via the
438+
vfio_ap mediated device's sysfs attribute files.
441439

442440
close_device:
443-
unregisters the VFIO_GROUP_NOTIFY_SET_KVM notifier callback function for the
444-
matrix mdev device and deconfigures the guest's AP matrix.
441+
this callback deconfigures the guest's AP matrix.
445442

446443
ioctl:
447444
this callback handles the VFIO_DEVICE_GET_INFO and VFIO_DEVICE_RESET ioctls
448445
defined by the vfio framework.
449446

450447
Configure the guest's AP resources
451448
----------------------------------
452-
Configuring the AP resources for a KVM guest will be performed when the
453-
VFIO_GROUP_NOTIFY_SET_KVM notifier callback is invoked. The notifier
454-
function is called when userspace connects to KVM. The guest's AP resources are
449+
Configuring the AP resources for a KVM guest will be performed at the
450+
time of ``open_device`` and ``close_device``. The guest's AP resources are
455451
configured via its APCB by:
456452

457453
* Setting the bits in the APM corresponding to the APIDs assigned to the

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27902,6 +27902,12 @@ L: kvm@vger.kernel.org
2790227902
S: Maintained
2790327903
F: drivers/vfio/pci/hisilicon/
2790427904

27905+
VFIO ISM PCI DRIVER
27906+
M: Julian Ruess <julianr@linux.ibm.com>
27907+
L: kvm@vger.kernel.org
27908+
S: Maintained
27909+
F: drivers/vfio/pci/ism/
27910+
2790527911
VFIO MEDIATED DEVICE DRIVERS
2790627912
M: Kirti Wankhede <kwankhede@nvidia.com>
2790727913
L: kvm@vger.kernel.org

drivers/vfio/group.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
#include <linux/anon_inodes.h>
1616
#include "vfio.h"
1717

18+
static char *vfio_devnode(const struct device *, umode_t *);
19+
static const struct class vfio_class = {
20+
.name = "vfio",
21+
.devnode = vfio_devnode
22+
};
23+
1824
static struct vfio {
19-
struct class *class;
2025
struct list_head group_list;
2126
struct mutex group_lock; /* locks group_list */
2227
struct ida group_ida;
@@ -456,7 +461,6 @@ static int vfio_group_fops_release(struct inode *inode, struct file *filep)
456461
* Device FDs hold a group file reference, therefore the group release
457462
* is only called when there are no open devices.
458463
*/
459-
WARN_ON(group->notifier.head);
460464
if (group->container)
461465
vfio_group_detach_container(group);
462466
if (group->iommufd) {
@@ -527,7 +531,7 @@ static struct vfio_group *vfio_group_alloc(struct iommu_group *iommu_group,
527531

528532
device_initialize(&group->dev);
529533
group->dev.devt = MKDEV(MAJOR(vfio.group_devt), minor);
530-
group->dev.class = vfio.class;
534+
group->dev.class = &vfio_class;
531535
group->dev.release = vfio_group_release;
532536
cdev_init(&group->cdev, &vfio_group_fops);
533537
group->cdev.owner = THIS_MODULE;
@@ -541,7 +545,6 @@ static struct vfio_group *vfio_group_alloc(struct iommu_group *iommu_group,
541545
/* put in vfio_group_release() */
542546
iommu_group_ref_get(iommu_group);
543547
group->type = type;
544-
BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier);
545548

546549
return group;
547550
}
@@ -720,7 +723,6 @@ void vfio_device_remove_group(struct vfio_device *device)
720723
* properly hold the group reference.
721724
*/
722725
WARN_ON(!list_empty(&group->device_list));
723-
WARN_ON(group->notifier.head);
724726

725727
/*
726728
* Revoke all users of group->iommu_group. At this point we know there
@@ -901,22 +903,17 @@ int __init vfio_group_init(void)
901903
return ret;
902904

903905
/* /dev/vfio/$GROUP */
904-
vfio.class = class_create("vfio");
905-
if (IS_ERR(vfio.class)) {
906-
ret = PTR_ERR(vfio.class);
906+
ret = class_register(&vfio_class);
907+
if (ret)
907908
goto err_group_class;
908-
}
909-
910-
vfio.class->devnode = vfio_devnode;
911909

912910
ret = alloc_chrdev_region(&vfio.group_devt, 0, MINORMASK + 1, "vfio");
913911
if (ret)
914912
goto err_alloc_chrdev;
915913
return 0;
916914

917915
err_alloc_chrdev:
918-
class_destroy(vfio.class);
919-
vfio.class = NULL;
916+
class_unregister(&vfio_class);
920917
err_group_class:
921918
vfio_container_cleanup();
922919
return ret;
@@ -927,7 +924,6 @@ void vfio_group_cleanup(void)
927924
WARN_ON(!list_empty(&vfio.group_list));
928925
ida_destroy(&vfio.group_ida);
929926
unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
930-
class_destroy(vfio.class);
931-
vfio.class = NULL;
927+
class_unregister(&vfio_class);
932928
vfio_container_cleanup();
933929
}

drivers/vfio/pci/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ config VFIO_PCI_DMABUF
6060

6161
source "drivers/vfio/pci/mlx5/Kconfig"
6262

63+
source "drivers/vfio/pci/ism/Kconfig"
64+
6365
source "drivers/vfio/pci/hisilicon/Kconfig"
6466

6567
source "drivers/vfio/pci/pds/Kconfig"

drivers/vfio/pci/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ obj-$(CONFIG_VFIO_PCI) += vfio-pci.o
1111

1212
obj-$(CONFIG_MLX5_VFIO_PCI) += mlx5/
1313

14+
obj-$(CONFIG_ISM_VFIO_PCI) += ism/
15+
1416
obj-$(CONFIG_HISI_ACC_VFIO_PCI) += hisilicon/
1517

1618
obj-$(CONFIG_PDS_VFIO_PCI) += pds/

drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -857,18 +857,12 @@ static long hisi_acc_vf_precopy_ioctl(struct file *filp,
857857
struct hisi_acc_vf_core_device *hisi_acc_vdev = migf->hisi_acc_vdev;
858858
loff_t *pos = &filp->f_pos;
859859
struct vfio_precopy_info info;
860-
unsigned long minsz;
861860
int ret;
862861

863-
if (cmd != VFIO_MIG_GET_PRECOPY_INFO)
864-
return -ENOTTY;
865-
866-
minsz = offsetofend(struct vfio_precopy_info, dirty_bytes);
867-
868-
if (copy_from_user(&info, (void __user *)arg, minsz))
869-
return -EFAULT;
870-
if (info.argsz < minsz)
871-
return -EINVAL;
862+
ret = vfio_check_precopy_ioctl(&hisi_acc_vdev->core_device.vdev, cmd,
863+
arg, &info);
864+
if (ret)
865+
return ret;
872866

873867
mutex_lock(&hisi_acc_vdev->state_mutex);
874868
if (hisi_acc_vdev->mig_state != VFIO_DEVICE_STATE_PRE_COPY) {
@@ -893,7 +887,8 @@ static long hisi_acc_vf_precopy_ioctl(struct file *filp,
893887
mutex_unlock(&migf->lock);
894888
mutex_unlock(&hisi_acc_vdev->state_mutex);
895889

896-
return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0;
890+
return copy_to_user((void __user *)arg, &info,
891+
offsetofend(struct vfio_precopy_info, dirty_bytes)) ? -EFAULT : 0;
897892
out:
898893
mutex_unlock(&migf->lock);
899894
mutex_unlock(&hisi_acc_vdev->state_mutex);

drivers/vfio/pci/ism/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
config ISM_VFIO_PCI
3+
tristate "VFIO support for ISM devices"
4+
depends on S390
5+
select VFIO_PCI_CORE
6+
help
7+
This provides user space support for IBM Internal Shared Memory (ISM)
8+
Adapter devices using the VFIO framework.
9+
10+
If you don't know what to do here, say N.

drivers/vfio/pci/ism/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
obj-$(CONFIG_ISM_VFIO_PCI) += ism-vfio-pci.o
3+
ism-vfio-pci-y := main.o

0 commit comments

Comments
 (0)