From: David Woodhouse Date: Fri, 13 Jan 2023 09:51:16 +0000 (+0000) Subject: Revert "KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET" X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=652a19630713424501a2e8529df3f369e92bc047;p=users%2Fdwmw2%2Flinux.git Revert "KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET" This reverts commit a79b53aaaab53de017517bf9579b6106397a523c. --- diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 651f9c5b873dd..e407fa00ccf4c 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1959,42 +1959,18 @@ static int kvm_xen_eventfd_deassign(struct kvm *kvm, u32 port) static int kvm_xen_eventfd_reset(struct kvm *kvm) { - struct evtchnfd *evtchnfd, **all_evtchnfds; + struct evtchnfd *evtchnfd; int i; - int n = 0; mutex_lock(&kvm->lock); - - /* - * 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. - */ - idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i) - n++; - - all_evtchnfds = kmalloc_array(n, sizeof(struct evtchnfd *), GFP_KERNEL); - if (!all_evtchnfds) { - mutex_unlock(&kvm->lock); - return -ENOMEM; - } - - n = 0; idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i) { - all_evtchnfds[n++] = evtchnfd; idr_remove(&kvm->arch.xen.evtchn_ports, evtchnfd->send_port); - } - mutex_unlock(&kvm->lock); - - synchronize_srcu(&kvm->srcu); - - while (n--) { - evtchnfd = all_evtchnfds[n]; + synchronize_srcu(&kvm->srcu); if (!evtchnfd->deliver.port.port) eventfd_ctx_put(evtchnfd->deliver.eventfd.ctx); kfree(evtchnfd); } - kfree(all_evtchnfds); + mutex_unlock(&kvm->lock); return 0; } diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c index dae510c263b45..721f6a693799b 100644 --- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c +++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c @@ -962,12 +962,6 @@ int main(int argc, char *argv[]) } done: - struct kvm_xen_hvm_attr evt_reset = { - .type = KVM_XEN_ATTR_TYPE_EVTCHN, - .u.evtchn.flags = KVM_XEN_EVTCHN_RESET, - }; - vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset); - alarm(0); clock_gettime(CLOCK_REALTIME, &max_ts);