Skip to content

Commit 8c0795d

Browse files
Tony KrowiakVasily Gorbik
authored andcommitted
s390/vfio-ap: clean up mdev resources when remove callback invoked
The mdev remove callback for the vfio_ap device driver bails out with -EBUSY if the mdev is in use by a KVM guest (i.e., the KVM pointer in the struct ap_matrix_mdev is not NULL). The intended purpose was to prevent the mdev from being removed while in use. There are two problems with this scenario: 1. Returning a non-zero return code from the remove callback does not prevent the removal of the mdev. 2. The KVM pointer in the struct ap_matrix_mdev will always be NULL because the remove callback will not get invoked until the mdev fd is closed. When the mdev fd is closed, the mdev release callback is invoked and clears the KVM pointer from the struct ap_matrix_mdev. Let's go ahead and remove the check for KVM in the remove callback and allow the cleanup of mdev resources to proceed. Signed-off-by: Tony Krowiak <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vasily Gorbik <[email protected]>
1 parent ca1f4d7 commit 8c0795d

File tree

1 file changed

+0
-10
lines changed

1 file changed

+0
-10
lines changed

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,16 +366,6 @@ static int vfio_ap_mdev_remove(struct mdev_device *mdev)
366366
struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
367367

368368
mutex_lock(&matrix_dev->lock);
369-
370-
/*
371-
* If the KVM pointer is in flux or the guest is running, disallow
372-
* un-assignment of control domain.
373-
*/
374-
if (matrix_mdev->kvm_busy || matrix_mdev->kvm) {
375-
mutex_unlock(&matrix_dev->lock);
376-
return -EBUSY;
377-
}
378-
379369
vfio_ap_mdev_reset_queues(mdev);
380370
list_del(&matrix_mdev->node);
381371
kfree(matrix_mdev);

0 commit comments

Comments
 (0)