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

[PATCH] xenfilt: Complete enumeration for empty BusRelations


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jiaqing Zhao <Zhao.Jiaqing@xxxxxxx>
  • Date: Tue, 24 Nov 2026 16:15:15 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YajWnb1y44/BmJeysZl1+bBJHvsKcSwdVpjHDCcEEhg=; b=A+E05GEBNpbIwX0eYyylGWOGFB+sg1xjHDufcjg7O/FEK1mqJZ4ylA7Wu3Q0+FeacKUtTnoAUbqm8zJYmETaRiY7DLE032xyT5FdFtifsWv640RDXvz6gr9n5Mye9F7NxDnhUMpAGKJhhFBaZFL1f/InoRwQeN7KLzejnVLHOK61YCRZHBpXQ9wYAe0MIcnhH6UqJIPqnDr2O2zEfT54K1djZoc5nq8ZlFbUo3xYTLzLvlsJnopHsiJGiFLI60l0g/3Pj36MpOk331aq6OS/b5akXxsRQsLua2wCbghQWrTVcIaMVDPjCVnpf7vKwcoxkXh6EF7tBpfdwaY9QOWErQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6j8TErzF5xaGFhaTsx3P4HGRIaDXMsvhlggbuaxWJvhVkAaBe9UUy5gt5pnJoHoH5yK/6SodlaMDBXZwPeP9XjpPYi63HUi04VsssNcLOfdHcvUbVr7RHT+zsqxjFvGb2JVt04+knWAokmCSIIiVjYWANva2mCc8kP2l+vYAYRLX55PlERmbIxU3FKSogL5/e2zdl1jVzpYeOWJ6jEMi/iBSlCK+oFJYikpOF78jCIyeOY/7q4LA+iX6Vh85h+WiGX0AhexJztIXUagCkhOdOMerbVToEo5s/0C+SuHeL1+MAEnU05DzmEyOkgAC92l2RQCAGuBWmH+ttyvOVB1Yw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Jiaqing Zhao <Zhao.Jiaqing@xxxxxxx>, Owen Smith <owen.smith@xxxxxxxxxx>, Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Delivery-date: Tue, 24 Nov 2026 09:33:40 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

A successful BusRelations query may return no PDOs if no device is
present on that bus. Skipping FdoEnumerate() in that case leaves the
XenFilt FDO marked as not enumerated, so the filter state never moves
from XENFILT_FILTER_ENABLED to PENDING. On an HVM guest with a PV disk
and a CD-ROM on secondary IDE channel (leaving the primary channel
empty), this blocks XenVbd and the guest fails to boot.

Always call FdoEnumerate() so that tracked PDOs are reconciled and the
FDO is marked enumerated even when the bus is empty.

Signed-off-by: Jiaqing Zhao <Zhao.Jiaqing@xxxxxxx>
---
Cc: Owen Smith <owen.smith@xxxxxxxxxx>
Cc: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 src/xenfilt/fdo.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/xenfilt/fdo.c b/src/xenfilt/fdo.c
index 04427bf..c8d98c6 100644
--- a/src/xenfilt/fdo.c
+++ b/src/xenfilt/fdo.c
@@ -409,17 +409,20 @@ FdoEnumerate(
     NTSTATUS                status;
 
     Count = Relations->Count;
-    ASSERT(Count != 0);
+    PhysicalDeviceObject = NULL;
+    if (Count != 0) {
+        PhysicalDeviceObject = __FdoAllocate(sizeof (PDEVICE_OBJECT) * Count);
 
-    PhysicalDeviceObject = __FdoAllocate(sizeof (PDEVICE_OBJECT) * Count);
-
-    status = STATUS_NO_MEMORY;
-    if (PhysicalDeviceObject == NULL)
-        goto fail1;
+        status = STATUS_NO_MEMORY;
+        if (PhysicalDeviceObject == NULL)
+            goto fail1;
 
-    RtlCopyMemory(PhysicalDeviceObject,
-                  Relations->Objects,
-                  sizeof (PDEVICE_OBJECT) * Count);
+        RtlCopyMemory(PhysicalDeviceObject,
+                      Relations->Objects,
+                      sizeof (PDEVICE_OBJECT) * Count);
+    } else {
+        Info("%s: Enumerated empty BusRelations\n", __FdoGetName(Fdo));
+    }
 
     // Remove any PDOs that do not appear in the device list
     ListEntry = Fdo->List.Flink;
@@ -498,7 +501,8 @@ FdoEnumerate(
 
     __FdoSetEnumerated(Fdo);
 
-    __FdoFree(PhysicalDeviceObject);
+    if (PhysicalDeviceObject != NULL)
+        __FdoFree(PhysicalDeviceObject);
     return;
 
 fail1:
@@ -942,10 +946,10 @@ FdoQueryDeviceRelations(
 
     Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
 
-    if (Relations->Count != 0)
-        FdoEnumerate(Fdo, Relations);
+    FdoEnumerate(Fdo, Relations);
 
     ExFreePool(Relations);
+    Irp->IoStatus.Information = 0;
 
     State = DriverGetFilterState();
     Count = 0;
-- 
2.53.0




 


Rackspace

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