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

[win-pv-devel] [PATCH] Update EVTCHN and GNTTAB interface headers



Fixes Evtchn Unmask calls
Updates inf revision to 09000004

This will fix an issue where under certain conditions and timings, xenvbd
will request a second reboot to function correctly.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 include/evtchn_interface.h | 128 +++++++++++++++++++++++++++++++++------------
 include/gnttab_interface.h |  92 +++++++++++++++++++++++++++++++-
 src/xenvbd.inf             |   6 +--
 src/xenvbd/ring.c          |   6 ++-
 4 files changed, 193 insertions(+), 39 deletions(-)

diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index 6f8fe42..068a697 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,8 +128,8 @@ typedef NTSTATUS
     IN  UCHAR                   Number
     );
 
-typedef BOOLEAN
-(*XENBUS_EVTCHN_UNMASK_V1)(
+typedef VOID
+(*XENBUS_EVTCHN_UNMASK_V4)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
     IN  BOOLEAN                 InCallback
@@ -148,17 +141,28 @@ typedef BOOLEAN
     \param Interface The interface header
     \param Channel The channel handle
     \param InCallback Set to TRUE if this method is invoked in context of the 
channel callback
+    \param Force Set to TRUE if the unmask must succeed, otherwise set to 
FALSE and the function will return FALSE if the unmask did not complete.
 */
-typedef VOID
+typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InCallback
+    IN  BOOLEAN                 InCallback,
+    IN  BOOLEAN                 Force
+    );
+
+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,6 +184,42 @@ 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 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
+    );
+
 /*! \typedef XENBUS_EVTCHN_GET_PORT
     \brief Get the local port number bound to the channel
 
@@ -209,61 +249,83 @@ 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
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
+    \brief EVTCHN interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V1 {
+struct _XENBUS_EVTCHN_INTERFACE_V4 {
     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_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
+    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
     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_V5
+    \brief EVTCHN interface version 5
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V2 {
+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_UNMASK_V1 EvtchnUnmaskVersion1;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
+    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_V6
+    \brief EVTCHN interface version 6
+    \ingroup interfaces
+*/
+struct _XENBUS_EVTCHN_INTERFACE_V6 {
+    INTERFACE               Interface;
+    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
+    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
+    XENBUS_EVTCHN_OPEN      EvtchnOpen;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
     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_V3
-    \brief EVTCHN interface version 3
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V7
+    \brief EVTCHN interface version 7
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V3 {
+struct _XENBUS_EVTCHN_INTERFACE_V7 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
-    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
     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;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V8
+    \brief EVTCHN interface version 8
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
+struct _XENBUS_EVTCHN_INTERFACE_V8 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -272,11 +334,13 @@ struct _XENBUS_EVTCHN_INTERFACE_V4 {
     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_V4 XENBUS_EVTCHN_INTERFACE, 
*PXENBUS_EVTCHN_INTERFACE;
+typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, 
*PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -286,8 +350,8 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V4 
XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 1
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 4
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 8
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
 
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index d29440a..61272ab 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -148,6 +148,26 @@ typedef ULONG
     IN  PXENBUS_GNTTAB_ENTRY        Entry
     );
 
+/*! \typedef XENBUS_GNTTAB_QUERY_REFERENCE
+    \brief Get the reference number of the entry
+
+    \param Interface The interface header
+    \param Reference The reference number
+    \param Pfn An optional pointer to receive the value of the reference frame 
number
+    \param ReadOnly An optional pointer to receive the boolean value of the 
read-only flag
+*/
+typedef NTSTATUS
+(*XENBUS_GNTTAB_QUERY_REFERENCE)(
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Reference,
+    OUT PPFN_NUMBER Pfn OPTIONAL,
+    OUT PBOOLEAN    ReadOnly OPTIONAL
+    );
+
+#define XENBUS_GNTTAB_CONSOLE_REFERENCE 0
+#define XENBUS_GNTTAB_STORE_REFERENCE   1
+
+
 /*! \typedef XENBUS_GNTTAB_DESTROY_CACHE
     \brief Destroy a cache of grant table entries
 
@@ -163,6 +183,39 @@ typedef VOID
     IN  PXENBUS_GNTTAB_CACHE    Cache
     );
 
+/*! \typedef XENBUS_GNTTAB_MAP_FOREIGN_PAGES
+    \brief Map foreign memory pages into the system address space
+
+    \param Interface The interface header
+    \param Domain The domid of the foreign domain that granted the pages
+    \param NumberPages Number of pages to map
+    \param References Array of grant reference numbers shared by the foreign 
domain
+    \param ReadOnly If TRUE, pages are mapped with read-only access
+    \param Address The physical address that the foreign pages are mapped under
+*/
+
+typedef NTSTATUS
+(*XENBUS_GNTTAB_MAP_FOREIGN_PAGES)(
+    IN  PINTERFACE              Interface,
+    IN  USHORT                  Domain,
+    IN  ULONG                   NumberPages,
+    IN  PULONG                  References,
+    IN  BOOLEAN                 ReadOnly,
+    OUT PHYSICAL_ADDRESS        *Address
+    );
+
+/*! \typedef XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES
+    \brief Unmap foreign memory pages from the system address space
+
+    \param Interface The interface header
+    \param Address The physical address that the foreign pages are mapped under
+*/
+typedef NTSTATUS
+(*XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES)(
+    IN  PINTERFACE              Interface,
+    IN  PHYSICAL_ADDRESS        Address
+    );
+
 // {763679C5-E5C2-4A6D-8B88-6BB02EC42D8E}
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
@@ -182,7 +235,42 @@ struct _XENBUS_GNTTAB_INTERFACE_V1 {
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V1 XENBUS_GNTTAB_INTERFACE, 
*PXENBUS_GNTTAB_INTERFACE;
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
+    \brief GNTTAB interface version 2
+    \ingroup interfaces
+*/
+struct _XENBUS_GNTTAB_INTERFACE_V2 {
+    INTERFACE                           Interface;
+    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
+    XENBUS_GNTTAB_RELEASE               GnttabRelease;
+    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
+    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
+    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
+};
+
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
+    \brief GNTTAB interface version 3
+    \ingroup interfaces
+*/
+struct _XENBUS_GNTTAB_INTERFACE_V3 {
+    INTERFACE                           Interface;
+    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
+    XENBUS_GNTTAB_RELEASE               GnttabRelease;
+    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
+    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
+    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
+    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
+};
+
+typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, 
*PXENBUS_GNTTAB_INTERFACE;
 
 /*! \def XENBUS_GNTTAB
     \brief Macro at assist in method invocation
@@ -193,7 +281,7 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V1 
XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 #endif  // _WINDLL
 
 #define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 1
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 3
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
 
diff --git a/src/xenvbd.inf b/src/xenvbd.inf
index bb5ada2..5220add 100644
--- a/src/xenvbd.inf
+++ b/src/xenvbd.inf
@@ -54,9 +54,9 @@ xenvbd_coinst.dll=0,,
 %Vendor%=Inst,NT$ARCH$
 
 [Inst.NT$ARCH$]
-%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VBD&REV_09000000
-%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VBD&REV_09000000
-%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VBD&REV_09000000
+%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VBD&REV_09000004
+%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VBD&REV_09000004
+%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VBD&REV_09000004
 
 [XenVbd_Inst] 
 CopyFiles=XenVbd_Copyfiles
diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index a7b636d..2f5c876 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1649,7 +1649,8 @@ BlkifRingDpc(
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
                   BlkifRing->Channel,
-                  FALSE);
+                  FALSE,
+                  TRUE);
 }
 
 static NTSTATUS
@@ -1923,7 +1924,8 @@ BlkifRingConnect(
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
                   BlkifRing->Channel,
-                  FALSE);
+                  FALSE,
+                  TRUE);
 
     status = RtlStringCchPrintfA(Name,
                                  MAX_NAME_LEN,
-- 
2.16.2.windows.1


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

 


Rackspace

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