linux/Documentation/virt/kvm
David Woodhouse 310bc39546 KVM: x86/xen: Avoid deadlock by adding kvm->arch.xen.xen_lock leaf node lock
In commit 14243b3871 ("KVM: x86/xen: Add KVM_IRQ_ROUTING_XEN_EVTCHN
and event channel delivery") the clever version of me left some helpful
notes for those who would come after him:

       /*
        * For the irqfd workqueue, using the main kvm->lock mutex is
        * fine since this function is invoked from kvm_set_irq() with
        * no other lock held, no srcu. In future if it will be called
        * directly from a vCPU thread (e.g. on hypercall for an IPI)
        * then it may need to switch to using a leaf-node mutex for
        * serializing the shared_info mapping.
        */
       mutex_lock(&kvm->lock);

In commit 2fd6df2f2b ("KVM: x86/xen: intercept EVTCHNOP_send from guests")
the other version of me ran straight past that comment without reading it,
and introduced a potential deadlock by taking vcpu->mutex and kvm->lock
in the wrong order.

Solve this as originally suggested, by adding a leaf-node lock in the Xen
state rather than using kvm->lock for it.

Fixes: 2fd6df2f2b ("KVM: x86/xen: intercept EVTCHNOP_send from guests")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20230111180651.14394-4-dwmw2@infradead.org>
[Rebase, add docs. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-01-11 17:45:58 -05:00
..
arm KVM: arm64: Fix pvtime documentation 2022-11-11 16:29:22 +00:00
devices KVM/arm64 updates for 6.2 2022-12-09 09:12:12 +01:00
s390 ARM: 2022-08-04 14:59:54 -07:00
x86 KVM: Move halt-polling documentation into common directory 2022-12-02 13:20:30 -05:00
api.rst KVM/arm64 fixes for 6.2, take #1 2023-01-11 13:31:53 -05:00
halt-polling.rst KVM: Document the interaction between KVM_CAP_HALT_POLL and halt_poll_ns 2022-12-02 13:20:30 -05:00
index.rst KVM: Move halt-polling documentation into common directory 2022-12-02 13:20:30 -05:00
locking.rst KVM: x86/xen: Avoid deadlock by adding kvm->arch.xen.xen_lock leaf node lock 2023-01-11 17:45:58 -05:00
ppc-pv.rst docs: kvm: Convert ppc-pv.txt to ReST format 2020-02-12 20:10:05 +01:00
review-checklist.rst docs: fix broken references for ReST files that moved around 2020-04-20 15:45:03 -06:00
vcpu-requests.rst KVM: remove KVM_REQ_UNHALT 2022-09-26 12:37:21 -04:00