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

[PATCH] Correct return codes during racy destruction (2).


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Martin Harvey <Martin.Harvey@xxxxxxxxxx>
  • Date: Tue, 8 Nov 2022 10:58:37 +0000
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Martin Harvey <Martin.Harvey@xxxxxxxxxx>, Martin Harvey <martin.harvey@xxxxxxxxxx>
  • Delivery-date: Tue, 08 Nov 2022 10:58:54 +0000
  • Ironport-data: A9a23:H/hXNK1N+gY6wkRp3/bD5Ytxkn2cJEfYwER7XKvMYLTBsI5bpzJVz jAZWD/VafmJYWSmKYsnO4iz8UoBsZ6DzNZiSgZupC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK5ULSfUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS9nuDgNyo4GlC5wVmNagS1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfDE8Tx 78JMDs2Pj+in/CI3ayfU81RmZF2RCXrFNt3VnBIyDjYCbAtQIzZQrWM7thdtNsyrpkQR7CEP ZNfMGcxKkSbC/FMEg5/5JYWme6ymnj5NT1RskyYtII84nTJzRw327/oWDbQUozWFZ0LxxvCz o7A1zj8HjVFFN3H9QOm/XCmgs/+wHzWXLtHQdVU8dY12QbOlwT/EiY+Slq95OGnz0KzRd9bA 0gV4TY167g/8lSxSdvwVAH+p2SL1iPwQPIJTbd8slvUjPOJvUDJXQDoUwKtdvQrmpIEBi0y3 WTZsPLxFwJyrpmMbU+Co+L8QSyJBQAZKmoLZCkhRAQD4sX+rIxbsi8jXuqPA4bu0ISrRGiYL ySi6XFn2u5N1ZJjO7CTpwivvt66mnTeoufZDC3zV3nt0A52bZXNi2eAuQmCtqYowGp0ozC8U Jk4dyq2tr5m4XKlznblrAAx8FaBtp643MX02wIHInXY323FFr7KVdk4DMtCDEloKN0YXjTif VXevwhcjLcKYiX1PfMpOtrpUZp6pUQFKTgCfqmKBuein7ArLFPXlM2QTRL4M5/RfLgEzvhkZ MbznTeEBncGE6V3pAdatM9EuYLGB0kWmwvueHwM50/+gOLDOCbMEe1t3ZnnRrlR0Z5oaT79q 753X/ZmAT0DOAEiSkE7KbIuEG0=
  • Ironport-hdrordr: A9a23:d71xAauOaZv2TbTKe7UjDFgb7skDfNV00zEX/kB9WHVpmszxra +TdZMgpHrJYVcqKRYdcL+7WZVoLUmwyXcX2/hyAV7BZmnbUQKTRekIh7cKqweQfxEWndQy6U 4PScRD4aXLfDtHsfo=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>
---
 src/xenbus/driver.c  | 12 ++++++++++++
 src/xenfilt/driver.c | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index e07de55..cd03fce 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -760,8 +760,20 @@ DriverDispatch(
     ASSERT3P(Dx->DeviceObject, ==, DeviceObject);
 
     if (Dx->DevicePnpState == Deleted) {
+        PIO_STACK_LOCATION StackLocation = IoGetCurrentIrpStackLocation(Irp);
+        UCHAR MajorFunction = StackLocation->MajorFunction;
+        UCHAR MinorFunction = StackLocation->MinorFunction;
         status = STATUS_NO_SUCH_DEVICE;
 
+        if (MajorFunction == IRP_MJ_PNP) {
+            if ((MinorFunction == IRP_MN_SURPRISE_REMOVAL) ||
+               (MinorFunction == IRP_MN_REMOVE_DEVICE)) {
+                /* FDO and PDO deletions can block after being marked deleted, 
but before IoDeleteDevice */
+                status = STATUS_SUCCESS;
+            }
+            ASSERT((MinorFunction != IRP_MN_CANCEL_REMOVE_DEVICE) && 
(MinorFunction != IRP_MN_CANCEL_STOP_DEVICE));
+        }
+
         Irp->IoStatus.Status = status;
         IoCompleteRequest(Irp, IO_NO_INCREMENT);
         goto done;
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 8a8396e..6e00485 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -862,8 +862,20 @@ DriverDispatch(
     ASSERT3P(Dx->DeviceObject, ==, DeviceObject);
 
     if (Dx->DevicePnpState == Deleted) {
+        PIO_STACK_LOCATION StackLocation = IoGetCurrentIrpStackLocation(Irp);
+        UCHAR MajorFunction = StackLocation->MajorFunction;
+        UCHAR MinorFunction = StackLocation->MinorFunction;
         status = STATUS_NO_SUCH_DEVICE;
 
+        if (MajorFunction == IRP_MJ_PNP) {
+            if ((MinorFunction == IRP_MN_SURPRISE_REMOVAL) ||
+               (MinorFunction == IRP_MN_REMOVE_DEVICE)) {
+                /* FDO and PDO deletions can block after being marked deleted, 
but before IoDeleteDevice */
+                status = STATUS_SUCCESS;
+            }
+            ASSERT((MinorFunction != IRP_MN_CANCEL_REMOVE_DEVICE) && 
(MinorFunction != IRP_MN_CANCEL_STOP_DEVICE));
+        }
+
         Irp->IoStatus.Status = status;
         IoCompleteRequest(Irp, IO_NO_INCREMENT);
         goto done;
-- 
2.25.0.windows.1




 


Rackspace

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