Lines Matching refs:matrix_mdev

100 static inline void get_update_locks_for_mdev(struct ap_matrix_mdev *matrix_mdev)  in get_update_locks_for_mdev()  argument
103 if (matrix_mdev && matrix_mdev->kvm) in get_update_locks_for_mdev()
104 mutex_lock(&matrix_mdev->kvm->lock); in get_update_locks_for_mdev()
123 static inline void release_update_locks_for_mdev(struct ap_matrix_mdev *matrix_mdev) in release_update_locks_for_mdev() argument
126 if (matrix_mdev && matrix_mdev->kvm) in release_update_locks_for_mdev()
127 mutex_unlock(&matrix_mdev->kvm->lock); in release_update_locks_for_mdev()
152 struct ap_matrix_mdev *matrix_mdev; in get_update_locks_by_apqn() local
156 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in get_update_locks_by_apqn()
157 if (test_bit_inv(AP_QID_CARD(apqn), matrix_mdev->matrix.apm) && in get_update_locks_by_apqn()
158 test_bit_inv(AP_QID_QUEUE(apqn), matrix_mdev->matrix.aqm)) { in get_update_locks_by_apqn()
159 if (matrix_mdev->kvm) in get_update_locks_by_apqn()
160 mutex_lock(&matrix_mdev->kvm->lock); in get_update_locks_by_apqn()
164 return matrix_mdev; in get_update_locks_by_apqn()
192 if (q->matrix_mdev && q->matrix_mdev->kvm) in get_update_locks_for_queue()
193 mutex_lock(&q->matrix_mdev->kvm->lock); in get_update_locks_for_queue()
207 struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_get_queue() argument
212 hash_for_each_possible(matrix_mdev->qtable.queues, q, mdev_qnode, in vfio_ap_mdev_get_queue()
274 !WARN_ON(!(q->matrix_mdev && q->matrix_mdev->kvm))) { in vfio_ap_free_aqic_resources()
275 kvm_s390_gisc_unregister(q->matrix_mdev->kvm, q->saved_isc); in vfio_ap_free_aqic_resources()
278 if (q->saved_iova && !WARN_ON(!q->matrix_mdev)) { in vfio_ap_free_aqic_resources()
279 vfio_unpin_pages(&q->matrix_mdev->vdev, q->saved_iova, 1); in vfio_ap_free_aqic_resources()
406 ret = vfio_pin_pages(&q->matrix_mdev->vdev, nib, 1, in vfio_ap_irq_enable()
420 kvm = q->matrix_mdev->kvm; in vfio_ap_irq_enable()
449 vfio_unpin_pages(&q->matrix_mdev->vdev, nib, 1); in vfio_ap_irq_enable()
543 struct ap_matrix_mdev *matrix_mdev; in handle_pqap() local
564 matrix_mdev = container_of(vcpu->kvm->arch.crypto.pqap_hook, in handle_pqap()
568 if (!matrix_mdev->kvm) { in handle_pqap()
569 vfio_ap_le_guid_to_be_uuid(&matrix_mdev->mdev->uuid, uuid); in handle_pqap()
576 q = vfio_ap_mdev_get_queue(matrix_mdev, apqn); in handle_pqap()
607 static void vfio_ap_mdev_update_guest_apcb(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_update_guest_apcb() argument
609 if (matrix_mdev->kvm) in vfio_ap_mdev_update_guest_apcb()
610 kvm_arch_crypto_set_masks(matrix_mdev->kvm, in vfio_ap_mdev_update_guest_apcb()
611 matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_update_guest_apcb()
612 matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_update_guest_apcb()
613 matrix_mdev->shadow_apcb.adm); in vfio_ap_mdev_update_guest_apcb()
616 static bool vfio_ap_mdev_filter_cdoms(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_filter_cdoms() argument
620 bitmap_copy(prev_shadow_adm, matrix_mdev->shadow_apcb.adm, AP_DOMAINS); in vfio_ap_mdev_filter_cdoms()
621 bitmap_and(matrix_mdev->shadow_apcb.adm, matrix_mdev->matrix.adm, in vfio_ap_mdev_filter_cdoms()
624 return !bitmap_equal(prev_shadow_adm, matrix_mdev->shadow_apcb.adm, in vfio_ap_mdev_filter_cdoms()
645 struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_filter_matrix() argument
652 bitmap_copy(prev_shadow_apm, matrix_mdev->shadow_apcb.apm, AP_DEVICES); in vfio_ap_mdev_filter_matrix()
653 bitmap_copy(prev_shadow_aqm, matrix_mdev->shadow_apcb.aqm, AP_DOMAINS); in vfio_ap_mdev_filter_matrix()
654 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); in vfio_ap_mdev_filter_matrix()
661 bitmap_and(matrix_mdev->shadow_apcb.apm, matrix_mdev->matrix.apm, in vfio_ap_mdev_filter_matrix()
663 bitmap_and(matrix_mdev->shadow_apcb.aqm, matrix_mdev->matrix.aqm, in vfio_ap_mdev_filter_matrix()
677 q = vfio_ap_mdev_get_queue(matrix_mdev, apqn); in vfio_ap_mdev_filter_matrix()
680 matrix_mdev->shadow_apcb.apm); in vfio_ap_mdev_filter_matrix()
686 return !bitmap_equal(prev_shadow_apm, matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_filter_matrix()
688 !bitmap_equal(prev_shadow_aqm, matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_filter_matrix()
694 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_init_dev() local
697 matrix_mdev->mdev = to_mdev_device(vdev->dev); in vfio_ap_mdev_init_dev()
698 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->matrix); in vfio_ap_mdev_init_dev()
699 matrix_mdev->pqap_hook = handle_pqap; in vfio_ap_mdev_init_dev()
700 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); in vfio_ap_mdev_init_dev()
701 hash_init(matrix_mdev->qtable.queues); in vfio_ap_mdev_init_dev()
708 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_probe() local
711 matrix_mdev = vfio_alloc_device(ap_matrix_mdev, vdev, &mdev->dev, in vfio_ap_mdev_probe()
713 if (IS_ERR(matrix_mdev)) in vfio_ap_mdev_probe()
714 return PTR_ERR(matrix_mdev); in vfio_ap_mdev_probe()
716 ret = vfio_register_emulated_iommu_dev(&matrix_mdev->vdev); in vfio_ap_mdev_probe()
719 dev_set_drvdata(&mdev->dev, matrix_mdev); in vfio_ap_mdev_probe()
721 list_add(&matrix_mdev->node, &matrix_dev->mdev_list); in vfio_ap_mdev_probe()
726 vfio_put_device(&matrix_mdev->vdev); in vfio_ap_mdev_probe()
730 static void vfio_ap_mdev_link_queue(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_link_queue() argument
734 q->matrix_mdev = matrix_mdev; in vfio_ap_mdev_link_queue()
735 hash_add(matrix_mdev->qtable.queues, &q->mdev_qnode, q->apqn); in vfio_ap_mdev_link_queue()
739 static void vfio_ap_mdev_link_apqn(struct ap_matrix_mdev *matrix_mdev, int apqn) in vfio_ap_mdev_link_apqn() argument
744 vfio_ap_mdev_link_queue(matrix_mdev, q); in vfio_ap_mdev_link_apqn()
754 q->matrix_mdev = NULL; in vfio_ap_unlink_mdev_fr_queue()
757 static void vfio_ap_mdev_unlink_fr_queues(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_unlink_fr_queues() argument
762 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) { in vfio_ap_mdev_unlink_fr_queues()
763 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, in vfio_ap_mdev_unlink_fr_queues()
765 q = vfio_ap_mdev_get_queue(matrix_mdev, in vfio_ap_mdev_unlink_fr_queues()
768 q->matrix_mdev = NULL; in vfio_ap_mdev_unlink_fr_queues()
775 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(&mdev->dev); in vfio_ap_mdev_remove() local
777 vfio_unregister_group_dev(&matrix_mdev->vdev); in vfio_ap_mdev_remove()
781 vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); in vfio_ap_mdev_remove()
782 vfio_ap_mdev_unlink_fr_queues(matrix_mdev); in vfio_ap_mdev_remove()
783 list_del(&matrix_mdev->node); in vfio_ap_mdev_remove()
786 vfio_put_device(&matrix_mdev->vdev); in vfio_ap_mdev_remove()
792 static void vfio_ap_mdev_log_sharing_err(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_log_sharing_err() argument
797 const struct device *dev = mdev_dev(matrix_mdev->mdev); in vfio_ap_mdev_log_sharing_err()
820 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_verify_no_sharing() local
824 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_verify_no_sharing()
829 if (mdev_apm == matrix_mdev->matrix.apm && in vfio_ap_mdev_verify_no_sharing()
830 mdev_aqm == matrix_mdev->matrix.aqm) in vfio_ap_mdev_verify_no_sharing()
840 if (!bitmap_and(apm, mdev_apm, matrix_mdev->matrix.apm, in vfio_ap_mdev_verify_no_sharing()
844 if (!bitmap_and(aqm, mdev_aqm, matrix_mdev->matrix.aqm, in vfio_ap_mdev_verify_no_sharing()
848 vfio_ap_mdev_log_sharing_err(matrix_mdev, apm, aqm); in vfio_ap_mdev_verify_no_sharing()
871 static int vfio_ap_mdev_validate_masks(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_validate_masks() argument
873 if (ap_apqn_in_matrix_owned_by_def_drv(matrix_mdev->matrix.apm, in vfio_ap_mdev_validate_masks()
874 matrix_mdev->matrix.aqm)) in vfio_ap_mdev_validate_masks()
877 return vfio_ap_mdev_verify_no_sharing(matrix_mdev->matrix.apm, in vfio_ap_mdev_validate_masks()
878 matrix_mdev->matrix.aqm); in vfio_ap_mdev_validate_masks()
881 static void vfio_ap_mdev_link_adapter(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_link_adapter() argument
886 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, AP_DOMAINS) in vfio_ap_mdev_link_adapter()
887 vfio_ap_mdev_link_apqn(matrix_mdev, in vfio_ap_mdev_link_adapter()
932 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in assign_adapter_store() local
935 get_update_locks_for_mdev(matrix_mdev); in assign_adapter_store()
941 if (apid > matrix_mdev->matrix.apm_max) { in assign_adapter_store()
946 if (test_bit_inv(apid, matrix_mdev->matrix.apm)) { in assign_adapter_store()
951 set_bit_inv(apid, matrix_mdev->matrix.apm); in assign_adapter_store()
953 ret = vfio_ap_mdev_validate_masks(matrix_mdev); in assign_adapter_store()
955 clear_bit_inv(apid, matrix_mdev->matrix.apm); in assign_adapter_store()
959 vfio_ap_mdev_link_adapter(matrix_mdev, apid); in assign_adapter_store()
964 matrix_mdev->matrix.aqm, matrix_mdev)) in assign_adapter_store()
965 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in assign_adapter_store()
969 release_update_locks_for_mdev(matrix_mdev); in assign_adapter_store()
977 *vfio_ap_unlink_apqn_fr_mdev(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_unlink_apqn_fr_mdev() argument
982 q = vfio_ap_mdev_get_queue(matrix_mdev, AP_MKQID(apid, apqi)); in vfio_ap_unlink_apqn_fr_mdev()
998 static void vfio_ap_mdev_unlink_adapter(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_unlink_adapter() argument
1005 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, AP_DOMAINS) { in vfio_ap_mdev_unlink_adapter()
1006 q = vfio_ap_unlink_apqn_fr_mdev(matrix_mdev, apid, apqi); in vfio_ap_mdev_unlink_adapter()
1009 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && in vfio_ap_mdev_unlink_adapter()
1010 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) in vfio_ap_mdev_unlink_adapter()
1017 static void vfio_ap_mdev_hot_unplug_adapter(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_hot_unplug_adapter() argument
1025 vfio_ap_mdev_unlink_adapter(matrix_mdev, apid, qtable); in vfio_ap_mdev_hot_unplug_adapter()
1027 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm)) { in vfio_ap_mdev_hot_unplug_adapter()
1028 clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); in vfio_ap_mdev_hot_unplug_adapter()
1029 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_unplug_adapter()
1063 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in unassign_adapter_store() local
1065 get_update_locks_for_mdev(matrix_mdev); in unassign_adapter_store()
1071 if (apid > matrix_mdev->matrix.apm_max) { in unassign_adapter_store()
1076 if (!test_bit_inv(apid, matrix_mdev->matrix.apm)) { in unassign_adapter_store()
1081 clear_bit_inv((unsigned long)apid, matrix_mdev->matrix.apm); in unassign_adapter_store()
1082 vfio_ap_mdev_hot_unplug_adapter(matrix_mdev, apid); in unassign_adapter_store()
1085 release_update_locks_for_mdev(matrix_mdev); in unassign_adapter_store()
1090 static void vfio_ap_mdev_link_domain(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_link_domain() argument
1095 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) in vfio_ap_mdev_link_domain()
1096 vfio_ap_mdev_link_apqn(matrix_mdev, in vfio_ap_mdev_link_domain()
1141 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in assign_domain_store() local
1144 get_update_locks_for_mdev(matrix_mdev); in assign_domain_store()
1150 if (apqi > matrix_mdev->matrix.aqm_max) { in assign_domain_store()
1155 if (test_bit_inv(apqi, matrix_mdev->matrix.aqm)) { in assign_domain_store()
1160 set_bit_inv(apqi, matrix_mdev->matrix.aqm); in assign_domain_store()
1162 ret = vfio_ap_mdev_validate_masks(matrix_mdev); in assign_domain_store()
1164 clear_bit_inv(apqi, matrix_mdev->matrix.aqm); in assign_domain_store()
1168 vfio_ap_mdev_link_domain(matrix_mdev, apqi); in assign_domain_store()
1172 if (vfio_ap_mdev_filter_matrix(matrix_mdev->matrix.apm, aqm_delta, in assign_domain_store()
1173 matrix_mdev)) in assign_domain_store()
1174 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in assign_domain_store()
1178 release_update_locks_for_mdev(matrix_mdev); in assign_domain_store()
1185 static void vfio_ap_mdev_unlink_domain(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_unlink_domain() argument
1192 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) { in vfio_ap_mdev_unlink_domain()
1193 q = vfio_ap_unlink_apqn_fr_mdev(matrix_mdev, apid, apqi); in vfio_ap_mdev_unlink_domain()
1196 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && in vfio_ap_mdev_unlink_domain()
1197 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) in vfio_ap_mdev_unlink_domain()
1204 static void vfio_ap_mdev_hot_unplug_domain(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_hot_unplug_domain() argument
1212 vfio_ap_mdev_unlink_domain(matrix_mdev, apqi, qtable); in vfio_ap_mdev_hot_unplug_domain()
1214 if (test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { in vfio_ap_mdev_hot_unplug_domain()
1215 clear_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm); in vfio_ap_mdev_hot_unplug_domain()
1216 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_unplug_domain()
1250 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in unassign_domain_store() local
1252 get_update_locks_for_mdev(matrix_mdev); in unassign_domain_store()
1258 if (apqi > matrix_mdev->matrix.aqm_max) { in unassign_domain_store()
1263 if (!test_bit_inv(apqi, matrix_mdev->matrix.aqm)) { in unassign_domain_store()
1268 clear_bit_inv((unsigned long)apqi, matrix_mdev->matrix.aqm); in unassign_domain_store()
1269 vfio_ap_mdev_hot_unplug_domain(matrix_mdev, apqi); in unassign_domain_store()
1273 release_update_locks_for_mdev(matrix_mdev); in unassign_domain_store()
1298 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in assign_control_domain_store() local
1300 get_update_locks_for_mdev(matrix_mdev); in assign_control_domain_store()
1306 if (id > matrix_mdev->matrix.adm_max) { in assign_control_domain_store()
1311 if (test_bit_inv(id, matrix_mdev->matrix.adm)) { in assign_control_domain_store()
1321 set_bit_inv(id, matrix_mdev->matrix.adm); in assign_control_domain_store()
1322 if (vfio_ap_mdev_filter_cdoms(matrix_mdev)) in assign_control_domain_store()
1323 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in assign_control_domain_store()
1327 release_update_locks_for_mdev(matrix_mdev); in assign_control_domain_store()
1352 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in unassign_control_domain_store() local
1354 get_update_locks_for_mdev(matrix_mdev); in unassign_control_domain_store()
1360 if (domid > matrix_mdev->matrix.adm_max) { in unassign_control_domain_store()
1365 if (!test_bit_inv(domid, matrix_mdev->matrix.adm)) { in unassign_control_domain_store()
1370 clear_bit_inv(domid, matrix_mdev->matrix.adm); in unassign_control_domain_store()
1372 if (test_bit_inv(domid, matrix_mdev->shadow_apcb.adm)) { in unassign_control_domain_store()
1373 clear_bit_inv(domid, matrix_mdev->shadow_apcb.adm); in unassign_control_domain_store()
1374 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in unassign_control_domain_store()
1379 release_update_locks_for_mdev(matrix_mdev); in unassign_control_domain_store()
1392 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in control_domains_show() local
1393 unsigned long max_domid = matrix_mdev->matrix.adm_max; in control_domains_show()
1396 for_each_set_bit_inv(id, matrix_mdev->matrix.adm, max_domid + 1) { in control_domains_show()
1453 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in matrix_show() local
1456 nchars = vfio_ap_mdev_matrix_show(&matrix_mdev->matrix, buf); in matrix_show()
1467 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); in guest_matrix_show() local
1470 nchars = vfio_ap_mdev_matrix_show(&matrix_mdev->shadow_apcb, buf); in guest_matrix_show()
1509 static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_set_kvm() argument
1516 kvm->arch.crypto.pqap_hook = &matrix_mdev->pqap_hook; in vfio_ap_mdev_set_kvm()
1522 if (m != matrix_mdev && m->kvm == kvm) { in vfio_ap_mdev_set_kvm()
1529 matrix_mdev->kvm = kvm; in vfio_ap_mdev_set_kvm()
1530 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_set_kvm()
1538 static void unmap_iova(struct ap_matrix_mdev *matrix_mdev, u64 iova, u64 length) in unmap_iova() argument
1540 struct ap_queue_table *qtable = &matrix_mdev->qtable; in unmap_iova()
1553 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_dma_unmap() local
1558 unmap_iova(matrix_mdev, iova, length); in vfio_ap_mdev_dma_unmap()
1569 static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_unset_kvm() argument
1571 struct kvm *kvm = matrix_mdev->kvm; in vfio_ap_mdev_unset_kvm()
1581 vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); in vfio_ap_mdev_unset_kvm()
1583 matrix_mdev->kvm = NULL; in vfio_ap_mdev_unset_kvm()
1721 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_open_device() local
1727 return vfio_ap_mdev_set_kvm(matrix_mdev, vdev->kvm); in vfio_ap_mdev_open_device()
1732 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_close_device() local
1735 vfio_ap_mdev_unset_kvm(matrix_mdev); in vfio_ap_mdev_close_device()
1761 struct ap_matrix_mdev *matrix_mdev = in vfio_ap_mdev_ioctl() local
1771 ret = vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); in vfio_ap_mdev_ioctl()
1784 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_for_queue() local
1788 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_for_queue()
1789 if (test_bit_inv(apid, matrix_mdev->matrix.apm) && in vfio_ap_mdev_for_queue()
1790 test_bit_inv(apqi, matrix_mdev->matrix.aqm)) in vfio_ap_mdev_for_queue()
1791 return matrix_mdev; in vfio_ap_mdev_for_queue()
1803 struct ap_matrix_mdev *matrix_mdev; in status_show() local
1808 matrix_mdev = vfio_ap_mdev_for_queue(q); in status_show()
1810 if (matrix_mdev) { in status_show()
1811 if (matrix_mdev->kvm) in status_show()
1895 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_probe_queue() local
1909 matrix_mdev = get_update_locks_by_apqn(q->apqn); in vfio_ap_mdev_probe_queue()
1911 if (matrix_mdev) { in vfio_ap_mdev_probe_queue()
1912 vfio_ap_mdev_link_queue(matrix_mdev, q); in vfio_ap_mdev_probe_queue()
1914 if (vfio_ap_mdev_filter_matrix(matrix_mdev->matrix.apm, in vfio_ap_mdev_probe_queue()
1915 matrix_mdev->matrix.aqm, in vfio_ap_mdev_probe_queue()
1916 matrix_mdev)) in vfio_ap_mdev_probe_queue()
1917 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_probe_queue()
1920 release_update_locks_for_mdev(matrix_mdev); in vfio_ap_mdev_probe_queue()
1933 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_remove_queue() local
1938 matrix_mdev = q->matrix_mdev; in vfio_ap_mdev_remove_queue()
1940 if (matrix_mdev) { in vfio_ap_mdev_remove_queue()
1950 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && in vfio_ap_mdev_remove_queue()
1951 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { in vfio_ap_mdev_remove_queue()
1952 clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); in vfio_ap_mdev_remove_queue()
1953 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_remove_queue()
1960 release_update_locks_for_mdev(matrix_mdev); in vfio_ap_mdev_remove_queue()
2001 static void vfio_ap_mdev_hot_unplug_cfg(struct ap_matrix_mdev *matrix_mdev, in vfio_ap_mdev_hot_unplug_cfg() argument
2009 do_hotplug |= bitmap_andnot(matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_hot_unplug_cfg()
2010 matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_hot_unplug_cfg()
2015 do_hotplug |= bitmap_andnot(matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_hot_unplug_cfg()
2016 matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_hot_unplug_cfg()
2021 do_hotplug |= bitmap_andnot(matrix_mdev->shadow_apcb.adm, in vfio_ap_mdev_hot_unplug_cfg()
2022 matrix_mdev->shadow_apcb.adm, in vfio_ap_mdev_hot_unplug_cfg()
2026 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_unplug_cfg()
2046 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_cfg_remove() local
2052 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_cfg_remove()
2053 mutex_lock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_cfg_remove()
2057 matrix_mdev->matrix.apm, in vfio_ap_mdev_cfg_remove()
2060 matrix_mdev->matrix.aqm, in vfio_ap_mdev_cfg_remove()
2063 matrix_mdev->matrix.adm, in vfio_ap_mdev_cfg_remove()
2067 vfio_ap_mdev_hot_unplug_cfg(matrix_mdev, aprem, aqrem, in vfio_ap_mdev_cfg_remove()
2071 mutex_unlock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_cfg_remove()
2190 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_mdev_cfg_add() local
2197 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_mdev_cfg_add()
2198 bitmap_and(matrix_mdev->apm_add, in vfio_ap_mdev_cfg_add()
2199 matrix_mdev->matrix.apm, apm_add, AP_DEVICES); in vfio_ap_mdev_cfg_add()
2200 bitmap_and(matrix_mdev->aqm_add, in vfio_ap_mdev_cfg_add()
2201 matrix_mdev->matrix.aqm, aqm_add, AP_DOMAINS); in vfio_ap_mdev_cfg_add()
2202 bitmap_and(matrix_mdev->adm_add, in vfio_ap_mdev_cfg_add()
2203 matrix_mdev->matrix.adm, adm_add, AP_DEVICES); in vfio_ap_mdev_cfg_add()
2265 static void vfio_ap_mdev_hot_plug_cfg(struct ap_matrix_mdev *matrix_mdev) in vfio_ap_mdev_hot_plug_cfg() argument
2273 mutex_lock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_hot_plug_cfg()
2276 filter_adapters = bitmap_and(apm, matrix_mdev->matrix.apm, in vfio_ap_mdev_hot_plug_cfg()
2277 matrix_mdev->apm_add, AP_DEVICES); in vfio_ap_mdev_hot_plug_cfg()
2278 filter_domains = bitmap_and(aqm, matrix_mdev->matrix.aqm, in vfio_ap_mdev_hot_plug_cfg()
2279 matrix_mdev->aqm_add, AP_DOMAINS); in vfio_ap_mdev_hot_plug_cfg()
2282 do_hotplug |= vfio_ap_mdev_filter_matrix(apm, aqm, matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2286 matrix_mdev->shadow_apcb.aqm, in vfio_ap_mdev_hot_plug_cfg()
2287 matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2290 vfio_ap_mdev_filter_matrix(matrix_mdev->shadow_apcb.apm, in vfio_ap_mdev_hot_plug_cfg()
2291 aqm, matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2293 if (bitmap_intersects(matrix_mdev->matrix.adm, matrix_mdev->adm_add, in vfio_ap_mdev_hot_plug_cfg()
2295 do_hotplug |= vfio_ap_mdev_filter_cdoms(matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2298 vfio_ap_mdev_update_guest_apcb(matrix_mdev); in vfio_ap_mdev_hot_plug_cfg()
2301 mutex_unlock(&matrix_mdev->kvm->lock); in vfio_ap_mdev_hot_plug_cfg()
2307 struct ap_matrix_mdev *matrix_mdev; in vfio_ap_on_scan_complete() local
2311 list_for_each_entry(matrix_mdev, &matrix_dev->mdev_list, node) { in vfio_ap_on_scan_complete()
2312 if (bitmap_empty(matrix_mdev->apm_add, AP_DEVICES) && in vfio_ap_on_scan_complete()
2313 bitmap_empty(matrix_mdev->aqm_add, AP_DOMAINS) && in vfio_ap_on_scan_complete()
2314 bitmap_empty(matrix_mdev->adm_add, AP_DOMAINS)) in vfio_ap_on_scan_complete()
2317 vfio_ap_mdev_hot_plug_cfg(matrix_mdev); in vfio_ap_on_scan_complete()
2318 bitmap_clear(matrix_mdev->apm_add, 0, AP_DEVICES); in vfio_ap_on_scan_complete()
2319 bitmap_clear(matrix_mdev->aqm_add, 0, AP_DOMAINS); in vfio_ap_on_scan_complete()
2320 bitmap_clear(matrix_mdev->adm_add, 0, AP_DOMAINS); in vfio_ap_on_scan_complete()