]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Only veto PDO start when InitSafeBootMode is set
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 1 Mar 2016 17:22:00 +0000 (17:22 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 1 Mar 2016 17:22:00 +0000 (17:22 +0000)
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@citrix.com>
src/xenvif/driver.c
src/xenvif/driver.h
src/xenvif/pdo.c

index f8a8777a86cf075712a318761522ffb62378465e..4b1e5385dd63af1a2c14db3d8dba181d509fe421 100644 (file)
@@ -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;
index 53b85af9f7fe45dda7e8840f28e47af9a7f15c61..ec23933da84aab9a6f87236d4f6696c065265ee5 100644 (file)
 #ifndef _XENVIF_DRIVER_H
 #define _XENVIF_DRIVER_H
 
+extern BOOLEAN
+DriverSafeMode(
+    VOID
+    );
+
 extern PDRIVER_OBJECT
 DriverGetDriverObject(
     VOID
index bda8925bcc3cfeb5ca640e48ec04b305b3a0359c..418c16198ee361ec28410be1cc63ca92bd69c227 100644 (file)
@@ -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");