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

[PATCH] Correct return codes during racy destruction.


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Martin Harvey <Martin.Harvey@xxxxxxxxxx>
  • Date: Tue, 8 Nov 2022 10:41:16 +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:41:42 +0000
  • Ironport-data: A9a23:kvfNo6B4Q1dSWBVW/3Hjw5YqxClBgxIJ4kV8jS/XYbTApDN30TdWy WQbWG7QM/yCMWbxLtwlad+2oRgE7cPdmNdlQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nNHuCnYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFtcpvlDs15K6o4WpA7gRnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw3PYqX11jq MMkDBcCb0m539qnnL+hRbw57igjBJGD0II3v3hhyXfSDOo8QICFSKLPjTNa9G5u3IYUR6+YP pdHL2o0BPjDS0Qn1lM/DZskgOauwHn2aSNVuXqepLYt4niVxwt0uFToGIqJKoTXH5oK9qqej nmcxEryXU4DCO3B6ifZ/Wvvr+XsjTyuDer+E5Xnr6U30TV/3Fc7FxwQEEOl5PW0lEO6c9ZeM FAPvDojq7Ao806mRcW7WAe3yENopTZFBYAWSbdjrljQlOyEuG51G1ToUBZneIF4iOJregAO8 VCIxumxPS0zvaeaHCf1GqivkRu+Pi0cLGknbCACTBcY79SLnLzfni4jXf44Tvfr04Sd9SXYh mnT8XNg3+l7Ydsjjf3TwLzRv967SnElpCYR7x6fYG+q5xgRiGWNN93xsgizARqtwe+kori9U JoswZb2AAMmV8vleMmxrAIlTdmUCw6tamG0vLKWN8BJGvTE0yfLkXpsyD9/Plx1Fc0PZCXkZ kTe0SsIusEMbCf0NPcvOdzhYyjP8UQHPY27Ps04k/IUOsQhHON51H0GibGsM5DFzxF3zPBX1 WazesewF3cKYZmLPxLvL9rwENYDmEgD+I8kbcuinkz6jeLHPCT9pHVsGALmU93VJZis+G39m +uz/ePTo/mDeIUSuhXqzLM=
  • Ironport-hdrordr: A9a23:x/jR1qspAkKDYsUABX0tFM//7skDetV00zEX/kB9WHVpmszxra 6TdZMgpHvJYVcqKRcdcL+7WJVoLUmxyXcX2/h1AV7BZniEhILAFugLhuGO/9SJIVyYygc378 ZdmsZFZ+EYdWIK7/rH3A==
  • 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/xenbus/fdo.c     |  2 +-
 src/xenbus/pdo.c     |  2 +-
 src/xenfilt/driver.c | 12 ++++++++++++
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index e07de55..167dd22 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;
+            }
+            BUG_ON((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/xenbus/fdo.c b/src/xenbus/fdo.c
index d08c518..4242f07 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -4708,7 +4708,7 @@ FdoDispatchPnp(
           MinorFunction, 
           PnpMinorFunctionName(MinorFunction)); 
 
-    switch (StackLocation->MinorFunction) {
+    switch (MinorFunction) {
     case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
         status = FdoFilterResourceRequirements(Fdo, Irp);
         break;
diff --git a/src/xenbus/pdo.c b/src/xenbus/pdo.c
index efd29dc..fe88d5d 100644
--- a/src/xenbus/pdo.c
+++ b/src/xenbus/pdo.c
@@ -1609,7 +1609,7 @@ PdoDispatchPnp(
           MinorFunction, 
           PnpMinorFunctionName(MinorFunction));
 
-    switch (StackLocation->MinorFunction) {
+    switch (MinorFunction) {
     case IRP_MN_START_DEVICE:
         status = PdoStartDevice(Pdo, Irp);
         break;
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 8a8396e..894fd24 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;
+            }
+            BUG_ON((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®.