win-pvdrivers

changeset 646:84e37987cdbc 0.10.0.98

xenbus dpc could be scheduled on multiple cpu's simultaneously. protect with a spinlock.
author James Harper <james.harper@bendigoit.com.au>
date Tue Aug 25 21:44:08 2009 +1000 (2009-08-25)
parents 748f32b33e5d
children 3804bcbab502
files xenpci/xenbus.c xenpci/xenpci.h
line diff
     1.1 --- a/xenpci/xenbus.c	Tue Aug 25 11:50:21 2009 +1000
     1.2 +++ b/xenpci/xenbus.c	Tue Aug 25 21:44:08 2009 +1000
     1.3 @@ -265,6 +265,8 @@ XenBus_Dpc(PVOID ServiceContext)
     1.4    WDFWORKITEM workitem;
     1.5  
     1.6    //FUNCTION_ENTER();
     1.7 +  
     1.8 +  KeAcquireSpinLockAtDpcLevel(&xpdd->xb_ring_spinlock);
     1.9  
    1.10    //KdPrint((__DRIVER_NAME "     rsp_prod = %d, rsp_cons = %d\n", xpdd->xen_store_interface->rsp_prod, xpdd->xen_store_interface->rsp_cons));
    1.11    while (xpdd->xen_store_interface->rsp_prod != xpdd->xen_store_interface->rsp_cons)
    1.12 @@ -315,6 +317,7 @@ XenBus_Dpc(PVOID ServiceContext)
    1.13        WdfWorkItemEnqueue(workitem);
    1.14      }
    1.15    }
    1.16 +  KeReleaseSpinLockFromDpcLevel(&xpdd->xb_ring_spinlock);
    1.17    
    1.18    //FUNCTION_EXIT();
    1.19  }
    1.20 @@ -355,6 +358,7 @@ XenBus_Init(PXENPCI_DEVICE_DATA xpdd)
    1.21  
    1.22    ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
    1.23  
    1.24 +  KeInitializeSpinLock(&xpdd->xb_ring_spinlock);
    1.25    ExInitializeFastMutex(&xpdd->xb_request_mutex);
    1.26    ExInitializeFastMutex(&xpdd->xb_watch_mutex);
    1.27  
     2.1 --- a/xenpci/xenpci.h	Tue Aug 25 11:50:21 2009 +1000
     2.2 +++ b/xenpci/xenpci.h	Tue Aug 25 21:44:08 2009 +1000
     2.3 @@ -172,6 +172,7 @@ typedef struct {
     2.4    
     2.5    /* xenbus related */
     2.6    XENBUS_WATCH_ENTRY XenBus_WatchEntries[MAX_WATCH_ENTRIES];
     2.7 +  KSPIN_LOCK xb_ring_spinlock;
     2.8    FAST_MUTEX xb_watch_mutex;
     2.9    FAST_MUTEX xb_request_mutex;
    2.10    KEVENT xb_request_complete_event;