xen/events: mask events when changing their VCPU binding
authorDavid Vrabel <david.vrabel@citrix.com>
Thu, 15 Aug 2013 12:21:07 +0000 (13:21 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 10 Sep 2013 00:57:26 +0000 (01:57 +0100)
commit5e72fdb8d827560893642e85a251d339109a00f4
tree9e04091d3399f52e0fc5a253908c48f8fc4f75bd
parent63493b3e3db6d027fe9b9a53616b8c1a9038ea44
xen/events: mask events when changing their VCPU binding

commit 4704fe4f03a5ab27e3c36184af85d5000e0f8a48 upstream.

When a event is being bound to a VCPU there is a window between the
EVTCHNOP_bind_vpcu call and the adjustment of the local per-cpu masks
where an event may be lost.  The hypervisor upcalls the new VCPU but
the kernel thinks that event is still bound to the old VCPU and
ignores it.

There is even a problem when the event is being bound to the same VCPU
as there is a small window beween the clear_bit() and set_bit() calls
in bind_evtchn_to_cpu().  When scanning for pending events, the kernel
may read the bit when it is momentarily clear and ignore the event.

Avoid this by masking the event during the whole bind operation.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
[bwh: Backported to 3.2: remove the BM() cast]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/xen/events.c