Files
linux/arch/x86/include/asm
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
..
2021-10-20 22:35:04 +02:00
2021-03-18 15:31:53 +01:00
2022-08-04 11:11:59 +02:00
2022-11-01 13:44:10 +01:00
2020-01-23 10:41:20 -08:00
2022-09-26 10:13:16 -07:00
2021-03-18 15:31:53 +01:00
2022-10-17 16:41:15 +02:00
2020-05-07 16:06:20 +02:00
2021-12-11 09:09:47 +01:00
2021-10-28 23:25:26 +02:00
2020-10-28 20:26:25 +01:00
2021-10-05 21:48:30 +02:00
2022-08-19 04:05:42 -04:00
2020-11-26 12:58:56 +01:00
2022-06-28 13:20:21 +02:00
2020-11-06 23:14:58 +01:00
2022-10-03 14:03:26 -07:00
2022-04-07 08:27:52 -07:00
2022-11-01 13:44:10 +01:00
2022-11-10 13:12:45 +01:00
2022-04-14 14:09:43 +02:00
2020-09-16 16:52:28 +02:00
2021-12-11 09:09:45 +01:00
2021-07-01 11:06:03 -07:00
2022-12-15 10:37:28 -08:00
2022-08-21 10:06:28 -07:00
2022-08-25 15:54:03 +02:00
2021-12-11 09:09:45 +01:00
2019-04-10 09:53:31 +02:00
2020-03-21 16:03:25 +01:00
2020-11-17 14:36:13 +01:00
2022-08-18 12:36:42 +02:00
2022-01-30 21:17:00 -05:00
2022-01-30 21:17:00 -05:00
2020-03-23 18:45:14 +01:00
2022-06-08 05:56:24 -04:00
2020-01-14 12:20:58 +01:00