win-pvdrivers

changeset 134:f3f156c524ee

Set ndis buffer size back to what it was allocated as before freeing as per MS docs.
Free memory after freeing buffer (eg reverse order of allocation)
Added debugging to count memory allocs and frees.
Still crashes on disable.
author James Harper <james.harper@bendigoit.com.au>
date Fri Jan 18 23:50:25 2008 +1100 (2008-01-18)
parents e5e6978fd09e
children 307dd7532ca1
files xenhide/sources xenhide/xenhide.c xennet/sources xennet/xennet.c xenpci/sources xenpci/xenbus.c
line diff
     1.1 --- a/xenhide/sources	Fri Jan 18 20:25:32 2008 +1100
     1.2 +++ b/xenhide/sources	Fri Jan 18 23:50:25 2008 +1100
     1.3 @@ -1,7 +1,7 @@
     1.4  TARGETNAME=XENHIDE
     1.5  TARGETTYPE=DRIVER
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7 -VERSION=0.5.0.8
     1.8 +VERSION=0.5.0.9
     1.9  KMDF_VERSION=1
    1.10  MSC_WARNING_LEVEL=/W4
    1.11  INF_NAME=xenhide
     2.1 --- a/xenhide/xenhide.c	Fri Jan 18 20:25:32 2008 +1100
     2.2 +++ b/xenhide/xenhide.c	Fri Jan 18 23:50:25 2008 +1100
     2.3 @@ -247,12 +247,10 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
     2.4          break;
     2.5        }
     2.6        // Qemu Network
     2.7 -#if 0 // we don't need this because we can specify type=netfront instead of type=ioemu
     2.8        if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139&SUBSYS_00015853")) {
     2.9          Match = 1;
    2.10          break;
    2.11        }
    2.12 -#endif
    2.13        RtlStringCchLengthW(Ptr, Length, &StrLen);
    2.14      }
    2.15      if (Match)
     3.1 --- a/xennet/sources	Fri Jan 18 20:25:32 2008 +1100
     3.2 +++ b/xennet/sources	Fri Jan 18 23:50:25 2008 +1100
     3.3 @@ -1,7 +1,7 @@
     3.4  TARGETNAME=XENNET
     3.5  TARGETTYPE=DRIVER
     3.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     3.7 -VERSION=0.5.0.92
     3.8 +VERSION=0.5.0.96
     3.9  KMDF_VERSION=1
    3.10  MSC_WARNING_LEVEL=/W4
    3.11  INF_NAME=xennet
     4.1 --- a/xennet/xennet.c	Fri Jan 18 20:25:32 2008 +1100
     4.2 +++ b/xennet/xennet.c	Fri Jan 18 23:50:25 2008 +1100
     4.3 @@ -130,6 +130,14 @@ struct xennet_info
     4.4    ULONG64 stat_rx_no_buffer;
     4.5  };
     4.6  
     4.7 +static int NdisAlloc;
     4.8 +static int MdlAlloc;
     4.9 +static int BufferAlloc;
    4.10 +static int PacketAlloc;
    4.11 +static int PageAlloc;
    4.12 +static int PacketPoolAlloc;
    4.13 +static int BufferPoolAlloc;
    4.14 +
    4.15  /* This function copied from linux's lib/vsprintf.c, see it for attribution */
    4.16  static unsigned long
    4.17  simple_strtoul(const char *cp,char **endp,unsigned int base)
    4.18 @@ -220,7 +228,9 @@ XenNet_TxBufferGC(struct xennet_info *xi
    4.19        /* free linearized data page */
    4.20        pmdl = *(PMDL *)pkt->MiniportReservedEx;
    4.21        NdisFreeMemory(MmGetMdlVirtualAddress(pmdl), 0, 0); // <= DISPATCH_LEVEL
    4.22 +NdisAlloc--;
    4.23        IoFreeMdl(pmdl);
    4.24 +MdlAlloc--;
    4.25  
    4.26        InterlockedDecrement(&xi->tx_outstanding);
    4.27        xi->stat_tx_ok++;
    4.28 @@ -271,7 +281,9 @@ XenNet_TxBufferFree(struct xennet_info *
    4.29      /* free linearized data page */
    4.30      pmdl = *(PMDL *)packet->MiniportReservedEx;
    4.31      NdisFreeMemory(MmGetMdlVirtualAddress(pmdl), 0, 0); // <= DISPATCH_LEVEL
    4.32 +NdisAlloc--;
    4.33      IoFreeMdl(pmdl);
    4.34 +MdlAlloc--;
    4.35  
    4.36      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_FAILURE);
    4.37  
    4.38 @@ -292,7 +304,9 @@ XenNet_TxBufferFree(struct xennet_info *
    4.39      /* free linearized data page */
    4.40      pmdl = *(PMDL *)packet->MiniportReservedEx;
    4.41      NdisFreeMemory(MmGetMdlVirtualAddress(pmdl), 0, 0); // <= DISPATCH_LEVEL
    4.42 +NdisAlloc--;
    4.43      IoFreeMdl(pmdl);
    4.44 +MdlAlloc--;
    4.45  
    4.46      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_FAILURE);
    4.47    }
    4.48 @@ -323,12 +337,14 @@ XenNet_RxBufferAlloc(struct xennet_info 
    4.49       * Allocate memory and an NDIS_BUFFER.
    4.50       */
    4.51      status = NdisAllocateMemoryWithTag(&start, PAGE_SIZE, XENNET_POOL_TAG);
    4.52 +NdisAlloc++;
    4.53      if (status != NDIS_STATUS_SUCCESS)
    4.54      {
    4.55        KdPrint(("NdisAllocateMemoryWithTag Failed! status = 0x%x\n", status));
    4.56        break;
    4.57      }
    4.58      NdisAllocateBuffer(&status, &buffer, xi->buffer_pool, start, PAGE_SIZE);
    4.59 +BufferAlloc++;
    4.60      ASSERT(status == NDIS_STATUS_SUCCESS); // should never fail
    4.61  
    4.62      /* Give to netback */
    4.63 @@ -370,6 +386,7 @@ XenNet_RxBufferFree(struct xennet_info *
    4.64    grant_ref_t ref;
    4.65    PNDIS_BUFFER buffer;
    4.66    KIRQL OldIrql;
    4.67 +  PVOID buff_va;
    4.68  
    4.69    ASSERT(!xi->connected);
    4.70  
    4.71 @@ -386,8 +403,12 @@ XenNet_RxBufferFree(struct xennet_info *
    4.72      /* don't check return, what can we do about it on failure? */
    4.73      xi->XenInterface.GntTbl_EndAccess(xi->XenInterface.InterfaceHeader.Context, ref);
    4.74  
    4.75 -    NdisFreeMemory(NdisBufferVirtualAddressSafe(buffer, NormalPagePriority), 0, 0);
    4.76 +    NdisAdjustBufferLength(buffer, PAGE_SIZE);
    4.77 +    buff_va = NdisBufferVirtualAddressSafe(buffer, NormalPagePriority);
    4.78      NdisFreeBuffer(buffer);
    4.79 +BufferAlloc--;
    4.80 +    NdisFreeMemory(buff_va, 0, 0);
    4.81 +NdisAlloc--;
    4.82    }
    4.83  
    4.84    KeReleaseSpinLock(&xi->rx_lock, OldIrql);
    4.85 @@ -416,12 +437,17 @@ XenNet_ReturnPacket(
    4.86    while (buffer)
    4.87    {
    4.88      NdisGetNextBuffer(buffer, &next_buffer);
    4.89 -    NdisFreeMemory(NdisBufferVirtualAddressSafe(buffer, NormalPagePriority), 0, 0);
    4.90 +    NdisAdjustBufferLength(buffer, PAGE_SIZE);
    4.91 +    buff_va = NdisBufferVirtualAddressSafe(buffer, NormalPagePriority);
    4.92      NdisFreeBuffer(buffer);
    4.93 +BufferAlloc--;
    4.94 +    NdisFreeMemory(buff_va, 0, 0);
    4.95 +NdisAlloc--;
    4.96      buffer = next_buffer;
    4.97    }
    4.98  
    4.99    NdisFreePacket(Packet);
   4.100 +PacketAlloc--;
   4.101  
   4.102    InterlockedDecrement(&xi->rx_outstanding);
   4.103  
   4.104 @@ -464,6 +490,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   4.105        {
   4.106          //  KdPrint((__DRIVER_NAME "     Got a packet\n"));
   4.107          NdisAllocatePacket(&status, &packet, xi->packet_pool);
   4.108 +PacketAlloc++;
   4.109          ASSERT(status == NDIS_STATUS_SUCCESS);
   4.110          NDIS_SET_PACKET_HEADER_SIZE(packet, XN_HDR_SIZE);
   4.111        }
   4.112 @@ -611,6 +638,7 @@ XenNet_BackEndStateHandler(char *Path, P
   4.113      /* TODO: must free pages in MDL as well as MDL using MmFreePagesFromMdl and ExFreePool */
   4.114      // or, allocate mem and then get mdl, then free mdl
   4.115      xi->tx_mdl = AllocatePage();
   4.116 +PageAlloc++;
   4.117      xi->tx_pgs = MmGetMdlVirtualAddress(xi->tx_mdl);
   4.118      SHARED_RING_INIT(xi->tx_pgs);
   4.119      FRONT_RING_INIT(&xi->tx, xi->tx_pgs, PAGE_SIZE);
   4.120 @@ -619,6 +647,7 @@ XenNet_BackEndStateHandler(char *Path, P
   4.121        *MmGetMdlPfnArray(xi->tx_mdl), FALSE);
   4.122  
   4.123      xi->rx_mdl = AllocatePage();
   4.124 +PageAlloc++;
   4.125      xi->rx_pgs = MmGetMdlVirtualAddress(xi->rx_mdl);
   4.126      SHARED_RING_INIT(xi->rx_pgs);
   4.127      FRONT_RING_INIT(&xi->rx, xi->rx_pgs, PAGE_SIZE);
   4.128 @@ -743,6 +772,7 @@ XenNet_Init(
   4.129  
   4.130    /* Alloc memory for adapter private info */
   4.131    status = NdisAllocateMemoryWithTag(&xi, sizeof(*xi), XENNET_POOL_TAG);
   4.132 +NdisAlloc++;
   4.133    if (!NT_SUCCESS(status))
   4.134    {
   4.135      KdPrint(("NdisAllocateMemoryWithTag failed with 0x%x\n", status));
   4.136 @@ -768,6 +798,7 @@ XenNet_Init(
   4.137  
   4.138    NdisAllocatePacketPool(&status, &xi->packet_pool, NET_RX_RING_SIZE,
   4.139      PROTOCOL_RESERVED_SIZE_IN_PACKET);
   4.140 +PacketPoolAlloc++;
   4.141    if (status != NDIS_STATUS_SUCCESS)
   4.142    {
   4.143      KdPrint(("NdisAllocatePacketPool failed with 0x%x\n", status));
   4.144 @@ -777,6 +808,7 @@ XenNet_Init(
   4.145    NdisSetPacketPoolProtocolId(xi->packet_pool, NDIS_PROTOCOL_ID_TCP_IP);
   4.146  
   4.147    NdisAllocateBufferPool(&status, &xi->buffer_pool, NET_RX_RING_SIZE);
   4.148 +BufferPoolAlloc++;
   4.149    if (status != NDIS_STATUS_SUCCESS)
   4.150    {
   4.151      KdPrint(("NdisAllocateBufferPool failed with 0x%x\n", status));
   4.152 @@ -919,6 +951,7 @@ XenNet_Init(
   4.153  
   4.154  err:
   4.155    NdisFreeMemory(xi, 0, 0);
   4.156 +NdisAlloc--;
   4.157    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   4.158    return status;
   4.159  }
   4.160 @@ -1437,16 +1470,19 @@ XenNet_Linearize(PNDIS_PACKET Packet)
   4.161    ASSERT(tot_buff_len <= XN_MAX_PKT_SIZE);
   4.162  
   4.163    status = NdisAllocateMemoryWithTag(&start, tot_buff_len, XENNET_POOL_TAG);
   4.164 +NdisAlloc++;
   4.165    if (!NT_SUCCESS(status))
   4.166    {
   4.167      KdPrint(("Could not allocate memory for linearization\n"));
   4.168      return NULL;
   4.169    }
   4.170    pmdl = IoAllocateMdl(start, tot_buff_len, FALSE, FALSE, FALSE);
   4.171 +MdlAlloc++;
   4.172    if (!pmdl)
   4.173    {
   4.174      KdPrint(("Could not allocate MDL for linearization\n"));
   4.175      NdisFreeMemory(start, 0, 0);
   4.176 +NdisAlloc--;
   4.177      return NULL;
   4.178    }
   4.179    MmBuildMdlForNonPagedPool(pmdl);
   4.180 @@ -1651,17 +1687,34 @@ XenNet_Halt(
   4.181    KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
   4.182    KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
   4.183  
   4.184 +KdPrint((__DRIVER_NAME "     NdisAlloc = %d\n", NdisAlloc));
   4.185 +KdPrint((__DRIVER_NAME "     MdlAlloc = %d\n", MdlAlloc));
   4.186 +KdPrint((__DRIVER_NAME "     BufferAlloc = %d\n", BufferAlloc));
   4.187 +KdPrint((__DRIVER_NAME "     PacketAlloc = %d\n", PacketAlloc));
   4.188 +KdPrint((__DRIVER_NAME "     PageAlloc = %d\n", PageAlloc));
   4.189 +KdPrint((__DRIVER_NAME "     PacketPoolAlloc = %d\n", PacketPoolAlloc));
   4.190 +KdPrint((__DRIVER_NAME "     BufferPoolAlloc = %d\n", BufferPoolAlloc));
   4.191 +
   4.192    /* free TX resources */
   4.193    if (xi->XenInterface.GntTbl_EndAccess(if_cxt, xi->tx_ring_ref))
   4.194    {
   4.195      xi->tx_ring_ref = GRANT_INVALID_REF;
   4.196      FreePages(xi->tx_mdl);
   4.197 +PageAlloc--;
   4.198    }
   4.199    /* if EndAccess fails then tx/rx ring pages LEAKED -- it's not safe to reuse
   4.200       pages Dom0 still has access to */
   4.201    xi->tx_pgs = NULL;
   4.202    XenNet_TxBufferFree(xi);
   4.203  
   4.204 +KdPrint((__DRIVER_NAME "     NdisAlloc = %d\n", NdisAlloc));
   4.205 +KdPrint((__DRIVER_NAME "     MdlAlloc = %d\n", MdlAlloc));
   4.206 +KdPrint((__DRIVER_NAME "     BufferAlloc = %d\n", BufferAlloc));
   4.207 +KdPrint((__DRIVER_NAME "     PacketAlloc = %d\n", PacketAlloc));
   4.208 +KdPrint((__DRIVER_NAME "     PageAlloc = %d\n", PageAlloc));
   4.209 +KdPrint((__DRIVER_NAME "     PacketPoolAlloc = %d\n", PacketPoolAlloc));
   4.210 +KdPrint((__DRIVER_NAME "     BufferPoolAlloc = %d\n", BufferPoolAlloc));
   4.211 +
   4.212    KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
   4.213    KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
   4.214  
   4.215 @@ -1670,6 +1723,7 @@ XenNet_Halt(
   4.216    {
   4.217      xi->rx_ring_ref = GRANT_INVALID_REF;
   4.218      FreePages(xi->rx_mdl);
   4.219 +PageAlloc--;
   4.220    }
   4.221    xi->rx_pgs = NULL;
   4.222    XenNet_RxBufferFree(MiniportAdapterContext);
   4.223 @@ -1684,12 +1738,23 @@ XenNet_Halt(
   4.224    WdfDriverMiniportUnload(WdfGetDriver());
   4.225  
   4.226    NdisFreeBufferPool(xi->buffer_pool);
   4.227 +BufferPoolAlloc--;
   4.228    NdisFreePacketPool(xi->packet_pool);
   4.229 +PacketPoolAlloc--;
   4.230 +
   4.231 +KdPrint((__DRIVER_NAME "     NdisAlloc = %d\n", NdisAlloc));
   4.232 +KdPrint((__DRIVER_NAME "     MdlAlloc = %d\n", MdlAlloc));
   4.233 +KdPrint((__DRIVER_NAME "     BufferAlloc = %d\n", BufferAlloc));
   4.234 +KdPrint((__DRIVER_NAME "     PacketAlloc = %d\n", PacketAlloc));
   4.235 +KdPrint((__DRIVER_NAME "     PageAlloc = %d\n", PageAlloc));
   4.236 +KdPrint((__DRIVER_NAME "     PacketPoolAlloc = %d\n", PacketPoolAlloc));
   4.237 +KdPrint((__DRIVER_NAME "     BufferPoolAlloc = %d\n", BufferPoolAlloc));
   4.238  
   4.239    KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
   4.240    KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
   4.241  
   4.242    NdisFreeMemory(xi, 0, 0); // <= DISPATCH_LEVEL
   4.243 +NdisAlloc--;
   4.244  
   4.245    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   4.246  }
   4.247 @@ -1705,6 +1770,14 @@ DriverEntry(
   4.248    NDIS_HANDLE ndis_wrapper_handle;
   4.249    NDIS_MINIPORT_CHARACTERISTICS mini_chars;
   4.250  
   4.251 +NdisAlloc = 0;
   4.252 +MdlAlloc = 0;
   4.253 +BufferAlloc = 0;
   4.254 +PacketAlloc = 0;
   4.255 +PageAlloc = 0;
   4.256 +PacketPoolAlloc = 0;
   4.257 +BufferPoolAlloc = 0;
   4.258 +
   4.259    RtlZeroMemory(&mini_chars, sizeof(mini_chars));
   4.260  
   4.261    WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK);
     5.1 --- a/xenpci/sources	Fri Jan 18 20:25:32 2008 +1100
     5.2 +++ b/xenpci/sources	Fri Jan 18 23:50:25 2008 +1100
     5.3 @@ -1,7 +1,7 @@
     5.4  TARGETNAME=XENPCI
     5.5  TARGETTYPE=DRIVER
     5.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     5.7 -VERSION=0.5.0.32
     5.8 +VERSION=0.5.0.33
     5.9  KMDF_VERSION=1
    5.10  MSC_WARNING_LEVEL=/W4
    5.11  INF_NAME=xenpci
     6.1 --- a/xenpci/xenbus.c	Fri Jan 18 20:25:32 2008 +1100
     6.2 +++ b/xenpci/xenbus.c	Fri Jan 18 23:50:25 2008 +1100
     6.3 @@ -43,7 +43,7 @@ static int allocate_xenbus_id(WDFDEVICE 
     6.4    static int probe;
     6.5    int o_probe;
     6.6  
     6.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     6.8 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     6.9  
    6.10    for (;;)
    6.11    {
    6.12 @@ -70,7 +70,7 @@ static int allocate_xenbus_id(WDFDEVICE 
    6.13    //init_waitqueue_head(&req_info[o_probe].waitq);
    6.14    KeInitializeEvent(&xpdd->req_info[o_probe].WaitEvent, SynchronizationEvent, FALSE);
    6.15  
    6.16 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.17 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.18  
    6.19    return o_probe;
    6.20  }
    6.21 @@ -140,7 +140,7 @@ static void xb_write(
    6.22    struct xsd_sockmsg m = {type, req_id, trans_id };
    6.23    struct write_req header_req = { &m, sizeof(m) };
    6.24  
    6.25 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.26 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.27  
    6.28    for (r = 0; r < nr_reqs; r++)
    6.29      len += req[r].len;
    6.30 @@ -205,7 +205,7 @@ static void xb_write(
    6.31    /* Send evtchn to notify remote */
    6.32    EvtChn_Notify(Device, xpdd->xen_store_evtchn);
    6.33  
    6.34 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.35 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.36  }
    6.37  
    6.38  static struct xsd_sockmsg *
    6.39 @@ -219,7 +219,7 @@ xenbus_msg_reply(
    6.40    PXENPCI_DEVICE_DATA xpdd = GetDeviceData(Device);
    6.41    int id;
    6.42  
    6.43 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.44 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.45  
    6.46    id = allocate_xenbus_id(Device);
    6.47  
    6.48 @@ -229,7 +229,7 @@ xenbus_msg_reply(
    6.49  
    6.50    release_xenbus_id(Device, id);
    6.51  
    6.52 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.53 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.54  
    6.55    return xpdd->req_info[id].Reply;
    6.56  }
    6.57 @@ -247,7 +247,7 @@ XenBus_Read(
    6.58    char *res;
    6.59    char *msg;
    6.60  
    6.61 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.62 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.63  
    6.64    rep = xenbus_msg_reply(Device, XS_READ, xbt, req, ARRAY_SIZE(req));
    6.65    msg = errmsg(rep);
    6.66 @@ -261,7 +261,7 @@ XenBus_Read(
    6.67    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    6.68    *value = res;
    6.69  
    6.70 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.71 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.72  
    6.73    return NULL;
    6.74  }
    6.75 @@ -281,7 +281,7 @@ XenBus_Write(
    6.76    struct xsd_sockmsg *rep;
    6.77    char *msg;
    6.78  
    6.79 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.80 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.81  
    6.82    rep = xenbus_msg_reply(Device, XS_WRITE, xbt, req, ARRAY_SIZE(req));
    6.83    msg = errmsg(rep);
    6.84 @@ -289,7 +289,7 @@ XenBus_Write(
    6.85      return msg;
    6.86    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    6.87  
    6.88 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.89 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.90  
    6.91    return NULL;
    6.92  }
    6.93 @@ -388,31 +388,15 @@ XenBus_Close(WDFDEVICE Device)
    6.94  
    6.95    xpdd->XenBus_ShuttingDown = TRUE;
    6.96  
    6.97 -  KdPrint((__DRIVER_NAME "     Signalling Threads\n"));
    6.98    KeSetEvent(&xpdd->XenBus_ReadThreadEvent, 1, FALSE);
    6.99    KeSetEvent(&xpdd->XenBus_WatchThreadEvent, 1, FALSE);
   6.100 -  KdPrint((__DRIVER_NAME "     Waiting for threads to die\n"));
   6.101    ObReferenceObjectByHandle(xpdd->XenBus_ReadThreadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &WaitArray[0], NULL);
   6.102    ObReferenceObjectByHandle(xpdd->XenBus_WatchThreadHandle, THREAD_ALL_ACCESS, NULL, KernelMode, &WaitArray[1], NULL);
   6.103 -  //KeWaitForMultipleObjects(1, &WaitArray[0], WaitAny, Executive, KernelMode, FALSE, NULL, WaitBlockArray);
   6.104 -  KdPrint((__DRIVER_NAME "     Waiting for ReadThread\n"));
   6.105    KeWaitForSingleObject(WaitArray[0], Executive, KernelMode, FALSE, NULL);
   6.106 -  KdPrint((__DRIVER_NAME "     Waiting for WatchThread\n"));
   6.107 -  //KeWaitForMultipleObjects(1, &WaitArray[1], WaitAny, Executive, KernelMode, FALSE, NULL, WaitBlockArray);
   6.108    KeWaitForSingleObject(WaitArray[1], Executive, KernelMode, FALSE, NULL);
   6.109 -  KdPrint((__DRIVER_NAME "     Threads are dead\n"));
   6.110 -
   6.111    xpdd->XenBus_ShuttingDown = FALSE;
   6.112  
   6.113 -//  ObDereferenceObject(WaitArray[0]);
   6.114 -//  ObDereferenceObject(WaitArray[1]);
   6.115 -
   6.116 -  KdPrint((__DRIVER_NAME "     A\n"));
   6.117 -
   6.118    ZwClose(xpdd->XenBus_WatchThreadHandle);
   6.119 -
   6.120 -  KdPrint((__DRIVER_NAME "     B\n"));
   6.121 -
   6.122    ZwClose(xpdd->XenBus_ReadThreadHandle);
   6.123  
   6.124    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.125 @@ -434,14 +418,14 @@ XenBus_List(
   6.126    char **res;
   6.127    char *msg;
   6.128  
   6.129 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.130 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.131  
   6.132    repmsg = xenbus_msg_reply(Device, XS_DIRECTORY, xbt, req, ARRAY_SIZE(req));
   6.133    msg = errmsg(repmsg);
   6.134    if (msg)
   6.135    {
   6.136      *contents = NULL;
   6.137 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.138 +//    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.139      return msg;
   6.140    }
   6.141    reply = repmsg + 1;
   6.142 @@ -461,7 +445,7 @@ XenBus_List(
   6.143    res[i] = NULL;
   6.144    ExFreePoolWithTag(repmsg, XENPCI_POOL_TAG);
   6.145    *contents = res;
   6.146 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.147 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.148    return NULL;
   6.149  }
   6.150  
   6.151 @@ -601,7 +585,7 @@ XenBus_AddWatch(
   6.152    PXENBUS_WATCH_ENTRY w_entry;
   6.153    KIRQL OldIrql;
   6.154  
   6.155 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.156 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.157  
   6.158    ASSERT(strlen(Path) < ARRAY_SIZE(w_entry->Path));
   6.159  
   6.160 @@ -647,7 +631,7 @@ XenBus_AddWatch(
   6.161      return msg;
   6.162    }
   6.163  
   6.164 -  KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch\n"));
   6.165 +//  KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch\n"));
   6.166  
   6.167    return NULL;
   6.168  }
   6.169 @@ -669,7 +653,7 @@ XenBus_RemWatch(
   6.170    struct write_req req[2];
   6.171    KIRQL OldIrql;
   6.172  
   6.173 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.174 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.175  
   6.176    KeAcquireSpinLock(&xpdd->WatchLock, &OldIrql);
   6.177  
   6.178 @@ -719,7 +703,7 @@ XenBus_RemWatch(
   6.179  
   6.180    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
   6.181  
   6.182 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.183 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.184  
   6.185    return NULL;
   6.186  }
   6.187 @@ -735,7 +719,7 @@ XenBus_StartTransaction(PVOID Context, x
   6.188    struct xsd_sockmsg *rep;
   6.189    char *err;
   6.190  
   6.191 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.192 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.193  
   6.194    rep = xenbus_msg_reply(Device, XS_TRANSACTION_START, 0, &req, 1);
   6.195    err = errmsg(rep);
   6.196 @@ -745,7 +729,7 @@ XenBus_StartTransaction(PVOID Context, x
   6.197    //sscanf((char *)(rep + 1), "%u", xbt);
   6.198    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
   6.199  
   6.200 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.201 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.202  
   6.203    return NULL;
   6.204  }
   6.205 @@ -762,7 +746,7 @@ XenBus_EndTransaction(
   6.206    struct write_req req;
   6.207    char *err;
   6.208  
   6.209 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.210 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.211  
   6.212    *retry = 0;
   6.213  
   6.214 @@ -781,7 +765,7 @@ XenBus_EndTransaction(
   6.215    }
   6.216    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
   6.217  
   6.218 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.219 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.220  
   6.221    return NULL;
   6.222  }
   6.223 @@ -794,11 +778,11 @@ XenBus_Interrupt(PKINTERRUPT Interrupt, 
   6.224  
   6.225    UNREFERENCED_PARAMETER(Interrupt);
   6.226  
   6.227 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.228 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.229  
   6.230    KeSetEvent(&xpdd->XenBus_ReadThreadEvent, 1, FALSE);
   6.231  
   6.232 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.233 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.234  
   6.235    return TRUE;
   6.236  }
   6.237 @@ -816,14 +800,14 @@ XenBus_Printf(
   6.238    char buf[512];
   6.239    char *retval;
   6.240  
   6.241 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.242 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.243  
   6.244    va_start(ap, fmt);
   6.245    RtlStringCbVPrintfA(buf, ARRAY_SIZE(buf), fmt, ap);
   6.246    va_end(ap);
   6.247    retval = XenBus_Write(Device, xbt, path, buf);
   6.248  
   6.249 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.250 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.251  
   6.252    return retval;
   6.253  }