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

[win-pv-devel] [PATCH 5/6] Add strict version check between XEN and XENFILT/XENBUS



Because the ABI between XEN and the other drivers in the package is
(intentionally) unstable, add a strict version check using the single
function XenTouch to prevent XENBUS or XENFILT loading if an incumbent
XEN is from a previous package installation.

Also add code to the co-installer to request a reboot, as this is needed
to bring up a compatible set of modules.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 include/xen.h        |  8 ++++++--
 src/coinst/coinst.c  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 src/xen/driver.c     | 28 +++++++++++++++++++++++-----
 src/xenbus/driver.c  | 12 +++++++++---
 src/xenfilt/driver.c | 12 +++++++++---
 5 files changed, 92 insertions(+), 13 deletions(-)

diff --git a/include/xen.h b/include/xen.h
index 0c76fe7..29e32f9 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -62,9 +62,13 @@
 
 // Dummy function to cause XEN.SYS to be loaded and initialized
 XEN_API
-VOID
+NTSTATUS
 XenTouch(
-    VOID
+    IN  const CHAR  *Name,
+    IN  ULONG       MajorVersion,
+    IN  ULONG       MinorVersion,
+    IN  ULONG       MicroVersion,
+    IN  ULONG       BuildNumber
     );
 
 // HYPERCALL
diff --git a/src/coinst/coinst.c b/src/coinst/coinst.c
index bc33182..4b3e532 100644
--- a/src/coinst/coinst.c
+++ b/src/coinst/coinst.c
@@ -1827,6 +1827,50 @@ fail1:
 }
 
 static BOOLEAN
+RequestReboot(
+    IN  HDEVINFO            DeviceInfoSet,
+    IN  PSP_DEVINFO_DATA    DeviceInfoData
+    )
+{
+    SP_DEVINSTALL_PARAMS    DeviceInstallParams;
+    HRESULT                 Error;
+
+    DeviceInstallParams.cbSize = sizeof (DeviceInstallParams);
+
+    if (!SetupDiGetDeviceInstallParams(DeviceInfoSet,
+                                       DeviceInfoData,
+                                       &DeviceInstallParams))
+        goto fail1;
+
+    DeviceInstallParams.Flags |= DI_NEEDREBOOT;
+
+    Log("Flags = %08x", DeviceInstallParams.Flags);
+
+    if (!SetupDiSetDeviceInstallParams(DeviceInfoSet,
+                                       DeviceInfoData,
+                                       &DeviceInstallParams))
+        goto fail2;
+
+    return TRUE;
+
+fail2:
+    Log("fail2");
+
+fail1:
+    Error = GetLastError();
+
+    {
+        PTCHAR  Message;
+
+        Message = GetErrorMessage(Error);
+        Log("fail1 (%s)", Message);
+        LocalFree(Message);
+    }
+
+    return FALSE;
+}
+
+static BOOLEAN
 SetFriendlyName(
     IN  HDEVINFO            DeviceInfoSet,
     IN  PSP_DEVINFO_DATA    DeviceInfoData,
@@ -2205,6 +2249,7 @@ DifInstallPostProcess(
 
         (VOID) InstallFilter(&GUID_DEVCLASS_SYSTEM, "XENFILT");
         (VOID) InstallFilter(&GUID_DEVCLASS_HDC, "XENFILT");
+        (VOID) RequestReboot(DeviceInfoSet, DeviceInfoData);
     }
 
     free(DeviceID);
diff --git a/src/xen/driver.c b/src/xen/driver.c
index 716367c..a319541 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -55,10 +55,14 @@ typedef struct _XEN_DRIVER {
 static XEN_DRIVER   Driver;
 
 XEN_API
-VOID
+NTSTATUS
 XenTouch(
-    VOID
-    )
+    IN  const CHAR  *Name,
+    IN  ULONG       MajorVersion,
+    IN  ULONG       MinorVersion,
+    IN  ULONG       MicroVersion,
+    IN  ULONG       BuildNumber
+   )
 {
     static ULONG    Reference;
     ULONG           Major;
@@ -66,8 +70,14 @@ XenTouch(
     CHAR            Extra[XEN_EXTRAVERSION_LEN];
     NTSTATUS        status;
 
+    if (MajorVersion != MAJOR_VERSION ||
+        MinorVersion != MINOR_VERSION ||
+        MicroVersion != MICRO_VERSION ||
+        BuildNumber != BUILD_NUMBER)
+        goto fail1;
+
     if (Reference++ != 0)
-        return;
+        goto done;
 
     status = XenVersion(&Major, &Minor);
     ASSERT(NT_SUCCESS(status));
@@ -81,6 +91,14 @@ XenTouch(
               Minor,
               Extra,
               __XEN_INTERFACE_VERSION__);
+
+done:
+    return STATUS_SUCCESS;
+
+fail1:
+    Info("MODULE '%s' NOT COMPATIBLE (REBOOT REQUIRED)\n", Name);
+
+    return STATUS_INCOMPATIBLE_DRIVER_BLOCKED;
 }
 
 static VOID
@@ -136,7 +154,7 @@ DllInitialize(
                                &Driver.InfoDisposition);
     ASSERT(NT_SUCCESS(status));
 
-    Info("XEN %d.%d.%d (%d) (%02d.%02d.%04d)\n",
+    Info("%d.%d.%d (%d) (%02d.%02d.%04d)\n",
          MAJOR_VERSION,
          MINOR_VERSION,
          MICRO_VERSION,
diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index 628e0fa..e74d369 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -512,9 +512,7 @@ DriverEntry(
     if (*InitSafeBootMode > 0)
         goto done;
 
-    XenTouch();
-
-    Info("XENBUS %d.%d.%d (%d) (%02d.%02d.%04d)\n",
+    Info("%d.%d.%d (%d) (%02d.%02d.%04d)\n",
          MAJOR_VERSION,
          MINOR_VERSION,
          MICRO_VERSION,
@@ -523,6 +521,14 @@ DriverEntry(
          MONTH,
          YEAR);
 
+    status = XenTouch(__MODULE__,
+                      MAJOR_VERSION,
+                      MINOR_VERSION,
+                      MICRO_VERSION,
+                      BUILD_NUMBER);
+    if (!NT_SUCCESS(status))
+        goto done;
+
     status = RegistryInitialize(RegistryPath);
     if (!NT_SUCCESS(status))
         goto fail1;
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 8279bd7..420e827 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -787,9 +787,7 @@ DriverEntry(
     if (*InitSafeBootMode > 0)
         goto done;
 
-    XenTouch();
-
-    Info("XENFILT %d.%d.%d (%d) (%02d.%02d.%04d)\n",
+    Info("%d.%d.%d (%d) (%02d.%02d.%04d)\n",
          MAJOR_VERSION,
          MINOR_VERSION,
          MICRO_VERSION,
@@ -798,6 +796,14 @@ DriverEntry(
          MONTH,
          YEAR);
 
+    status = XenTouch(__MODULE__,
+                      MAJOR_VERSION,
+                      MINOR_VERSION,
+                      MICRO_VERSION,
+                      BUILD_NUMBER);
+    if (!NT_SUCCESS(status))
+        goto done;
+
     status = RegistryInitialize(RegistryPath);
     if (!NT_SUCCESS(status))
         goto fail1;
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://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®.