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

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


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Martin Harvey <Martin.Harvey@xxxxxxxxxx>
  • Date: Mon, 14 Nov 2022 11:36:25 +0000
  • Authentication-results: esa4.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: Mon, 14 Nov 2022 11:36:44 +0000
  • Ironport-data: A9a23:DfAOQqI7Og+UNP8gFE+RiZUlxSXFcZb7ZxGr2PjKsXjdYENSgj0Ax jBMXWmDa6zZZGameI10bNjj9UoDusTRztBkG1dlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPdwP9TlK6q4mlB5wViPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5IIlF+s t4YFwsJTRuZo/qP2ZOqVrFj05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpPE+ojx5nYz/7DLo7lf20h3+5czRCtl+EjaE2/3LS3Ep6172F3N/9KoPQFJkOzxfwS mTu5GT1OhREMuWmjnm1/C2plrGWvCjWYddHfFG/3qEz2wDCroAJMzUJVF3+uef8hkOgVtZ3L 00P5jFovaU07FasTNT2Q1u/unHsg/IHc4MOSatgsljLk/eKpVbCboQZctJfQOMFhP9xZzwV7 VuqlMnNHQV2kayJEX3Io994sgiOESQSKGYDYwoNQg0E/8TvrekPs/7fcjpwOPXr14OoQFkc1 xjP9XFj3OtL0abnwo3hpTj6bySQSo8lp+LfziHeRSqb4wxwf+ZJjKT4uAGAvZ6swGt0J2RtX UToeeDEvYji7rnXzkRhpdnh+5n3j8tpyBWG3TZS82AJrlxAOxeLJOi8Gg1WKkZzKdojcjT0e kLVsg45zMYNYivxM/MrPd7qU5VCIU3c+TPND628UzazSsIpKF/vEN9GOCZ8IFwBYGBzyPpia P93gO6nDGoACLQP8dZFb7517FLqrwhgrV7uqWfTlE73jODEPi7IFd/o8jKmN4gE0U9Nmy2Nm /43CidA4083vDHWCsUPzbMuEA==
  • Ironport-hdrordr: A9a23:aT8/c6zfBc9NRwZnaFsdKrPwJr1zdoMgy1knxilNoRw8SKOlfq eV7ZEmPH7P+VEssR4b+OxoVJPsfZq+z+8W3WByB9eftWDd0QPCRr2KhbGSpwEIcBeRygcy78 tdmtBFeb7NMWQ=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Errors in PnP retun codes found when testing under driver
verifier with mixed VM lifecycle operations. Under some
rare cases, it is possible to get more than one PnP
"remove like" operation. This results in a PnP remove
operation being processed whilst the device is already
in the deleted state.

This patch fixes the immediate cause of the bugfixes,
buy fixing the return code. Device destruction is
unchanged. Investigation into the root cause is still
ongoing.

Signed-off-by: Martin Harvey <martin.harvey@xxxxxxxxxx>
---
 src/xendisk/driver.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/xendisk/driver.c b/src/xendisk/driver.c
index 4b004c5..c165c90 100644
--- a/src/xendisk/driver.c
+++ b/src/xendisk/driver.c
@@ -170,8 +170,20 @@ Dispatch(
     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®.