[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH] Make use of updated XENBUS_EVTCHN interface



The latest version of the interface has modified the semantics of the
Wait method to avoid races. The patch takes advantage of these new
semantics.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 include/evtchn_interface.h | 106 +++++++++++++++++++++++----------------------
 src/xenvif.inf             |   6 +--
 src/xenvif/controller.c    |   7 +++
 3 files changed, 65 insertions(+), 54 deletions(-)

diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index a9952d6..310850b 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -112,13 +112,6 @@ typedef PXENBUS_EVTCHN_CHANNEL
     ...
     );
 
-typedef NTSTATUS
-(*XENBUS_EVTCHN_BIND_V2)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Cpu
-    );
-
 /*! \typedef XENBUS_EVTCHN_BIND
     \brief Bind an event channel to a specific CPU
 
@@ -135,13 +128,6 @@ typedef NTSTATUS
     IN  UCHAR                   Number
     );
 
-typedef BOOLEAN
-(*XENBUS_EVTCHN_UNMASK_V1)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InCallback
-    );
-
 /*! \typedef XENBUS_EVTCHN_UNMASK
     \brief Unmask an event channel
 
@@ -156,9 +142,18 @@ typedef VOID
     IN  BOOLEAN                 InCallback
     );
 
+typedef VOID
+(*XENBUS_EVTCHN_SEND_V1)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    );
+
 /*! \typedef XENBUS_EVTCHN_SEND
     \brief Send an event to the remote end of the channel
 
+    It is assumed that the domain cannot suspend during this call so
+    IRQL must be >= DISPATCH_LEVEL.
+
     \param Interface The interface header
     \param Channel The channel handle
 */  
@@ -180,17 +175,39 @@ typedef VOID
     IN  PXENBUS_EVTCHN_CHANNEL  Channel
     );
 
+/*! \typedef XENBUS_EVTCHN_GET_COUNT
+    \brief Get the number of events received by the channel since it was opened
+
+    \param Interface The interface header
+    \param Channel The channel handle
+    \return The number of events
+*/
+typedef ULONG
+(*XENBUS_EVTCHN_GET_COUNT)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    );
+
+typedef NTSTATUS
+(*XENBUS_EVTCHN_WAIT_V5)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
+    IN  PLARGE_INTEGER          Timeout OPTIONAL
+    );
+
 /*! \typedef XENBUS_EVTCHN_WAIT
-    \brief Wait for an event to the local end of the channel
+    \brief Wait for events to the local end of the channel
 
     \param Interface The interface header
     \param Channel The channel handle
+    \param Count The event count to wait for
     \param Timeout An optional timeout value (similar to 
KeWaitForSingleObject(), but non-zero values are allowed at DISPATCH_LEVEL).
 */
 typedef NTSTATUS
 (*XENBUS_EVTCHN_WAIT)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
+    IN  ULONG                   Count,
     IN  PLARGE_INTEGER          Timeout OPTIONAL
     );
 
@@ -223,61 +240,46 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V1
-    \brief EVTCHN interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_EVTCHN_INTERFACE_V1 {
-    INTERFACE               Interface;
-    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
-    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
-    XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_UNMASK_V1 EvtchnUnmaskVersion1;
-    XENBUS_EVTCHN_SEND      EvtchnSend;
-    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
-    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
-    XENBUS_EVTCHN_CLOSE     EvtchnClose;
-};
-
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V2
-    \brief EVTCHN interface version 2
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
+    \brief EVTCHN interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V2 {
+struct _XENBUS_EVTCHN_INTERFACE_V4 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
-    XENBUS_EVTCHN_UNMASK_V1 EvtchnUnmaskVersion1;
-    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V3
-    \brief EVTCHN interface version 3
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V5
+    \brief EVTCHN interface version 5
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V3 {
+struct _XENBUS_EVTCHN_INTERFACE_V5 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
-    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_WAIT_V5   EvtchnWaitVersion5;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V6
+    \brief EVTCHN interface version 6
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
+struct _XENBUS_EVTCHN_INTERFACE_V6 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -286,15 +288,16 @@ struct _XENBUS_EVTCHN_INTERFACE_V4 {
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_WAIT_V5   EvtchnWaitVersion5;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V5
-    \brief EVTCHN interface version 5
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V7
+    \brief EVTCHN interface version 7
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V5 {
+struct _XENBUS_EVTCHN_INTERFACE_V7 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -303,12 +306,13 @@ struct _XENBUS_EVTCHN_INTERFACE_V5 {
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
     XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V5 XENBUS_EVTCHN_INTERFACE, 
*PXENBUS_EVTCHN_INTERFACE;
+typedef struct _XENBUS_EVTCHN_INTERFACE_V7 XENBUS_EVTCHN_INTERFACE, 
*PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -318,8 +322,8 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V5 
XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 1
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 7
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
 
diff --git a/src/xenvif.inf b/src/xenvif.inf
index 4ba1ef5..bc4e555 100644
--- a/src/xenvif.inf
+++ b/src/xenvif.inf
@@ -59,9 +59,9 @@ 
xenvif_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll
 ; DisplayName          Section         DeviceID
 ; -----------          -------         --------
 
-%XenVifName%           =XenVif_Inst,   
XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_09000000
-%XenVifName%           =XenVif_Inst,   
XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_09000000
-%XenVifName%           =XenVif_Inst,   
XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_09000000
+%XenVifName%           =XenVif_Inst,   
XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_09000002
+%XenVifName%           =XenVif_Inst,   
XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_09000002
+%XenVifName%           =XenVif_Inst,   
XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_09000002
 
 [XenVif_Inst] 
 CopyFiles=XenVif_Copyfiles
diff --git a/src/xenvif/controller.c b/src/xenvif/controller.c
index a542c0d..629b6b7 100644
--- a/src/xenvif/controller.c
+++ b/src/xenvif/controller.c
@@ -259,6 +259,12 @@ ControllerGetResponse(
     Timeout.QuadPart = TIME_RELATIVE(TIME_MS(XENVIF_CONTROLLER_POLL_PERIOD));
 
     for (;;) {
+        ULONG   Count;
+
+        Count = XENBUS_EVTCHN(GetCount,
+                              &Controller->EvtchnInterface,
+                              Controller->Channel);
+
         ControllerPoll(Controller);
         KeMemoryBarrier();
 
@@ -268,6 +274,7 @@ ControllerGetResponse(
         status = XENBUS_EVTCHN(Wait,
                                &Controller->EvtchnInterface,
                                Controller->Channel,
+                               Count + 1,
                                &Timeout);
         if (status == STATUS_TIMEOUT)
             __ControllerSend(Controller);
-- 
2.5.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.