From: David Woodhouse Date: Tue, 24 Jan 2023 09:18:15 +0000 (+0100) Subject: XX: GSI assertion locking hack X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=54eb57c3617662855f39fad639fa8708ba47d306;p=people%2Fpauldu%2Fqemu.git XX: GSI assertion locking hack We see lockups with xen-disk and GSI evtchn delivery. The events stop being delivered to the guest. Empirically, this makes that stop happening. It shouldn't; I have no idea why. Signed-off-by: David Woodhouse --- diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index 9950bbecd1..6f3ab059ac 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -395,13 +395,16 @@ void kvm_xen_maybe_deassert_callback(CPUState *cs) return; } + qemu_mutex_lock_iothread(); /* If the evtchn_upcall_pending flag is cleared, turn the GSI off. */ - if (!vi->evtchn_upcall_pending) { - qemu_mutex_lock_iothread(); - X86_CPU(cs)->env.xen_callback_asserted = false; - xen_evtchn_set_callback_level(0); - qemu_mutex_unlock_iothread(); + if (X86_CPU(cs)->env.xen_callback_asserted && + !vi->evtchn_upcall_pending) { + if (!vi->evtchn_upcall_pending) { + X86_CPU(cs)->env.xen_callback_asserted = false; + xen_evtchn_set_callback_level(0); + } } + qemu_mutex_unlock_iothread(); } void kvm_xen_set_callback_asserted(void)