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

[PATCH 1/2] Avoid potential race with FiltersInstall


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 28 Jun 2021 13:58:38 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Mon, 28 Jun 2021 12:58:50 +0000
  • Ironport-hdrordr: A9a23:aU3u6agPBQXuxBxSl+oViJ/a1nBQXhsji2hC6mlwRA09TyXBrb HNoB1p726QtN9xYgBZpTnuAsm9qB/nmKKdgrNhRotKPjOW21dARbsKheCJ/9SKIULDH5tmtJ uIBJIRNDSfNzRHZRqT2njDLz9q+qjizEnhv5a48159CQVxL61w5QZwDQiWVkd/QQVACJIjUI CR/cpKvX6hfm4LZsOwCj0EUoH41rv2fbzdEGc7OyI=
  • Ironport-sdr: 5BRhEq6pJ908TG7HHuGOYUiqcH3MwCZwxLjTy/QTHn07+sx2UsJhxPhRWYTy+7COyF9D4xiQjJ TjjJbiZzVs5qcIDFazeuxoh3O6Cw0d2WVBio9OlaCWjEPTpnNULgDVGAjQELruIK6XGV6MfKy+ Utc+hGKcEC6spssoqsrzkB7bUsDdBv0Ve5dMEpPxzXCX2Q7TdS5ubcXeStoxHGV9KiiQJcG87w Or1Ss5MXZiMffQmi42JCUYcSbOKkgqYYCqJKVlUR20id79lup1EklA5azSY6jmk5wluCGS3iLy eY8=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Is certain situations, a race between XENFILT and XENBUS can lead to XENFILT
not being loaded on the root PCI device node. This is due to XENBUS!DriverEntry
removing the registry value just before the PnP manager determines what filters
to load, and fails to load XENFILT on the root PCI node. This leads to XENBUS
being unable to determine the correct ActiveDevice. Without an ActiveDevice,
no Unplugs are issued, and emulated devices are used for boot, leading to a
reboot prompt before XENVBD can be used as the boot device. The race appears to
be reliable once triggered, and a reboot will follow the same sequence. This
appears to be caused by OS upgrades which affect the order the PnP manager
starts different driver stacks.

This contains a reversion to 9d28a9e9b79, which fixed an upgrade issue that
triggered multiple reboot requirements to reload XENFILT correctly.
If an incompatibility is detected, which can be resolved by a reboot to
complete the driver installation, XENFILT is inserted into the UpperFilters so
that XENFILT is loaded on this reboot. This avoids requiring a second reboot so
that XENFILT can load and determine the ActiveDevice.

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

diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index 1b621fa..067bb68 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,17 @@ DriverEntry(
                       MICRO_VERSION,
                       BUILD_NUMBER);
     if (!NT_SUCCESS(status)) {
-        if (status == STATUS_INCOMPATIBLE_DRIVER_BLOCKED)
+        if (status == STATUS_INCOMPATIBLE_DRIVER_BLOCKED) {
+            // XenBus.sys is not the same version as Xen.sys
+            // Insert XenFilt to avoid a 2nd reboot in upgrade cases, as 
AddDevice
+            // will not be called to insert XenFilt.
+            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®.