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

[PATCH v2 00/10] Defer completion and ring destruction until backend grant release


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Date: Wed, 28 Oct 2026 18:16:29 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Feedback-ID"
  • Cc: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
  • Delivery-date: Wed, 28 Oct 2026 17:16:40 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

When a backend is accessing a grant entry, it'll set the GTF_reading|
GTF_writing bits on that entry. RevokeForeignAccess will fail as long as
these bits are still set.

WinPV drivers assume that you can ignore RevokeForeignAccess failures
after a certain number of retries. This is unfortunately not the case,
as backends can still access the grants and corrupt things. We've
observed data corruption that we suspect as being caused by this issue.

This series converts RevokeForeignAccess into a fallible call named
TryRevokeForeignAccess, and fixes the problem by deferring request
completion and ring destruction until after the corresponding grants
have been released by the backend.

It has undergone testing using a harness for suspending I/O handling at
critical points, and showed no deadlock or data corruption when the
associated issues in tapdisk are fixed.

This is the first series of fix for a class of similar issues. Further
fixes will be needed in other drivers using the grant interface (esp.
XenVif, XenIface); there are also other issues that have not been
discussed in this series.

Changes in V2:
* Rename RevokeForeignAccess in GNTTAB V5 to TryRevokeForeignAccess
* Fix a deadlock during RingD0ToD3 (see the "ring: Defer destruction
  until backend grant release" commit for more details)
* Add a fix for a C6387 warning in BlkifRing

Tu Dinh (10):
  ring: Fix warning C6387: 'BlkifRing' could be '0'
  granter: Correct the accounting of Current
  Use GNTTAB_INTERFACE_V5
  frontend: Initialize the granter before the ring
  granter: Split GranterTryPut to its own function
  granter: Decouple cache lifetime from Connected
  granter: Introduce GranterD0ToD3/D3ToD0
  ring: Introduce RingD3ToD0/RingD0ToD3
  ring: Defer destruction until backend grant release
  ring: Defer request completion until backend grant release

 include/gnttab_interface.h | 116 ++++--
 src/xenvbd.inf             |   6 +-
 src/xenvbd/frontend.c      |  63 ++--
 src/xenvbd/frontend.h      |   4 +-
 src/xenvbd/granter.c       | 177 +++++++---
 src/xenvbd/granter.h       |  17 +-
 src/xenvbd/ring.c          | 707 ++++++++++++++++++++++++++++++-------
 src/xenvbd/ring.h          |  13 +
 8 files changed, 867 insertions(+), 236 deletions(-)

-- 
2.56.0.windows.4



--
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®.