[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH xenbus] Avoid a small race window that can lead to stuck EvtchnWait() calls
Make sure an event is ack-ed before Channel->Count is incremented otherwise EvtchnGetCount() could sample the incremented value whilst new events would be missed. Thus EvtchnWait() could end up waiting for a Count value that my never be reached. Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx> --- src/xenbus/evtchn.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c index 0748e50..8a819f3 100644 --- a/src/xenbus/evtchn.c +++ b/src/xenbus/evtchn.c @@ -507,8 +507,6 @@ EvtchnPoll( KeMemoryBarrier(); if (!Channel->Closed) { - Channel->Count++; - RemoveEntryList(&Channel->PendingListEntry); InitializeListHead(&Channel->PendingListEntry); @@ -521,6 +519,16 @@ EvtchnPoll( &Context->EvtchnAbi, Channel->LocalPort); + /* + * Make sure the event is ack-ed before Count is incremented + * otherwise there is a small window where EvtchnWait() could + * end up waiting on the incremented value whilst new events + * would be missed (hence Count would not be further + * incremented to wake the waiter). + */ + KeMemoryBarrier(); + Channel->Count++; + #pragma warning(suppress:6387) // NULL argument DoneSomething |= Channel->Callback(NULL, Channel->Argument); } else if (List != NULL) { @@ -923,6 +931,8 @@ EvtchnGetCount( { UNREFERENCED_PARAMETER(Interface); + KeMemoryBarrier(); + return Channel->Count; } -- 2.17.1 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |