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

[win-pv-devel] [PATCH 1/4] Add a new method to XENBUS_GNNTAB to a query a reference



This will be used a subsequent patch to extract the STORE and CONSOLE
PFNs from the grant table reserved entries, which form part of the Xen
ABI.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 include/gnttab_interface.h | 42 ++++++++++++++++++++++++--
 include/revision.h         |  3 +-
 src/xenbus/gnttab.c        | 73 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index b0f4adf..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
 
@@ -232,7 +252,25 @@ struct _XENBUS_GNTTAB_INTERFACE_V2 {
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V2 XENBUS_GNTTAB_INTERFACE, 
*PXENBUS_GNTTAB_INTERFACE;
+/*! \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
@@ -243,7 +281,7 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V2 
XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 #endif  // _WINDLL
 
 #define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 2
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 3
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
 
diff --git a/include/revision.h b/include/revision.h
index 6aaf888..ea489f5 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -53,6 +53,7 @@
     DEFINE_REVISION(0x09000000,  1,  2,  5,  1,  2,  1,  1,  2,  1,  0,  1), \
     DEFINE_REVISION(0x09000001,  1,  2,  6,  1,  2,  1,  1,  2,  1,  1,  1), \
     DEFINE_REVISION(0x09000002,  1,  2,  7,  1,  2,  1,  1,  2,  1,  1,  1), \
-    DEFINE_REVISION(0x09000003,  1,  2,  8,  1,  2,  1,  1,  2,  1,  1,  1)
+    DEFINE_REVISION(0x09000003,  1,  2,  8,  1,  2,  1,  1,  2,  1,  1,  1), \
+    DEFINE_REVISION(0x09000004,  1,  2,  8,  1,  2,  1,  1,  3,  1,  1,  1)
 
 #endif  // _REVISION_H
diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index bb11250..335d306 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -546,6 +546,35 @@ GnttabGetReference(
 }
 
 static NTSTATUS
+GnttabQueryReference(
+    IN  PINTERFACE          Interface,
+    IN ULONG               Reference,
+    OUT PPFN_NUMBER         Pfn OPTIONAL,
+    OUT PBOOLEAN            ReadOnly OPTIONAL
+    )
+{
+    PXENBUS_GNTTAB_CONTEXT  Context = Interface->Context;
+    NTSTATUS                status;
+
+    status = STATUS_INVALID_PARAMETER;
+    if (Reference >= (Context->FrameIndex + 1) * XENBUS_GNTTAB_ENTRY_PER_FRAME)
+        goto fail1;
+
+    if (Pfn != NULL)
+        *Pfn = Context->Table[Reference].frame;
+
+    if (ReadOnly != NULL)
+        *ReadOnly = (Context->Table[Reference].frame & GTF_readonly) ? TRUE : 
FALSE;
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+static NTSTATUS
 GnttabMapForeignPages(
     IN  PINTERFACE              Interface,
     IN  USHORT                  Domain,
@@ -789,6 +818,11 @@ GnttabAcquire(
     if (!NT_SUCCESS(status))
         goto fail10;
 
+    /* Make sure at least the reserved refrences are present */
+    status = GnttabExpand(Context);
+    if (!NT_SUCCESS(status))
+        goto fail11;
+
     Trace("<====\n");
 
 done:
@@ -796,6 +830,14 @@ done:
 
     return STATUS_SUCCESS;
 
+fail11:
+    Error("fail11\n");
+
+    XENBUS_DEBUG(Deregister,
+                 &Context->DebugInterface,
+                 Context->DebugCallback);
+    Context->DebugCallback = NULL;
+
 fail10:
     Error("fail10\n");
 
@@ -956,6 +998,20 @@ static struct _XENBUS_GNTTAB_INTERFACE_V2   
GnttabInterfaceVersion2 = {
     GnttabUnmapForeignPages
 };
 
+static struct _XENBUS_GNTTAB_INTERFACE_V3   GnttabInterfaceVersion3 = {
+    { sizeof (struct _XENBUS_GNTTAB_INTERFACE_V3), 3, NULL, NULL, NULL },
+    GnttabAcquire,
+    GnttabRelease,
+    GnttabCreateCache,
+    GnttabPermitForeignAccess,
+    GnttabRevokeForeignAccess,
+    GnttabGetReference,
+    GnttabQueryReference,
+    GnttabDestroyCache,
+    GnttabMapForeignPages,
+    GnttabUnmapForeignPages
+};
+
 NTSTATUS
 GnttabInitialize(
     IN  PXENBUS_FDO             Fdo,
@@ -1069,6 +1125,23 @@ GnttabGetInterface(
         status = STATUS_SUCCESS;
         break;
     }
+    case 3: {
+        struct _XENBUS_GNTTAB_INTERFACE_V3  *GnttabInterface;
+
+        GnttabInterface = (struct _XENBUS_GNTTAB_INTERFACE_V3 *)Interface;
+
+        status = STATUS_BUFFER_OVERFLOW;
+        if (Size < sizeof (struct _XENBUS_GNTTAB_INTERFACE_V3))
+            break;
+
+        *GnttabInterface = GnttabInterfaceVersion3;
+
+        ASSERT3U(Interface->Version, ==, Version);
+        Interface->Context = Context;
+
+        status = STATUS_SUCCESS;
+        break;
+    }
     default:
         status = STATUS_NOT_SUPPORTED;
         break;
-- 
2.5.3


_______________________________________________
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®.