diff --git a/patches.suse/s390-vfio-ap-prepare-for-dynamic-update-of-guest-s-APCB-on-queue b/patches.suse/s390-vfio-ap-prepare-for-dynamic-update-of-guest-s-APCB-on-queue index f7ed328..5cd10f2 100644 --- a/patches.suse/s390-vfio-ap-prepare-for-dynamic-update-of-guest-s-APCB-on-queue +++ b/patches.suse/s390-vfio-ap-prepare-for-dynamic-update-of-guest-s-APCB-on-queue @@ -1,10 +1,12 @@ +From 2c1ee8983aa377fef4f725162f4f3aa5f9575d4a Mon Sep 17 00:00:00 2001 From: Tony Krowiak Date: Thu, 17 Mar 2022 12:19:04 -0400 -Subject: s390/vfio-ap: prepare for dynamic update of guest's APCB on queue - probe/remove -Git-commit: 2c1ee8983aa377fef4f725162f4f3aa5f9575d4a -Patch-mainline: v6.0-rc1 +Subject: [PATCH] s390/vfio-ap: prepare for dynamic update of guest's APCB on + queue probe/remove + References: bsc#1205701 +Patch-mainline: v6.0-rc1 +Git-commit: 2c1ee8983aa377fef4f725162f4f3aa5f9575d4a The callback functions for probing and removing a queue device must take and release the locks required to perform a dynamic update of a guest's @@ -47,15 +49,18 @@ Reviewed-by: Jason J. Herne Signed-off-by: Alexander Gordeev Acked-by: Joerg Roedel --- - drivers/s390/crypto/vfio_ap_ops.c | 124 ++++++++++++++++++++++++++------------ + drivers/s390/crypto/vfio_ap_ops.c | 124 ++++++++++++++++++++---------- 1 file changed, 85 insertions(+), 39 deletions(-) +diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c +index dcd36d427b86..fd0f0f241197 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c -@@ -125,6 +125,72 @@ static inline void release_update_locks_ +@@ -124,6 +124,72 @@ static inline void release_update_locks_for_mdev(struct ap_matrix_mdev *matrix_m + mutex_unlock(&matrix_dev->guests_lock); } - /** ++/** + * get_update_locks_by_apqn: Find the mdev to which an APQN is assigned and + * acquire the locks required to update the APCB of + * the KVM guest to which the mdev is attached. @@ -121,11 +126,10 @@ Acked-by: Joerg Roedel + mutex_lock(&matrix_dev->mdevs_lock); +} + -+/** + /** * vfio_ap_mdev_get_queue - retrieve a queue with a specific APQN from a * hash table of queues assigned to a matrix mdev - * @matrix_mdev: the matrix mdev -@@ -615,21 +681,17 @@ static int vfio_ap_mdev_probe(struct mde +@@ -622,21 +688,17 @@ static int vfio_ap_mdev_probe(struct mdev_device *mdev) matrix_mdev->pqap_hook = handle_pqap; vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); hash_init(matrix_mdev->qtable.queues); @@ -134,7 +138,7 @@ Acked-by: Joerg Roedel - list_add(&matrix_mdev->node, &matrix_dev->mdev_list); - mutex_unlock(&matrix_dev->mdevs_lock); - ret = vfio_register_group_dev(&matrix_mdev->vdev); + ret = vfio_register_emulated_iommu_dev(&matrix_mdev->vdev); if (ret) goto err_list; dev_set_drvdata(&mdev->dev, matrix_mdev); @@ -150,7 +154,7 @@ Acked-by: Joerg Roedel vfio_uninit_group_dev(&matrix_mdev->vdev); kfree(matrix_mdev); err_dec_available: -@@ -692,11 +754,13 @@ static void vfio_ap_mdev_remove(struct m +@@ -699,11 +761,13 @@ static void vfio_ap_mdev_remove(struct mdev_device *mdev) vfio_unregister_group_dev(&matrix_mdev->vdev); @@ -164,7 +168,7 @@ Acked-by: Joerg Roedel vfio_uninit_group_dev(&matrix_mdev->vdev); kfree(matrix_mdev); atomic_inc(&matrix_dev->available_instances); -@@ -1656,32 +1720,11 @@ void vfio_ap_mdev_unregister(void) +@@ -1701,32 +1765,11 @@ void vfio_ap_mdev_unregister(void) mdev_unregister_driver(&vfio_ap_matrix_driver); } @@ -198,7 +202,7 @@ Acked-by: Joerg Roedel ret = sysfs_create_group(&apdev->device.kobj, &vfio_queue_attr_group); if (ret) -@@ -1691,17 +1734,18 @@ int vfio_ap_mdev_probe_queue(struct ap_d +@@ -1736,17 +1779,18 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) if (!q) return -ENOMEM; @@ -224,7 +228,7 @@ Acked-by: Joerg Roedel return 0; } -@@ -1710,12 +1754,14 @@ void vfio_ap_mdev_remove_queue(struct ap +@@ -1755,12 +1799,14 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) { unsigned long apid; struct vfio_ap_queue *q; @@ -241,10 +245,13 @@ Acked-by: Joerg Roedel vfio_ap_unlink_queue_fr_mdev(q); apid = AP_QID_CARD(q->apqn); -@@ -1726,5 +1772,5 @@ void vfio_ap_mdev_remove_queue(struct ap +@@ -1771,5 +1817,5 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) vfio_ap_mdev_reset_queue(q, 1); dev_set_drvdata(&apdev->device, NULL); kfree(q); - mutex_unlock(&matrix_dev->mdevs_lock); + release_update_locks_for_mdev(matrix_mdev); } +-- +2.39.2 + diff --git a/patches.suse/s390-vfio-ap-rename-matrix_dev-lock-mutex-to-matrix_dev-mdevs_lo b/patches.suse/s390-vfio-ap-rename-matrix_dev-lock-mutex-to-matrix_dev-mdevs_lo index d9f7405..b6f4c3b 100644 --- a/patches.suse/s390-vfio-ap-rename-matrix_dev-lock-mutex-to-matrix_dev-mdevs_lo +++ b/patches.suse/s390-vfio-ap-rename-matrix_dev-lock-mutex-to-matrix_dev-mdevs_lo @@ -1,9 +1,12 @@ +From d0786556caa1a9b63a7bee321546c6cac1e84e96 Mon Sep 17 00:00:00 2001 From: Tony Krowiak Date: Wed, 16 Mar 2022 12:23:12 -0400 -Subject: s390/vfio-ap: rename matrix_dev->lock mutex to matrix_dev->mdevs_lock -Git-commit: d0786556caa1a9b63a7bee321546c6cac1e84e96 -Patch-mainline: v6.0-rc1 +Subject: [PATCH] s390/vfio-ap: rename matrix_dev->lock mutex to + matrix_dev->mdevs_lock + References: bsc#1205701 +Patch-mainline: v6.0-rc1 +Git-commit: d0786556caa1a9b63a7bee321546c6cac1e84e96 The matrix_dev->lock mutex is being renamed to matrix_dev->mdevs_lock to better reflect its purpose, which is to control access to the state of the @@ -14,14 +17,16 @@ Reviewed-by: Jason J. Herne Signed-off-by: Alexander Gordeev Acked-by: Joerg Roedel --- - drivers/s390/crypto/vfio_ap_drv.c | 2 - drivers/s390/crypto/vfio_ap_ops.c | 76 +++++++++++++++++----------------- - drivers/s390/crypto/vfio_ap_private.h | 4 - + drivers/s390/crypto/vfio_ap_drv.c | 2 +- + drivers/s390/crypto/vfio_ap_ops.c | 76 ++++++++++++++------------- + drivers/s390/crypto/vfio_ap_private.h | 4 +- 3 files changed, 42 insertions(+), 40 deletions(-) +diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c +index 1ff6e3dbbffe..ed162732b139 100644 --- a/drivers/s390/crypto/vfio_ap_drv.c +++ b/drivers/s390/crypto/vfio_ap_drv.c -@@ -98,7 +98,7 @@ static int vfio_ap_matrix_dev_create(voi +@@ -98,7 +98,7 @@ static int vfio_ap_matrix_dev_create(void) goto matrix_alloc_err; } @@ -30,9 +35,11 @@ Acked-by: Joerg Roedel INIT_LIST_HEAD(&matrix_dev->mdev_list); dev_set_name(&matrix_dev->device, "%s", VFIO_AP_DEV_NAME); +diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c +index f1f24b359a85..6f091cd602d3 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c -@@ -390,10 +390,12 @@ static int handle_pqap(struct kvm_vcpu * +@@ -397,10 +397,12 @@ static int handle_pqap(struct kvm_vcpu *vcpu) return -EOPNOTSUPP; } @@ -46,7 +53,7 @@ Acked-by: Joerg Roedel goto out_unlock; } -@@ -428,7 +430,7 @@ static int handle_pqap(struct kvm_vcpu * +@@ -435,7 +437,7 @@ static int handle_pqap(struct kvm_vcpu *vcpu) out_unlock: memcpy(&vcpu->run->s.regs.gprs[1], &qstatus, sizeof(qstatus)); vcpu->run->s.regs.gprs[1] >>= 32; @@ -55,7 +62,7 @@ Acked-by: Joerg Roedel return 0; } -@@ -524,9 +526,9 @@ static int vfio_ap_mdev_probe(struct mde +@@ -531,9 +533,9 @@ static int vfio_ap_mdev_probe(struct mdev_device *mdev) vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); hash_init(matrix_mdev->qtable.queues); dev_set_drvdata(&mdev->dev, matrix_mdev); @@ -65,9 +72,9 @@ Acked-by: Joerg Roedel - mutex_unlock(&matrix_dev->lock); + mutex_unlock(&matrix_dev->mdevs_lock); - ret = vfio_register_group_dev(&matrix_mdev->vdev); + ret = vfio_register_emulated_iommu_dev(&matrix_mdev->vdev); if (ret) -@@ -535,9 +537,9 @@ static int vfio_ap_mdev_probe(struct mde +@@ -542,9 +544,9 @@ static int vfio_ap_mdev_probe(struct mdev_device *mdev) return 0; err_list: @@ -79,7 +86,7 @@ Acked-by: Joerg Roedel vfio_uninit_group_dev(&matrix_mdev->vdev); kfree(matrix_mdev); err_dec_available: -@@ -600,11 +602,11 @@ static void vfio_ap_mdev_remove(struct m +@@ -607,11 +609,11 @@ static void vfio_ap_mdev_remove(struct mdev_device *mdev) vfio_unregister_group_dev(&matrix_mdev->vdev); @@ -93,7 +100,7 @@ Acked-by: Joerg Roedel vfio_uninit_group_dev(&matrix_mdev->vdev); kfree(matrix_mdev); atomic_inc(&matrix_dev->available_instances); -@@ -780,7 +782,7 @@ static ssize_t assign_adapter_store(stru +@@ -787,7 +789,7 @@ static ssize_t assign_adapter_store(struct device *dev, struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); @@ -102,7 +109,7 @@ Acked-by: Joerg Roedel /* If the KVM guest is running, disallow assignment of adapter */ if (matrix_mdev->kvm) { -@@ -812,7 +814,7 @@ static ssize_t assign_adapter_store(stru +@@ -819,7 +821,7 @@ static ssize_t assign_adapter_store(struct device *dev, matrix_mdev->matrix.aqm, matrix_mdev); ret = count; done: @@ -111,7 +118,7 @@ Acked-by: Joerg Roedel return ret; } -@@ -855,7 +857,7 @@ static ssize_t unassign_adapter_store(st +@@ -862,7 +864,7 @@ static ssize_t unassign_adapter_store(struct device *dev, unsigned long apid; struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); @@ -120,7 +127,7 @@ Acked-by: Joerg Roedel /* If the KVM guest is running, disallow unassignment of adapter */ if (matrix_mdev->kvm) { -@@ -880,7 +882,7 @@ static ssize_t unassign_adapter_store(st +@@ -887,7 +889,7 @@ static ssize_t unassign_adapter_store(struct device *dev, ret = count; done: @@ -129,7 +136,7 @@ Acked-by: Joerg Roedel return ret; } static DEVICE_ATTR_WO(unassign_adapter); -@@ -935,7 +937,7 @@ static ssize_t assign_domain_store(struc +@@ -942,7 +944,7 @@ static ssize_t assign_domain_store(struct device *dev, struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); unsigned long max_apqi = matrix_mdev->matrix.aqm_max; @@ -138,7 +145,7 @@ Acked-by: Joerg Roedel /* If the KVM guest is running, disallow assignment of domain */ if (matrix_mdev->kvm) { -@@ -966,7 +968,7 @@ static ssize_t assign_domain_store(struc +@@ -973,7 +975,7 @@ static ssize_t assign_domain_store(struct device *dev, matrix_mdev); ret = count; done: @@ -147,7 +154,7 @@ Acked-by: Joerg Roedel return ret; } -@@ -1009,7 +1011,7 @@ static ssize_t unassign_domain_store(str +@@ -1016,7 +1018,7 @@ static ssize_t unassign_domain_store(struct device *dev, unsigned long apqi; struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); @@ -156,7 +163,7 @@ Acked-by: Joerg Roedel /* If the KVM guest is running, disallow unassignment of domain */ if (matrix_mdev->kvm) { -@@ -1035,7 +1037,7 @@ static ssize_t unassign_domain_store(str +@@ -1042,7 +1044,7 @@ static ssize_t unassign_domain_store(struct device *dev, ret = count; done: @@ -165,7 +172,7 @@ Acked-by: Joerg Roedel return ret; } static DEVICE_ATTR_WO(unassign_domain); -@@ -1062,7 +1064,7 @@ static ssize_t assign_control_domain_sto +@@ -1069,7 +1071,7 @@ static ssize_t assign_control_domain_store(struct device *dev, unsigned long id; struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); @@ -174,7 +181,7 @@ Acked-by: Joerg Roedel /* If the KVM guest is running, disallow assignment of control domain */ if (matrix_mdev->kvm) { -@@ -1088,7 +1090,7 @@ static ssize_t assign_control_domain_sto +@@ -1095,7 +1097,7 @@ static ssize_t assign_control_domain_store(struct device *dev, vfio_ap_mdev_filter_cdoms(matrix_mdev); ret = count; done: @@ -183,7 +190,7 @@ Acked-by: Joerg Roedel return ret; } static DEVICE_ATTR_WO(assign_control_domain); -@@ -1116,7 +1118,7 @@ static ssize_t unassign_control_domain_s +@@ -1123,7 +1125,7 @@ static ssize_t unassign_control_domain_store(struct device *dev, struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); unsigned long max_domid = matrix_mdev->matrix.adm_max; @@ -192,7 +199,7 @@ Acked-by: Joerg Roedel /* If a KVM guest is running, disallow unassignment of control domain */ if (matrix_mdev->kvm) { -@@ -1139,7 +1141,7 @@ static ssize_t unassign_control_domain_s +@@ -1146,7 +1148,7 @@ static ssize_t unassign_control_domain_store(struct device *dev, ret = count; done: @@ -201,7 +208,7 @@ Acked-by: Joerg Roedel return ret; } static DEVICE_ATTR_WO(unassign_control_domain); -@@ -1155,13 +1157,13 @@ static ssize_t control_domains_show(stru +@@ -1162,13 +1164,13 @@ static ssize_t control_domains_show(struct device *dev, struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); unsigned long max_domid = matrix_mdev->matrix.adm_max; @@ -217,7 +224,7 @@ Acked-by: Joerg Roedel return nchars; } -@@ -1184,7 +1186,7 @@ static ssize_t matrix_show(struct device +@@ -1191,7 +1193,7 @@ static ssize_t matrix_show(struct device *dev, struct device_attribute *attr, apid1 = find_first_bit_inv(matrix_mdev->matrix.apm, napm_bits); apqi1 = find_first_bit_inv(matrix_mdev->matrix.aqm, naqm_bits); @@ -226,7 +233,7 @@ Acked-by: Joerg Roedel if ((apid1 < napm_bits) && (apqi1 < naqm_bits)) { for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, napm_bits) { -@@ -1210,7 +1212,7 @@ static ssize_t matrix_show(struct device +@@ -1217,7 +1219,7 @@ static ssize_t matrix_show(struct device *dev, struct device_attribute *attr, } } @@ -235,7 +242,7 @@ Acked-by: Joerg Roedel return nchars; } -@@ -1258,12 +1260,12 @@ static int vfio_ap_mdev_set_kvm(struct a +@@ -1265,12 +1267,12 @@ static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev, up_write(&kvm->arch.crypto.pqap_hook_rwsem); mutex_lock(&kvm->lock); @@ -250,7 +257,7 @@ Acked-by: Joerg Roedel return -EPERM; } } -@@ -1275,7 +1277,7 @@ static int vfio_ap_mdev_set_kvm(struct a +@@ -1282,7 +1284,7 @@ static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev, matrix_mdev->shadow_apcb.adm); mutex_unlock(&kvm->lock); @@ -259,7 +266,7 @@ Acked-by: Joerg Roedel } return 0; -@@ -1306,7 +1308,7 @@ static void vfio_ap_mdev_unset_kvm(struc +@@ -1334,7 +1336,7 @@ static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev) up_write(&kvm->arch.crypto.pqap_hook_rwsem); mutex_lock(&kvm->lock); @@ -268,7 +275,7 @@ Acked-by: Joerg Roedel kvm_arch_crypto_clear_masks(kvm); vfio_ap_mdev_reset_queues(matrix_mdev); -@@ -1314,7 +1316,7 @@ static void vfio_ap_mdev_unset_kvm(struc +@@ -1342,7 +1344,7 @@ static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev) matrix_mdev->kvm = NULL; mutex_unlock(&kvm->lock); @@ -277,7 +284,7 @@ Acked-by: Joerg Roedel } } -@@ -1451,7 +1453,7 @@ static ssize_t vfio_ap_mdev_ioctl(struct +@@ -1497,7 +1499,7 @@ static ssize_t vfio_ap_mdev_ioctl(struct vfio_device *vdev, container_of(vdev, struct ap_matrix_mdev, vdev); int ret; @@ -286,7 +293,7 @@ Acked-by: Joerg Roedel switch (cmd) { case VFIO_DEVICE_GET_INFO: ret = vfio_ap_mdev_get_device_info(arg); -@@ -1463,7 +1465,7 @@ static ssize_t vfio_ap_mdev_ioctl(struct +@@ -1509,7 +1511,7 @@ static ssize_t vfio_ap_mdev_ioctl(struct vfio_device *vdev, ret = -EOPNOTSUPP; break; } @@ -295,7 +302,7 @@ Acked-by: Joerg Roedel return ret; } -@@ -1492,7 +1494,7 @@ static ssize_t status_show(struct device +@@ -1538,7 +1540,7 @@ static ssize_t status_show(struct device *dev, struct ap_matrix_mdev *matrix_mdev; struct ap_device *apdev = to_ap_dev(dev); @@ -304,7 +311,7 @@ Acked-by: Joerg Roedel q = dev_get_drvdata(&apdev->device); matrix_mdev = vfio_ap_mdev_for_queue(q); -@@ -1508,7 +1510,7 @@ static ssize_t status_show(struct device +@@ -1554,7 +1556,7 @@ static ssize_t status_show(struct device *dev, AP_QUEUE_UNASSIGNED); } @@ -313,7 +320,7 @@ Acked-by: Joerg Roedel return nchars; } -@@ -1604,7 +1606,7 @@ int vfio_ap_mdev_probe_queue(struct ap_d +@@ -1649,7 +1651,7 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) if (!q) return -ENOMEM; @@ -322,7 +329,7 @@ Acked-by: Joerg Roedel q->apqn = to_ap_queue(&apdev->device)->qid; q->saved_isc = VFIO_AP_ISC_INVALID; vfio_ap_queue_link_mdev(q); -@@ -1614,7 +1616,7 @@ int vfio_ap_mdev_probe_queue(struct ap_d +@@ -1659,7 +1661,7 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) q->matrix_mdev); } dev_set_drvdata(&apdev->device, q); @@ -331,7 +338,7 @@ Acked-by: Joerg Roedel return 0; } -@@ -1624,7 +1626,7 @@ void vfio_ap_mdev_remove_queue(struct ap +@@ -1669,7 +1671,7 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) unsigned long apid; struct vfio_ap_queue *q; @@ -340,13 +347,15 @@ Acked-by: Joerg Roedel sysfs_remove_group(&apdev->device.kobj, &vfio_queue_attr_group); q = dev_get_drvdata(&apdev->device); -@@ -1639,5 +1641,5 @@ void vfio_ap_mdev_remove_queue(struct ap +@@ -1684,5 +1686,5 @@ void vfio_ap_mdev_remove_queue(struct ap_device *apdev) vfio_ap_mdev_reset_queue(q, 1); dev_set_drvdata(&apdev->device, NULL); kfree(q); - mutex_unlock(&matrix_dev->lock); + mutex_unlock(&matrix_dev->mdevs_lock); } +diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h +index acb3f9d22025..cb4a626b4b0f 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -33,7 +33,7 @@ @@ -367,3 +376,6 @@ Acked-by: Joerg Roedel struct ap_driver *vfio_ap_drv; }; +-- +2.39.2 + diff --git a/patches.suse/vfio-simplify-iommu-group-allocation-for-mediated-devices b/patches.suse/vfio-simplify-iommu-group-allocation-for-mediated-devices index e1d0f1c..3e6d12e 100644 --- a/patches.suse/vfio-simplify-iommu-group-allocation-for-mediated-devices +++ b/patches.suse/vfio-simplify-iommu-group-allocation-for-mediated-devices @@ -1,9 +1,11 @@ +From c68ea0d00ad82428154aed890ec9f793e460fa1c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 24 Sep 2021 17:56:57 +0200 -Subject: vfio: simplify iommu group allocation for mediated devices -Git-commit: c68ea0d00ad82428154aed890ec9f793e460fa1c -Patch-mainline: v5.16-rc1 +Subject: [PATCH] vfio: simplify iommu group allocation for mediated devices + References: bsc#1205701 +Patch-mainline: v5.16-rc1 +Git-commit: c68ea0d00ad82428154aed890ec9f793e460fa1c Reuse the logic in vfio_noiommu_group_alloc to allocate a fake single-device iommu group for mediated devices by factoring out a common @@ -16,15 +18,31 @@ Link: https://lore.kernel.org/r/20210924155705.4258-8-hch@lst.de Signed-off-by: Alex Williamson Acked-by: Joerg Roedel --- - drivers/vfio/mdev/mdev_driver.c | 45 +------------------ - drivers/vfio/mdev/vfio_mdev.c | 2 - drivers/vfio/vfio.c | 92 ++++++++++++++++++++++++++++------------ - include/linux/vfio.h | 1 - samples/vfio-mdev/mbochs.c | 2 - samples/vfio-mdev/mdpy.c | 2 - samples/vfio-mdev/mtty.c | 2 - 7 files changed, 75 insertions(+), 71 deletions(-) + drivers/s390/crypto/vfio_ap_ops.c | 2 +- + drivers/vfio/mdev/mdev_driver.c | 45 ++------------- + drivers/vfio/mdev/vfio_mdev.c | 2 +- + drivers/vfio/vfio.c | 92 ++++++++++++++++++++++--------- + include/linux/vfio.h | 1 + + samples/vfio-mdev/mbochs.c | 2 +- + samples/vfio-mdev/mdpy.c | 2 +- + samples/vfio-mdev/mtty.c | 2 +- + 8 files changed, 76 insertions(+), 72 deletions(-) +diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c +index 118939a7729a..24755d1aedd5 100644 +--- a/drivers/s390/crypto/vfio_ap_ops.c ++++ b/drivers/s390/crypto/vfio_ap_ops.c +@@ -351,7 +351,7 @@ static int vfio_ap_mdev_probe(struct mdev_device *mdev) + list_add(&matrix_mdev->node, &matrix_dev->mdev_list); + mutex_unlock(&matrix_dev->lock); + +- ret = vfio_register_group_dev(&matrix_mdev->vdev); ++ ret = vfio_register_emulated_iommu_dev(&matrix_mdev->vdev); + if (ret) + goto err_list; + dev_set_drvdata(&mdev->dev, matrix_mdev); +diff --git a/drivers/vfio/mdev/mdev_driver.c b/drivers/vfio/mdev/mdev_driver.c +index e2cb1ff56f6c..7927ed4f1711 100644 --- a/drivers/vfio/mdev/mdev_driver.c +++ b/drivers/vfio/mdev/mdev_driver.c @@ -13,60 +13,23 @@ @@ -92,9 +110,11 @@ Acked-by: Joerg Roedel } static int mdev_match(struct device *dev, struct device_driver *drv) +diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c +index 7a9883048216..a90e24b0c851 100644 --- a/drivers/vfio/mdev/vfio_mdev.c +++ b/drivers/vfio/mdev/vfio_mdev.c -@@ -119,7 +119,7 @@ static int vfio_mdev_probe(struct mdev_d +@@ -119,7 +119,7 @@ static int vfio_mdev_probe(struct mdev_device *mdev) return -ENOMEM; vfio_init_group_dev(vdev, &mdev->dev, &vfio_mdev_dev_ops); @@ -103,6 +123,8 @@ Acked-by: Joerg Roedel if (ret) goto out_uninit; +diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c +index 23eaebd2e28c..2508c8c39840 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -67,6 +67,30 @@ struct vfio_unbound_dev { @@ -145,7 +167,7 @@ Acked-by: Joerg Roedel unsigned int dev_counter; struct kvm *kvm; struct blocking_notifier_head notifier; -@@ -336,7 +360,7 @@ static void vfio_group_unlock_and_free(s +@@ -336,7 +360,7 @@ static void vfio_group_unlock_and_free(struct vfio_group *group) * Group objects - create, release, get, put, search */ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group, @@ -154,7 +176,7 @@ Acked-by: Joerg Roedel { struct vfio_group *group, *tmp; struct device *dev; -@@ -355,7 +379,7 @@ static struct vfio_group *vfio_create_gr +@@ -355,7 +379,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group, atomic_set(&group->opened, 0); init_waitqueue_head(&group->container_q); group->iommu_group = iommu_group; @@ -163,7 +185,7 @@ Acked-by: Joerg Roedel BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier); group->nb.notifier_call = vfio_iommu_group_notifier; -@@ -391,8 +415,8 @@ static struct vfio_group *vfio_create_gr +@@ -391,8 +415,8 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group, } dev = device_create(vfio.class, NULL, @@ -174,7 +196,7 @@ Acked-by: Joerg Roedel iommu_group_id(iommu_group)); if (IS_ERR(dev)) { vfio_free_group_minor(minor); -@@ -778,8 +802,8 @@ void vfio_uninit_group_dev(struct vfio_d +@@ -778,8 +802,8 @@ void vfio_uninit_group_dev(struct vfio_device *device) } EXPORT_SYMBOL_GPL(vfio_uninit_group_dev); @@ -185,7 +207,7 @@ Acked-by: Joerg Roedel { struct iommu_group *iommu_group; struct vfio_group *group; -@@ -794,7 +818,7 @@ static struct vfio_group *vfio_noiommu_g +@@ -794,7 +818,7 @@ static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev) if (ret) goto out_put_group; @@ -194,7 +216,7 @@ Acked-by: Joerg Roedel if (IS_ERR(group)) { ret = PTR_ERR(group); goto out_remove_device; -@@ -808,7 +832,6 @@ out_put_group: +@@ -808,7 +832,6 @@ static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev) iommu_group_put(iommu_group); return ERR_PTR(ret); } @@ -202,7 +224,7 @@ Acked-by: Joerg Roedel static struct vfio_group *vfio_group_find_or_alloc(struct device *dev) { -@@ -824,7 +847,7 @@ static struct vfio_group *vfio_group_fin +@@ -824,7 +847,7 @@ static struct vfio_group *vfio_group_find_or_alloc(struct device *dev) * bus. Taint the kernel because we're about to give a DMA * capable device to a user without IOMMU protection. */ @@ -211,7 +233,7 @@ Acked-by: Joerg Roedel if (!IS_ERR(group)) { add_taint(TAINT_USER, LOCKDEP_STILL_OK); dev_warn(dev, "Adding kernel taint for vfio-noiommu group on device\n"); -@@ -841,7 +864,7 @@ static struct vfio_group *vfio_group_fin +@@ -841,7 +864,7 @@ static struct vfio_group *vfio_group_find_or_alloc(struct device *dev) goto out_put; /* a newly created vfio_group keeps the reference. */ @@ -220,7 +242,7 @@ Acked-by: Joerg Roedel if (IS_ERR(group)) goto out_put; return group; -@@ -851,10 +874,13 @@ out_put: +@@ -851,10 +874,13 @@ static struct vfio_group *vfio_group_find_or_alloc(struct device *dev) return group; } @@ -236,7 +258,7 @@ Acked-by: Joerg Roedel /* * If the driver doesn't specify a set then the device is added to a -@@ -863,16 +889,13 @@ int vfio_register_group_dev(struct vfio_ +@@ -863,16 +889,13 @@ int vfio_register_group_dev(struct vfio_device *device) if (!device->dev_set) vfio_assign_device_set(device, device); @@ -255,7 +277,7 @@ Acked-by: Joerg Roedel iommu_group_remove_device(device->dev); vfio_group_put(group); return -EBUSY; -@@ -891,8 +914,25 @@ int vfio_register_group_dev(struct vfio_ +@@ -891,8 +914,25 @@ int vfio_register_group_dev(struct vfio_device *device) return 0; } @@ -281,7 +303,7 @@ Acked-by: Joerg Roedel /** * Get a reference to the vfio_device for a device. Even if the * caller thinks they own the device, they could be racing with a -@@ -1019,7 +1059,7 @@ void vfio_unregister_group_dev(struct vf +@@ -1019,7 +1059,7 @@ void vfio_unregister_group_dev(struct vfio_device *device) if (list_empty(&group->device_list)) wait_event(group->container_q, !group->container); @@ -290,7 +312,7 @@ Acked-by: Joerg Roedel iommu_group_remove_device(device->dev); /* Matches the get in vfio_register_group_dev() */ -@@ -1368,7 +1408,7 @@ static int vfio_group_set_container(stru +@@ -1368,7 +1408,7 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd) if (atomic_read(&group->container_users)) return -EINVAL; @@ -299,7 +321,7 @@ Acked-by: Joerg Roedel return -EPERM; f = fdget(container_fd); -@@ -1388,7 +1428,7 @@ static int vfio_group_set_container(stru +@@ -1388,7 +1428,7 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd) /* Real groups and fake groups cannot mix */ if (!list_empty(&container->group_list) && @@ -308,7 +330,7 @@ Acked-by: Joerg Roedel ret = -EPERM; goto unlock_out; } -@@ -1402,7 +1442,7 @@ static int vfio_group_set_container(stru +@@ -1402,7 +1442,7 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd) } group->container = container; @@ -317,7 +339,7 @@ Acked-by: Joerg Roedel list_add(&group->container_next, &container->group_list); /* Get a reference on the container and mark a user within the group */ -@@ -1426,7 +1466,7 @@ static int vfio_group_add_container_user +@@ -1426,7 +1466,7 @@ static int vfio_group_add_container_user(struct vfio_group *group) if (!atomic_inc_not_zero(&group->container_users)) return -EINVAL; @@ -326,7 +348,7 @@ Acked-by: Joerg Roedel atomic_dec(&group->container_users); return -EPERM; } -@@ -1451,7 +1491,7 @@ static int vfio_group_get_device_fd(stru +@@ -1451,7 +1491,7 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) !group->container->iommu_driver || !vfio_group_viable(group)) return -EINVAL; @@ -335,7 +357,7 @@ Acked-by: Joerg Roedel return -EPERM; device = vfio_device_get_from_name(group, buf); -@@ -1498,7 +1538,7 @@ static int vfio_group_get_device_fd(stru +@@ -1498,7 +1538,7 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) fd_install(fdno, filep); @@ -344,7 +366,7 @@ Acked-by: Joerg Roedel dev_warn(device->dev, "vfio-noiommu device opened by user " "(%s:%d)\n", current->comm, task_pid_nr(current)); return fdno; -@@ -1594,7 +1634,7 @@ static int vfio_group_fops_open(struct i +@@ -1594,7 +1634,7 @@ static int vfio_group_fops_open(struct inode *inode, struct file *filep) if (!group) return -ENODEV; @@ -353,9 +375,11 @@ Acked-by: Joerg Roedel vfio_group_put(group); return -EPERM; } +diff --git a/include/linux/vfio.h b/include/linux/vfio.h +index f7083c2fd0d0..bbe293008626 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h -@@ -75,6 +75,7 @@ void vfio_init_group_dev(struct vfio_dev +@@ -75,6 +75,7 @@ void vfio_init_group_dev(struct vfio_device *device, struct device *dev, const struct vfio_device_ops *ops); void vfio_uninit_group_dev(struct vfio_device *device); int vfio_register_group_dev(struct vfio_device *device); @@ -363,9 +387,11 @@ Acked-by: Joerg Roedel void vfio_unregister_group_dev(struct vfio_device *device); extern struct vfio_device *vfio_device_get_from_dev(struct device *dev); extern void vfio_device_put(struct vfio_device *device); +diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c +index c313ab4d1f4e..cd41bec5fdeb 100644 --- a/samples/vfio-mdev/mbochs.c +++ b/samples/vfio-mdev/mbochs.c -@@ -553,7 +553,7 @@ static int mbochs_probe(struct mdev_devi +@@ -553,7 +553,7 @@ static int mbochs_probe(struct mdev_device *mdev) mbochs_create_config_space(mdev_state); mbochs_reset(mdev_state); @@ -374,9 +400,11 @@ Acked-by: Joerg Roedel if (ret) goto err_mem; dev_set_drvdata(&mdev->dev, mdev_state); +diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c +index 8d1a80a0722a..fe5d43e797b6 100644 --- a/samples/vfio-mdev/mdpy.c +++ b/samples/vfio-mdev/mdpy.c -@@ -258,7 +258,7 @@ static int mdpy_probe(struct mdev_device +@@ -258,7 +258,7 @@ static int mdpy_probe(struct mdev_device *mdev) mdpy_count++; @@ -385,9 +413,11 @@ Acked-by: Joerg Roedel if (ret) goto err_mem; dev_set_drvdata(&mdev->dev, mdev_state); +diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c +index 5983cdb16e3d..a0e1a469bd47 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c -@@ -741,7 +741,7 @@ static int mtty_probe(struct mdev_device +@@ -741,7 +741,7 @@ static int mtty_probe(struct mdev_device *mdev) mtty_create_config_space(mdev_state); @@ -396,3 +426,6 @@ Acked-by: Joerg Roedel if (ret) goto err_vconfig; dev_set_drvdata(&mdev->dev, mdev_state); +-- +2.39.2 +