evtchn: don't reuse ports that are still "busy"
authorDavid Vrabel <david.vrabel@citrix.com>
Wed, 2 Dec 2015 14:21:46 +0000 (15:21 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 2 Dec 2015 14:21:46 +0000 (15:21 +0100)
commit78e24c269b0a4a8b864ece725e6d4209ed95dfa7
treec9de49b55ec8fab17a85b94d7b84e8d9b9eb54ac
parente513d8f7bc3db90e66bd2ed963b3142f412b770d
evtchn: don't reuse ports that are still "busy"

When using the FIFO ABI a guest may close an event channel that is
still LINKED.  If this port is reused, subsequent events may be lost
because they may become pending on the wrong queue.

This could be fixed by requiring guests to only close event channels
that are not linked.  This is difficult since: a) irq cleanup in the
guest may be done in a context that cannot wait for the event to be
unlinked; b) the guest may attempt to rebind a PIRQ whose previous
close is still pending; and c) existing guests already have the
problematic behaviour.

Instead, simply check a port is not "busy" (i.e., it's not linked)
before reusing it.

Guests should still drain any queues for VCPUs that are being
offlined, or the port will become unusable until the VCPU is onlined
and starts processing events again.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/event_channel.c
xen/common/event_fifo.c
xen/include/xen/event.h