win-pvdrivers

changeset 901:70738d39e3cc

Another approach to avoid free race in highsync
author James Harper <james.harper@bendigoit.com.au>
date Fri Apr 01 11:35:29 2011 +1100 (2011-04-01)
parents 938de6b8623d
children 44029b09876a
files xenpci/xenpci_highsync.c
line diff
     1.1 --- a/xenpci/xenpci_highsync.c	Thu Mar 31 20:20:36 2011 +1100
     1.2 +++ b/xenpci/xenpci_highsync.c	Fri Apr 01 11:35:29 2011 +1100
     1.3 @@ -92,6 +92,12 @@ XenPci_HighSyncCallFunction0(
     1.4      KeMemoryBarrier();
     1.5    }
     1.6    InterlockedDecrement(&highsync_info->nr_procs_at_dispatch_level);
     1.7 +  /* wait until nr_procs_at_dispatch_level drops to 0 indicating that nothing else requires highsync_info */
     1.8 +  while (highsync_info->nr_spinning_at_dispatch_level)
     1.9 +  {
    1.10 +    KeStallExecutionProcessor(1);
    1.11 +    KeMemoryBarrier();
    1.12 +  }
    1.13    KeSetEvent(&highsync_info->highsync_complete_event, IO_NO_INCREMENT, FALSE);
    1.14  
    1.15    FUNCTION_EXIT();
    1.16 @@ -194,12 +200,6 @@ XenPci_HighSync(PXENPCI_HIGHSYNC_FUNCTIO
    1.17  
    1.18    KdPrint((__DRIVER_NAME "     Waiting for highsync_complete_event\n"));
    1.19    KeWaitForSingleObject(&highsync_info->highsync_complete_event, Executive, KernelMode, FALSE, NULL);
    1.20 -  /* wait until nr_procs_at_dispatch_level drops to 0 indicating that nothing else requires highsync_info */
    1.21 -  while (highsync_info->nr_procs_at_dispatch_level)
    1.22 -  {
    1.23 -    KeStallExecutionProcessor(1);
    1.24 -    KeMemoryBarrier();
    1.25 -  }
    1.26    ExFreePoolWithTag(highsync_info, XENPCI_POOL_TAG);
    1.27    FUNCTION_EXIT();
    1.28  }