From: Matthew Rosato <mjrosato@linux.ibm.com>
To: alex.williamson@redhat.com, pbonzini@redhat.com
Cc: jgg@nvidia.com, cohuck@redhat.com, farman@linux.ibm.com,
pmorel@linux.ibm.com, borntraeger@linux.ibm.com,
frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com,
akrowiak@linux.ibm.com, jjherne@linux.ibm.com,
pasic@linux.ibm.com, zhenyuw@linux.intel.com,
zhi.a.wang@intel.com, linux-s390@vger.kernel.org,
kvm@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] kvm/vfio: fix potential deadlock on vfio group lock
Date: Mon, 9 Jan 2023 15:10:35 -0500 [thread overview]
Message-ID: <20230109201037.33051-1-mjrosato@linux.ibm.com> (raw)
Hi Alex, Paolo,
As reported by Alex [1], since commit 421cfe6596f6 it is possible for
a kvm_put_kvm call to hit a refcount of 0 and trigger kvm_destroy_vm
while the vfio group lock is held. However, if this occurs, and the
associated group is still in the kvm device list, this thread of
execution will attempt to acquire the vfio group lock again, resulting
in a deadlock.
This series proposes to resolve this by adding a new kvm_put_kvm_async
which behaves the same as kvm_put_kvm but, in the case where the refcount
hits 0, will use a workqueue to perform the kvm_destroy_vm asynchronously.
The fix is provided in 2 patches because s390 PCI passthrough has the same
issue, albeit introduced slightly later via a different commit.
[1]: https://lore.kernel.org/kvm/20230105150930.6ee65182.alex.williamson@redhat.com/
Matthew Rosato (2):
KVM: async kvm_destroy_vm for vfio devices
KVM: s390: pci: use asyncronous kvm put
arch/s390/kvm/pci.c | 8 ++++++--
drivers/gpu/drm/i915/gvt/kvmgt.c | 6 +++++-
drivers/s390/crypto/vfio_ap_ops.c | 7 ++++++-
include/linux/kvm_host.h | 3 +++
virt/kvm/kvm_main.c | 22 ++++++++++++++++++++++
5 files changed, 42 insertions(+), 4 deletions(-)
--
2.39.0
next reply other threads:[~2023-01-09 20:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 20:10 Matthew Rosato [this message]
2023-01-09 20:10 ` [PATCH 1/2] KVM: async kvm_destroy_vm for vfio devices Matthew Rosato
2023-01-09 20:13 ` Jason Gunthorpe
2023-01-09 20:24 ` Matthew Rosato
2023-01-09 21:07 ` Anthony Krowiak
2023-01-11 19:54 ` Sean Christopherson
2023-01-11 20:05 ` Jason Gunthorpe
2023-01-11 20:53 ` Sean Christopherson
2023-01-12 12:45 ` Jason Gunthorpe
2023-01-12 17:21 ` Matthew Rosato
2023-01-12 17:27 ` Jason Gunthorpe
2023-01-09 20:10 ` [PATCH 2/2] KVM: s390: pci: use asyncronous kvm put Matthew Rosato
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=20230109201037.33051-1-mjrosato@linux.ibm.com \
--to=mjrosato@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=farman@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jgg@nvidia.com \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=pmorel@linux.ibm.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).