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

[win-pv-devel] [PATCH 4/4] Use new query method in XENBUS_GNTTAB method to get STORE and CONSOLE PFNs



Since XENBUS_GNTTAB now has a query method, the PFNs of the STORE and
CONSOLE shared pages can be found without the need to make hypercalls (to
get them via HVMOP_get_param).

This patch makes use of the new mechanism but this also requires a
re-ordering of some of the interface initialization code in FdoCreate().

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenbus/console.c | 128 +++++++++++++++++++++++++++------------------------
 src/xenbus/fdo.c     |  62 ++++++++++++-------------
 src/xenbus/store.c   | 124 ++++++++++++++++++++++++++++++++-----------------
 3 files changed, 183 insertions(+), 131 deletions(-)

diff --git a/src/xenbus/console.c b/src/xenbus/console.c
index 1ca25f0..8573ea7 100644
--- a/src/xenbus/console.c
+++ b/src/xenbus/console.c
@@ -64,10 +64,10 @@ struct _XENBUS_CONSOLE_CONTEXT {
     PXENBUS_EVTCHN_CHANNEL      Channel;
     ULONG                       Events;
     ULONG                       Dpcs;
+    XENBUS_GNTTAB_INTERFACE     GnttabInterface;
     XENBUS_EVTCHN_INTERFACE     EvtchnInterface;
     XENBUS_SUSPEND_INTERFACE    SuspendInterface;
     XENBUS_DEBUG_INTERFACE      DebugInterface;
-    PXENBUS_SUSPEND_CALLBACK    SuspendCallbackEarly;
     PXENBUS_SUSPEND_CALLBACK    SuspendCallbackLate;
     PXENBUS_DEBUG_CALLBACK      DebugCallback;
     BOOLEAN                     Enabled;
@@ -371,40 +371,36 @@ ConsoleEnable(
         Context->Dpcs++;
 }
 
-static PHYSICAL_ADDRESS
+static
 ConsoleGetAddress(
-    PXENBUS_CONSOLE_CONTEXT Context
+    IN  PXENBUS_CONSOLE_CONTEXT Context,
+    OUT PPHYSICAL_ADDRESS       Address
     )
 {
-    PHYSICAL_ADDRESS        Address;
-    NTSTATUS                status;
-
-    UNREFERENCED_PARAMETER(Context);
+    PFN_NUMBER                  Pfn;
+    NTSTATUS                    status;
 
-    status = HvmGetParam(HVM_PARAM_CONSOLE_PFN,
-                         (PULONGLONG)&Address.QuadPart);
-    ASSERT(NT_SUCCESS(status));
+    status = XENBUS_GNTTAB(QueryReference,
+                           &Context->GnttabInterface,
+                           XENBUS_GNTTAB_CONSOLE_REFERENCE,
+                           &Pfn,
+                           NULL);
+    if (!NT_SUCCESS(status))
+        goto fail1;
 
-    Address.QuadPart <<= PAGE_SHIFT;
+    Address->QuadPart = Pfn << PAGE_SHIFT;
 
     LogPrintf(LOG_LEVEL_INFO,
               "CONSOLE: PAGE @ %08x.%08x\n",
-              Address.HighPart,
-              Address.LowPart);
+              Address->HighPart,
+              Address->LowPart);
 
-    return Address;
-}
+    return STATUS_SUCCESS;
 
-static VOID
-ConsoleSuspendCallbackEarly(
-    IN  PVOID               Argument
-    )
-{
-    PXENBUS_CONSOLE_CONTEXT Context = Argument;
-    PHYSICAL_ADDRESS        Address;
+fail1:
+    Error("fail1 (%08x)\n", status);
 
-    Address = ConsoleGetAddress(Context);
-    ASSERT3U(Address.QuadPart, ==, Context->Address.QuadPart);
+    return status;
 }
 
 static VOID
@@ -415,6 +411,11 @@ ConsoleSuspendCallbackLate(
     PXENBUS_CONSOLE_CONTEXT     Context = Argument;
     struct xencons_interface    *Shared;
     KIRQL                       Irql;
+    PHYSICAL_ADDRESS            Address;
+    NTSTATUS                    status;
+
+    status = ConsoleGetAddress(Context, &Address);
+    ASSERT3U(Address.QuadPart, ==, Context->Address.QuadPart);
 
     Shared = Context->Shared;
 
@@ -671,6 +672,7 @@ ConsoleAcquire(
 {
     PXENBUS_CONSOLE_CONTEXT Context = Interface->Context;
     KIRQL                   Irql;
+    PHYSICAL_ADDRESS        Address;
     NTSTATUS                status;
 
     KeAcquireSpinLock(&Context->Lock, &Irql);
@@ -680,32 +682,31 @@ ConsoleAcquire(
 
     Trace("====>\n");
 
-    Context->Address = ConsoleGetAddress(Context);
+    status = XENBUS_GNTTAB(Acquire, &Context->GnttabInterface);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = ConsoleGetAddress(Context, &Address);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    Context->Address = Address;
     Context->Shared = (struct xencons_interface 
*)MmMapIoSpace(Context->Address,
                                                                PAGE_SIZE,
                                                                MmCached);
     status = STATUS_UNSUCCESSFUL;
     if (Context->Shared == NULL)
-        goto fail1;
+        goto fail3;
 
     status = XENBUS_EVTCHN(Acquire, &Context->EvtchnInterface);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail4;
 
     ConsoleEnable(Context);
 
     status = XENBUS_SUSPEND(Acquire, &Context->SuspendInterface);
     if (!NT_SUCCESS(status))
-        goto fail3;
-
-    status = XENBUS_SUSPEND(Register,
-                            &Context->SuspendInterface,
-                            SUSPEND_CALLBACK_EARLY,
-                            ConsoleSuspendCallbackEarly,
-                            Context,
-                            &Context->SuspendCallbackEarly);
-    if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail5;
 
     status = XENBUS_SUSPEND(Register,
                             &Context->SuspendInterface,
@@ -714,11 +715,11 @@ ConsoleAcquire(
                             Context,
                             &Context->SuspendCallbackLate);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     status = XENBUS_DEBUG(Acquire, &Context->DebugInterface);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail7;
 
     status = XENBUS_DEBUG(Register,
                           &Context->DebugInterface,
@@ -727,7 +728,7 @@ ConsoleAcquire(
                           Context,
                           &Context->DebugCallback);
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail8;
 
     Trace("<====\n");
 
@@ -736,44 +737,46 @@ done:
 
     return STATUS_SUCCESS;
 
-fail7:
-    Error("fail7\n");
+fail8:
+    Error("fail8\n");
 
     XENBUS_DEBUG(Release, &Context->DebugInterface);
 
-fail6:
-    Error("fail6\n");
+fail7:
+    Error("fail7\n");
 
     XENBUS_SUSPEND(Deregister,
                    &Context->SuspendInterface,
                    Context->SuspendCallbackLate);
     Context->SuspendCallbackLate = NULL;
 
+fail6:
+    Error("fail6\n");
+
+    XENBUS_SUSPEND(Release, &Context->SuspendInterface);
+
 fail5:
     Error("fail5\n");
 
-    XENBUS_SUSPEND(Deregister,
-                   &Context->SuspendInterface,
-                   Context->SuspendCallbackEarly);
-    Context->SuspendCallbackEarly = NULL;
+    ConsoleDisable(Context);
+
+    XENBUS_EVTCHN(Release, &Context->EvtchnInterface);
 
 fail4:
     Error("fail4\n");
 
-    XENBUS_SUSPEND(Release, &Context->SuspendInterface);
+    MmUnmapIoSpace(Context->Shared, PAGE_SIZE);
+    Context->Shared = NULL;
 
 fail3:
     Error("fail3\n");
 
-    ConsoleDisable(Context);
-
-    XENBUS_EVTCHN(Release, &Context->EvtchnInterface);
+    Context->Address.QuadPart = 0;
 
 fail2:
     Error("fail2\n");
 
-    MmUnmapIoSpace(Context->Shared, PAGE_SIZE);
-    Context->Shared = NULL;
+    XENBUS_GNTTAB(Release, &Context->GnttabInterface);
 
 fail1:
     Error("fail1 (%08x)\n", status);
@@ -817,11 +820,6 @@ ConsoleRelease(
                    Context->SuspendCallbackLate);
     Context->SuspendCallbackLate = NULL;
 
-    XENBUS_SUSPEND(Deregister,
-                   &Context->SuspendInterface,
-                   Context->SuspendCallbackEarly);
-    Context->SuspendCallbackEarly = NULL;
-
     XENBUS_SUSPEND(Release, &Context->SuspendInterface);
 
     ConsoleDisable(Context);
@@ -833,6 +831,8 @@ ConsoleRelease(
 
     Context->Address.QuadPart = 0;
 
+    XENBUS_GNTTAB(Release, &Context->GnttabInterface);
+
     Trace("<====\n");
 
 done:
@@ -867,6 +867,13 @@ ConsoleInitialize(
     if (*Context == NULL)
         goto fail1;
 
+    status = GnttabGetInterface(FdoGetGnttabContext(Fdo),
+                                XENBUS_GNTTAB_INTERFACE_VERSION_MAX,
+                                (PINTERFACE)&(*Context)->GnttabInterface,
+                                sizeof ((*Context)->GnttabInterface));
+    ASSERT(NT_SUCCESS(status));
+    ASSERT((*Context)->GnttabInterface.Interface.Context != NULL);
+
     status = EvtchnGetInterface(FdoGetEvtchnContext(Fdo),
                                 XENBUS_EVTCHN_INTERFACE_VERSION_MAX,
                                 (PINTERFACE)&(*Context)->EvtchnInterface,
@@ -984,6 +991,9 @@ ConsoleTeardown(
     RtlZeroMemory(&Context->EvtchnInterface,
                   sizeof (XENBUS_EVTCHN_INTERFACE));
 
+    RtlZeroMemory(&Context->GnttabInterface,
+                  sizeof (XENBUS_GNTTAB_INTERFACE));
+
     ASSERT(IsZeroMemory(Context, sizeof (XENBUS_CONSOLE_CONTEXT)));
     __ConsoleFree(Context);
 
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 7b9da12..25a6cfc 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -5154,23 +5154,23 @@ FdoCreate(
     if (!NT_SUCCESS(status))
         goto fail12;
 
-    status = StoreInitialize(Fdo, &Fdo->StoreContext);
+    status = RangeSetInitialize(Fdo, &Fdo->RangeSetContext);
     if (!NT_SUCCESS(status))
         goto fail13;
 
-    status = ConsoleInitialize(Fdo, &Fdo->ConsoleContext);
+    status = CacheInitialize(Fdo, &Fdo->CacheContext);
     if (!NT_SUCCESS(status))
         goto fail14;
 
-    status = RangeSetInitialize(Fdo, &Fdo->RangeSetContext);
+    status = GnttabInitialize(Fdo, &Fdo->GnttabContext);
     if (!NT_SUCCESS(status))
         goto fail15;
 
-    status = CacheInitialize(Fdo, &Fdo->CacheContext);
+    status = StoreInitialize(Fdo, &Fdo->StoreContext);
     if (!NT_SUCCESS(status))
         goto fail16;
 
-    status = GnttabInitialize(Fdo, &Fdo->GnttabContext);
+    status = ConsoleInitialize(Fdo, &Fdo->ConsoleContext);
     if (!NT_SUCCESS(status))
         goto fail17;
 
@@ -5205,6 +5205,13 @@ FdoCreate(
     ASSERT(NT_SUCCESS(status));
     ASSERT(Fdo->EvtchnInterface.Interface.Context != NULL);
 
+    status = RangeSetGetInterface(__FdoGetRangeSetContext(Fdo),
+                                  XENBUS_RANGE_SET_INTERFACE_VERSION_MAX,
+                                  (PINTERFACE)&Fdo->RangeSetInterface,
+                                  sizeof (Fdo->RangeSetInterface));
+    ASSERT(NT_SUCCESS(status));
+    ASSERT(Fdo->RangeSetInterface.Interface.Context != NULL);
+
     status = StoreGetInterface(__FdoGetStoreContext(Fdo),
                                XENBUS_STORE_INTERFACE_VERSION_MAX,
                                (PINTERFACE)&Fdo->StoreInterface,
@@ -5219,13 +5226,6 @@ FdoCreate(
     ASSERT(NT_SUCCESS(status));
     ASSERT(Fdo->ConsoleInterface.Interface.Context != NULL);
 
-    status = RangeSetGetInterface(__FdoGetRangeSetContext(Fdo),
-                                  XENBUS_RANGE_SET_INTERFACE_VERSION_MAX,
-                                  (PINTERFACE)&Fdo->RangeSetInterface,
-                                  sizeof (Fdo->RangeSetInterface));
-    ASSERT(NT_SUCCESS(status));
-    ASSERT(Fdo->RangeSetInterface.Interface.Context != NULL);
-
     status = BalloonGetInterface(__FdoGetBalloonContext(Fdo),
                                  XENBUS_BALLOON_INTERFACE_VERSION_MAX,
                                  (PINTERFACE)&Fdo->BalloonInterface,
@@ -5260,32 +5260,32 @@ fail19:
 fail18:
     Error("fail18\n");
 
-    GnttabTeardown(Fdo->GnttabContext);
-    Fdo->GnttabContext = NULL;
+    ConsoleTeardown(Fdo->ConsoleContext);
+    Fdo->ConsoleContext = NULL;
 
 fail17:
     Error("fail17\n");
 
-    CacheTeardown(Fdo->CacheContext);
-    Fdo->CacheContext = NULL;
+    StoreTeardown(Fdo->StoreContext);
+    Fdo->StoreContext = NULL;
 
 fail16:
     Error("fail16\n");
 
-    RangeSetTeardown(Fdo->RangeSetContext);
-    Fdo->RangeSetContext = NULL;
+    GnttabTeardown(Fdo->GnttabContext);
+    Fdo->GnttabContext = NULL;
 
 fail15:
     Error("fail15\n");
 
-    ConsoleTeardown(Fdo->ConsoleContext);
-    Fdo->ConsoleContext = NULL;
+    CacheTeardown(Fdo->CacheContext);
+    Fdo->CacheContext = NULL;
 
 fail14:
     Error("fail14\n");
 
-    StoreTeardown(Fdo->StoreContext);
-    Fdo->StoreContext = NULL;
+    RangeSetTeardown(Fdo->RangeSetContext);
+    Fdo->RangeSetContext = NULL;
 
 fail13:
     Error("fail13\n");
@@ -5400,15 +5400,15 @@ FdoDestroy(
         RtlZeroMemory(&Fdo->BalloonInterface,
                       sizeof (XENBUS_BALLOON_INTERFACE));
 
-        RtlZeroMemory(&Fdo->RangeSetInterface,
-                      sizeof (XENBUS_RANGE_SET_INTERFACE));
-
         RtlZeroMemory(&Fdo->ConsoleInterface,
                       sizeof (XENBUS_CONSOLE_INTERFACE));
 
         RtlZeroMemory(&Fdo->StoreInterface,
                       sizeof (XENBUS_STORE_INTERFACE));
 
+        RtlZeroMemory(&Fdo->RangeSetInterface,
+                      sizeof (XENBUS_RANGE_SET_INTERFACE));
+
         RtlZeroMemory(&Fdo->EvtchnInterface,
                       sizeof (XENBUS_EVTCHN_INTERFACE));
 
@@ -5426,6 +5426,12 @@ FdoDestroy(
         UnplugTeardown(Fdo->UnplugContext);
         Fdo->UnplugContext = NULL;
 
+        ConsoleTeardown(Fdo->ConsoleContext);
+        Fdo->ConsoleContext = NULL;
+
+        StoreTeardown(Fdo->StoreContext);
+        Fdo->StoreContext = NULL;
+
         GnttabTeardown(Fdo->GnttabContext);
         Fdo->GnttabContext = NULL;
 
@@ -5435,12 +5441,6 @@ FdoDestroy(
         RangeSetTeardown(Fdo->RangeSetContext);
         Fdo->RangeSetContext = NULL;
 
-        ConsoleTeardown(Fdo->ConsoleContext);
-        Fdo->ConsoleContext = NULL;
-
-        StoreTeardown(Fdo->StoreContext);
-        Fdo->StoreContext = NULL;
-
         EvtchnTeardown(Fdo->EvtchnContext);
         Fdo->EvtchnContext = NULL;
 
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 0dee054..556d040 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -141,6 +141,7 @@ struct _XENBUS_STORE_CONTEXT {
     PXENBUS_EVTCHN_CHANNEL              Channel;
     XENBUS_SUSPEND_INTERFACE            SuspendInterface;
     XENBUS_DEBUG_INTERFACE              DebugInterface;
+    XENBUS_GNTTAB_INTERFACE             GnttabInterface;
     PXENBUS_SUSPEND_CALLBACK            SuspendCallbackEarly;
     PXENBUS_SUSPEND_CALLBACK            SuspendCallbackLate;
     PXENBUS_DEBUG_CALLBACK              DebugCallback;
@@ -2169,28 +2170,36 @@ StoreEnable(
         Context->Dpcs++;
 }
 
-static PHYSICAL_ADDRESS
+static
 StoreGetAddress(
-    PXENBUS_STORE_CONTEXT   Context
+    IN  PXENBUS_STORE_CONTEXT   Context,
+    OUT PPHYSICAL_ADDRESS       Address
     )
 {
-    PHYSICAL_ADDRESS        Address;
-    NTSTATUS                status;
-
-    UNREFERENCED_PARAMETER(Context);
+    PFN_NUMBER                  Pfn;
+    NTSTATUS                    status;
 
-    status = HvmGetParam(HVM_PARAM_STORE_PFN,
-                         (PULONGLONG)&Address.QuadPart);
-    ASSERT(NT_SUCCESS(status));
+    status = XENBUS_GNTTAB(QueryReference,
+                           &Context->GnttabInterface,
+                           XENBUS_GNTTAB_STORE_REFERENCE,
+                           &Pfn,
+                           NULL);
+    if (!NT_SUCCESS(status))
+        goto fail1;
 
-    Address.QuadPart <<= PAGE_SHIFT;
+    Address->QuadPart = Pfn << PAGE_SHIFT;
 
     LogPrintf(LOG_LEVEL_INFO,
               "STORE: PAGE @ %08x.%08x\n",
-              Address.HighPart,
-              Address.LowPart);
+              Address->HighPart,
+              Address->LowPart);
+
+    return STATUS_SUCCESS;
 
-    return Address;
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
 }
 
 static VOID
@@ -2200,10 +2209,6 @@ StoreSuspendCallbackEarly(
 {
     PXENBUS_STORE_CONTEXT   Context = Argument;
     PLIST_ENTRY             ListEntry;
-    PHYSICAL_ADDRESS        Address;
-
-    Address = StoreGetAddress(Context);
-    ASSERT3U(Address.QuadPart, ==, Context->Address.QuadPart);
 
     for (ListEntry = Context->TransactionList.Flink;
          ListEntry != &(Context->TransactionList);
@@ -2232,14 +2237,17 @@ StoreSuspendCallbackLate(
     )
 {
     PXENBUS_STORE_CONTEXT               Context = Argument;
-    struct xenstore_domain_interface    *Shared;
     PLIST_ENTRY                         ListEntry;
     KIRQL                               Irql;
-
-    Shared = Context->Shared;
+    PHYSICAL_ADDRESS                    Address;
+    NTSTATUS                            status;
 
     KeAcquireSpinLock(&Context->Lock, &Irql);
 
+    status = StoreGetAddress(Context, &Address);
+    ASSERT(NT_SUCCESS(status));
+    ASSERT3U(Address.QuadPart, ==, Context->Address.QuadPart);
+
     StoreDisable(Context);
     StoreResetResponse(Context);
     StoreEnable(Context);
@@ -2272,7 +2280,7 @@ StoreDebugCallback(
                  Context->Address.LowPart);
 
     if (!Crashing) {
-        struct xenstore_domain_interface    *Shared;
+        struct xenstore_domain_interface *Shared;
 
         Shared = Context->Shared;
 
@@ -2415,6 +2423,7 @@ StoreAcquire(
 {
     PXENBUS_STORE_CONTEXT   Context = Interface->Context;
     KIRQL                   Irql;
+    PHYSICAL_ADDRESS        Address;
     NTSTATUS                status;
 
     KeAcquireSpinLock(&Context->Lock, &Irql);
@@ -2424,24 +2433,32 @@ StoreAcquire(
 
     Trace("====>\n");
 
-    Context->Address = StoreGetAddress(Context);
+    status = XENBUS_GNTTAB(Acquire, &Context->GnttabInterface);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = StoreGetAddress(Context, &Address);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    Context->Address = Address;
     Context->Shared = (struct xenstore_domain_interface 
*)MmMapIoSpace(Context->Address,
                                                                        
PAGE_SIZE,
                                                                        
MmCached);
     status = STATUS_UNSUCCESSFUL;
     if (Context->Shared == NULL)
-        goto fail1;
+        goto fail3;
 
     status = XENBUS_EVTCHN(Acquire, &Context->EvtchnInterface);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail4;
 
     StoreResetResponse(Context);
     StoreEnable(Context);
 
     status = XENBUS_SUSPEND(Acquire, &Context->SuspendInterface);
     if (!NT_SUCCESS(status))
-        goto fail3;
+        goto fail5;
 
     status = XENBUS_SUSPEND(Register,
                             &Context->SuspendInterface,
@@ -2450,7 +2467,7 @@ StoreAcquire(
                             Context,
                             &Context->SuspendCallbackEarly);
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail6;
 
     status = XENBUS_SUSPEND(Register,
                             &Context->SuspendInterface,
@@ -2459,11 +2476,11 @@ StoreAcquire(
                             Context,
                             &Context->SuspendCallbackLate);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail7;
 
     status = XENBUS_DEBUG(Acquire, &Context->DebugInterface);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail8;
 
     status = XENBUS_DEBUG(Register,
                           &Context->DebugInterface,
@@ -2472,7 +2489,7 @@ StoreAcquire(
                           Context,
                           &Context->DebugCallback);
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail9;
 
     Trace("<====\n");
 
@@ -2481,46 +2498,56 @@ done:
 
     return STATUS_SUCCESS;
 
-fail7:
-    Error("fail7\n");
+fail9:
+    Error("fail9\n");
 
     XENBUS_DEBUG(Release, &Context->DebugInterface);
 
-fail6:
-    Error("fail6\n");
+fail8:
+    Error("fail8\n");
 
     XENBUS_SUSPEND(Deregister,
                    &Context->SuspendInterface,
                    Context->SuspendCallbackLate);
     Context->SuspendCallbackLate = NULL;
 
-fail5:
-    Error("fail5\n");
+fail7:
+    Error("fail7\n");
 
     XENBUS_SUSPEND(Deregister,
                    &Context->SuspendInterface,
                    Context->SuspendCallbackEarly);
     Context->SuspendCallbackEarly = NULL;
 
-fail4:
-    Error("fail4\n");
+fail6:
+    Error("fail6\n");
 
     XENBUS_SUSPEND(Release, &Context->SuspendInterface);
 
-fail3:
-    Error("fail3\n");
+fail5:
+    Error("fail5\n");
 
     StoreDisable(Context);
     RtlZeroMemory(&Context->Response, sizeof (XENBUS_STORE_RESPONSE));
 
     XENBUS_EVTCHN(Release, &Context->EvtchnInterface);
 
-fail2:
-    Error("fail2\n");
+fail4:
+    Error("fail4\n");
 
     MmUnmapIoSpace(Context->Shared, PAGE_SIZE);
     Context->Shared = NULL;
 
+fail3:
+    Error("fail3\n");
+
+    Context->Address.QuadPart = 0;
+
+fail2:
+    Error("fail2\n");
+
+    XENBUS_GNTTAB(Release, &Context->GnttabInterface);
+
 fail1:
     Error("fail1 (%08x)\n", status);
 
@@ -2587,6 +2614,8 @@ StoreRelease(
 
     Context->Address.QuadPart = 0;
 
+    XENBUS_GNTTAB(Release, &Context->GnttabInterface);
+
     Trace("<====\n");
 
 done:
@@ -2644,6 +2673,13 @@ StoreInitialize(
     if (*Context == NULL)
         goto fail1;
 
+    status = GnttabGetInterface(FdoGetGnttabContext(Fdo),
+                                XENBUS_GNTTAB_INTERFACE_VERSION_MAX,
+                                (PINTERFACE)&(*Context)->GnttabInterface,
+                                sizeof ((*Context)->GnttabInterface));
+    ASSERT(NT_SUCCESS(status));
+    ASSERT((*Context)->GnttabInterface.Interface.Context != NULL);
+
     status = EvtchnGetInterface(FdoGetEvtchnContext(Fdo),
                                 XENBUS_EVTCHN_INTERFACE_VERSION_MAX,
                                 (PINTERFACE)&(*Context)->EvtchnInterface,
@@ -2722,6 +2758,9 @@ fail2:
     RtlZeroMemory(&(*Context)->EvtchnInterface,
                   sizeof (XENBUS_EVTCHN_INTERFACE));
 
+    RtlZeroMemory(&(*Context)->GnttabInterface,
+                  sizeof (XENBUS_GNTTAB_INTERFACE));
+
     ASSERT(IsZeroMemory(*Context, sizeof (XENBUS_STORE_CONTEXT)));
     __StoreFree(*Context);
 
@@ -2838,6 +2877,9 @@ StoreTeardown(
     RtlZeroMemory(&Context->EvtchnInterface,
                   sizeof (XENBUS_EVTCHN_INTERFACE));
 
+    RtlZeroMemory(&Context->GnttabInterface,
+                  sizeof (XENBUS_GNTTAB_INTERFACE));
+
     ASSERT(IsZeroMemory(Context, sizeof (XENBUS_STORE_CONTEXT)));
     __StoreFree(Context);
 
-- 
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®.