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

[PATCH 6/6] Dont always remove XenFilt from UpperFilters


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Thu, 17 Jun 2021 13:33:56 +0100
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Thu, 17 Jun 2021 12:34:30 +0000
  • Ironport-hdrordr: A9a23:iEUyWqye2XZKjvHyUxMHKrPwKr1zdoMgy1knxilNoRw8SKOlfq eV7ZMmPH7P+U8ssR4b+OxoVJPsfZqYz+8W3WBzB8bHYOCFgguVxehZhOOIqQEIWReOk9K1vZ 0QFZSWY+efMbEVt6rHCXGDYrUd/OU=
  • Ironport-sdr: 6W9D32Qk6E6MJOBB33sL7FpKy69THOag0pdo05xHss6djU19SZhb0qi20Ek+DMGA6Fz757Fs9e +pMSJnDz0MSLBa8B81IJH5eM4QJkrhd9PUrL0In0aVG37JVM2xao/wlWv4Uc8F4Zu/MAlKSoVa 6zK3bXx2AKPQR3QhEawKgUnpxMcfMTeZgWl3K4N6OM1tcXpI1qLO4aWFfwpB4k0uqTnduALXzG k6e7IFOYItdbmyltNVEmuyn0qxY/cBXfrNeBarh/QEYMU2lyp8krXlKBT64fCMFcIVWahsn1nd U/I=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

There is a race which can prevent XenFilt from having AddDevice
correctly called on some devices. This seems to happen more frequently
after driver upgrades.
It seems this is due to XenBus!DriverEntry removing XenFilt before
XenBus!AddDevice inserts XenFilt into the UpperFilters value. In this
gap, PnP manager can sample the UpperFilters key and fail to bind
XenFilt to the required device stacks. This leads to XenFilt failing
to determine the active device, which prevents the device unplugs
from occuring, leading to a constant cycle of reboot prompts from
xenbus_monitor.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenbus/driver.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index 1b621fa..e66bf45 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -296,6 +296,9 @@ DriverRemoveFunctionDeviceObject(
     RemoveEntryList(&Dx->ListEntry);
     ASSERT3U(Driver.References, !=, 0);
     References = --Driver.References;
+
+    if (References == 1)
+        FiltersUninstall();
 }
 
 //
@@ -859,16 +862,15 @@ DriverEntry(
                       MICRO_VERSION,
                       BUILD_NUMBER);
     if (!NT_SUCCESS(status)) {
-        if (status == STATUS_INCOMPATIBLE_DRIVER_BLOCKED)
+        if (status == STATUS_INCOMPATIBLE_DRIVER_BLOCKED) {
+            // Re-instate XenFilt to avoid a second required reboot
+            FiltersInstall();
             __DriverRequestReboot();
+        }
 
         goto done;
     }
 
-    // Remove the filters from the registry. They will be re-instated by
-    // the first successful AddDevice.
-    FiltersUninstall();
-
     DriverObject->DriverExtension->AddDevice = DriverAddDevice;
 
     for (Index = 0; Index <= IRP_MJ_MAXIMUM_FUNCTION; Index++) {
-- 
2.31.1.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.