archive mirror
 help / color / mirror / Atom feed
From: Tony Krowiak <>
Subject: [PATCH v6 1/2] s390/vfio-ap: clean up mdev resources when remove callback invoked
Date: Mon, 21 Jun 2021 11:57:13 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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 <>
Reviewed-by: Jason Gunthorpe <>
 drivers/s390/crypto/vfio_ap_ops.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index b2c7e10dfdcd..122c85c22469 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -366,16 +366,6 @@ static int vfio_ap_mdev_remove(struct mdev_device *mdev)
 	struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev);
-	/*
-	 * If the KVM pointer is in flux or the guest is running, disallow
-	 * un-assignment of control domain.
-	 */
-	if (matrix_mdev->kvm_busy || matrix_mdev->kvm) {
-		mutex_unlock(&matrix_dev->lock);
-		return -EBUSY;
-	}

  reply	other threads:[~2021-06-21 15:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21 15:57 [PATCH v6 0/2] s390/vfio-ap: fix memory leak in mdev remove callback Tony Krowiak
2021-06-21 15:57 ` Tony Krowiak [this message]
2021-06-21 16:04   ` [PATCH v6 1/2] s390/vfio-ap: clean up mdev resources when remove callback invoked Christian Borntraeger
2021-06-21 17:27     ` Jason Gunthorpe
2021-06-21 15:57 ` [PATCH v6 2/2] s390/vfio-ap: r/w lock for PQAP interception handler function pointer Tony Krowiak
2021-06-30 15:18   ` Tony Krowiak
2021-07-01 15:25     ` Christian Borntraeger
2021-07-01 16:28       ` Tony Krowiak
2021-07-07 17:16       ` Tony Krowiak
2021-07-01 15:13   ` Tony Krowiak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).