Re: [PATCH] KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET

From: Michal Luczaj
Date: Fri Feb 24 2023 - 13:18:25 EST


On 28/12/2022 12:04, Paolo Bonzini wrote:
> 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.
>
> [...]
>
> + /*
> + * Because synchronize_srcu() cannot be called inside the
> + * critical section, first collect all the evtchnfd objects
> + * in an array as they are removed from evtchn_ports.
> + */

With the recent changes regarding the locking order (locking.rst:
"synchronize_srcu(&kvm->srcu) is called inside critical sections for kvm->lock,
vcpu->mutex and kvm->slots_lock"), is this comment still valid?

Or is there a rule that forbids synchronize_srcu() under the newly introduced
kvm->arch.xen.xen_lock?

thanks,
Michal