From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Tony Krowiak <akrowiak@linux.ibm.com>,
Jason Gunthorpe <jgg@nvidia.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.12 2/7] s390/vfio-ap: clean up mdev resources when remove callback invoked
Date: Mon, 5 Jul 2021 06:59:29 -0400 [thread overview]
Message-ID: <20210705105934.1513188-3-sashal@kernel.org> (raw)
In-Reply-To: <20210705105934.1513188-1-sashal@kernel.org>
From: Tony Krowiak <akrowiak@linux.ibm.com>
[ Upstream commit 8c0795d2a0f50e2b131f5b2a8c2795939a94058e ]
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 <akrowiak@linux.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20210609224634.575156-2-akrowiak@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 6946a7e26eff..ef5e792c665f 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);
mutex_lock(&matrix_dev->lock);
-
- /*
- * 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;
- }
-
vfio_ap_mdev_reset_queues(mdev);
list_del(&matrix_mdev->node);
kfree(matrix_mdev);
--
2.30.2
next prev parent reply other threads:[~2021-07-05 10:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 10:59 [PATCH 5.12 0/7] 5.12.15-rc1 review Sasha Levin
2021-07-05 10:59 ` [PATCH 5.12 1/7] scsi: sr: Return appropriate error code when disk is ejected Sasha Levin
2021-07-05 10:59 ` Sasha Levin [this message]
2021-07-05 10:59 ` [PATCH 5.12 3/7] gpio: mxc: Fix disabled interrupt wake-up support Sasha Levin
2021-07-05 10:59 ` [PATCH 5.12 4/7] drm/nouveau: fix dma_address check for CPU/GPU sync Sasha Levin
2021-07-05 10:59 ` [PATCH 5.12 5/7] gpio: AMD8111 and TQMX86 require HAS_IOPORT_MAP Sasha Levin
2021-07-05 10:59 ` [PATCH 5.12 6/7] Revert "KVM: x86/mmu: Drop kvm_mmu_extended_role.cr4_la57 hack" Sasha Levin
2021-07-05 10:59 ` [PATCH 5.12 7/7] Linux 5.12.15-rc1 Sasha Levin
2021-07-05 13:55 ` [PATCH 5.12 0/7] 5.12.15-rc1 review Fox Chen
2021-07-05 20:39 ` Guenter Roeck
2021-07-06 4:52 ` Naresh Kamboju
2021-07-06 22:15 ` Justin Forbes
2021-07-07 12:27 ` Sasha Levin
2021-07-06 22:44 ` Shuah Khan
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210705105934.1513188-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=akrowiak@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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