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

Re: [PATCH v2] Call EvtchnUnmask within the BlkifRing lock


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 13 Apr 2026 10:41:01 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • 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=SQHbyCwYZITgMCypobwDSzc7muZ9WSntCYzZhMn2lio=; b=zUaZHqZ6OIleDjsqr0j6HBChUqTnkP2AYJHVuHhXdA2nggg7BQo0GDfDua7jVcLplWqApcn0AHYUVmaLyCEKY4BGMxdwV2+USgDVrUMcG7Qt5ORFLpo4mlZQCLLa163fqbOyVxIMPTUgXNpY0LNDeD9IquvAyy5EpMcl4AqRy5QmAa1ncCH89mffBNiWcyaWvEZBULDwlHu5Ux7aBaAIaMz2/PvNsgG3fkVuYdJRxdiNBL9rkOApwHdT55OUEp23rCY9/4JcQr5saHIOCUy88Bm9T79BevUdXUD2dwmpuPEAW1a9WibHVe/SHrbKHn5GF4xqB7JcZ2m0N/lpsYZqMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ga72El2UJX20Bo0Xh9S3ETBYqXtw0Kb/Qj7W44zgMhmpTf9qofna8tioR/UliwqQX1UKl4BqM7lFgc4kVqftNpTSnaWexVHUwfiKqxjp7fipPfcncrKOAjpYGEZ1z1lakkFf7dUiosxey8gCsQjTc/YlGm0ywlRVraAPHourjRZFyWhG/nDl+HB3FvzY0WeIYiNlUJntmCHL1Iy7AyiBjIRHBlyA2dTjo6r735V1i919Aj7sjhSbx8GUjR+mxicxLNZxeqsctcjh33dwRmpBn21ghM8nuFIxw9jA24l1ZzWmWiJ9SN6Bq88Y4XSqvpSIzGuzr3lk6JRztX4xfdfQSg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Mon, 13 Apr 2026 10:41:08 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHcwB/BRos8PQKdQUCVagRUGwN05LXc47Wx
  • Thread-topic: [PATCH v2] Call EvtchnUnmask within the BlkifRing lock

Reviewed-by: Owen Smith <owen.smith@xxxxxxxxxx>

________________________________________
From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
Sent: 30 March 2026 9:32 AM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Cc: Tu Dinh; Owen Smith
Subject: [PATCH v2] Call EvtchnUnmask within the BlkifRing lock

The call to EvtchnUnmask accesses Channel outside of the blkif ring
lock. Therefore, it can access a stale channel if the DPC is still
running after the channel has been closed in BlkifRingDisconnect. Since
BlkifRingDisconnect runs at DISPATCH_LEVEL, we cannot use
KeFlushQueuedDpcs and have to guard against the event channel's closure
via the Enabled flag instead.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
v2: Invert the check conditions before calling EvtchnUnmask
---
 src/xenvbd/ring.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 50f8d58..af8a2fc 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1612,18 +1612,21 @@ BlkifRingDpc(
         KeRaiseIrql(DISPATCH_LEVEL, &Irql);
         __BlkifRingAcquireLock(BlkifRing);
         Retry = BlkifRingPoll(BlkifRing);
+
+        if (!Retry && BlkifRing->Enabled) {
+            (VOID) XENBUS_EVTCHN(Unmask,
+                                 &Ring->EvtchnInterface,
+                                 BlkifRing->Channel,
+                                 FALSE,
+                                 TRUE);
+        }
+
         __BlkifRingReleaseLock(BlkifRing);
         KeLowerIrql(Irql);

         if (!Retry)
             break;
     }
-
-    XENBUS_EVTCHN(Unmask,
-                  &Ring->EvtchnInterface,
-                  BlkifRing->Channel,
-                  FALSE,
-                  TRUE);
 }

 #define TIME_US(_us)        ((_us) * 10)
--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

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