xen/events: avoid race with raising an event in unmask_evtchn()
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 25 Mar 2013 14:11:19 +0000 (14:11 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2013 16:26:16 +0000 (09:26 -0700)
commit88d1e05fd3f0bf7aa8712da17ffae839988fe81c
tree83d85300867d29df492d6f4a6da5b3674c435477
parent4ee541ed9f8c55799222434d5c20a3a6417294a9
xen/events: avoid race with raising an event in unmask_evtchn()

commit c26377e62f4e6bfb4d99ef88526047209701a83f upstream.

In unmask_evtchn(), when the mask bit is cleared after testing for
pending and the event becomes pending between the test and clear, then
the upcall will not become pending and the event may be lost or
delayed.

Avoid this by always clearing the mask bit before checking for
pending.  If a hypercall is needed, remask the event as
EVTCHNOP_unmask will only retrigger pending events if they were
masked.

This fixes a regression introduced in 3.7 by
b5e579232d635b79a3da052964cb357ccda8d9ea (xen/events: fix
unmask_evtchn for PV on HVM guests) which reordered the clear mask and
check pending operations.

Changes in v2:
- set mask before hypercall.

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Lingzhu Xiang <lxiang@redhat.com>
Reviewed-by: CAI Qian <caiqian@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/xen/events.c