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

[win-pv-devel] [PATCH] Only veto PDO start when InitSafeBootMode is set



There is no need to prevent FDO or PDO creation to stop PV network devices
from coming up, we just need to prevent the PDOs from starting.

Thie patch removes the global veto and instead bails out of PdoStartDevice()
if the system is in safe mode.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/driver.c | 28 ++++++++++++++++++----------
 src/xenvif/driver.h |  5 +++++
 src/xenvif/pdo.c    | 38 ++++++++++++++++++++++----------------
 3 files changed, 45 insertions(+), 26 deletions(-)

diff --git a/src/xenvif/driver.c b/src/xenvif/driver.c
index f8a8777..4b1e538 100644
--- a/src/xenvif/driver.c
+++ b/src/xenvif/driver.c
@@ -42,8 +42,6 @@
 #include "assert.h"
 #include "util.h"
 
-extern PULONG       InitSafeBootMode;
-
 typedef struct _XENVIF_DRIVER {
     PDRIVER_OBJECT      DriverObject;
     HANDLE              ParametersKey;
@@ -53,6 +51,24 @@ typedef struct _XENVIF_DRIVER {
 
 static XENVIF_DRIVER    Driver;
 
+extern PULONG   InitSafeBootMode;
+
+static FORCEINLINE BOOLEAN
+__DriverSafeMode(
+    VOID
+    )
+{
+    return (*InitSafeBootMode > 0) ? TRUE : FALSE;
+}
+
+BOOLEAN
+DriverSafeMode(
+    VOID
+    )
+{
+    return __DriverSafeMode();
+}
+
 static FORCEINLINE VOID
 __DriverSetDriverObject(
     IN  PDRIVER_OBJECT  DriverObject
@@ -154,9 +170,6 @@ DriverUnload(
 
     Trace("====>\n");
 
-    if (*InitSafeBootMode > 0)
-        goto done;
-
     Driver.NeedReboot = FALSE;
 
     StatusKey = __DriverGetStatusKey();
@@ -180,7 +193,6 @@ DriverUnload(
          MONTH,
          YEAR);
 
-done:
     __DriverSetDriverObject(NULL);
 
     ASSERT(IsZeroMemory(&Driver, sizeof (XENVIF_DRIVER)));
@@ -284,9 +296,6 @@ DriverEntry(
 
     __DriverSetDriverObject(DriverObject);
 
-    if (*InitSafeBootMode > 0)
-        goto done;
-
     Driver.DriverObject->DriverUnload = DriverUnload;
 
     Info("XENVIF %d.%d.%d (%d) (%02d.%02d.%04d)\n",
@@ -334,7 +343,6 @@ DriverEntry(
         DriverObject->MajorFunction[Index] = Dispatch;
     }
 
-done:
     Trace("<====\n");
 
     return STATUS_SUCCESS;
diff --git a/src/xenvif/driver.h b/src/xenvif/driver.h
index 53b85af..ec23933 100644
--- a/src/xenvif/driver.h
+++ b/src/xenvif/driver.h
@@ -32,6 +32,11 @@
 #ifndef _XENVIF_DRIVER_H
 #define _XENVIF_DRIVER_H
 
+extern BOOLEAN
+DriverSafeMode(
+    VOID
+    );
+
 extern PDRIVER_OBJECT
 DriverGetDriverObject(
     VOID
diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index bda8925..418c161 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -1199,17 +1199,20 @@ PdoStartDevice(
 
     PdoUnplugRequest(Pdo, TRUE);
 
+    if (DriverSafeMode())
+        goto fail2;
+
     status = RegistryOpenSoftwareKey(__PdoGetDeviceObject(Pdo),
                                      KEY_ALL_ACCESS,
                                      &SoftwareKey);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail3;
 
     status = RegistryOpenHardwareKey(__PdoGetDeviceObject(Pdo),
                                      KEY_ALL_ACCESS,
                                      &HardwareKey);
     if (!NT_SUCCESS(status))
-        goto fail3;
+        goto fail4;
 
     (VOID) PdoSetFriendlyName(Pdo,
                               SoftwareKey,
@@ -1217,23 +1220,23 @@ PdoStartDevice(
 
     status = __PdoSetCurrentAddress(Pdo, SoftwareKey);
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail5;
 
     status = LinkGetRoutineAddress("netio.sys",
                                    "GetIfTable2",
                                    (PVOID *)&__GetIfTable2);
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     status = LinkGetRoutineAddress("netio.sys",
                                    "FreeMibTable",
                                    (PVOID *)&__FreeMibTable);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail7;
 
     status = __GetIfTable2(&Table);
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail8;
 
     //
     // Look for a network interface with the same permanent address
@@ -1259,7 +1262,7 @@ PdoStartDevice(
             continue;
 
         status = STATUS_UNSUCCESSFUL;
-        goto fail8;
+        goto fail9;
     }
 
     //
@@ -1287,7 +1290,7 @@ PdoStartDevice(
 
     status = PdoD3ToD0(Pdo);
     if (!NT_SUCCESS(status))
-        goto fail9;
+        goto fail10;
 
     __PdoSetDevicePnpState(Pdo, Started);
 
@@ -1300,15 +1303,15 @@ PdoStartDevice(
 
     return STATUS_SUCCESS;
 
-fail9:
-    Error("fail9\n");
+fail10:
+    Error("fail10\n");
 
     __FreeMibTable(Table);
 
     goto fail6;
 
-fail8:
-    Error("fail8\n");
+fail9:
+    Error("fail9\n");
 
     (VOID) SettingsSave(SoftwareKey,
                         Row->Alias,
@@ -1319,27 +1322,30 @@ fail8:
     DriverRequestReboot();
     __FreeMibTable(Table);
 
+fail8:
+    Error("fail8\n");
+
 fail7:
     Error("fail7\n");
 
 fail6:
     Error("fail6\n");
 
+    RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+
 fail5:
     Error("fail5\n");
 
-    RtlZeroMemory(&Pdo->CurrentAddress, sizeof (ETHERNET_ADDRESS));
+    RegistryCloseKey(HardwareKey);
 
 fail4:
     Error("fail4\n");
 
-    RegistryCloseKey(HardwareKey);
+    RegistryCloseKey(SoftwareKey);
 
 fail3:
     Error("fail3\n");
 
-    RegistryCloseKey(SoftwareKey);
-
 fail2:
     Error("fail2\n");
 
-- 
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®.