Re: [PATCH] vfio: Use file-based reference counting for KVM
"Jason J. Herne" <[email protected]>
| Newsgroups | org.kernel.vger.kvm,org.kernel.vger.linux-kernel,org.kernel.vger.linux-s390 |
|---|---|
| Message-ID | <[email protected]> |
On 8/12/26 2:55 PM, Steffen Eiden wrote:
> ...
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 99a0efd999ef..42d331c84e66 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -1817,17 +1817,27 @@ static const struct attribute_group *vfio_ap_mdev_attr_groups[] = {
>
> /**
> * vfio_ap_mdev_set_kvm - sets all data for @matrix_mdev that are needed
> - * to manage AP resources for the guest whose state is represented by @kvm
> + * to manage AP resources for the guest whose state is represented by
> + * @kvm_file
> *
> * @matrix_mdev: a mediated matrix device
> - * @kvm: reference to KVM instance
> + * @kvm_file: the KVM VM file this vfio device is associated with
> *
> - * Return: 0 if no other mediated matrix device has a reference to @kvm;
> + * Return: 0 if no other mediated matrix device has a reference to the VM;
> * otherwise, returns an -EPERM.
> */
> static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev,
> - struct kvm *kvm)
> + struct file *kvm_file)
> {
> + struct kvm *kvm;
> +
> + if (!kvm_file)
> + return -ENOENT;
> +
> + kvm = kvm_file->private_data;
> + if (!kvm)
> + return -ENOENT;
> +
> if (kvm->arch.crypto.crycbd) {
> get_update_locks_for_kvm(kvm);
> if (kvm->arch.crypto.pqap_hook) {
> @@ -1836,7 +1846,6 @@ static int vfio_ap_mdev_set_kvm(struct ap_matrix_mdev *matrix_mdev,
> }
> kvm->arch.crypto.pqap_hook = &matrix_mdev->pqap_hook;
>
> - kvm_get_kvm(kvm);
> matrix_mdev->kvm = kvm;
> vfio_ap_mdev_update_guest_apcb(matrix_mdev);
> release_update_locks_for_kvm(kvm);
> @@ -1889,7 +1898,6 @@ static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev)
> matrix_mdev->kvm = NULL;
>
> release_update_locks_for_kvm(kvm);
> - kvm_put_kvm(kvm);
> }
> }
Reviewed-by: Jason J. Herne <[email protected]>