win-pvdrivers

changeset 408:853fa6745f58

Fixed race in closing threads
author James Harper <james.harper@bendigoit.com.au>
date Mon Jul 28 13:31:56 2008 +1000 (2008-07-28)
parents d84a58b968e8
children a7cf863172cf
files xenpci/evtchn.c
line diff
     1.1 --- a/xenpci/evtchn.c	Fri Jul 25 16:25:40 2008 +1000
     1.2 +++ b/xenpci/evtchn.c	Mon Jul 28 13:31:56 2008 +1000
     1.3 @@ -78,7 +78,7 @@ EvtChn_Interrupt(PKINTERRUPT Interrupt, 
     1.4    if (xpdd->interrupts_masked)
     1.5    {
     1.6      KdPrint((__DRIVER_NAME "     unhandled interrupt\n"));
     1.7 -    //KeBugCheckEx(('X' << 16)|('E' << 8)|('N'), 0x00000003, 0x00000000, 0x00000000, 0x00000000);
     1.8 +    return TRUE;
     1.9    }
    1.10      
    1.11    //ASSERT(!no_more_interrupts);
    1.12 @@ -112,7 +112,7 @@ EvtChn_Interrupt(PKINTERRUPT Interrupt, 
    1.13          KdPrint((__DRIVER_NAME "     Unhandled Event!!!\n"));
    1.14          break;
    1.15        }
    1.16 -      synch_clear_bit(port, (volatile xen_long_t *)&shared_info_area->evtchn_pending[evt_word]);
    1.17 +      synch_clear_bit(evt_bit, (volatile xen_long_t *)&shared_info_area->evtchn_pending[evt_word]);
    1.18      }
    1.19    }
    1.20  
    1.21 @@ -220,22 +220,22 @@ EvtChn_Unbind(PVOID Context, evtchn_port
    1.22  }
    1.23  
    1.24  NTSTATUS
    1.25 -EvtChn_Mask(PVOID Context, evtchn_port_t Port)
    1.26 +EvtChn_Mask(PVOID Context, evtchn_port_t port)
    1.27  {
    1.28    PXENPCI_DEVICE_DATA xpdd = Context;
    1.29  
    1.30 -  synch_set_bit(Port,
    1.31 -    (volatile xen_long_t *)&xpdd->shared_info_area->evtchn_mask[0]);
    1.32 +  synch_set_bit(port & 31,
    1.33 +    (volatile xen_long_t *)&xpdd->shared_info_area->evtchn_mask[port >> 5]);
    1.34    return STATUS_SUCCESS;
    1.35  }
    1.36  
    1.37  NTSTATUS
    1.38 -EvtChn_Unmask(PVOID Context, evtchn_port_t Port)
    1.39 +EvtChn_Unmask(PVOID context, evtchn_port_t port)
    1.40  {
    1.41 -  PXENPCI_DEVICE_DATA xpdd = Context;
    1.42 +  PXENPCI_DEVICE_DATA xpdd = context;
    1.43  
    1.44 -  synch_clear_bit(Port,
    1.45 -    (volatile xen_long_t *)&xpdd->shared_info_area->evtchn_mask[0]);
    1.46 +  synch_clear_bit(port & 31,
    1.47 +    (volatile xen_long_t *)&xpdd->shared_info_area->evtchn_mask[port >> 5]);
    1.48    return STATUS_SUCCESS;
    1.49  }
    1.50  
    1.51 @@ -261,6 +261,16 @@ EvtChn_AllocUnbound(PVOID Context, domid
    1.52    return op.port;
    1.53  }
    1.54  
    1.55 +VOID
    1.56 +EvtChn_Close(PVOID Context, evtchn_port_t port )
    1.57 +{
    1.58 +  PXENPCI_DEVICE_DATA xpdd = Context;
    1.59 +  evtchn_close_t op;
    1.60 +  op.port = port;
    1.61 +  HYPERVISOR_event_channel_op(xpdd, EVTCHNOP_close, &op);
    1.62 +  return;
    1.63 +}
    1.64 +
    1.65  NTSTATUS
    1.66  EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    1.67  {
    1.68 @@ -284,7 +294,7 @@ EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    1.69    {
    1.70      xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_pending = 0;
    1.71      xpdd->shared_info_area->vcpu_info[i].evtchn_pending_sel = 0;
    1.72 -    xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_mask = 1;
    1.73 +    xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_mask = 1; /* apparantly this doesn't do anything */
    1.74    }
    1.75  
    1.76    KeMemoryBarrier();