]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 28 Dec 2022 10:33:41 +0000 (05:33 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Feb 2023 10:25:40 +0000 (11:25 +0100)
commitac715e2d61aed4dc6cb3ab5391c52edf34d98e17
tree44c2ce7d29b3029c217cafd7382cf56d1756e797
parent98b9583142598ef46bd1f6e34c8c5782c47e272c
KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET

[ Upstream commit be50f2831594da0a19f3ba519bc9fa86cef81c89 ]

While KVM_XEN_EVTCHN_RESET is usually called with no vCPUs running,
if that happened it could cause a deadlock.  This is due to
kvm_xen_eventfd_reset() doing a synchronize_srcu() inside
a kvm->lock critical section.

To avoid this, first collect all the evtchnfd objects in an
array and free all of them once the kvm->lock critical section
is over and th SRCU grace period has expired.

Reported-by: Michal Luczaj <mhal@rbox.co>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/xen.c
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c