From win-pv-devel-bounces@lists.xenproject.org Tue Apr 07 08:19:09 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 07 Apr 2026 08:19:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1274535.1560621 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wA1eO-0005Mh-NW; Tue, 07 Apr 2026 08:19:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1274535.1560621; Tue, 07 Apr 2026 08:19:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wA1eO-0005Ma-Kx; Tue, 07 Apr 2026 08:19:08 +0000
Received: by outflank-mailman (input) for mailman id 1274535;
 Tue, 07 Apr 2026 08:19:07 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69d4bdf8.v1-231cc2aaaa3b453cb6053d39cbb1c99e@bounce.vates.tech>)
 id 1wA1eN-0005MU-3U
 for win-pv-devel@lists.xenproject.org; Tue, 07 Apr 2026 08:19:07 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wA1eM-005hKc-41
 for win-pv-devel@lists.xenproject.org; Tue, 07 Apr 2026 10:19:06 +0200
Received: from [10.42.69.1] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69d4bdf8.v1-231cc2aaaa3b453cb6053d39cbb1c99e@bounce.vates.tech>)
 id 69d4bdf6-5cb7-0a2a0a5109dd-0a2a4501a4c4-26
 for <win-pv-devel@lists.xenproject.org>; Tue, 07 Apr 2026 10:19:06 +0200
Received: from [198.2.136.16] (helo=mail136-16.atl41.mandrillapp.com)
 by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69d4bdf8.v1-231cc2aaaa3b453cb6053d39cbb1c99e@bounce.vates.tech>)
 id 69d4bdf8-6fc9-0a2a45010019-c6028810d95e-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 07 Apr 2026 10:19:05 +0200
Received: from pmta11.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1])
 by mail136-16.atl41.mandrillapp.com (Mailchimp) with ESMTP id
 4fqfHD46LZz8XRqX2
 for <win-pv-devel@lists.xenproject.org>; Tue,  7 Apr 2026 08:19:04 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 231cc2aaaa3b453cb6053d39cbb1c99e; Tue, 07 Apr 2026 08:19:04 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1775549944; x=1775819944;
	bh=/rJOIImRS7oG3+RDkaDW0DqAbE2j+iq1qLsBpp2TxNs=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=bxcjCAPrs8qqqPcfUzIRTZG6muIdTQviTQ033JO4IYZl8Kq4tebvLorvnYaJ9x9Sm
	 YNSHE6wNrqEuzAg9Br2+BK8MBhXlUCdf0LrqlwD2lkLHwcUn1KwmM6YSstcqNg7kHv
	 /dqk4EZ4Io/zwJTZF6/WI32+4Y20K72WLXv/8mhLD6RxPGYvI8smRjYeIZF3rYUHQj
	 5/Zplk2JvD3Y7wroPkarlYOdN/POqbKXcTaxIQSA/gfICT/xwkmGvE4SEUQ2tAOhkf
	 Mo+vPetrHa0QTn7jpJg67rOKfD1ZUrd5a8Ew/ewrqXsgNqpSjkkNKexUTn+vEhztWy
	 5LzZj9d9mtc5g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1775549944; x=1775810444; i=ngoc-tu.dinh@vates.tech;
	bh=/rJOIImRS7oG3+RDkaDW0DqAbE2j+iq1qLsBpp2TxNs=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=X2px/ZyXHsdd7EtQIbDkCwARQTC4QEvdQ1dXwa9nzoWrG/gl/1NWJUUrl3hPlT3o7
	 7L2ydLciMFRR5iJiQ9seGtmiplmncjCrcO4gDo34lGq924rwrENlI5pLvt/aCTLoP6
	 /PasNtgPn0JDRZOhAnw5MinuS6OzOnwCCtsISFCUgQMZy3Ckf0epr9IGzswf2kPbi6
	 lIQSXYy1WlELRzwmxGhRIF4psRk7LKNLCzQnoeMo1JTfKl2Rfn0GObKbV1xeZXJBXS
	 ahoyFwJc8eeUUSKHEhK1ufr/p3UG5HxBNQNjBWaMvRK1b5BCeElNdSvkQj9o++wyMe
	 fmOVs7tKThv1w==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=201/2]=20Unplug:=20Set=20bit=20for=20NVME=20disk=20unplug?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1775549943474
Message-Id: <80edbbca-3ce9-4083-a554-dca3ad2cb9ff@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org, "david ambu" <david.preetham@citrix.com>
References: <20260306160800.774-1-owen.smith@citrix.com>
In-Reply-To: <20260306160800.774-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.231cc2aaaa3b453cb6053d39cbb1c99e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260407:md
Date: Tue, 07 Apr 2026 08:19:04 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-d62444/1775549946-B7AFD185-483949B5/0/0
X-purgate-type: clean
X-purgate-size: 2275

Hello, I'd like to send a reminder for your series.

Patch 1 has received an ack and can be committed.
Patch 2 has a small comment about the removal of xenbus_monitor.dll.

Thanks,

On 06/03/2026 17:08, Owen Smith wrote:
> When issuing a DISK unplug command, set the bits for emulated IDE/SCSI
> and emulated NVME devices.
> 
> Also defines and uses symbols to represent each bit in the unplug protocol.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   src/xen/unplug.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/src/xen/unplug.c b/src/xen/unplug.c
> index 282ed93..3b6593a 100644
> --- a/src/xen/unplug.c
> +++ b/src/xen/unplug.c
> @@ -49,6 +49,12 @@
>   
>   #define UNPLUG_TAG  'LPNU'
>   
> +#define UNPLUG_FLAGS_IDE_SCSI_DISKS   0x0001
> +#define UNPLUG_FLAGS_ALL_NICS         0x0002
> +#define UNPLUG_FLAGS_AUX_IDE_DISKS    0x0004  // ignored if UNPLUG_FLAGS_IDE_SCSI_DISKS is set
> +#define UNPLUG_FLAGS_NVME_DISKS       0x0008
> +#define UNPLUG_FLAGS_ALL_DISKS        (UNPLUG_FLAGS_IDE_SCSI_DISKS | UNPLUG_FLAGS_NVME_DISKS)
> +
>   typedef struct _UNPLUG_DATA {
>       PSTR        Name;
>       BOOLEAN     Found;
> @@ -116,19 +122,19 @@ UnplugDeviceType(
>       case UNPLUG_DISKS:
>           if (Context->BootEmulated) {
>   #pragma prefast(suppress:28138)
> -            WRITE_PORT_USHORT((PUSHORT)0x10, 0x0004);
> +            WRITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_AUX_IDE_DISKS);
>   
>               LogPrintf(LOG_LEVEL_WARNING, "UNPLUG: AUX DISKS\n");
>           } else {
>   #pragma prefast(suppress:28138)
> -            WRITE_PORT_USHORT((PUSHORT)0x10, 0x0001);
> +            WRITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_ALL_DISKS);
>   
>               LogPrintf(LOG_LEVEL_WARNING, "UNPLUG: DISKS\n");
>           }
>           break;
>       case UNPLUG_NICS:
>   #pragma prefast(suppress:28138)
> -        WRITE_PORT_USHORT((PUSHORT)0x10, 0x0002);
> +        WRITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_ALL_NICS);
>   
>           LogPrintf(LOG_LEVEL_WARNING, "UNPLUG: NICS\n");
>           break;



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 07 13:24:18 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 07 Apr 2026 13:24:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1274537.1560942 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wA6Pg-0002DE-Iu; Tue, 07 Apr 2026 13:24:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1274537.1560942; Tue, 07 Apr 2026 13:24:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wA6Pg-0002D7-Fw; Tue, 07 Apr 2026 13:24:16 +0000
Received: by outflank-mailman (input) for mailman id 1274537;
 Tue, 07 Apr 2026 08:32:03 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <david.preetham@citrix.com>) id 1wA1qs-0007bo-Om
 for win-pv-devel@lists.xenproject.org; Tue, 07 Apr 2026 08:32:03 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wA1qr-004Tdx-JR
 for win-pv-devel@lists.xenproject.org; Tue, 07 Apr 2026 10:32:01 +0200
Received: from [10.42.69.6] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <david.preetham@citrix.com>)
 id 69d4c0fa-5cb7-0a2a0a5109dd-0a2a450680b0-28
 for <win-pv-devel@lists.xenproject.org>; Tue, 07 Apr 2026 10:32:01 +0200
Received: from [40.107.200.25]
 (helo=CH5PR02CU005.outbound.protection.outlook.com)
 by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <david.preetham@citrix.com>)
 id 69d4c100-0df0-0a2a45060019-286bc8198333-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 07 Apr 2026 10:32:01 +0200
Received: from IA3PR03MB7740.namprd03.prod.outlook.com (2603:10b6:208:512::11)
 by DS7PR03MB8220.namprd03.prod.outlook.com (2603:10b6:8:263::24) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.19; Tue, 7 Apr
 2026 08:31:57 +0000
Received: from IA3PR03MB7740.namprd03.prod.outlook.com
 ([fe80::c380:74fc:823a:8213]) by IA3PR03MB7740.namprd03.prod.outlook.com
 ([fe80::c380:74fc:823a:8213%5]) with mapi id 15.20.9769.015; Tue, 7 Apr 2026
 08:31:56 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=hLEwvnYSN1oYqgoFKJKv0wT1ZazgOSfLxdpCTUOBY6pcM6P+t0YoljvCa5lYvrvKPBwCEsivfpqwywo/7gFz94dmmYCzcPYg3O86pAVOFhmWMxy2J0gVnF0vpTUxCtc8a7ZVmV77P50hwkziypGVziojY0De/AjB0jXN6jq9HFuOs7+iFDEg1B+J56OvyzzLmVKz/9ieG2HDxrKPkHOsawgrRUjIJxxU03TUwnd62u9Xya4w8kHdhIB2OJLuidkzrxQrjdjWTwyCVth80f1x2ZCm+Ni0YtAKOFySzf1A21f4nzwyWLZS7QRwC9/aBI6X4lmyHjiQNehfswODPcIa8w==
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=HLFrJ0CamuZFkvs+4C1P4GN4Cmg0q24vBUUqEhAQGnE=;
 b=xZzc5WrMKlzyeOctarkudjx3aHvpbLAuJ4sJwRmVvz48jEoFta4twRr9EoV9tiOzZbwKZxvWKLIDmN7GyYT497AN7GOadf4rQvsuqXf4xvdjRZWUsP7PXuiovbUq0W1bxGQ8ZwfEq0zfcO3osxdEbgjziXyHIB9gbbqylpZ0e4cyyc0EZvAa2zXu2Sy9XrN/lsSSQtkM8259wX4S2wFCus7SeBPEEJLtsOanqsL8PXdkrVaP8eW0UFh5OGB44P9WxQ8TxQWvVFf+Hztbf81B6brQsTtoYCv81dzoePfvJlep6Qy6FU4SIL2thPpgcUk+KF3bBmYwpnqFlqDN8X+n5w==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=HLFrJ0CamuZFkvs+4C1P4GN4Cmg0q24vBUUqEhAQGnE=;
 b=WwnhkMDO7ZrQvSmf62brkaGZWQJcHqSYLCH+B81Icu2vChURqJ5xbdGlCzZ98FtslnqpfO1bYWKcLR6k2XseUQAUpMI5Emf8v6r3KUph8WEJs5P9Ke5sEC0T29peFCtNMngs37jWL0x16enf2oKgw/XoHMMd/I9FS4CJr7lzwkE=
From: David ambu <david.preetham@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, Owen Smith <owen.smith@citrix.com>,
	"win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/2] Unplug: Set bit for NVME disk unplug
Thread-Topic: [PATCH 1/2] Unplug: Set bit for NVME disk unplug
Thread-Index: AQHcxmc08XekXB7m6EWtklteHmg/NLXTQ9W/
Date: Tue, 7 Apr 2026 08:31:56 +0000
Message-ID:
 <IA3PR03MB7740DF3AE6D2A65A967EBF35EA5AA@IA3PR03MB7740.namprd03.prod.outlook.com>
References: <20260306160800.774-1-owen.smith@citrix.com>
 <80edbbca-3ce9-4083-a554-dca3ad2cb9ff@vates.tech>
In-Reply-To: <80edbbca-3ce9-4083-a554-dca3ad2cb9ff@vates.tech>
Accept-Language: en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-reactions: allow
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: IA3PR03MB7740:EE_|DS7PR03MB8220:EE_
x-ms-office365-filtering-correlation-id: b286633a-ccab-4b38-d64e-08de94802140
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|366016|1800799024|38070700021|22082099003|13003099007|56012099003|18002099003|8096899003;
x-microsoft-antispam-message-info:
 hiYDAePgpDMFt96zxblibIvKrpfwH6PK2C/wI9aJm03VCLZ5aO47Q0htjQKQriqYR5DZSm2AnSand+fNth6VDtK08/ZgeFyd7XF0ffuog4aAzidoIWFe6ahuSdYQeocA+TzlAupUr3UfFEoHhX11SQ1T3/78E2NqJf7SQdDjihdS6Gfx7T44FDIMxVXGxGZPuaJDoce5/C3v8JpkX75oxja0MXXrh8DiehX7nviJS8ktiwZpNn5GdK+2wKKSoW4ch/3Kx8pvGKImp20NqaIeE5RvM8CJh7lsLMaWSC9wg4zfCODJ6yGlFMRnN6TJG9hdJ6vxBnb0dlELWqChmXTq8D25oVGFbJ1CDBiLZXBACb7lbHd29H42vSIYuJxDO4/p1rfZ6e6IbRG83fZWvEBMK5ICr8lrHL3StWSq79w8Wdn2H6uuXiEr1g8KuLY67DgN4OZrPZaguLLYzox+5z2BBiM+3s0P/m3ZYduvbxckqCOPfo47Wm53+/coBE5kripvSUSWw09wdty8DwG2huwbywaKUYps8v4xOKj6aehJwMK4RDYYA8MPhv4B6FuDfReQfhN67esEHVXhDKQNsP/D8TRJE3GM5BIrvgO92npHzT2e6Wp8DkBV7bmOHG3KiaIn6K4fSVlfvAVOw5aE+Ct5QTsv9tGDXiVrllLlMAdfsbvLyMiLk8ZCen9HOo1ytzTm8eeUTjzmMW96C2ex8wI0uR7pNZOHytKRCLtlLOiXek0=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:IA3PR03MB7740.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021)(22082099003)(13003099007)(56012099003)(18002099003)(8096899003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?Windows-1252?Q?arHNZHEoULGw+7KjhwY6qrDBZJe56at0XItNuagV7810SOdn2Eh1eSzq?=
 =?Windows-1252?Q?/WSrfgtQb597sID+OCipRRJx2JHCVI6xAeeuPiiY4OQMi+6cT30mdpR8?=
 =?Windows-1252?Q?G2KGF44sThViDPsSxtHcoC3lHlKfL64YQNKpbQTZy7lL1axzNc57dZf7?=
 =?Windows-1252?Q?wYGGoNyDJdI8gDBZyTyCTTYbnA27+LN76Se/B3/6vGdH9mWFIJikFI4C?=
 =?Windows-1252?Q?QKIqbCLHkdsUtfnlkISY6DAS/f4hUvtQqtzlqbUIfBfEF+qE4Oynb8y/?=
 =?Windows-1252?Q?VkuljjMc2rZpVEBHSFAz6o6znneBpIC8fhj0pcXuyagc0zA9fRCFUk/p?=
 =?Windows-1252?Q?yVKyg6XBm8zUAAN2+A201BJZEtYCd43HjOVbi2CtxZ4oQvqPe14vU53w?=
 =?Windows-1252?Q?D+/Fv3KgsW18BMBqaxG1kFbFjA1hbYfFzvKEffJX6scCQ//4jANrlt8E?=
 =?Windows-1252?Q?KMgkXUxOKGHsBNljEjgP0oSRLYcZZ5u10zybmCAHvlTYSxWgypdYhoVG?=
 =?Windows-1252?Q?q7CfUC9a4Vtx+YeX/6dP4uFLCB7dnICiLdlWMBiRugyEekYJHZp+DVHI?=
 =?Windows-1252?Q?HRbyTrT29+TsNUHJWmQZMrT04NTtt74eqyROxCrtkfYONVrHDS1Lv0ZJ?=
 =?Windows-1252?Q?k3RKHmVXs4ZtsMI2R9V/bhz1zOtMIqGwA/3WihauYa3mVjtf9BUcXMTy?=
 =?Windows-1252?Q?0WNF3LU4+mW0MqWj+BAfcjn/toZiDVav2bgBNYe+mS73nK6aUJzy0/7n?=
 =?Windows-1252?Q?9YyEb3ehWkMsslM7/pLKAm9kRCyFBruImjuHIgwb4IDDIgjHy64BmAn1?=
 =?Windows-1252?Q?2cms77p565BGqtCJMBzzBi7y04QzyF/ZGqBNNmuxUxe8CjZzR2RenIt5?=
 =?Windows-1252?Q?w78Vq21b4hSJ4r03uYxT/6swDbVOciuMB0S5CYwu3WB1cIzcVYo1SD93?=
 =?Windows-1252?Q?QsFx2EYzNTYqH7PqJfIM/MjgiqlvErsP4iFxm68JMVCOvT7wN0A0PzyN?=
 =?Windows-1252?Q?bmq3pkRfcyr2gl9lRonz0R6xjwbUnIA8KGkaCGx/GSl+i84KNwl03q0r?=
 =?Windows-1252?Q?v0TfWnCWdqeaTevF5ybYe208MuMCKKMu+dQ/9yNvGvI8dM3/cJSFmTB7?=
 =?Windows-1252?Q?jiM2+lXJuhzdScULDVh4c3rgcI1Pr3Lbuep7GEl6DVT++TNkuZjV+0em?=
 =?Windows-1252?Q?ynyG1nb0p19O09kyUUAMqu4OwOt58/vSqkdSGydCJjOlI39eDg0JHJyK?=
 =?Windows-1252?Q?OjbOefEiMDhyGn2xQI2sDUTuovty0OOt33am5g7OWn/2aK0m1tw+D7z1?=
 =?Windows-1252?Q?Gu5nuHgEPmrFWfu+mtbldeOsQQSAptBnPAa/+3eVVlwl4abENOwaEeDF?=
 =?Windows-1252?Q?5SYcwjjRkmo2kQicI+uPBsUI4RgOaId/7zar/xBQ4HFcQba/ugKUfJ4/?=
 =?Windows-1252?Q?ZfBA9Wa0bocunxC38FCZc4zvwu11vtmY84poR9QY/p1KwdM8LITmwsJB?=
 =?Windows-1252?Q?RBxHv+i1xFaanttcI5pNYnooi2C5h8gkrgG14zrWDk/CYE2nKXBzdf7X?=
 =?Windows-1252?Q?SMSyKnqAP0l5V1dbTfL+v4j/aJ7KZ5z9jHIn3NxSE6jwcJvOw2M8GA2b?=
 =?Windows-1252?Q?NCvxduJrIsivMOw/gO1vj6Yhuh2IXk7dw733c6PaS7BF8I57zzNRzUtP?=
 =?Windows-1252?Q?NE/hqj4a8XYJPyirw2hDQVHLELG7Scz+QrHVbycucof15Ry6Vm0pik/T?=
 =?Windows-1252?Q?FPKD3b0pBrQzWcHFy2HenZHEjJa6H7bebTq1tjCWgxQmi6oC07WmD2Uw?=
 =?Windows-1252?Q?jYsX5R/ikE8uwDNuPBZwlg+PPaK+BIr1OQy68hIgsnPFxWaJ+mipcXhG?=
 =?Windows-1252?Q?QCbKJST0qTqj1bB9WZM7wUMmG0pIiLxGNk8=3D?=
Content-Type: multipart/alternative;
	boundary="_000_IA3PR03MB7740DF3AE6D2A65A967EBF35EA5AAIA3PR03MB7740namp_"
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: IA3PR03MB7740.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: b286633a-ccab-4b38-d64e-08de94802140
X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2026 08:31:56.7299
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 7PuFuU/6xqhBcAFBG9Wp+GssNuW0LNSetsN1xvJNrc+SUN+A33YWlyvrUdb4lU5viWLn3b9lbxtH7Ei+fg7LNoZW1SQje6G2z05hg6Ciu+M=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR03MB8220
X-purgate-ID: tlsNG-16d1c6/1775550721-64E4E3D8-76C63E47/0/0
X-purgate-type: clean
X-purgate-size: 10734

--_000_IA3PR03MB7740DF3AE6D2A65A967EBF35EA5AAIA3PR03MB7740namp_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

Hi Tu Dinh,

Thanks for the reminder.

Just to note that Owen Smith is currently on leave due to vacation. We=92ll=
 follow up on the series once he=92s back and can address the comment on pa=
tch 2.

Thanks for your patience.

Best regards,

David


Sent from Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: Tuesday, April 7, 2026 9:19:04 AM
To: Owen Smith <owen.smith@citrix.com>; win-pv-devel@lists.xenproject.org <=
win-pv-devel@lists.xenproject.org>; David ambu <david.preetham@citrix.com>
Subject: Re: [PATCH 1/2] Unplug: Set bit for NVME disk unplug

Hello, I'd like to send a reminder for your series.

Patch 1 has received an ack and can be committed.
Patch 2 has a small comment about the removal of xenbus_monitor.dll.

Thanks,

On 06/03/2026 17:08, Owen Smith wrote:
> When issuing a DISK unplug command, set the bits for emulated IDE/SCSI
> and emulated NVME devices.
>
> Also defines and uses symbols to represent each bit in the unplug protoco=
l.
>
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   src/xen/unplug.c | 12 +++++++++---
>   1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/src/xen/unplug.c b/src/xen/unplug.c
> index 282ed93..3b6593a 100644
> --- a/src/xen/unplug.c
> +++ b/src/xen/unplug.c
> @@ -49,6 +49,12 @@
>
>   #define UNPLUG_TAG  'LPNU'
>
> +#define UNPLUG_FLAGS_IDE_SCSI_DISKS   0x0001
> +#define UNPLUG_FLAGS_ALL_NICS         0x0002
> +#define UNPLUG_FLAGS_AUX_IDE_DISKS    0x0004  // ignored if UNPLUG_FLAGS=
_IDE_SCSI_DISKS is set
> +#define UNPLUG_FLAGS_NVME_DISKS       0x0008
> +#define UNPLUG_FLAGS_ALL_DISKS        (UNPLUG_FLAGS_IDE_SCSI_DISKS | UNP=
LUG_FLAGS_NVME_DISKS)
> +
>   typedef struct _UNPLUG_DATA {
>       PSTR        Name;
>       BOOLEAN     Found;
> @@ -116,19 +122,19 @@ UnplugDeviceType(
>       case UNPLUG_DISKS:
>           if (Context->BootEmulated) {
>   #pragma prefast(suppress:28138)
> -            WRITE_PORT_USHORT((PUSHORT)0x10, 0x0004);
> +            WRITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_AUX_IDE_DISKS)=
;
>
>               LogPrintf(LOG_LEVEL_WARNING, "UNPLUG: AUX DISKS\n");
>           } else {
>   #pragma prefast(suppress:28138)
> -            WRITE_PORT_USHORT((PUSHORT)0x10, 0x0001);
> +            WRITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_ALL_DISKS);
>
>               LogPrintf(LOG_LEVEL_WARNING, "UNPLUG: DISKS\n");
>           }
>           break;
>       case UNPLUG_NICS:
>   #pragma prefast(suppress:28138)
> -        WRITE_PORT_USHORT((PUSHORT)0x10, 0x0002);
> +        WRITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_ALL_NICS);
>
>           LogPrintf(LOG_LEVEL_WARNING, "UNPLUG: NICS\n");
>           break;



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech


--_000_IA3PR03MB7740DF3AE6D2A65A967EBF35EA5AAIA3PR03MB7740namp_
Content-Type: text/html; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1=
252">
</head>
<body>
<p dir=3D"ltr" style=3D"line-height: normal; margin: 0px 0px 12px;"><span s=
tyle=3D"font-family: Aptos, Aptos_MSFontService, -apple-system, Roboto, Ari=
al, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Hi Tu Din=
h,</span></p>
<p style=3D"line-height: normal; margin: 0px 0px 12px;"><span style=3D"font=
-family: Aptos, Aptos_MSFontService, -apple-system, Roboto, Arial, Helvetic=
a, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Thanks for the remind=
er.</span></p>
<p style=3D"line-height: normal; margin: 0px 0px 12px;"><span style=3D"font=
-family: Aptos, Aptos_MSFontService, -apple-system, Roboto, Arial, Helvetic=
a, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Just to note that Owe=
n Smith is currently on leave due to
 vacation. We=92ll follow up on the series once he=92s back and can address=
 the comment on patch 2.</span></p>
<p style=3D"line-height: normal; margin: 0px 0px 12px;"><span style=3D"font=
-family: Aptos, Aptos_MSFontService, -apple-system, Roboto, Arial, Helvetic=
a, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Thanks for your patie=
nce.</span></p>
<p style=3D"line-height: normal; margin: 0px 0px 12px;"><span style=3D"font=
-family: Aptos, Aptos_MSFontService, -apple-system, Roboto, Arial, Helvetic=
a, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Best regards,</span><=
/p>
<p style=3D"line-height: normal; margin: 0px 0px 12px;"><span style=3D"font=
-family: Aptos, Aptos_MSFontService, -apple-system, Roboto, Arial, Helvetic=
a, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">David</span></p>
<div dir=3D"ltr" style=3D"font-family: Aptos, Aptos_MSFontService, -apple-s=
ystem, Roboto, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0,=
 0, 0);">
<br>
</div>
<div id=3D"ms-outlook-mobile-body-separator-line" data-applydefaultfontstyl=
es=3D"true" style=3D"font-family: Aptos, Aptos_MSFontService, -apple-system=
, Roboto, Arial, Helvetica, sans-serif; font-size: 12pt;" dir=3D"ltr">
<div dir=3D"ltr" style=3D"font-family: Aptos, Aptos_MSFontService, -apple-s=
ystem, Roboto, Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
</div>
<div style=3D"font-family: Aptos, Aptos_MSFontService, -apple-system, Robot=
o, Arial, Helvetica, sans-serif; font-size: 12pt;" id=3D"ms-outlook-mobile-=
signature">
<span style=3D"font-family: Aptos, Aptos_MSFontService, -apple-system, Robo=
to, Arial, Helvetica, sans-serif; font-size: 12pt;">Sent from
<a href=3D"https://aka.ms/o0ukef">Outlook for iOS</a></span></div>
<hr style=3D"display:inline-block;width:98%" tabindex=3D"-1">
<div id=3D"divRplyFwdMsg" dir=3D"ltr"><font face=3D"Calibri, sans-serif" st=
yle=3D"font-size:11pt" color=3D"#000000"><b>From:</b> Tu Dinh &lt;ngoc-tu.d=
inh@vates.tech&gt;<br>
<b>Sent:</b> Tuesday, April 7, 2026 9:19:04 AM<br>
<b>To:</b> Owen Smith &lt;owen.smith@citrix.com&gt;; win-pv-devel@lists.xen=
project.org &lt;win-pv-devel@lists.xenproject.org&gt;; David ambu &lt;david=
.preetham@citrix.com&gt;<br>
<b>Subject:</b> Re: [PATCH 1/2] Unplug: Set bit for NVME disk unplug</font>
<div>&nbsp;</div>
</div>
<div class=3D"BodyFragment"><font size=3D"2"><span style=3D"font-size:11pt;=
">
<div class=3D"PlainText">Hello, I'd like to send a reminder for your series=
.<br>
<br>
Patch 1 has received an ack and can be committed.<br>
Patch 2 has a small comment about the removal of xenbus_monitor.dll.<br>
<br>
Thanks,<br>
<br>
On 06/03/2026 17:08, Owen Smith wrote:<br>
&gt; When issuing a DISK unplug command, set the bits for emulated IDE/SCSI=
<br>
&gt; and emulated NVME devices.<br>
&gt; <br>
&gt; Also defines and uses symbols to represent each bit in the unplug prot=
ocol.<br>
&gt; <br>
&gt; Signed-off-by: Owen Smith &lt;owen.smith@citrix.com&gt;<br>
&gt; ---<br>
&gt;&nbsp;&nbsp; src/xen/unplug.c | 12 +++++++++---<br>
&gt;&nbsp;&nbsp; 1 file changed, 9 insertions(+), 3 deletions(-)<br>
&gt; <br>
&gt; diff --git a/src/xen/unplug.c b/src/xen/unplug.c<br>
&gt; index 282ed93..3b6593a 100644<br>
&gt; --- a/src/xen/unplug.c<br>
&gt; +++ b/src/xen/unplug.c<br>
&gt; @@ -49,6 +49,12 @@<br>
&gt;&nbsp;&nbsp; <br>
&gt;&nbsp;&nbsp; #define UNPLUG_TAG&nbsp; 'LPNU'<br>
&gt;&nbsp;&nbsp; <br>
&gt; +#define UNPLUG_FLAGS_IDE_SCSI_DISKS&nbsp;&nbsp; 0x0001<br>
&gt; +#define UNPLUG_FLAGS_ALL_NICS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; 0x0002<br>
&gt; +#define UNPLUG_FLAGS_AUX_IDE_DISKS&nbsp;&nbsp;&nbsp; 0x0004&nbsp; // =
ignored if UNPLUG_FLAGS_IDE_SCSI_DISKS is set<br>
&gt; +#define UNPLUG_FLAGS_NVME_DISKS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0=
x0008<br>
&gt; +#define UNPLUG_FLAGS_ALL_DISKS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; (UNPLUG_FLAGS_IDE_SCSI_DISKS | UNPLUG_FLAGS_NVME_DISKS)<br>
&gt; +<br>
&gt;&nbsp;&nbsp; typedef struct _UNPLUG_DATA {<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PSTR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; Name;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BOOLEAN&nbsp;&nbsp;&nbsp;&nbsp; Fo=
und;<br>
&gt; @@ -116,19 +122,19 @@ UnplugDeviceType(<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case UNPLUG_DISKS:<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (Contex=
t-&gt;BootEmulated) {<br>
&gt;&nbsp;&nbsp; #pragma prefast(suppress:28138)<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WR=
ITE_PORT_USHORT((PUSHORT)0x10, 0x0004);<br>
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WR=
ITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_AUX_IDE_DISKS);<br>
&gt;&nbsp;&nbsp; <br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; LogPrintf(LOG_LEVEL_WARNING, &quot;UNPLUG: AUX DISKS\n&quot;)=
;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<b=
r>
&gt;&nbsp;&nbsp; #pragma prefast(suppress:28138)<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WR=
ITE_PORT_USHORT((PUSHORT)0x10, 0x0001);<br>
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WR=
ITE_PORT_USHORT((PUSHORT)0x10, UNPLUG_FLAGS_ALL_DISKS);<br>
&gt;&nbsp;&nbsp; <br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; LogPrintf(LOG_LEVEL_WARNING, &quot;UNPLUG: DISKS\n&quot;);<br=
>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case UNPLUG_NICS:<br>
&gt;&nbsp;&nbsp; #pragma prefast(suppress:28138)<br>
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WRITE_PORT_USHORT((PUSHORT=
)0x10, 0x0002);<br>
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WRITE_PORT_USHORT((PUSHORT=
)0x10, UNPLUG_FLAGS_ALL_NICS);<br>
&gt;&nbsp;&nbsp; <br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogPrintf(=
LOG_LEVEL_WARNING, &quot;UNPLUG: NICS\n&quot;);<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>
<br>
<br>
<br>
--<br>
Ngoc Tu Dinh | Vates XCP-ng Developer<br>
<br>
XCP-ng &amp; Xen Orchestra - Vates solutions<br>
<br>
web: <a href=3D"https://vates.tech">https://vates.tech</a><br>
<br>
</div>
</span></font></div>
</body>
</html>

--_000_IA3PR03MB7740DF3AE6D2A65A967EBF35EA5AAIA3PR03MB7740namp_--


From win-pv-devel-bounces@lists.xenproject.org Thu Apr 09 15:29:14 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 09 Apr 2026 15:29:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1277918.1562996 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wArJh-00055C-5j; Thu, 09 Apr 2026 15:29:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1277918.1562996; Thu, 09 Apr 2026 15:29:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wArJh-000554-32; Thu, 09 Apr 2026 15:29:13 +0000
Received: by outflank-mailman (input) for mailman id 1277918;
 Thu, 09 Apr 2026 15:29:12 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69d7c5c5.v1-814dabfff3a24a1b96f77a3487250d3a@bounce.vates.tech>)
 id 1wArJg-00054y-5p
 for win-pv-devel@lists.xenproject.org; Thu, 09 Apr 2026 15:29:12 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wArJf-00A6HW-GC
 for win-pv-devel@lists.xenproject.org; Thu, 09 Apr 2026 17:29:11 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69d7c5c5.v1-814dabfff3a24a1b96f77a3487250d3a@bounce.vates.tech>)
 id 69d7c597-2eae-0a2a0a5409dd-0a2a450ce3d2-44
 for <win-pv-devel@lists.xenproject.org>; Thu, 09 Apr 2026 17:29:11 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69d7c5c5.v1-814dabfff3a24a1b96f77a3487250d3a@bounce.vates.tech>)
 id 69d7c5c6-f40c-0a2a450c0019-c602bb01ba03-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 09 Apr 2026 17:29:11 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fs3kY6JPlzBsTsPy
 for <win-pv-devel@lists.xenproject.org>; Thu,  9 Apr 2026 15:29:09 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 814dabfff3a24a1b96f77a3487250d3a; Thu, 09 Apr 2026 15:29:09 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:Cc:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:Cc:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1775748549; x=1776018549;
	bh=DfHdg3d3CWkPWHMIAdyW5lsDdl6TqNiIsBSgQWzfGrQ=;
	h=From:Subject:Message-Id:To:Cc:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=ZOZQ0fcq+OvVcTbjgW1S4LuGeEzXD4jJZjXCsaLjSnaSdnQcavR2/2MSOdp0Nb1NX
	 HEcujvy3nrPoaRnqEVdwRJxyIbtTt5Xc7rlT19kRSLVsRX994ass6JlwDcdYCieBy4
	 9R6aV6vxU1Jrn9pKKW+f7gZZIpAzr/GaaKpfFxH7yS17vaVuLOU25MDfiOF5rXklRn
	 9C+hPaX4JcdwPNkhOcWY81stq2CrNvZmP3t+lrSH4rDYqSzNzTVkcRP33IHkTKqrjp
	 VY6g4x1yWKO8rEIP/h/Xlxmgwb3yXEmTnDRpe0BxMgnOWlwQ24pYhAnnDJBrZ0077O
	 TnYQd7FknR2+Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1775748549; x=1776009049; i=ngoc-tu.dinh@vates.tech;
	bh=DfHdg3d3CWkPWHMIAdyW5lsDdl6TqNiIsBSgQWzfGrQ=;
	h=From:Subject:Message-Id:To:Cc:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=fSFg0GX6rcV0JY24QVFXaLzIviq4G+7dzOs1vxs9FhkUsRLYE2kOkurs2ktZ/lA4t
	 2nPj5qAjjaF8o2meBqd32OqIAKgUdaHgcqK8AjHBAg2gun3zd0wwGUoQI723OObckK
	 tpzF9sVj/Hh5evI3I3/BAdTg80ojzJaw7bPYNu77aVfa4vQhW3tJZwQIfZl1oMDH2W
	 3TOe8sFXDuP0aigPbP2iMODAH0i7UAqoBz4swf98kRRVrVOgLGM25dbMzFinRVk0zx
	 Eq5Hp8VnTWVDR6fb9+OiVAr8zLEghOdplH5eGWUXlebAgxO8KahiR1OFcT3VYNCili
	 rQs5JojB6nCBA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Issues=20with=20the=20device=20eject=20path=20in=20XenVif?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1775748549080
Message-Id: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech>
To: win-pv-devel <win-pv-devel@lists.xenproject.org>
Cc: "Owen Smith" <owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.814dabfff3a24a1b96f77a3487250d3a?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260409:md
Date: Thu, 09 Apr 2026 15:29:09 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-d25034/1775748551-81B54A3D-BA447101/0/0
X-purgate-type: clean
X-purgate-size: 2349

Hi all,

I'm currently trying to fix some lingering issues with VIF unplug, which 
will let me replace the MRSW lock with a simpler and faster implementation.

Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the 
FrontendEject worker thread, which watches backend/vif/DOMID/X/online 
among a few other things. I've run into several issues with this code path:

- When removing the VIF using `xe vif-unplug force=true`, the entire 
xenstore key of the backend is removed without a chance to tear down the 
connection. However, the watch on BACKEND/online will be triggered 
before the watch on device/vif, which causes the PDO to be marked as 
ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE 
instead of being a surprise removal.
- In the REMOVE_DEVICE case, NDIS will wait for packets to be returned 
before continuing. Yet we cannot make progress because the backend has 
already disappeared, so the system will hang. This can be reproduced by 
doing an unplug with force=true while having some outbound traffic, but 
the timing is quite tight with the current code.
- BACKEND/online is an internal, backend-specific value that is not 
documented in xenstore-paths or netif.h. So frontends should not use 
this value. I also find converting a VIF unplug to a query remove based 
on reading BACKEND/online somewhat dubious.

I've considered several options for a fix, which I have documented below:

1. Make FrontendIsBackendOnline return a status code if BACKEND/online 
doesn't exist, and treat an error to read the key as a surprise removal.
   - This ends up being unworkable, since QEMU will always first set 
BACKEND/online to 0 even if the VIF is being force-unplugged.

2. Make FrontendIsBackendOnline check the backend's existence (i.e. 
reading the backend key instead of backend/online).
   - This changes the unplug order slightly, but looks like the cleanest 
solution. Though I'm not sure if it breaks cancelling of device removal 
requests.

3. Remove the eject codepath and rely on FdoScan instead.
   - This might break a few things that assume the presence of this 
codepath.

I'd be glad to hear your opinions on this matter.

Thanks,


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 10:15:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 10:15:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281024.1564087 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCEKY-0004nB-Ir; Mon, 13 Apr 2026 10:15:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281024.1564087; Mon, 13 Apr 2026 10:15:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCEKY-0004n4-GB; Mon, 13 Apr 2026 10:15:46 +0000
Received: by outflank-mailman (input) for mailman id 1281024;
 Mon, 13 Apr 2026 10:15:46 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wCEKX-0004my-UE
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 10:15:46 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCEKX-004VIV-9T
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 12:15:45 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69dcc244-2eae-0a2a0a5409dd-0a2a4508d07e-36
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 12:15:45 +0200
Received: from [40.107.201.12]
 (helo=CH4PR04CU002.outbound.protection.outlook.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <owen.smith@citrix.com>)
 id 69dcc24f-fab6-0a2a45080019-286bc90c2a86-4
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 12:15:44 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by SA3PR03MB7255.namprd03.prod.outlook.com (2603:10b6:806:2ff::19)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Mon, 13 Apr
 2026 10:15:41 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9769.046; Mon, 13 Apr 2026
 10:15:41 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=K6WwmDtxUwmTJDyDi0tjSfIaDjiMGizkH+z4WFRbIW8NtmDWFWNXRZP2RC5Md8STI3U7wIGTVnCIaPXXMdFkj4ySVT+wfrL6cAFQ9nled7CaazycVeBqjH2gEqT5RiSwpt3oo+M2NOBR8QRQ0DjAAKYgBN7p5YaGmmEqiQPfsP1MJXJhg3Ti95mZGMD22Qv2LYYS4zqWfv+QFU/wMlWIKWuaGkRym/hTJqNdmAHSvjvOFbgNnrwUXz1sURRb7SzALQ8qyaPtk6SPxQH34heJiPy/6kRVwcgHP0brk9KorCSp6thPJCQ0syxUzre0sbyR8wzKrsrPmjl+z7HM/LCH8Q==
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=hhGpBLG0G0QghJg9Qmmuph4kUCN08003E6UoA3PZhnA=;
 b=MFD5bHZswHM5wWjY566TCj7RFLZqnv7YuCTl1TPiiS6Ie56N8aK598BGfFloecGtSEXnRasyaNU1TPFNN3sfaNy9NkKXizjjgEbIDs5R4IrkS8JAbDEKhY8qdCFrVILDp2ku95zir6sEec9bEWXSIj14juPyDKRzzMPOPlMbmM0LFeWpXNdGuLh3nom/NHC8+Vv8FtoMTNM/vm187PXvzB/5onL/JrrZdFJSnV6oytobAOjPx2QBl0HIlbA0ts8sF4Buwd+h09ybmG5ztDFl5nBDdm1TD64UrtCi8YEdQ7Q4GCIxt7VisupZVrl6Wbj4vSmSokmiDkq1HKcjNxwlcA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=hhGpBLG0G0QghJg9Qmmuph4kUCN08003E6UoA3PZhnA=;
 b=ZYhbQiw+LDN4l5mztiPS6wxwFGCxeIhCGL1uB82TKP4LaanPsOf9mAqsJjGh1h5MkrOZZBNuoMwEi84fEWNXxQa7SRymUfoE9aDiP2CEq0XDRF0M9bML5HcXCNWAb/v4EePxHvk4NKugP5gIXcIi5OAfTkWxMETIewpU16/RjGs=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH v2] Call RingPoll/EvtchnUnmask within the ring lock
Thread-Topic: [PATCH v2] Call RingPoll/EvtchnUnmask within the ring lock
Thread-Index: AQHcwB/W6hRdGdthxEuR3PE/TYeu37Xc3J7M
Date: Mon, 13 Apr 2026 10:15:40 +0000
Message-ID:
 <SA6PR03MB7760BB0CFEBEA9E4D87157CAFE242@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260330083227.1353-1-ngoc-tu.dinh@vates.tech>
 <20260330083300.472-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260330083300.472-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|SA3PR03MB7255:EE_
x-ms-office365-filtering-correlation-id: 33d62be3-1b81-4e6d-80de-08de99459da6
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|1800799024|366016|376014|56012099003|22082099003|18002099003|38070700021;
x-microsoft-antispam-message-info:
 VqA0ekHGQP4pPRLfr/TlwcLpcDFV3XwjIpJLU26kuVfmANndw28NKAvxweq+2ZRk4Qsd0UaqYWn/BAeZN4ey14vGxNTcX8KF9nyIkuZRbkfk5OhyAuZS7sKDJMOeVbXaWsrfxGNT/9YFS2CCcY+04ypeEkTKrd+eQ5prjzfcVHLcQZKz3Bitb3o123fM4R0MRmHIukFhtVCJ4c+YC8QEFJfzDNUHKKAahLbhoXSKZjMFtjS6W+hg7YQIGiXa5ByZD06hEf5QoeE9vvD/7SSqSbZ42d9U7PMlEmxbU8easQq+Ct6PNORfVTJaC+mglAwws8+JGsPB5iSsK7jt52sGtDHhTrhGA64uXr5D5r5FZsWKfHUl25Lkr14TJNdMJlHRic/RqJuvNaZ+hvKGqp9gTok3R3h4P2+jnetrPt1AcnAYBjv4K2NDwSQd46F/kxbHwOSxB55M3C8DPb827wnxXzfppBJHRTpCklB3STrvLKRF5JZXC1aRNFMCJ2GCQCh6IH4TvS1l4lEOaU7lf+Q5xij39QChv7hJGKlgTN2cJ/ww99GBIwAsvzCLq3FQE+EhydfGlZ4Y708aRs9T8fVfPsUqk2WjiZREB2dnAKxsEWYf0Ax+XogGG1Gw2LbAsyNEe1icp7Kqd3kmBoDYnv2Y3a4wIoNC7ECY/KZ2fTqOTA1pcKgxUZErZCSCfjyrySUIu84Ja12gX+VGLcHWicdWBqSO0rhR/aY3ujxMEMf8BHg=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(56012099003)(22082099003)(18002099003)(38070700021);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?SviM8ey0+3FekxQuCqJ1aJBtfn6ReTnaEZlINtFp72H8k2+JBQvIdH73nF3P?=
 =?us-ascii?Q?/l3kWLLf9WV/z+4bHUOIhYsyt2dWDnc7hQKoBFHmn7POD6sWT30Kn6qQbHoa?=
 =?us-ascii?Q?yLdIJRMMOqzgCSNl09SC9kGlt+U/HHlIPI5u21PdCbsnZoCoHVmykIiwRPhF?=
 =?us-ascii?Q?d9TDsZFybnBl3/088xB5cHmQfz7DFU0MwnEIvGfmx13U8wCC84cgJf/ugwaD?=
 =?us-ascii?Q?N//BfbL5Lbmczo/ov/05Dx1b9gNePL36zEZ1SOP5X9NWLdNisvDiHkAW0wRo?=
 =?us-ascii?Q?4wLNfsNoRbsT5JGBJrgHoCoAPzd7fClUxUceFMLh2+QNoPuouoIFBQg5ZlKq?=
 =?us-ascii?Q?v1TFc6at3PEWMDuqkB8bqYIx5q8j4pu1j2t/jxH+h+6b8ZheKWiyRvCE+89y?=
 =?us-ascii?Q?b+JmE6/+3PpsBbNV0sP44tg4+sCtS4B4vrie6Ptne4XuBfI7cAlk+rVHYI+o?=
 =?us-ascii?Q?BUNks2Wuo63UvFvbMqM0WnVs4Y1xkAzg0Bpvf5Wsf2F/aGMcrkyVB7c2CJ6o?=
 =?us-ascii?Q?hkN3B0/dcKUsHO3rRWwVKABJkxH2Op7vIOS919R0gN43VZSoMfuI3WYatfgk?=
 =?us-ascii?Q?IdhpqZXmJv/PTe2EAy7BI1WSpcGL22FV5Duf5AZo1zaZNGA4A/TQQ56Rvvhw?=
 =?us-ascii?Q?obqg1HNHKmhnbME+BkSdTSY8+J0GhpB7mLrPsswY8FXShOxlIeEjTvdwq/5M?=
 =?us-ascii?Q?RL/Vi1h5JRLhRx/knY3nLofMzdCbeHNd34Ae95nL0XZ4urs0Bbnesym1nGPu?=
 =?us-ascii?Q?U2BgTKwPO1/6liFdHj+XPSRn0K38kHUwWP/rZfYkhkbwaOdAXQWoTOc3qYCf?=
 =?us-ascii?Q?EGvEYKl/bHzudD63YSGdv8BtnXDNwgRYRE41O0rRWH4MLCav9O0FCcFqHTiW?=
 =?us-ascii?Q?IoogtpVjD+VY+6KO4nKAv3Pz5PHXsbCDg9FOM27prcn+b/FJ8pjwLiYM/zqn?=
 =?us-ascii?Q?72Vi9NCTJpYM6UOBchoEapSYMYdx5nkleIHsHoof9acTPzsB5WWAFbElj6MX?=
 =?us-ascii?Q?kUVgrNSP/VOXHpsOEcPCAgT4YQY4nqmFatK3Su0uApMQdHoCry8TlHEcLd6Z?=
 =?us-ascii?Q?7J8vRnkjX5qzsNyhSczXOmpLWnSFWGzA8btlyjzqx1PUGjNaDo8aN8vw5VFy?=
 =?us-ascii?Q?0IFzKrd0xWpIRoqrIqQI1c0gDgrbfqIJvVWZDsZ4qb1I2Fjb9y91TnOGd7LN?=
 =?us-ascii?Q?lVealeud5LXBPsb8CQPFWl+B4t/RktaC7i+AMopnTBYsNI6dVNQtz0N+5OON?=
 =?us-ascii?Q?rI/MJUItznFL7k24YUoSiYznRiBYt7gOOBtIDymnjJEAm471YgqGNpkLt5h5?=
 =?us-ascii?Q?A72Vy05n50mSpe1+olYyVmMJS3BG1h1mClwsyOueUBE/IkqXhF4W/NpWCUiN?=
 =?us-ascii?Q?KYgoF3bWKOIx61P4ZTuPPQBXecxvHaVSKwzyKRNJvEHpecBJnnuu/5EsMplV?=
 =?us-ascii?Q?5FnH1xpPrLSMbt+Oeo92FD6r+y2Pw9iGuomPnWjb5w/V0F8jumgrtDmUGltt?=
 =?us-ascii?Q?EIQ3GDAcoJBOoM0ly4agjhU78eXicvsILLEDC+ZOA13YLUK/iBqKFbkhGEBE?=
 =?us-ascii?Q?nER7qU0QX/MPpeWudKqdjiP/dDmknAKe+LUJh2I3rk70ZrN3Zk8XBmqjp0rM?=
 =?us-ascii?Q?zaaIPGaFneBbECk6aDAjYPAhzkZcqJS8lAYu5RNYmRP+Yxx8QxUMP1p11+0t?=
 =?us-ascii?Q?Minx99XCFLvQHcsRU1tgjE0AtlZN5+DswQ1Tr1ERTuhy4id9?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 33d62be3-1b81-4e6d-80de-08de99459da6
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Apr 2026 10:15:40.9805
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: ksD0Ut4ReCuxIJVTd0j+rCaBK6ee37NnMCPgJ6zMQOruUocfqAIv1Alffe89uuNU+quvMKJXiFsF0JZzPEKFxw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR03MB7255
X-purgate-ID: tlsNG-c1860d/1776075345-94763497-32F45B21/0/0
X-purgate-type: clean
X-purgate-size: 2743


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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 30 March 2026 9:33 AM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH v2] Call RingPoll/EvtchnUnmask within the ring lock

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

Note that RingPoll is now also called within the ring lock, since it's
also vulnerable to teardown of the shared ring area. It also gains a
check to Ring->Enabled following the structure of XenVbd.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v2: Invert conditions. Call RingPoll within the lock too. Add a check
    for Ring->Enabled in RingPoll.
---
 src/xencons/ring.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/xencons/ring.c b/src/xencons/ring.c
index afa9311..866dc74 100644
--- a/src/xencons/ring.c
+++ b/src/xencons/ring.c
@@ -471,6 +471,9 @@ RingPoll(
     PCHAR               Buffer;
     NTSTATUS            status;

+    if (!Ring->Enabled)
+        return FALSE;
+
     for (;;) {
         ULONG           Read;

@@ -567,30 +570,25 @@ RingDpc(
     ASSERT(Ring !=3D NULL);

     for (;;) {
-        BOOLEAN Enabled;
         BOOLEAN Retry;
         KIRQL   Irql;

         KeAcquireSpinLock(&Ring->Lock, &Irql);
-        Enabled =3D Ring->Enabled;
-        KeReleaseSpinLock(&Ring->Lock, Irql);
+        Retry =3D RingPoll(Ring);

-        if (!Enabled)
-            break;
+        if (!Retry && Ring->Enabled) {
+            (VOID) XENBUS_EVTCHN(Unmask,
+                                 &Ring->EvtchnInterface,
+                                 Ring->Channel,
+                                 FALSE,
+                                 FALSE);
+        }

-        KeRaiseIrql(DISPATCH_LEVEL, &Irql);
-        Retry =3D RingPoll(Ring);
-        KeLowerIrql(Irql);
+        KeReleaseSpinLock(&Ring->Lock, Irql);

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

 _Function_class_(KSERVICE_ROUTINE)
--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 10:41:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 10:41:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281057.1564108 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCEj5-0000zE-RX; Mon, 13 Apr 2026 10:41:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281057.1564108; Mon, 13 Apr 2026 10:41:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCEj5-0000z7-Or; Mon, 13 Apr 2026 10:41:07 +0000
Received: by outflank-mailman (input) for mailman id 1281057;
 Mon, 13 Apr 2026 10:41:06 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wCEj4-0000z1-HS
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 10:41:06 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCEj3-00CTXf-Ti
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 12:41:05 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69dcc836-e002-0a2a0a5209dd-0a2a4508b164-48
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 12:41:05 +0200
Received: from [40.93.201.29]
 (helo=CY3PR05CU001.outbound.protection.outlook.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <owen.smith@citrix.com>)
 id 69dcc840-fab6-0a2a45080019-285dc91d1c68-4
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 12:41:05 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by CH4PR03MB7555.namprd03.prod.outlook.com (2603:10b6:610:23d::9)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Mon, 13 Apr
 2026 10:41:01 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9769.046; Mon, 13 Apr 2026
 10:41:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=ga72El2UJX20Bo0Xh9S3ETBYqXtw0Kb/Qj7W44zgMhmpTf9qofna8tioR/UliwqQX1UKl4BqM7lFgc4kVqftNpTSnaWexVHUwfiKqxjp7fipPfcncrKOAjpYGEZ1z1lakkFf7dUiosxey8gCsQjTc/YlGm0ywlRVraAPHourjRZFyWhG/nDl+HB3FvzY0WeIYiNlUJntmCHL1Iy7AyiBjIRHBlyA2dTjo6r735V1i919Aj7sjhSbx8GUjR+mxicxLNZxeqsctcjh33dwRmpBn21ghM8nuFIxw9jA24l1ZzWmWiJ9SN6Bq88Y4XSqvpSIzGuzr3lk6JRztX4xfdfQSg==
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-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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=SQHbyCwYZITgMCypobwDSzc7muZ9WSntCYzZhMn2lio=;
 b=A+bsQKtnM2CUupNTCZWHgroC7ja/a0YbNWzKJ9s380n21sjKNyPcZRK3iS2Q65PeSMamN3Rk8mreG1JONwv76/a0yywWyig7UMl5yh8bjm1R+pb0S83XLQ9AJdA8g7BthmBLc0THumIABFytgHPRM2Visxw2NOeI/shPRpqgt2c=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH v2] Call EvtchnUnmask within the BlkifRing lock
Thread-Topic: [PATCH v2] Call EvtchnUnmask within the BlkifRing lock
Thread-Index: AQHcwB/BRos8PQKdQUCVagRUGwN05LXc47Wx
Date: Mon, 13 Apr 2026 10:41:01 +0000
Message-ID:
 <SA6PR03MB7760540CC077B32D3D7BDAF2FE242@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260330083227.1353-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260330083227.1353-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|CH4PR03MB7555:EE_
x-ms-office365-filtering-correlation-id: 7a3c90c7-6f30-4c07-689f-08de994927ba
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|1800799024|366016|38070700021|22082099003|56012099003|18002099003;
x-microsoft-antispam-message-info:
 5PZGT/yyidjbL13oxPCO6S6sVdmXcKlfdA6EgOCKFKKVO5aT6n6C7xm+T8LI2jikQG8uYzDfHJ2EyeeyAVXad4PjMr+wI3bvWdK4dTyevjwrUMyCks/eWZJsbTDr6DUdkVKzVnUkIgSWH45/Co+NyqLreIR2FhKnlRt9I0+11gkRH40cNDzOIjNIeVZQ1PqJdiyuKqzu8z0mcg8VtptD4KHVX2g5Wo7htyXqdgiLxb51LVJaxhFb6+hehv/6Sp+u46ecZBSQu0FeHPnlPkNCXerm5N/3hLZGAwdRLYJVdjG6yuMYzQ46h40ROnUIWmK1qhAYu/b3yxd5L2YJq/ak19XoEVA+UtzjUBTilDvonx2nQRRBSsQRVGf/GKpuIsZA5e8IIVUwwgCRDDHRJVrNeI8iqZdlPsTifGeadRRQcEVJgWUmy4TrRLdNLFUSUAqwofuH9t0tSvkQwqkkdfIj++9dtRLdNR1pTsL16q+++asCqXezK7OTNJ4pfLLEomlNEUNh9bvh2FT8EzonSKE4ATuCdaAIYYydjyab68FcyFYanPYIGIh2M00kdg8/tOukcBYFYEMVRzo8xbNs5HTNCjTBpvKLxhCCeN9vD9ezTi0cxQZrjkmVBZY5F6/e8WqpU3hZA3qpfclqbskQVJ0wmtbZtNi711Zrlgn2UR8stiD46fmuWQNuyApYdkUc53UMiaQPQLV5prsd28aZxkHjC5BE7+AD3ZYD1KPP7aOM3/8=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(38070700021)(22082099003)(56012099003)(18002099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?LjcxWWYde40hR48BJ4MDQ4A3XWTxQdb20M6Xk00lqt+ZI6xVJEAhxeELxTYH?=
 =?us-ascii?Q?qfZGh5QxVeNjHTD3kuIhqIqLbgKmSBaIZa86gevVsVsJokRT4KMYM7q2aAMY?=
 =?us-ascii?Q?1lVhmX27+yOaX4MxrPWmHgVUhQe94ZYwQai6W7sw3ArUGnN/UQCmhdp1h8Pc?=
 =?us-ascii?Q?VvT6fZa3eM0ASO0P6VhS0Dd//k0Nid4uDh/IqNWLiLqObudxKHtPgiNGcrei?=
 =?us-ascii?Q?CMpImctQ9Z4y7NFmJ1LIsO+ZtrnGn/J1Z1QtpVfvOXieDiKfd/l4ZpR+oQxe?=
 =?us-ascii?Q?UDIBNoZkG8WP3rx7BB0DmNysgZoiUmGx18WySbpdXrWJCB7eKZLs78n1ZkBi?=
 =?us-ascii?Q?ClxpkhQKJVgXLrS+jp3bH5yS+gWxISY5Ws7e2HV8stBpXQjcNgnAMjTxL1QZ?=
 =?us-ascii?Q?2z3x4l2qaGREpwIBm72bxQw2rELPgAWvgxxkCeG4YzfSZQoFcgBpHKpGv0QK?=
 =?us-ascii?Q?ymriiwwxFh6xW42wZY/rnwKHEaG+3epF7YTcscV+2yqM9ejDynZIAbBIVVYP?=
 =?us-ascii?Q?M3j765auWr84kvAaKpulaAOga6cmaXXNDt3KqDSIaBgbdMcEx/7O1F8kTb/7?=
 =?us-ascii?Q?9n6dBpQfJaSQeSOjkvICT0u6VBO8vGYUlelL0dSDIL42k6Qd4ZfSBMH37V8I?=
 =?us-ascii?Q?ioi41kXVTdzFDiBQpIos8weQ0Wa0W53wt3xhC6GAmfXo07maQKCojR7k8d15?=
 =?us-ascii?Q?ih6qAq4JZwOhKRh/ak72oqF32Pag7iKG0DkIfSw0VlMGq6wD+XcLOyEM4sW7?=
 =?us-ascii?Q?OZn3gtzfK8NK7s6nMt21Hz70DWgT3+exGmienXfPNlOpzYLngV/tHLIGAYDz?=
 =?us-ascii?Q?Wzn3CpAAS4Cn5L7N0lj+FYf3qDUIblnFFSvR4uztUY0KMIuTI7lzWrIHILmO?=
 =?us-ascii?Q?bbTOzyRN7D8vrW63ONP5dwLHK62oF7eMgm0lwExmXXy+IwttTJoWld+dw/VU?=
 =?us-ascii?Q?RWOC4T8xGqF/5vBoJBSdUOsb8D0Orv5JNULMUkSfE14vk/Fx/r1HuOgSE4of?=
 =?us-ascii?Q?U5uu2PGLEsWbBpkRPqeeyIkVh5/Pw7Bo29o1eLNi6CazjVasb2TQpXK8LnIJ?=
 =?us-ascii?Q?OexgSHjug1aUdCeF+fF+NFx99eCsVp/KqaDI+LJ4TwYp0a9PlR3PsK0gw8zr?=
 =?us-ascii?Q?E7hqO2LsiRaUue8gduV8WDcfIwD7G2lwxjPJCfWFlidgkSgreDNqbPfH9PDV?=
 =?us-ascii?Q?qm1KqapWvwO6aPB6hqtTW2zlQ4iQa4XXRg3+rwSppkxhb9PHQ4SJHHLfrduT?=
 =?us-ascii?Q?C/p29fvrxksfkrm5wQEcdz4AyP7pOHMrniH4ZbNMKQD35tkMvvceYN5bMJbz?=
 =?us-ascii?Q?BvOx6lRo/cyNPW6T7kVmxd6XkLB7OaXL125k7jJPzN5zQ23xNGQIu5nenXfG?=
 =?us-ascii?Q?MBMXkQAiGfq0bTOB6JJ/7zQcElCHcfyuQI/5EhR2Ok7cJkxI/H+hGvvRp/kT?=
 =?us-ascii?Q?95f5kPQ3tI1S+y07k2UIF10k7FIVx7iNuq/pUP3gQnv4rh91breBTOuYP/ut?=
 =?us-ascii?Q?tnhq/dNgSfRhLxRAWbiZdIYG19lC8ER6Ebh3MBqF470atr9XKxAI5hM9kTbK?=
 =?us-ascii?Q?cCYtWNAQau7PxPl38B3dzqApjrMwSPmAY1+yeMFQBguu66Amd6a1B36RcBc3?=
 =?us-ascii?Q?N5wQCxEsbf/hvP3itBUJLMI8hTOc2Z73aGxY0QyIlC+UScZ+rC3DgdGTSSon?=
 =?us-ascii?Q?G5Ob419dtpLWstSuGm7++GHh7MC+6Aqse6Zl571y0CC89E4Q?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 7a3c90c7-6f30-4c07-689f-08de994927ba
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Apr 2026 10:41:01.0841
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 4CPHlml7y+DCuyPEuJC4wJtDzo2EmXYAfc5Ad2ZU/GKK4/7qCGZZp59O0+6Eu3phB8ei9/u7fjhN9+dBJ9kukg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH4PR03MB7555
X-purgate-ID: tlsNG-c1860d/1776076865-F6B4C497-FA0C4507/0/0
X-purgate-type: clean
X-purgate-size: 1984

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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 30 March 2026 9:32 AM
To: win-pv-devel@lists.xenproject.org
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@vates.tech>
---
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 =3D 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



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 10:48:13 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 10:48:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281058.1564112 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCEpw-0001Ba-Bs; Mon, 13 Apr 2026 10:48:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281058.1564112; Mon, 13 Apr 2026 10:48:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCEpw-0001BT-9K; Mon, 13 Apr 2026 10:48:12 +0000
Received: by outflank-mailman (input) for mailman id 1281058;
 Mon, 13 Apr 2026 10:48:10 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wCEpu-0001BM-C6
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 10:48:10 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCEpt-002lHC-JP
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 12:48:09 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69dcc9db-bab6-0a2a0a5309dd-0a2a45088504-32
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 12:48:09 +0200
Received: from [52.101.46.50]
 (helo=CO1PR03CU002.outbound.protection.outlook.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <owen.smith@citrix.com>)
 id 69dcc9e7-fab6-0a2a45080019-34652e3295f9-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 12:48:08 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by LV3PR03MB7753.namprd03.prod.outlook.com (2603:10b6:408:27e::10)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Mon, 13 Apr
 2026 10:48:04 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9769.046; Mon, 13 Apr 2026
 10:48:04 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=wPmToyCLNuwkvrtkT2b3OGyo85BLuT4bqHIMvIEwbWBbO+Fx3a0XU3FqJdh/2SkK77SE2HjhU3CgSXlOictUK6ldA016ntp3jsu3nxupVcKp1Oy1K4YpKr4CkUR0dy6eCzMlvvS7t0wnnx2tKW/pgEmY1E3nljAS7kFoj/PE0/qV7eljVuUZoL/XzL1DtrjmpQdtqw6gV3pE9Y04T8vfPqoRz1GKF+MuSR8bCSMmkdDUxJkKG70NKVImbBge8xJt0UFj0snQZQl0Y2jjFc5ezkND9nNKPtA2NPjNdn/GvoU/ZqXWMfq1c7R7aDPOwU64/lkebLvrlywLZnrI6K7E3Q==
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=qgRNUi8rWEe6zk7S+ksgz/HtR2PBOccta18zoMIz+sE=;
 b=sz91StIefk7vmWvr4o2mvD2KsSK5Hh/1fHNYGlEGt0xAdtNSWYByynAxHNs32m9Zv06u8M2/P8rI1FjL4YitmNHBOnzUjlhYf/h8NiM1Ya6UZVdD4yg1Gjr6vZyRcT80EzxIb3EQh3yDx6I8a8X+JsPP/U26wvhdeLgWsq43bTYl6iNFhgMtVBN24U6nR3x3FuRTSd8xl9TJzX4DHa62AkH4SVOeVb0IwMZJAsaMwVdegWjDto80CO0c+cLr7WHVB1jnmTC6vnKmGyPNi2idZOy6D0z1yXMtdEkSDeq78PWm7kRb22ti+ixDdG+7FmX1diWl+Z8Vf6vvBOakPJQabw==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qgRNUi8rWEe6zk7S+ksgz/HtR2PBOccta18zoMIz+sE=;
 b=ZVm5H9UEeF2qTDcPwCqsW9yYJebpAjvc2Y2x4hzd3xfOyyMdPnldhlLw9Pr3mqFlw7oKwgBcW6Obe8sJEaPG4au9lc5uLU6hb6fLu7tyWxR8SBeXjFFbxt9U3++qgt16RuUYisI4wNmLnaVq7WB3t+bXqq/MpToIGwypEZxtP1Y=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@cloud.com>
Subject: Re: [PATCH] Add missing return type for
 __TransmitterGet/PutNetBufferList
Thread-Topic: [PATCH] Add missing return type for
 __TransmitterGet/PutNetBufferList
Thread-Index: AQHcwB+x1KX/SySME0Gj27gthfx7HbXc5bPa
Date: Mon, 13 Apr 2026 10:48:04 +0000
Message-ID:
 <SA6PR03MB77608735F368D41F98C0EACDFE242@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260330083145.217-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260330083145.217-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|LV3PR03MB7753:EE_
x-ms-office365-filtering-correlation-id: 3925b7ba-ea39-4aa0-80d0-08de994a2443
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|1800799024|366016|376014|38070700021|22082099003|18002099003|56012099003;
x-microsoft-antispam-message-info:
 8gbLHMGC4Ou81QLacQzEpfPGDgRZxS9sYmsiunmCCvUNbYkFIXCnFMlaTfptA22q/weamTHKWT01X2XsqaLzZGkAgOeLKq1uO/48X7mYdo+Ap7OfSfvlJg91o9AcOEtfGGKG+6LPFaQHjHAT7Dxxc5EYxNyWE0YdQKS6z4ZZ5YibYMMmj9+tiO6DInELkgJWDaBqu5/910HeqRGtQKFYqJHqHG0bSxjRecorVySkaT2Ph7pOzvxm9WWK5vYK4IiJlWOIB2Rs2q8pPgola7xqdjOg8QphR5N/KopEJvuSLnxR80p8Vm8f+3FFrFCnFWYbWoppAkUR/a5ADMj1L/O9ErJIU1fCTmddSWvA28nrQv6V4pjhL1550DjMBHQAqqm/FjyUcyvl3zXeStIRtcnhHzK8mLESimXalXqKePEzIlAI9vM/ZKibIIjqwkjyo5KVkh1jPa8Qc76Bd1WcwnhQl7fD/MPiGXCao8k5dx7pitkOw8fyWWg4PL4AjBosoWxP1nDDOBEn7wRw2zAB3tLy7AEpfJwSDU+M7nwhEIO1YrQZpSV5Z/AfQoZ34h7iZwbcPGaso2JN9INDheKwZWlrT41yQnzniEueeJ9Ufio/Pw6Q58zH9riR5tIyWUpE7/6MvV+L5wQ4huNokf/+n6Q4n04ysGyB/LyzIVdv4vswPhJ5GKSuW+F+JOSMwf0ub7vSz0GNk0BnUbRbfC7M4HPbIyBUQDR0m4iRqoLEt1VVGW0=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(38070700021)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?P2q8vFkrsATXjwGFINxivGR4/iAxAZZi8QlU19E2Mt2anlQSOi2bBVChavpK?=
 =?us-ascii?Q?j4IRv5P+fRCXTwLHSZz36sv4v7ivtGyIsDUlVigHP9R6uyx5y3u3Cz+7JHNA?=
 =?us-ascii?Q?MKTs+lozoV++Xyb4mU3Va2sCrbd/cWjGt6QxC7WJhKNS/T3fL15wTk3Mu9qd?=
 =?us-ascii?Q?q0j77AHkWBHULWvp0eWAIyqjVhCYoyt93BO4MQA8sjAEkWx158AJ/5N1WhDO?=
 =?us-ascii?Q?ao23DAxkI0JaT1DObuUciIGq3zuW4IVK3S3G71ShbOoRS1hhHV5FN44wRSYr?=
 =?us-ascii?Q?NiyMbB1Lr+jeIU8XIJh98NOFTdiPffl5nIwH+OExtTC6aICocPS3DtguTxch?=
 =?us-ascii?Q?1gvUe583yE/qj1smdwbCPMvJgmo/uanMWI+SE1X379ZlpLSsoa4DQheuSW1g?=
 =?us-ascii?Q?ONUrTxCpHsiWZizxyAfFOq14lVxOsiUQjA+mquNg5DDg9zQhofFnntd8OxJS?=
 =?us-ascii?Q?XS31MgpOVtHMzNNCDLCFPWFKRJ6qEWQwMm0TPEPvbxP9OoezWu3AqLOyPlYt?=
 =?us-ascii?Q?Q0Kl4ETvFNpHxxYxrvVfS7BGKKpr120kAnZJyJ1jLEqw1xMtR765cE3n94YI?=
 =?us-ascii?Q?6YOJIjRsF/gGOz9bTFPpjJHfQ0imS+UsAYV+3OOGMNmHWxaEJmqEXy9L9qTX?=
 =?us-ascii?Q?/Np8vZmnXWQxLEGzFoeYMLpAU8fuTJdRmI3UhK+Nx34KNtYCM61OPdXGYLp2?=
 =?us-ascii?Q?slGX7OZ8b/Fdh70jaUfABIJ6nhwFAWrebNGXkpNFo11BolMhRffqiC+A7kSu?=
 =?us-ascii?Q?TFFmI6LMRdF5SVskEZSWQB8NLOsMc9ZfitT9RNdfgErHGRm73Ifm7uqGKy6X?=
 =?us-ascii?Q?tGygeJHAuzYf8Cpi36f1SPpyhnPJNQqbNUAIiPcr9dvN/n8/siTW1fuSMZkR?=
 =?us-ascii?Q?wlqy4jvPEsUr9N6e/nFTCDnL91MimvvdUS3LpW3wtr84obsqGYmDWOxA6sCd?=
 =?us-ascii?Q?LLNY5HfuIq0DyRAhmwiU/9BQXA2ERhiQ4MtFn8AhfvUFNweDvG3mNvM5sOSl?=
 =?us-ascii?Q?xYRDQiQKYGfutiHdjA+cX1q+WnxA0i1UCzr7vYD9wWsAQwHvoH/u0JNUMNJa?=
 =?us-ascii?Q?tCqYLEv14mnba1YLFoOWK4Fhqi+636X8pL4bsh0ZYtnlgDJXenWsy1Xu1Hjp?=
 =?us-ascii?Q?/4OE4Vot7mE44eHRGuSaT7QlnDUxPzyn6Lad6Eow4o8gNkkxVBy1ZYZFEd5d?=
 =?us-ascii?Q?OJwGFQJEtGJ4ZISDNsZRpIAnTFY0pisYZUR4slDRgZn8ibM1pXNCzD0xYUiX?=
 =?us-ascii?Q?Rf40KbqGQQJy4jF12bIF+mYfWf85tcQ6isM+44fUTIg1uEcSvO8+4MTKyI3/?=
 =?us-ascii?Q?eEsFYZlWLDGGojzw8KfZhk2+nPJx5AJks8T5u9ezG2gQQgr5jOA0zVdOqvFJ?=
 =?us-ascii?Q?8rW19fqwpclq9wIk/l4PG5sa8xNHbMPYIIllxgjY9ac2zFTEYRp/iMio0w+3?=
 =?us-ascii?Q?JCMo9K1HmwTInDH4wnMddDXeUCtJW0Ekonw11iYlBOaUysaKeoOPFLLYWaxe?=
 =?us-ascii?Q?/SDjBuq4L1yJjFw5AcJI5sHowlRIJDdWQcZS2FZWmOzZsOyhYBDEo+u7hqTK?=
 =?us-ascii?Q?hsEpFMuf6jYKTXgc63RKolWzcMNz65b7RYcn8VOdvIbDhC4XmCuL7lCm29k5?=
 =?us-ascii?Q?sTKXmwSVuigtdqHO3TtXhbCykuK5AduR/IhTvr4AKAVW4SVn+MgQik4GZMHy?=
 =?us-ascii?Q?LhiZ2EaivGdRpspfVvxTbXacp77dxjIamTGguISiSVWGBotJ?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 3925b7ba-ea39-4aa0-80d0-08de994a2443
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Apr 2026 10:48:04.8106
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 7+iihN4exjnHa8urjnYTreDGQ9g77ccx3HDV9fOMO1b32oBH9LPMDO1Tlyxk6n49BFNNiOLqXyKXC/b3rqRNGA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR03MB7753
X-purgate-ID: tlsNG-c1860d/1776077289-75756497-C6A60279/0/0
X-purgate-type: clean
X-purgate-size: 1361

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

________________________________________
From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of=
 Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 30 March 2026 9:31 AM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH] Add missing return type for __TransmitterGet/PutNetBufferL=
ist

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xennet/transmitter.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/xennet/transmitter.c b/src/xennet/transmitter.c
index 5507a1a..4bb82bc 100644
--- a/src/xennet/transmitter.c
+++ b/src/xennet/transmitter.c
@@ -123,6 +123,7 @@ __TransmitterCompleteNetBufferList(
                                     NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVE=
L);
 }

+static VOID
 __TransmitterGetNetBufferList(
     IN  PXENNET_TRANSMITTER     Transmitter,
     IN  PNET_BUFFER_LIST        NetBufferList
@@ -138,6 +139,7 @@ __TransmitterGetNetBufferList(
         ListReserved->Status =3D NDIS_STATUS_PENDING;
 }

+static VOID
 __TransmitterPutNetBufferList(
     IN  PXENNET_TRANSMITTER     Transmitter,
     IN  PNET_BUFFER_LIST        NetBufferList
--
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 12:41:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 12:41:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281137.1564161 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCGbD-0000ku-Bt; Mon, 13 Apr 2026 12:41:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281137.1564161; Mon, 13 Apr 2026 12:41:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCGbD-0000kn-9D; Mon, 13 Apr 2026 12:41:07 +0000
Received: by outflank-mailman (input) for mailman id 1281137;
 Mon, 13 Apr 2026 12:41:06 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <xadimgnik@gmail.com>) id 1wCGbC-0000kb-0s
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 12:41:06 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCGbB-007Ylm-8y
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 14:41:05 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <xadimgnik@gmail.com>)
 id 69dce449-e002-0a2a0a5209dd-0a2a4509ae52-40
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 14:41:05 +0200
Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <xadimgnik@gmail.com>)
 id 69dce460-bf79-0a2a45090019-d1558030d91f-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 14:41:05 +0200
Received: by mail-wm1-f48.google.com with SMTP id
 5b1f17b1804b1-4852b81c73aso41437455e9.3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 05:41:05 -0700 (PDT)
Received: from [10.45.19.224] ([15.248.2.232])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-488d67ce8b7sm142082725e9.8.2026.04.13.05.41.01
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 13 Apr 2026 05:41:03 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:In-Reply-To:Content-Language:References:To:Subject:User-Agent:MIME-Version:Date:Message-ID:From"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1776084064; x=1776688864; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:content-language:references
         :to:subject:user-agent:mime-version:date:message-id:from:from:to:cc
         :subject:date:message-id:reply-to;
        bh=tZvVmOy6y24OUild/kK0qXpUg2HGpLHu8bzpV8gIJYc=;
        b=j7c5MlUcYFEEz7lkDXVIJt/I+dwEDS5Id9rtowdOuzZlJvo8EPY4+J+GnwJtUyzjXu
         ipHS0d2urp0dN0REOKA1H+aXyJzf4QZU6WeQCYTZUltOUxlIniU4y/GxdbESkBSH1xTc
         JFtGYC0SBwkQtuoboMp7NLQzO/+ml8jiTyABlMIk5sBGtHXNJKA+ViEcR8V2zN+CSPVW
         vwoa6jlXgNjG57W/qgwptBbN3nfYcyNfE+RpDl9ZNjZ6+ONjUrcNP9Y1YRObQBJNcBHm
         wp54E9JEl+xlfKz/I7noJ9YIHYYWXqaABwMCXBeQIDY7CBSULHAV9o+/h+pQ+CrrZUz0
         JFtA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20251104; t=1776084064; x=1776688864;
        h=content-transfer-encoding:in-reply-to:content-language:references
         :to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
        bh=tZvVmOy6y24OUild/kK0qXpUg2HGpLHu8bzpV8gIJYc=;
        b=T5r0kMAKsceHKpUw1Zxx8KUwJfjYZe6NF5PGJ/JDel+tQQeoyrdrqGE6wybZKtgfuV
         AjSiu066MT8NqDwrmjcoLtT13iR2e9/gyDqOs+iBAtGiCFte1mLvY0rfDc8RZ5BIwOft
         WupRj/82JbcvhUCwtzBRM6AinemYYq+Qedgswe+npOacobRUVajMV+3o/hBa/YlrdE2t
         ydZY5ZSPN0RDbTQoLXIOWoKYlHYTsjAvyDtum23zHcNUhJGVeNEVdfDj1gONROyX7un1
         AScsQiOXh3+/efjfPonHOv42po5pvlNleiAxB5hY09d5zaEz+39YOD4CJXbNlWvDhgpe
         CGbA==
X-Gm-Message-State: AOJu0YwmuYwvpmRQ3cTDYet7J3wwqehS0XZ1EfL6ntYVY1IKsavLipco
	x3bT/axJvVbFvuv5+XrrqDgYmtylwjXEEn/r9xTKygS52Z3G4TRupn+sNwGosS4y
X-Gm-Gg: AeBDieu/4yPWW2tFyu+PfdAuWFihQxmlv7c/CoyZt0C5jLuozzGdV90kMYJwD8Doegj
	nSn/1gY+56gT/navAg79IWgng51BtF/IMKDy+1s7mWAziRZM0hTLsx5yVySk9dnfDYGi+/AcHDL
	rMsMCD9y5qarrRNcmyH876l3aAN9BWeudpxLCKRR9beM1q1UTEuLyDFHVgpugGLD4cJHo5imkvy
	BVrKgBY7r6oVP/BER6nez5Y1Sqv9XzGZvZQfq9LSTLq9SxjIKg7Okpu4n9m8QkkBdPWB8UiAcn7
	YpGF7e6ryqRaiACgvnf/T0g28l8Ka84XiWXeU1tC2Q2rSWlnWK9PV1LL2V7HwNxpaKC54iJvJ+4
	Z7A9UH8wuY3CYIz7XyXJJXTfMSqnaky7X3KgTAUPKi8zlQq+VyTJTOtYn1Ja0Uy4fcxcZQEiDjI
	Q2g5ykiJP1DRo4n/98IYeXtACf5/7xsQ==
X-Received: by 2002:a05:600c:8710:b0:485:3abe:ab86 with SMTP id 5b1f17b1804b1-488d67bbd1dmr195053745e9.4.1776084064464;
        Mon, 13 Apr 2026 05:41:04 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org>
Date: Mon, 13 Apr 2026 13:41:01 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Issues with the device eject path in XenVif
To: win-pv-devel@lists.xenproject.org
References: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech>
Content-Language: en-US
In-Reply-To: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-bad1c0/1776084065-54D5F152-65AA7F7A/0/0
X-purgate-type: clean
X-purgate-size: 2671

On 09/04/2026 16:29, Tu Dinh wrote:
> Hi all,
> 
> I'm currently trying to fix some lingering issues with VIF unplug, which
> will let me replace the MRSW lock with a simpler and faster implementation.
> 
> Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the
> FrontendEject worker thread, which watches backend/vif/DOMID/X/online
> among a few other things. I've run into several issues with this code path:
> 
> - When removing the VIF using `xe vif-unplug force=true`, the entire
> xenstore key of the backend is removed without a chance to tear down the
> connection. However, the watch on BACKEND/online will be triggered
> before the watch on device/vif, which causes the PDO to be marked as
> ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE
> instead of being a surprise removal.
> - In the REMOVE_DEVICE case, NDIS will wait for packets to be returned
> before continuing. Yet we cannot make progress because the backend has
> already disappeared, so the system will hang. This can be reproduced by
> doing an unplug with force=true while having some outbound traffic, but
> the timing is quite tight with the current code.
> - BACKEND/online is an internal, backend-specific value that is not
> documented in xenstore-paths or netif.h. So frontends should not use
> this value. I also find converting a VIF unplug to a query remove based
> on reading BACKEND/online somewhat dubious.
> 
> I've considered several options for a fix, which I have documented below:
> 
> 1. Make FrontendIsBackendOnline return a status code if BACKEND/online
> doesn't exist, and treat an error to read the key as a surprise removal.
>     - This ends up being unworkable, since QEMU will always first set
> BACKEND/online to 0 even if the VIF is being force-unplugged.

I still think this is the right way to deal with force unplug. Is there 
a tell-tale you can look for to see if it is forced? (E.g. has the 
frontend xenstore area completely gone?)

> 
> 2. Make FrontendIsBackendOnline check the backend's existence (i.e.
> reading the backend key instead of backend/online).
>     - This changes the unplug order slightly, but looks like the cleanest
> solution. Though I'm not sure if it breaks cancelling of device removal
> requests.
> 
> 3. Remove the eject codepath and rely on FdoScan instead.
>     - This might break a few things that assume the presence of this
> codepath.
> 
> I'd be glad to hear your opinions on this matter.
> 
> Thanks,
> 
> 
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
> 
> 



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 13:22:54 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 13:22:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281142.1564166 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHFd-0005Hg-4c; Mon, 13 Apr 2026 13:22:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281142.1564166; Mon, 13 Apr 2026 13:22:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHFd-0005HZ-1k; Mon, 13 Apr 2026 13:22:53 +0000
Received: by outflank-mailman (input) for mailman id 1281142;
 Mon, 13 Apr 2026 13:22:51 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69dcee28.v1-28242db51f0c40ddb2d2cf1934cd42fc@bounce.vates.tech>)
 id 1wCHFa-0005HT-Uj
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 13:22:51 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCHFa-002TP0-Af
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 15:22:50 +0200
Received: from [10.42.69.6] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69dcee28.v1-28242db51f0c40ddb2d2cf1934cd42fc@bounce.vates.tech>)
 id 69dcee22-bab6-0a2a0a5309dd-0a2a4506b172-26
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:22:50 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69dcee28.v1-28242db51f0c40ddb2d2cf1934cd42fc@bounce.vates.tech>)
 id 69dcee28-0df0-0a2a45060019-c602bb0e4ab8-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:22:49 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fvSkw4Wkbz8XS7ZW
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 13:22:48 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 28242db51f0c40ddb2d2cf1934cd42fc; Mon, 13 Apr 2026 13:22:48 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776086568; x=1776356568;
	bh=vjjH40MsIiC7XM3k2QsDy5XXrokac+wu0Rir43+mSeE=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=ILUVxz/icyGQGNGNn3ZD7SX8K8+T2/StGoE7K4mHklB3sRfIWn8knXyiXWleNUWHm
	 6QoR1t0J31jwpVnqJGO6nuD8IIj9itP8Zh+TCPJjUpwoa99xSiZWjtmArhKmeS05bU
	 I6/bZZ59lvOBAMAShnFCLq4PMRZveYqJ+cfadpXiN4pqipPVo3Z/WOs69y8NDhO4A5
	 o+TCLGh5OcYRjvmUSTwNHwrKsnLoy17+rZMudTJysbHPbU0oeybw7FiwJdK2sIzqQ/
	 VWWiEy2bV2xfyN5C0nItlvfLxlqAqRp1U6ln3ARheNTDC03e5Rt4dKzNrK+Hj43iyc
	 4/J4teg3iminw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776086568; x=1776347068; i=ngoc-tu.dinh@vates.tech;
	bh=vjjH40MsIiC7XM3k2QsDy5XXrokac+wu0Rir43+mSeE=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=uZaCOJKxduG+K1MtIEHEk80mOvWKxmlRwW65qzOPNiSWuGU2gdX50OZi5mRKCiJxp
	 jkGHZYQ8/HAASh0CWbWgdRrLk0FSzjermfZuN4ykNzVV1iNkuN67EGauuLQUpCYYC9
	 JcPYsF9ecafySRuxnf3uyy/s7SUsbFfcF4S2tISwvFBlUjXdF6pxrak7JFnGyf2zJ/
	 1AOeG0VuveqDVHzUdueS5ypX+wqKPxGRmFDLf+b5SFIqRedO8UkVC8yGOmeDQ+5Jyd
	 /18vz/jhzhgYSz7VsG4ljNy8R9DAom0RMTVSN4tKdoF2L0gELtWRMjgi4xLJTFDWNh
	 PpIsq9dN1tEMw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20Issues=20with=20the=20device=20eject=20path=20in=20XenVif?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776086567850
Message-Id: <81abeb0c-49d3-409c-b4ab-1eda7809d124@vates.tech>
To: "Paul Durrant" <xadimgnik@gmail.com>, win-pv-devel@lists.xenproject.org
References: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech> <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org>
In-Reply-To: <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.28242db51f0c40ddb2d2cf1934cd42fc?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260413:md
Date: Mon, 13 Apr 2026 13:22:48 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-purgate-ID: tlsNG-16d1c6/1776086570-AFF3D3D8-100D3DB0/0/0
X-purgate-type: clean
X-purgate-size: 3434

On 13/04/2026 14:41, Paul Durrant wrote:
> On 09/04/2026 16:29, Tu Dinh wrote:
>> Hi all,
>>
>> I'm currently trying to fix some lingering issues with VIF unplug, which
>> will let me replace the MRSW lock with a simpler and faster 
>> implementation.
>>
>> Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the
>> FrontendEject worker thread, which watches backend/vif/DOMID/X/online
>> among a few other things. I've run into several issues with this code 
>> path:
>>
>> - When removing the VIF using `xe vif-unplug force=3Dtrue`, the entire
>> xenstore key of the backend is removed without a chance to tear down the
>> connection. However, the watch on BACKEND/online will be triggered
>> before the watch on device/vif, which causes the PDO to be marked as
>> ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE
>> instead of being a surprise removal.
>> - In the REMOVE_DEVICE case, NDIS will wait for packets to be returned
>> before continuing. Yet we cannot make progress because the backend has
>> already disappeared, so the system will hang. This can be reproduced by
>> doing an unplug with force=3Dtrue while having some outbound traffic, bu=
t
>> the timing is quite tight with the current code.
>> - BACKEND/online is an internal, backend-specific value that is not
>> documented in xenstore-paths or netif.h. So frontends should not use
>> this value. I also find converting a VIF unplug to a query remove based
>> on reading BACKEND/online somewhat dubious.
>>
>> I've considered several options for a fix, which I have documented below=
:
>>
>> 1. Make FrontendIsBackendOnline return a status code if BACKEND/online
>> doesn't exist, and treat an error to read the key as a surprise removal.
>> =C2=A0=C2=A0=C2=A0 - This ends up being unworkable, since QEMU will alwa=
ys first set
>> BACKEND/online to 0 even if the VIF is being force-unplugged.
> 
> I still think this is the right way to deal with force unplug. Is there 
> a tell-tale you can look for to see if it is forced? (E.g. has the 
> frontend xenstore area completely gone?)
> 

What I observe during a force VIF unplug is an unplug request 
(BACKEND/online=3D0 / PdoRequestEject) shortly followed by the backend 
being wiped out. I couldn't find any tell I could use to distinguish the 
force unplug case from the normal one.

Maybe it can be fixed by attaching the watchdog thread's event to a 
watch on the backend, then (for transmitters) faking responses in the 
watchdog thread if we detect that the backend has disappeared.

>>
>> 2. Make FrontendIsBackendOnline check the backend's existence (i.e.
>> reading the backend key instead of backend/online).
>> =C2=A0=C2=A0=C2=A0 - This changes the unplug order slightly, but looks l=
ike the cleanest
>> solution. Though I'm not sure if it breaks cancelling of device removal
>> requests.
>>
>> 3. Remove the eject codepath and rely on FdoScan instead.
>> =C2=A0=C2=A0=C2=A0 - This might break a few things that assume the prese=
nce of this
>> codepath.
>>
>> I'd be glad to hear your opinions on this matter.
>>
>> Thanks,
>>
>>
>> -- 
>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>
>> XCP-ng & Xen Orchestra - Vates solutions
>>
>> web: https://vates.tech
>>
>>
> 
> 



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 13:34:59 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 13:34:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281149.1564169 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHRK-0006Tg-1B; Mon, 13 Apr 2026 13:34:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281149.1564169; Mon, 13 Apr 2026 13:34:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHRJ-0006TZ-Ux; Mon, 13 Apr 2026 13:34:57 +0000
Received: by outflank-mailman (input) for mailman id 1281149;
 Mon, 13 Apr 2026 13:34:56 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <xadimgnik@gmail.com>) id 1wCHRI-0006TT-9R
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 13:34:56 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCHRH-00CjO5-Gv
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 15:34:55 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <xadimgnik@gmail.com>)
 id 69dcf0fc-e002-0a2a0a5209dd-0a2a450be152-26
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:34:55 +0200
Received: from [209.85.221.49] (helo=mail-wr1-f49.google.com)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <xadimgnik@gmail.com>)
 id 69dcf0ff-bca8-0a2a450b0019-d155dd31b03d-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:34:55 +0200
Received: by mail-wr1-f49.google.com with SMTP id
 ffacd0b85a97d-43cf8fe9c2aso2784395f8f.2
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 06:34:55 -0700 (PDT)
Received: from [10.45.19.224] ([15.248.2.232])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-43d63dec295sm32785535f8f.14.2026.04.13.06.34.53
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 13 Apr 2026 06:34:54 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:In-Reply-To:Content-Language:References:To:Subject:User-Agent:MIME-Version:Date:Message-ID:From"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1776087295; x=1776692095; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:content-language:references
         :to:subject:user-agent:mime-version:date:message-id:from:from:to:cc
         :subject:date:message-id:reply-to;
        bh=4kxZLRrSAcYt5zmrmvaO2+4XlpwEIKl1Zj94LgLtP3k=;
        b=Uu+IqDontDnKNK4ppcsDXXBS5ZY/nbPivwcQ2pLLP8G8MKUvwQI2+3AudakalUBks4
         yIgTtuA9wyD7SeHWtOs1icRK8SQdd6+EojqjJNTW4IsaxhUU91TUZeAHyTC5lRQ20Z4R
         rskdEBU19BzaWRluDNgLmtPY+e4JNSrpZwwlR3oBnoOat2WvbSVVOV/1siqSO5NLxeig
         syq464IAXPIQhAkXFJzOEcKU0FgfnVtP8hjRAyszCPsv4b4xW9DcTkCzifantcuV+7+D
         xvRp8kBY+SwJYJ2PHYczl/2xS04DzXlBBGINLLaN6gzQihvQK6vuFmQ8mmiNCasxlIpY
         FeyA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20251104; t=1776087295; x=1776692095;
        h=content-transfer-encoding:in-reply-to:content-language:references
         :to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
        bh=4kxZLRrSAcYt5zmrmvaO2+4XlpwEIKl1Zj94LgLtP3k=;
        b=Bol3MPqWZ1NTucopkgMppYgk8uXAYU5K04oayoMD7+ZhgKlOca86p/N7RhxdZdxM+5
         7kaBzfhLjFhsgDK6hIZG1LmeXKcb5QI8nZK7AugaNHWcq+TIZuIMEmYTeU7thukxsdOl
         rPybQlD/JLLwgk6wt4vJq0zGFXaQ5l6xQRd/6fV2KPVPFNBwWmjrEVsC3Ya04FaRoL/e
         j2Ol2irCpReO6j7h8ZAdyp4fR1vHTxI0cXV3IOUuGvcc5uteEhp+H3wo2P/x7uh2eAoR
         0gEV/zskESHYoRHwZ6z3E282qNZIhZ5wSJAnslVE4oIFRxa4YcNnb2LELWNY3rhJGrJn
         QeRw==
X-Forwarded-Encrypted: i=1; AFNElJ+lEuFVZm/Zv12NkuFSCh/DeJAbwLt52ed5JpgKa7NMeR4JsUCEiGpYC1r061eAXVpIZvUptV9B31yNY9o=@lists.xenproject.org
X-Gm-Message-State: AOJu0Yx4bYW9TJnvTJNpXJzNwzjs+3RfDQ3kwkfIPFTr0IBvoNHI2FDG
	dnewrpXhLEFHEYh0SUVgLkVppXcmFdCRwUf6buwQieMD5dzDJGiSfUaF
X-Gm-Gg: AeBDietrjYleolvNWRnnL98WtCzor2YbBgxdXxJdMY19sEfuJ9uvXsgnhByv8yN2TaN
	cWACopyKmwbLlN8n7t493rEEtHX1tftrvsbnuzMVebkuqvphFNZMBraenYP/y4IErj9EkgKYGkv
	jI626KcWhJXtkm3qMjpL43IA6FhvyT+aljwpAHO94OF6DFYOEjQ9xQK4+Wj7hzKX9DM4oK+oCg3
	XVThlm4RL5QZM3sgdz54yjngr4oE1XnX8FYmc7+W3Soy+ZqdvMCwuZXg+4P+LAIgd8FSdTY4C3A
	DyS/djsfbPTmvhhy7veKjo1YZrMEiGSi2HHgqieIStHsMW9a7tPghPO+tSYovO8IL0kdM63LQag
	gLU0qAWaw+ZdSgZ2Qo48xdye+T1UNgUjXDtm4FKnP5xeifRPbp8cUxK3pryWNqfjLpiwleHzyJz
	R0/yc6FnqU5LV7IGgkoKaKJbnpk6D5HQ==
X-Received: by 2002:a05:6000:200f:b0:43d:2f94:3b40 with SMTP id ffacd0b85a97d-43d64255019mr19312887f8f.6.1776087294614;
        Mon, 13 Apr 2026 06:34:54 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <60ac07b2-c1fa-4283-82aa-efc3dd25fae5@xen.org>
Date: Mon, 13 Apr 2026 14:34:53 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Issues with the device eject path in XenVif
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, Paul Durrant <xadimgnik@gmail.com>,
 win-pv-devel@lists.xenproject.org
References: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech>
 <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org>
 <81abeb0c-49d3-409c-b4ab-1eda7809d124@vates.tech>
Content-Language: en-US
In-Reply-To: <81abeb0c-49d3-409c-b4ab-1eda7809d124@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-purgate-ID: tlsNG-42698a/1776087295-EE1552A1-4D46B878/0/0
X-purgate-type: clean
X-purgate-size: 3763

On 13/04/2026 14:22, Tu Dinh wrote:
> On 13/04/2026 14:41, Paul Durrant wrote:
>> On 09/04/2026 16:29, Tu Dinh wrote:
>>> Hi all,
>>>
>>> I'm currently trying to fix some lingering issues with VIF unplug, which
>>> will let me replace the MRSW lock with a simpler and faster
>>> implementation.
>>>
>>> Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the
>>> FrontendEject worker thread, which watches backend/vif/DOMID/X/online
>>> among a few other things. I've run into several issues with this code
>>> path:
>>>
>>> - When removing the VIF using `xe vif-unplug force=true`, the entire
>>> xenstore key of the backend is removed without a chance to tear down the
>>> connection. However, the watch on BACKEND/online will be triggered
>>> before the watch on device/vif, which causes the PDO to be marked as
>>> ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE
>>> instead of being a surprise removal.
>>> - In the REMOVE_DEVICE case, NDIS will wait for packets to be returned
>>> before continuing. Yet we cannot make progress because the backend has
>>> already disappeared, so the system will hang. This can be reproduced by
>>> doing an unplug with force=true while having some outbound traffic, but
>>> the timing is quite tight with the current code.
>>> - BACKEND/online is an internal, backend-specific value that is not
>>> documented in xenstore-paths or netif.h. So frontends should not use
>>> this value. I also find converting a VIF unplug to a query remove based
>>> on reading BACKEND/online somewhat dubious.
>>>
>>> I've considered several options for a fix, which I have documented below:
>>>
>>> 1. Make FrontendIsBackendOnline return a status code if BACKEND/online
>>> doesn't exist, and treat an error to read the key as a surprise removal.
>>>      - This ends up being unworkable, since QEMU will always first set
>>> BACKEND/online to 0 even if the VIF is being force-unplugged.
>>
>> I still think this is the right way to deal with force unplug. Is there
>> a tell-tale you can look for to see if it is forced? (E.g. has the
>> frontend xenstore area completely gone?)
>>
> 
> What I observe during a force VIF unplug is an unplug request
> (BACKEND/online=0 / PdoRequestEject) shortly followed by the backend
> being wiped out. I couldn't find any tell I could use to distinguish the
> force unplug case from the normal one.
> 
> Maybe it can be fixed by attaching the watchdog thread's event to a
> watch on the backend, then (for transmitters) faking responses in the
> watchdog thread if we detect that the backend has disappeared.
> 

The PdoRequestEject is trigger off the state change watch though isn't 
it. In the case of force does the state still change to 'closing'? I'd 
have thought the node would be removed, in which case the state would go 
to 'unknown' instead.

>>>
>>> 2. Make FrontendIsBackendOnline check the backend's existence (i.e.
>>> reading the backend key instead of backend/online).
>>>      - This changes the unplug order slightly, but looks like the cleanest
>>> solution. Though I'm not sure if it breaks cancelling of device removal
>>> requests.
>>>
>>> 3. Remove the eject codepath and rely on FdoScan instead.
>>>      - This might break a few things that assume the presence of this
>>> codepath.
>>>
>>> I'd be glad to hear your opinions on this matter.
>>>
>>> Thanks,
>>>
>>>
>>> -- 
>>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>>
>>> XCP-ng & Xen Orchestra - Vates solutions
>>>
>>> web: https://vates.tech
>>>
>>>
>>
>>
> 
> 
> 
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
> 
> 



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 13:43:56 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 13:43:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281151.1564173 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHZy-0007cp-MA; Mon, 13 Apr 2026 13:43:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281151.1564173; Mon, 13 Apr 2026 13:43:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHZy-0007ci-Jb; Mon, 13 Apr 2026 13:43:54 +0000
Received: by outflank-mailman (input) for mailman id 1281151;
 Mon, 13 Apr 2026 13:43:53 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69dcf315.v1-6e69fb0130734aeb9648559ac094de12@bounce.vates.tech>)
 id 1wCHZx-0007cc-06
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 13:43:53 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCHZv-007mCM-DO
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 15:43:51 +0200
Received: from [10.42.69.5] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69dcf315.v1-6e69fb0130734aeb9648559ac094de12@bounce.vates.tech>)
 id 69dcf30c-e002-0a2a0a5209dd-0a2a450585dc-30
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:43:51 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69dcf315.v1-6e69fb0130734aeb9648559ac094de12@bounce.vates.tech>)
 id 69dcf316-3760-0a2a45050019-c602bb0e2037-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:43:51 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fvTC95d1Yz8XRwKc
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 13:43:49 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 6e69fb0130734aeb9648559ac094de12; Mon, 13 Apr 2026 13:43:49 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776087829; x=1776357829;
	bh=wpjL1AfEM0eNUixcxkPNMxH/+Abb2rbPteGO1LFM1Wc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=wm8Gsj2R9XyJVBmeU39tmzIR7CxW8P014Xek9hxBA49oIISIvMa6zwneqaHjpbgig
	 sY4O8kprMer+5MRoZuZsa7J87MlyySpNL855fjhl6rbD0WctSEZAlu+JuYCKojFpCg
	 /AlvjQ9OYJBCIub3wLZeN8sYti5IQVFDNyJYk5telVHuvkzB9SxXp2eGCMq58D9o4e
	 WIFL64zlwGeetZqsd7OxRjis85vEWSgj8uDmE5fINlmL1zEOw/caMzyetQ2uEt7clF
	 34Wzm062XH10otpIJnBySSbnZpMUvrb2c6BaT4icohVrebVu+K34EwSfFjsJDuuZ7n
	 4Pz7T72mOEKWA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776087829; x=1776348329; i=ngoc-tu.dinh@vates.tech;
	bh=wpjL1AfEM0eNUixcxkPNMxH/+Abb2rbPteGO1LFM1Wc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=sBzP8wNzLZVwbnJKmEFDVz2tHtQMun3buhCPbMKqaJqYzrG7aTkUknxmt50oB70HJ
	 e2DkbWY008MR8E2cSIZsFDHiwQTQjtp1qI2iO4xDvv5ngn3fq/50jBCBmMkl91vfR7
	 5Ov6pR6k3/f8ogl6QQ2dkhMyvsWcLPdIDvumAygB+Y6ikMxzmRmHiF7OPC68wzMw4E
	 N1717r9WltakHEP6YLAiQ2xw5vfSuvZ6Nl5EW0Hmbdn0BPpv8FzI4ZG3OO8Whzd6S9
	 IAKx4RFWCb8N3oVA6f5OQP+UzhEkgHssJJTOl7pranDsO5peqC0i8U2BHoQvX1Njqs
	 zwaJ4JI5k35sQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20Issues=20with=20the=20device=20eject=20path=20in=20XenVif?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776087828988
Message-Id: <92d36174-2f88-4fcb-bfe6-70984e7b80d6@vates.tech>
To: "Paul Durrant" <xadimgnik@gmail.com>, win-pv-devel@lists.xenproject.org
References: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech> <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org> <81abeb0c-49d3-409c-b4ab-1eda7809d124@vates.tech> <60ac07b2-c1fa-4283-82aa-efc3dd25fae5@xen.org>
In-Reply-To: <60ac07b2-c1fa-4283-82aa-efc3dd25fae5@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.6e69fb0130734aeb9648559ac094de12?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260413:md
Date: Mon, 13 Apr 2026 13:43:49 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-purgate-ID: tlsNG-c201ff/1776087831-3372A96F-7832AC50/0/0
X-purgate-type: clean
X-purgate-size: 4467

On 13/04/2026 15:35, Paul Durrant wrote:
> On 13/04/2026 14:22, Tu Dinh wrote:
>> On 13/04/2026 14:41, Paul Durrant wrote:
>>> On 09/04/2026 16:29, Tu Dinh wrote:
>>>> Hi all,
>>>>
>>>> I'm currently trying to fix some lingering issues with VIF unplug, 
>>>> which
>>>> will let me replace the MRSW lock with a simpler and faster
>>>> implementation.
>>>>
>>>> Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the
>>>> FrontendEject worker thread, which watches backend/vif/DOMID/X/online
>>>> among a few other things. I've run into several issues with this code
>>>> path:
>>>>
>>>> - When removing the VIF using `xe vif-unplug force=3Dtrue`, the entire
>>>> xenstore key of the backend is removed without a chance to tear down 
>>>> the
>>>> connection. However, the watch on BACKEND/online will be triggered
>>>> before the watch on device/vif, which causes the PDO to be marked as
>>>> ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE
>>>> instead of being a surprise removal.
>>>> - In the REMOVE_DEVICE case, NDIS will wait for packets to be returned
>>>> before continuing. Yet we cannot make progress because the backend has
>>>> already disappeared, so the system will hang. This can be reproduced b=
y
>>>> doing an unplug with force=3Dtrue while having some outbound traffic, =
but
>>>> the timing is quite tight with the current code.
>>>> - BACKEND/online is an internal, backend-specific value that is not
>>>> documented in xenstore-paths or netif.h. So frontends should not use
>>>> this value. I also find converting a VIF unplug to a query remove base=
d
>>>> on reading BACKEND/online somewhat dubious.
>>>>
>>>> I've considered several options for a fix, which I have documented 
>>>> below:
>>>>
>>>> 1. Make FrontendIsBackendOnline return a status code if BACKEND/online
>>>> doesn't exist, and treat an error to read the key as a surprise 
>>>> removal.
>>>> =C2=A0=C2=A0=C2=A0=C2=A0 - This ends up being unworkable, since QEMU w=
ill always first set
>>>> BACKEND/online to 0 even if the VIF is being force-unplugged.
>>>
>>> I still think this is the right way to deal with force unplug. Is there
>>> a tell-tale you can look for to see if it is forced? (E.g. has the
>>> frontend xenstore area completely gone?)
>>>
>>
>> What I observe during a force VIF unplug is an unplug request
>> (BACKEND/online=3D0 / PdoRequestEject) shortly followed by the backend
>> being wiped out. I couldn't find any tell I could use to distinguish the
>> force unplug case from the normal one.
>>
>> Maybe it can be fixed by attaching the watchdog thread's event to a
>> watch on the backend, then (for transmitters) faking responses in the
>> watchdog thread if we detect that the backend has disappeared.
>>
> 
> The PdoRequestEject is trigger off the state change watch though isn't 
> it. In the case of force does the state still change to 'closing'? I'd 
> have thought the node would be removed, in which case the state would go 
> to 'unknown' instead.
> 

There's no watchdog thread waiting for BACKEND/state, and NDIS waits for 
packet return during initial handling of IRP_MN_REMOVE_DEVICE before 
xennet/xenvif is entered. So for now there's no opportunity for 
FrontendClose/FrontendWaitForBackendXenbusStateChange to be called in 
order to update the state to Unknown.

>>>>
>>>> 2. Make FrontendIsBackendOnline check the backend's existence (i.e.
>>>> reading the backend key instead of backend/online).
>>>> =C2=A0=C2=A0=C2=A0=C2=A0 - This changes the unplug order slightly, but=
 looks like the 
>>>> cleanest
>>>> solution. Though I'm not sure if it breaks cancelling of device remova=
l
>>>> requests.
>>>>
>>>> 3. Remove the eject codepath and rely on FdoScan instead.
>>>> =C2=A0=C2=A0=C2=A0=C2=A0 - This might break a few things that assume t=
he presence of this
>>>> codepath.
>>>>
>>>> I'd be glad to hear your opinions on this matter.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>> -- 
>>>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>>>
>>>> XCP-ng & Xen Orchestra - Vates solutions
>>>>
>>>> web: https://vates.tech
>>>>
>>>>
>>>
>>>
>>
>>
>>
>> -- 
>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>
>> XCP-ng & Xen Orchestra - Vates solutions
>>
>> web: https://vates.tech
>>
>>
> 
> 



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 13:47:59 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 13:47:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281161.1564186 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHdv-0008Di-7n; Mon, 13 Apr 2026 13:47:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281161.1564186; Mon, 13 Apr 2026 13:47:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHdv-0008Db-5A; Mon, 13 Apr 2026 13:47:59 +0000
Received: by outflank-mailman (input) for mailman id 1281161;
 Mon, 13 Apr 2026 13:47:58 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <xadimgnik@gmail.com>) id 1wCHdu-0008DV-0B
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 13:47:58 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCHdt-003PIl-CG
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 15:47:57 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <xadimgnik@gmail.com>)
 id 69dcf404-5cb7-0a2a0a5109dd-0a2a4502cbea-22
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:47:57 +0200
Received: from [209.85.218.47] (helo=mail-ej1-f47.google.com)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <xadimgnik@gmail.com>)
 id 69dcf40d-42fa-0a2a45020019-d155da2fdd87-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:47:57 +0200
Received: by mail-ej1-f47.google.com with SMTP id
 a640c23a62f3a-b9358bc9c50so574564866b.1
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 06:47:57 -0700 (PDT)
Received: from [10.45.19.224] ([15.248.3.92]) by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-b9d6dfd51bcsm320601066b.17.2026.04.13.06.47.55
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 13 Apr 2026 06:47:56 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:In-Reply-To:Content-Language:References:To:Subject:User-Agent:MIME-Version:Date:Message-ID:From"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1776088077; x=1776692877; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:content-language:references
         :to:subject:user-agent:mime-version:date:message-id:from:from:to:cc
         :subject:date:message-id:reply-to;
        bh=AlRlUVHa/eGkASdLyMIjFi1Gksf/JUgR1+vHsGQO42w=;
        b=rIwaqVrMbLn6tHtfIQ/PHtn8g/KTuuyPNGqw6rmxTD9wEaObBqTb7TzGRST0i7cBur
         uFwXqlEjEa6AcY0Iao4IzkPikDTre6xsCeKLURl46eOsOQaq+63MVtufZmhPHW6phLEV
         2pJF5CYJzrcR9g2Hq7mDMncBtMR7MoCUoJBGV0Xl4jHQo1gOixup19PVu5MgHVJfWwqy
         GIgFsM5kehtPeyOmjPtHamDf3GL9hWUNpG59VCDrQaWT6DHYgIUrcHfBeLu/vbck3UzB
         HMisWaemlZAVoXKDWbEiZdEXBvgbraAZkobVGPFwMcwD0UxeIn6OLBbfV9ro8xPwT+r+
         lx8g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20251104; t=1776088077; x=1776692877;
        h=content-transfer-encoding:in-reply-to:content-language:references
         :to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
        bh=AlRlUVHa/eGkASdLyMIjFi1Gksf/JUgR1+vHsGQO42w=;
        b=MSO4xLeyJRoErvJoRdlH/66IUzlMMS0X/p9N4YkKtoPoiytoa9RagTGDWCI+aebyvb
         Sh4uti29qFRZx1sDptocsmsmQ509hj+gzlVMGor5Mc++gO2i0OYIcgdHyC+C6DTIxqmI
         X/u0jxx9Rowcq+uHpn0Q4MsoiwT2w5r8Wf97xFWt2yTQtiEVsOkQsb49HoUrPjwJ01Yw
         FutKs7l+ueHEQNUNOjek5zlnVJELXio3GwvnN/Yh62bl5B254P9+XrbyJoAMB19o0vKC
         bJSCw+OKod13TiaFZYODcsJvi/hF/zVP0UMQml/ThM+fKxuQcqzkbJipE/HzxvwB9Hfu
         U2VA==
X-Forwarded-Encrypted: i=1; AFNElJ/gc3XJv4cA5XKyWOo8/fFxs2cYxRpsitqUwoV3fFmTssSLWYir/LAt6cQfmFSVmCT8UdnUXSwp3JK20Kc=@lists.xenproject.org
X-Gm-Message-State: AOJu0YxS5l0xnhxfP9+rr+d7TFh6lsxm/OILmajSro+/amuMlC2HgYNM
	QEUtlgtCF83HHkLoLjIaYo/T4noxgPIGFAlWQ7sxnSTdBwGs8yKMhbzN2MMdOzrX
X-Gm-Gg: AeBDiesCRCn+1gScaOL+VPDeFjTD7XE+0Ovd/zk2NFiG4qjAVWeE4AEG6laqiOIjJ07
	jo+rbKzzpiwB6ArHhORj62YE9qFxDgiz7bpsjdI5fyUNjkSnsifTdaomvOMuyiLHQUsBaM61t+v
	9p8k6H6sjFjARDTLPF1+cEHeh6ntOmqjs74zs0GoR07AVqEACsO+/3dDcpruVM1+y2vYuwH1jQ8
	T26kT0BF1hOjVcQp53qwm4LPCn7i7j+eEs3sMeYbsksGDJQQrikf0jw7gSBGatMVWi9+4Al4KSD
	zkx9rciH/X0fhFCzgv65JXNq5pl4dSFW5tsmXAW6cUQu/hLumQEzivLPdRhAKpubaJUFWe3ZryQ
	SD4xKObOtAUhKChFb5gc4xMLmtHKz+v/lDvXAXYL22mZIRDbbtGMue8Jji8AimWL89OZdKm+QWK
	DxbGa/TKwVUy/BkOg8snmiY5ACEGVx
X-Received: by 2002:a17:907:c081:b0:b9c:60bc:eafd with SMTP id a640c23a62f3a-b9d726615c5mr837857566b.34.1776088076603;
        Mon, 13 Apr 2026 06:47:56 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Message-ID: <732b923a-0846-419d-9d71-e0994293af88@xen.org>
Date: Mon, 13 Apr 2026 14:47:55 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Issues with the device eject path in XenVif
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, Paul Durrant <xadimgnik@gmail.com>,
 win-pv-devel@lists.xenproject.org
References: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech>
 <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org>
 <81abeb0c-49d3-409c-b4ab-1eda7809d124@vates.tech>
 <60ac07b2-c1fa-4283-82aa-efc3dd25fae5@xen.org>
 <92d36174-2f88-4fcb-bfe6-70984e7b80d6@vates.tech>
Content-Language: en-US
In-Reply-To: <92d36174-2f88-4fcb-bfe6-70984e7b80d6@vates.tech>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-purgate-ID: tlsNG-720697/1776088077-4CBF5CD1-FA0FCD7C/0/0
X-purgate-type: clean
X-purgate-size: 4762

On 13/04/2026 14:43, Tu Dinh wrote:
> On 13/04/2026 15:35, Paul Durrant wrote:
>> On 13/04/2026 14:22, Tu Dinh wrote:
>>> On 13/04/2026 14:41, Paul Durrant wrote:
>>>> On 09/04/2026 16:29, Tu Dinh wrote:
>>>>> Hi all,
>>>>>
>>>>> I'm currently trying to fix some lingering issues with VIF unplug,
>>>>> which
>>>>> will let me replace the MRSW lock with a simpler and faster
>>>>> implementation.
>>>>>
>>>>> Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the
>>>>> FrontendEject worker thread, which watches backend/vif/DOMID/X/online
>>>>> among a few other things. I've run into several issues with this code
>>>>> path:
>>>>>
>>>>> - When removing the VIF using `xe vif-unplug force=true`, the entire
>>>>> xenstore key of the backend is removed without a chance to tear down
>>>>> the
>>>>> connection. However, the watch on BACKEND/online will be triggered
>>>>> before the watch on device/vif, which causes the PDO to be marked as
>>>>> ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE
>>>>> instead of being a surprise removal.
>>>>> - In the REMOVE_DEVICE case, NDIS will wait for packets to be returned
>>>>> before continuing. Yet we cannot make progress because the backend has
>>>>> already disappeared, so the system will hang. This can be reproduced by
>>>>> doing an unplug with force=true while having some outbound traffic, but
>>>>> the timing is quite tight with the current code.
>>>>> - BACKEND/online is an internal, backend-specific value that is not
>>>>> documented in xenstore-paths or netif.h. So frontends should not use
>>>>> this value. I also find converting a VIF unplug to a query remove based
>>>>> on reading BACKEND/online somewhat dubious.
>>>>>
>>>>> I've considered several options for a fix, which I have documented
>>>>> below:
>>>>>
>>>>> 1. Make FrontendIsBackendOnline return a status code if BACKEND/online
>>>>> doesn't exist, and treat an error to read the key as a surprise
>>>>> removal.
>>>>>       - This ends up being unworkable, since QEMU will always first set
>>>>> BACKEND/online to 0 even if the VIF is being force-unplugged.
>>>>
>>>> I still think this is the right way to deal with force unplug. Is there
>>>> a tell-tale you can look for to see if it is forced? (E.g. has the
>>>> frontend xenstore area completely gone?)
>>>>
>>>
>>> What I observe during a force VIF unplug is an unplug request
>>> (BACKEND/online=0 / PdoRequestEject) shortly followed by the backend
>>> being wiped out. I couldn't find any tell I could use to distinguish the
>>> force unplug case from the normal one.
>>>
>>> Maybe it can be fixed by attaching the watchdog thread's event to a
>>> watch on the backend, then (for transmitters) faking responses in the
>>> watchdog thread if we detect that the backend has disappeared.
>>>
>>
>> The PdoRequestEject is trigger off the state change watch though isn't
>> it. In the case of force does the state still change to 'closing'? I'd
>> have thought the node would be removed, in which case the state would go
>> to 'unknown' instead.
>>
> 
> There's no watchdog thread waiting for BACKEND/state, and NDIS waits for
> packet return during initial handling of IRP_MN_REMOVE_DEVICE before
> xennet/xenvif is entered. So for now there's no opportunity for
> FrontendClose/FrontendWaitForBackendXenbusStateChange to be called in
> order to update the state to Unknown.
> 

Ok, that's the problem then. IIRC the eject protocol is setting online 
-> 0 and then setting state -> closing. So the eject should be driven by 
a watch on 'state' rather than a watch on 'online'.

>>>>>
>>>>> 2. Make FrontendIsBackendOnline check the backend's existence (i.e.
>>>>> reading the backend key instead of backend/online).
>>>>>       - This changes the unplug order slightly, but looks like the
>>>>> cleanest
>>>>> solution. Though I'm not sure if it breaks cancelling of device removal
>>>>> requests.
>>>>>
>>>>> 3. Remove the eject codepath and rely on FdoScan instead.
>>>>>       - This might break a few things that assume the presence of this
>>>>> codepath.
>>>>>
>>>>> I'd be glad to hear your opinions on this matter.
>>>>>
>>>>> Thanks,
>>>>>
>>>>>
>>>>> -- 
>>>>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>>>>
>>>>> XCP-ng & Xen Orchestra - Vates solutions
>>>>>
>>>>> web: https://vates.tech
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> -- 
>>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>>
>>> XCP-ng & Xen Orchestra - Vates solutions
>>>
>>> web: https://vates.tech
>>>
>>>
>>
>>
> 
> 
> 
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
> 
> 



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 13 13:57:00 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 13 Apr 2026 13:57:00 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281162.1564190 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHmd-0000xO-Sh; Mon, 13 Apr 2026 13:56:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281162.1564190; Mon, 13 Apr 2026 13:56:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCHmd-0000xH-QB; Mon, 13 Apr 2026 13:56:59 +0000
Received: by outflank-mailman (input) for mailman id 1281162;
 Mon, 13 Apr 2026 13:56:58 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69dcf622.v1-d11056c304c34f7ea58f250408d168e3@bounce.vates.tech>)
 id 1wCHmc-0000xB-AC
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 13:56:58 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCHma-00GvAF-Tk
 for win-pv-devel@lists.xenproject.org; Mon, 13 Apr 2026 15:56:56 +0200
Received: from [10.42.69.5] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69dcf622.v1-d11056c304c34f7ea58f250408d168e3@bounce.vates.tech>)
 id 69dcf61f-bab6-0a2a0a5309dd-0a2a4505a508-28
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:56:56 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69dcf622.v1-d11056c304c34f7ea58f250408d168e3@bounce.vates.tech>)
 id 69dcf622-3760-0a2a45050019-c602bb0efbd3-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 15:56:51 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fvTVB4Jgnz8XRvwg
 for <win-pv-devel@lists.xenproject.org>; Mon, 13 Apr 2026 13:56:50 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 d11056c304c34f7ea58f250408d168e3; Mon, 13 Apr 2026 13:56:50 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776088610; x=1776358610;
	bh=WAk1h/tJnbBj1eaDMMwxbTb6Ij9KhZOVGqcrQ0CjiPQ=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=b4U3z2cABZpSroY7wH9Us687fJAaFYUxOgwq1jzYhA7OqTULL9MCJMY9ud/EhEkun
	 RwE3oyhNiAQzVlblbW+JsjUBvL9uVcuCLS6OQMA1ViQkwsG+iP/mS1/gRpKI3Mjj6M
	 G71Cg0WQ9GKzCYD3/uovDJC7iyYqdusZWdelHDYPibF3LB6HxyBZAJbke4Sl8aVrhv
	 b8Vj3UA/8qQRyOOOX1QAJJ9B1+bj9G/qOryZg/47/pSBJvEihQ7TEosYiEhLn94qOK
	 or9puJWm2rRlsQRJF8id3aPwORWF6nBAxCs4GdyxZXmBEPnTTyPCw7QgzZYd9T7PCt
	 p3W0Vqk1IC6cg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776088610; x=1776349110; i=ngoc-tu.dinh@vates.tech;
	bh=WAk1h/tJnbBj1eaDMMwxbTb6Ij9KhZOVGqcrQ0CjiPQ=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=NKziOhGKHa/YPFZXje8fC8F/gpl5CnRvhIajb8AXg9U3q0QoBGqqEuxGYZbXr9PWv
	 wPpVyhDh2s1Xn1C82/OG3j44VYPQmdbntBKcygaOI6g1wERILuVRa0et0puszbp9GV
	 LlsO44lIE2sOsx7Vvr9BW2Pdq3L5ignLYDxQK5ijgPRmeONrwD6T+X+IRz4tI3N5ok
	 vMKYCT9JUKyS16Zoozq1MkXMuKGZ0GKoDTEpXYp14BvWPUKeQnoAMwqArEuSXPlrWo
	 YN72d7kHneu66JzWsryNi/PEdXhMmvP3iY3OjVzafq8knkNtnHjvJRK9y0Cg1Jnbj4
	 ybvLmrEILoT1A==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20Issues=20with=20the=20device=20eject=20path=20in=20XenVif?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776088609809
Message-Id: <05682cd9-5d35-4fbb-87d4-9a53581843bd@vates.tech>
To: "Paul Durrant" <xadimgnik@gmail.com>, win-pv-devel@lists.xenproject.org
References: <f587c8a1-e886-4c58-98d9-07a13722aced@vates.tech> <c01b7ad2-396e-4668-9706-6813ebf349cb@xen.org> <81abeb0c-49d3-409c-b4ab-1eda7809d124@vates.tech> <60ac07b2-c1fa-4283-82aa-efc3dd25fae5@xen.org> <92d36174-2f88-4fcb-bfe6-70984e7b80d6@vates.tech> <732b923a-0846-419d-9d71-e0994293af88@xen.org>
In-Reply-To: <732b923a-0846-419d-9d71-e0994293af88@xen.org>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.d11056c304c34f7ea58f250408d168e3?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260413:md
Date: Mon, 13 Apr 2026 13:56:50 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-purgate-ID: tlsNG-c201ff/1776088612-3392996F-CA156A5B/0/0
X-purgate-type: clean
X-purgate-size: 5282

On 13/04/2026 15:48, Paul Durrant wrote:
> On 13/04/2026 14:43, Tu Dinh wrote:
>> On 13/04/2026 15:35, Paul Durrant wrote:
>>> On 13/04/2026 14:22, Tu Dinh wrote:
>>>> On 13/04/2026 14:41, Paul Durrant wrote:
>>>>> On 09/04/2026 16:29, Tu Dinh wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> I'm currently trying to fix some lingering issues with VIF unplug,
>>>>>> which
>>>>>> will let me replace the MRSW lock with a simpler and faster
>>>>>> implementation.
>>>>>>
>>>>>> Pdo->Eject/PdoRequestEject (e.g. in XenVif) is signaled by the
>>>>>> FrontendEject worker thread, which watches backend/vif/DOMID/X/onlin=
e
>>>>>> among a few other things. I've run into several issues with this cod=
e
>>>>>> path:
>>>>>>
>>>>>> - When removing the VIF using `xe vif-unplug force=3Dtrue`, the enti=
re
>>>>>> xenstore key of the backend is removed without a chance to tear down
>>>>>> the
>>>>>> connection. However, the watch on BACKEND/online will be triggered
>>>>>> before the watch on device/vif, which causes the PDO to be marked as
>>>>>> ejected, and so goes through the QUERY_REMOVE_DEVICE/REMOVE_DEVICE
>>>>>> instead of being a surprise removal.
>>>>>> - In the REMOVE_DEVICE case, NDIS will wait for packets to be 
>>>>>> returned
>>>>>> before continuing. Yet we cannot make progress because the backend 
>>>>>> has
>>>>>> already disappeared, so the system will hang. This can be 
>>>>>> reproduced by
>>>>>> doing an unplug with force=3Dtrue while having some outbound 
>>>>>> traffic, but
>>>>>> the timing is quite tight with the current code.
>>>>>> - BACKEND/online is an internal, backend-specific value that is not
>>>>>> documented in xenstore-paths or netif.h. So frontends should not use
>>>>>> this value. I also find converting a VIF unplug to a query remove 
>>>>>> based
>>>>>> on reading BACKEND/online somewhat dubious.
>>>>>>
>>>>>> I've considered several options for a fix, which I have documented
>>>>>> below:
>>>>>>
>>>>>> 1. Make FrontendIsBackendOnline return a status code if BACKEND/ 
>>>>>> online
>>>>>> doesn't exist, and treat an error to read the key as a surprise
>>>>>> removal.
>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - This ends up being unworkable, sinc=
e QEMU will always 
>>>>>> first set
>>>>>> BACKEND/online to 0 even if the VIF is being force-unplugged.
>>>>>
>>>>> I still think this is the right way to deal with force unplug. Is 
>>>>> there
>>>>> a tell-tale you can look for to see if it is forced? (E.g. has the
>>>>> frontend xenstore area completely gone?)
>>>>>
>>>>
>>>> What I observe during a force VIF unplug is an unplug request
>>>> (BACKEND/online=3D0 / PdoRequestEject) shortly followed by the backend
>>>> being wiped out. I couldn't find any tell I could use to distinguish 
>>>> the
>>>> force unplug case from the normal one.
>>>>
>>>> Maybe it can be fixed by attaching the watchdog thread's event to a
>>>> watch on the backend, then (for transmitters) faking responses in the
>>>> watchdog thread if we detect that the backend has disappeared.
>>>>
>>>
>>> The PdoRequestEject is trigger off the state change watch though isn't
>>> it. In the case of force does the state still change to 'closing'? I'd
>>> have thought the node would be removed, in which case the state would g=
o
>>> to 'unknown' instead.
>>>
>>
>> There's no watchdog thread waiting for BACKEND/state, and NDIS waits for
>> packet return during initial handling of IRP_MN_REMOVE_DEVICE before
>> xennet/xenvif is entered. So for now there's no opportunity for
>> FrontendClose/FrontendWaitForBackendXenbusStateChange to be called in
>> order to update the state to Unknown.
>>
> 
> Ok, that's the problem then. IIRC the eject protocol is setting online - 
>  > 0 and then setting state -> closing. So the eject should be driven by 
> a watch on 'state' rather than a watch on 'online'.
> 

Thanks, I'll give that a try.

>>>>>>
>>>>>> 2. Make FrontendIsBackendOnline check the backend's existence (i.e.
>>>>>> reading the backend key instead of backend/online).
>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - This changes the unplug order sligh=
tly, but looks like the
>>>>>> cleanest
>>>>>> solution. Though I'm not sure if it breaks cancelling of device 
>>>>>> removal
>>>>>> requests.
>>>>>>
>>>>>> 3. Remove the eject codepath and rely on FdoScan instead.
>>>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - This might break a few things that =
assume the presence of 
>>>>>> this
>>>>>> codepath.
>>>>>>
>>>>>> I'd be glad to hear your opinions on this matter.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>>>>>
>>>>>> XCP-ng & Xen Orchestra - Vates solutions
>>>>>>
>>>>>> web: https://vates.tech
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> -- 
>>>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>>>
>>>> XCP-ng & Xen Orchestra - Vates solutions
>>>>
>>>> web: https://vates.tech
>>>>
>>>>
>>>
>>>
>>
>>
>>
>> -- 
>> Ngoc Tu Dinh | Vates XCP-ng Developer
>>
>> XCP-ng & Xen Orchestra - Vates solutions
>>
>> web: https://vates.tech
>>
>>
> 
> 



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 08:00:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 08:00:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281447.1564338 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCYhT-0008Nc-BC; Tue, 14 Apr 2026 08:00:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281447.1564338; Tue, 14 Apr 2026 08:00:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCYhT-0008NV-8c; Tue, 14 Apr 2026 08:00:47 +0000
Received: by outflank-mailman (input) for mailman id 1281447;
 Tue, 14 Apr 2026 08:00:45 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wCYhR-0008NP-Tn
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 08:00:45 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCYhN-005eOw-ON
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 10:00:43 +0200
Received: from [10.42.69.4] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69ddf423-e002-0a2a0a5209dd-0a2a4504d06e-42
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 10:00:43 +0200
Received: from [160.101.131.8] (helo=na1pdmzitismtp01.tibco.com)
 by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <owen.smith@citrix.com>)
 id 69ddf42a-bb33-0a2a45040019-a065830889ba-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 10:00:43 +0200
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp01.tibco.com (Postfix) with ESMTP id C7A10423FC0A;
 Tue, 14 Apr 2026 03:59:59 -0400 (EDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; none
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: david ambu <david.preetham@citrix.com>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 2/2] Xenbus remove event message information from INF file
Date: Tue, 14 Apr 2026 09:00:37 +0100
Message-ID: <20260414080037.474-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
In-Reply-To: <a18e73c0-7531-41ae-9c2b-a0c5e5d68131@vates.tech>
References: <a18e73c0-7531-41ae-9c2b-a0c5e5d68131@vates.tech>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-purgate-ID: tlsNG-ebf023/1776153643-B1B2051B-5B17FD66/0/0
X-purgate-type: clean
X-purgate-size: 1867

From: david ambu <david.preetham@citrix.com>

1876359a4fcdc7ee794f13ee190c05df6299d7a7 made the event message
information in the INF file redundant.

Signed-off-by: david ambu <david.preetham@citrix.com>

Remove xenbus_monitor.dll from INF file

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xenbus.inf | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/src/xenbus.inf b/src/xenbus.inf
index adc70bd..5499791 100644
--- a/src/xenbus.inf
+++ b/src/xenbus.inf
@@ -51,7 +51,6 @@ xen.sys=0,,
 xenbus.sys=0,,
 xenfilt.sys=0,,
 xenbus_monitor.exe=0,,
-xenbus_monitor.dll=0,,
 
 [XenBus_CopyFiles]
 xen.sys
@@ -60,7 +59,6 @@ xenfilt.sys
 
 [Monitor_CopyFiles]
 xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xenbus_monitor.exe
-xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xenbus_monitor.dll
 
 [Manufacturer] 
 %Vendor%=Inst,NT@INF_ARCH@
@@ -80,7 +78,7 @@ FeatureScore=0xFE
 AddReg = XenBus_Interrupts
 
 [XenBus_Inst.Services]
-AddService=xenbus_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Monitor_EventLog
+AddService=xenbus_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
 AddService=xenbus,%SPSVCINST_ASSOCSERVICE%,XenBus_Service
 AddService=xenfilt,,XenFilt_Service,
 
@@ -148,13 +146,6 @@ HKR,"Parameters","DialogTitle",0x00000000,%DialogTitle%
 HKR,"Parameters","DialogText",0x00000000,%DialogText%
 HKR,"Parameters","DialogQuestion",0x00000000,%DialogQuestion%
 
-[Monitor_EventLog]
-AddReg=Monitor_EventLog_AddReg
-
-[Monitor_EventLog_AddReg]
-HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
-HKR,,TypesSupported,0x00010001,7
-
 [Strings] 
 
 Vendor="@VENDOR_NAME@" 
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 08:38:33 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 08:38:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281476.1564360 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCZI0-0004jR-F5; Tue, 14 Apr 2026 08:38:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281476.1564360; Tue, 14 Apr 2026 08:38:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCZI0-0004jK-CX; Tue, 14 Apr 2026 08:38:32 +0000
Received: by outflank-mailman (input) for mailman id 1281476;
 Tue, 14 Apr 2026 08:38:30 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69ddfd04.v1-77afbbc0e7d140cca22fbfec636f9c6c@bounce.vates.tech>)
 id 1wCZHy-0004jE-R1
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 08:38:30 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCZHy-004yYg-3C
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 10:38:30 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69ddfd04.v1-77afbbc0e7d140cca22fbfec636f9c6c@bounce.vates.tech>)
 id 69ddfcfd-5cb7-0a2a0a5109dd-0a2a4508d42a-36
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 10:38:30 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69ddfd04.v1-77afbbc0e7d140cca22fbfec636f9c6c@bounce.vates.tech>)
 id 69ddfd04-fab6-0a2a45080019-c602bb0190a4-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 10:38:29 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fvyNN3Pj2zBsTmgQ
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 08:38:28 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 77afbbc0e7d140cca22fbfec636f9c6c; Tue, 14 Apr 2026 08:38:28 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776155908; x=1776425908;
	bh=F3+lgChWrNigWqniCMvr954qS7Dk119WPInb1/V1slI=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=YQjz0P/dXj7DQTcIhJGMrv+B8PiWqPgk8HLdKR/coCbhZ6TRhUwA8042ExqBZUoU5
	 TzmrKkhlosOYSWjfRFLYvf7Byb2FVflI0gFn57ThVGQxIQ8uwl1/3do8KTGmokCEF1
	 ZlQ0kwddTfOwMYsICWnKQ1GHIGqCLvXtncq5z65SHdkl6b4hvjO0mOZ+jiy/8K5Zfm
	 EqTc8cA6YS+OC8p6lY3y+ePy0ziCApcV/zpn3feBa1xq1o3u2RWxzuEwGOsQjBauP7
	 wqEbBqSNDWuScOCnECb0CKvhAOX41VYMdddHedMMlveaPu+csvgtEPh/3UGOR//Ow8
	 6ZMOlTbCswqmQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776155908; x=1776416408; i=ngoc-tu.dinh@vates.tech;
	bh=F3+lgChWrNigWqniCMvr954qS7Dk119WPInb1/V1slI=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=TJu9ZwqUWXFTCCUJnXuGy/geB3rOKbk3w9HDmE1K8CBAaf5Ccd0EFYr3qNbUoKj7J
	 dM4x1u0mty1jtHG70UJPPLQCOk/Bg1C5xhNezp5ztpALnyDN0LRCb+Kv3VL6ct3dkX
	 UVuD69YyhiUwx4TtIMhHQx2rlt0/B0tXTMRv05a20kAB8Jr9CUJFzr9+6i1yXZBVTI
	 dVxkdklmPcBBoFIWLCfLe6vsQlF9PSHcF8NoFn2jMUOOz94QA6fngQpQ6OWfPvb6rO
	 oTfsMYWiCf1GyHacWUtkQQIL9QXbE/ycOv2D2lXJD9V9FRKxmnboezowgIBefktjsi
	 m+/VQ+RCHKjpA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=202/2]=20Xenbus=20remove=20event=20message=20information=20from=20INF=20file?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776155907405
Message-Id: <db375814-e8db-4e49-96d0-571eb21912d7@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
Cc: "david ambu" <david.preetham@citrix.com>
References: <a18e73c0-7531-41ae-9c2b-a0c5e5d68131@vates.tech> <20260414080037.474-1-owen.smith@citrix.com>
In-Reply-To: <20260414080037.474-1-owen.smith@citrix.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.77afbbc0e7d140cca22fbfec636f9c6c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 08:38:28 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-c1860d/1776155909-7654F497-5D71C5B5/0/0
X-purgate-type: clean
X-purgate-size: 2501

On 14/04/2026 10:01, Owen Smith wrote:
> From: david ambu <david.preetham@citrix.com>
> 
> 1876359a4fcdc7ee794f13ee190c05df6299d7a7 made the event message
> information in the INF file redundant.
> 
> Signed-off-by: david ambu <david.preetham@citrix.com>
> 
> Remove xenbus_monitor.dll from INF file
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

I'd prefer that the DLL is removed from the build/packaging altogether 
due to the new rule on unreferenced files [1], but we can do that later.

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

[1] 
https://techcommunity.microsoft.com/blog/hardware-dev-center/attention-hdc-is-changing-the-policy-on-signing-unreferenced-files-in-driver-pac/4495518

> ---
>   src/xenbus.inf | 11 +----------
>   1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/src/xenbus.inf b/src/xenbus.inf
> index adc70bd..5499791 100644
> --- a/src/xenbus.inf
> +++ b/src/xenbus.inf
> @@ -51,7 +51,6 @@ xen.sys=0,,
>   xenbus.sys=0,,
>   xenfilt.sys=0,,
>   xenbus_monitor.exe=0,,
> -xenbus_monitor.dll=0,,
>   
>   [XenBus_CopyFiles]
>   xen.sys
> @@ -60,7 +59,6 @@ xenfilt.sys
>   
>   [Monitor_CopyFiles]
>   xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xenbus_monitor.exe
> -xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xenbus_monitor.dll
>   
>   [Manufacturer]
>   %Vendor%=Inst,NT@INF_ARCH@
> @@ -80,7 +78,7 @@ FeatureScore=0xFE
>   AddReg = XenBus_Interrupts
>   
>   [XenBus_Inst.Services]
> -AddService=xenbus_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Monitor_EventLog
> +AddService=xenbus_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
>   AddService=xenbus,%SPSVCINST_ASSOCSERVICE%,XenBus_Service
>   AddService=xenfilt,,XenFilt_Service,
>   
> @@ -148,13 +146,6 @@ HKR,"Parameters","DialogTitle",0x00000000,%DialogTitle%
>   HKR,"Parameters","DialogText",0x00000000,%DialogText%
>   HKR,"Parameters","DialogQuestion",0x00000000,%DialogQuestion%
>   
> -[Monitor_EventLog]
> -AddReg=Monitor_EventLog_AddReg
> -
> -[Monitor_EventLog_AddReg]
> -HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
> -HKR,,TypesSupported,0x00010001,7
> -
>   [Strings]
>   
>   Vendor="@VENDOR_NAME@"



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 08:45:12 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 08:45:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281477.1564365 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCZOQ-0005qE-VK; Tue, 14 Apr 2026 08:45:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281477.1564365; Tue, 14 Apr 2026 08:45:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCZOQ-0005q7-So; Tue, 14 Apr 2026 08:45:10 +0000
Received: by outflank-mailman (input) for mailman id 1281477;
 Tue, 14 Apr 2026 08:45:09 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wCZOO-0005q1-Ob
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 08:45:08 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCZOL-005rEy-Si
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 10:45:07 +0200
Received: from [10.42.69.4] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69ddfe90-5cb7-0a2a0a5109dd-0a2a45049ece-8
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 10:45:07 +0200
Received: from [52.101.193.15]
 (helo=CH1PR05CU001.outbound.protection.outlook.com)
 by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <owen.smith@citrix.com>)
 id 69ddfe91-bb33-0a2a45040019-3465c10f7568-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 10:45:06 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by PH7PR03MB7047.namprd03.prod.outlook.com (2603:10b6:510:2b0::12)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Tue, 14 Apr
 2026 08:45:01 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9769.046; Tue, 14 Apr 2026
 08:45:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=Xwt/O3G8Op1tV8yIlQi/0zKortiiuY3pmWvB1Jg7Bl8GN2YGIV5qmRt6BlINSdQI4V/1tK5h3eTN14vhH4S32jzxE3wJGz4elz0lcdogwdZRF2RfjNnaulOR79k/4ek2yW+SddxULogPnaEHje6Pxf18PMWDNsbKD7Im9xeVAK8BFVHrq6MG1eMKZ/No0NEJofYovZreRmKItDMN6qKpirR9qB7U33eq2AySAZWv8sGPxMUA5PNDbyd7MxT2vX6DrpgAxF4eq2IDjv56+gQUQ8LwFONiKCSIqpvXSlTSbOSDurAR6vW+wEWd9bKYgbqKqRAP/qegoL2A0dDcY7MZvA==
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=pQxiDS+DMUSRoBjk+Jflgi3ajUp02MAJ3m0K/V6PfOc=;
 b=ExghTYXE8ur6ptbm7N3x5jYGdkqdfTVs+qmhcsjTmSNf3Us7HpK5M4BPQYOsU0gRphbgVR9uXBKObhqn+85/TfzarTAhpl72LaRv5CGQFT6KXodP+PpwO4peowaR9N8MA54w8HHvfnWPDhqvZCx1d6NFN8SgD7p8ob1A3dRM6bTySzLxTzeACnxzMqlHLtvnc+apVUBRP24I4pIN6C6urU1y04E7gYsNjotqw1fVK5zXCtNW62mQU1RXp7jw00fO95Y02DEyQwexNF9SZUDAQXCN0AorfLYY4vwy+GVpk8wtzUZGRbzd1mKDDTekH8wlQ01s7N6zvp9ryV7haA5ZZQ==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=pQxiDS+DMUSRoBjk+Jflgi3ajUp02MAJ3m0K/V6PfOc=;
 b=E+OGTELHwIDtS2hEKl4j4Va2jXQjs/ZTRB+YhOV9iZYSdomCMloP1RrPrhy0VUvFbUzbM90tw9j2ixWgAesjDNVo/aYaDykJ/jarHZGeK6tEJMy7r0S3JV2B2Tcl7nwZlBBs7l60U/rkB9qzpqOMxS+xNwnhF1FLUEn6w08+tjM=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
CC: David ambu <david.preetham@citrix.com>
Subject: Re: [PATCH 2/2] Xenbus remove event message information from INF file
Thread-Topic: [PATCH 2/2] Xenbus remove event message information from INF
 file
Thread-Index: AQHcraNq6DTMUCVhg0qClt7cF3ws7rXebkeAgAAKkwCAAAFuBg==
Date: Tue, 14 Apr 2026 08:45:01 +0000
Message-ID:
 <SA6PR03MB77608FD19F1C8F990AFF635DFE252@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <a18e73c0-7531-41ae-9c2b-a0c5e5d68131@vates.tech>
 <20260414080037.474-1-owen.smith@citrix.com>
 <db375814-e8db-4e49-96d0-571eb21912d7@vates.tech>
In-Reply-To: <db375814-e8db-4e49-96d0-571eb21912d7@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|PH7PR03MB7047:EE_
x-ms-office365-filtering-correlation-id: 5d9a7855-c328-432f-f20d-08de9a021dba
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|1800799024|366016|38070700021|56012099003|18002099003|22082099003;
x-microsoft-antispam-message-info:
 Fdzq7TdqIdbiitmBlrJq8SnTpTNfTYuFpRTytyw1ZwvkpPQ4ean77TFkNkq4qbQiX7tJLPtRpwaUAPFqWd+axOt6XezNflgRH/He+K9MCIPk6297D8z2Hk0iiff19bMFbX7EPnltAZ1DSOvUV41LOV3tpv/ezsoM8omOJie9wRvik9aGx7XjKFetqjtQUCH0o2Pk6Y3x74800EblOVXYvWIIQskdbV3pXUlckPUPOs9Ft06OhB1AGaJgseJEcezE/71lqThcffV72+LYdHOU9oeUBX2ZdrrvPBrR4A1smdkddoI7kJ/ihRvni+KdMusoxyHvalodU5CjwSkuBYIE/kfoVdpmj9oOUkByFo3ZjCFzQn9fa5rDqoG7V7Yh+DpceZfJHqH06TRlSdOoRIgiSmJnoNiDFzCfcC/15VwqE4ol1ZvsSJnhrV+3Vie1BCDEJZnp54LByfCDRsgTlyIyUoji2Ld1HSAGKF9oWjFjHkcQ3Jpl6PsCi5dbEd0NXAIcdXM7h5m7R+5wdmKRjmd+Oys+fMoeCBxBZHyUDX8y0YniccZOmz4x9TqJLJrg6dAG+EvcupxF/5KamGFlbbLjh8Qya5xtZGY/o7cJCnUHSlsd8NDNLqUSyEHKabI85AEltguYW9A+WssQagXh1l/ConU656SdTe0yLI/G1DGP/kqH9zcaOJlx6xcR0ipdDkSKzCYgX2rvGOR51jvzKJ3hmmOjp7bEoPFO1ek7S1nRVFI=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(38070700021)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?sPfoq3MbKCpTJgJJy1DL7r+N+WSN1fZCRyP0dLnOdQMovcC1lzyJhVA+Ar51?=
 =?us-ascii?Q?Qw7S5KrOgP5wklnZNw7KF4Eng1CcLhcg6KwuJthYRSh12uY/pya/Y6O+Bu+i?=
 =?us-ascii?Q?vDEFHCZza/WzeGH/II7JTkkaK0d6RDyd+pfxhPVZpyzNGGXS8btEYopbsXqi?=
 =?us-ascii?Q?EaL3TzniJJ/gHXZM+dFsZZpXau4fTLBF47mK/gOzYhYcyLjr0E+JlFJvg620?=
 =?us-ascii?Q?OLZdLBK+2VrZTIuYg0dZwTfURZ4CeiKbabCCXDuJEXtnhZv9fIJYLY5h47Eg?=
 =?us-ascii?Q?19q5gxya6LcsD7GL9vsKrznMd26V1mAofnVVzVWDd56IhV+WU569kaKWunPJ?=
 =?us-ascii?Q?vnmec5Lk+nnebVDM+7iZ9ZY0AvfFhS/vTZIDFVtvD68jxLKSHcGIX4kVS5xU?=
 =?us-ascii?Q?JsryvWOBrJirhVW4MP4ydcCt6CSfpfYpaabD8Y67HYNGO4DarsiDNFO3bEUp?=
 =?us-ascii?Q?Lhgu1lDjf8R8GiSwD/vy4b4TargrtyEVsZ0D6AeAwXmkSOZACjzmHOIeltC8?=
 =?us-ascii?Q?1lZV+IghwjxuXURbumDB8XaH9SRkwdrGH6CdW7Gp7tWIHoGTmlbE6akn2k8h?=
 =?us-ascii?Q?qqUMJENueEkR1MX0j2vX2AnWnZwzW5GVrQEPpe4+t0hWpUaoxJVTNh67IGLo?=
 =?us-ascii?Q?RiSdNuLFNjRXzMhOtYNvFL2FIUd1m3BAflZRuACXN5yo/xTobuL7++hBfTIi?=
 =?us-ascii?Q?fDnmdZKH8b5IKEwgmvPBLNILunB5aRWYl5tXMM0coWDoE/c++EeS6O7jtgf6?=
 =?us-ascii?Q?BNLyOHGxMpnmV6/RDKt0blD0f83nKeKJDWed1NoYu2f21Snm+SRrptJDl8+Q?=
 =?us-ascii?Q?5U69FE7VX/eXYFkR9BzTalG2sQsdqiArJGnsziHD99MiDV/hoWkUpFfcpOD/?=
 =?us-ascii?Q?lgklpS3rANfO6inK9fT8BOXrSoQ83jZoqHEihjDNj1UdmO30U2OdFp/gMcsb?=
 =?us-ascii?Q?CaEkF5DHpHjq1ldLJLZ8IstDbUp3Q0c+JSjT3Zot762gs/KSHiy9C0TNdhAH?=
 =?us-ascii?Q?M986MabcXQWhP5JAQoSXr6BEuNr/IxeCED3KPWOCSDaQkTfKZebuQnsUEsE9?=
 =?us-ascii?Q?y9wpPKy2YbsVB1937/3YYmsoYoKjW1/daFfB/G6XNpDh3pl7/Iu12fkxsM2s?=
 =?us-ascii?Q?/YbHxtFYh+gB66M7G4HL15Dk2lw6/WERKVrSY15vk5ZYWW6ddR2/kqUFCwnA?=
 =?us-ascii?Q?+KUTP/rZWP8XsStUt4NLgpBHTsQjF1dCxjoF5WmfRnNfxXlItcFAC65bcHTD?=
 =?us-ascii?Q?8XTJG3orh4Z/kXhyoHXnEkXwRf6jGTpv3HhvRti5K/XXUAM4aL4qJVOLXRvS?=
 =?us-ascii?Q?2zuifJ/O6GGPNvNf1f1ajes1LrHIIDqbrsK+uDZ4wR3r/hV0eghTX4Q+j3Q3?=
 =?us-ascii?Q?zoNQryQO4jR93RzwN/+76lV5F56V7ffIYA21RMQuu05xbt11h7oIBRWop8h5?=
 =?us-ascii?Q?paUE8lS/kG+OIZV1ELK71SpMErOMDQFQh6rFV7yhEkr4Z4256rXbA7TZ66va?=
 =?us-ascii?Q?TXp5cytWm3oxrdM/WyIx/JaBm7yTEbSAYp6W5QqfvkIDabyF8AjfAH5Cy5lD?=
 =?us-ascii?Q?ZQ0kkUnc2fy6A47oxmItimKSJMGwYGKis/ZBG0dQh6QE8fIO6xhqZ91OLFq0?=
 =?us-ascii?Q?oNPZlAf7Nqpaw7cUooOwrBwm0SboiztLu4SHrTMAFv03SLw6SVBhHy36p5l/?=
 =?us-ascii?Q?aITbdE735ZIW/7GCAILFI8KYMj4pcPIUxJ/eTF9AUO+Lw9M2K27Afy2erdqB?=
 =?us-ascii?Q?uE4U5i9KPA=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 5d9a7855-c328-432f-f20d-08de9a021dba
X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Apr 2026 08:45:01.2571
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: JO6O5y5izt+HZPZCAWpkHJZklrRpwiWgrl4lCIhO716Zeenu3S/SK1S6U+8Tg4DXgt8NxF7zUT1qKO0UlGlL1Q==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR03MB7047
X-purgate-ID: tlsNG-ebf023/1776156306-3212551B-D5645D7F/0/0
X-purgate-type: clean
X-purgate-size: 3004

The new rule on unreferenced files is on my to-do list, as it means reorgan=
izing
the build output to some degree. Only INF referenced files in the 'driver' =
output, and
symbols, etc in another location.

Owen

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 14 April 2026 9:38 AM
To: Owen Smith; win-pv-devel@lists.xenproject.org
Cc: David ambu
Subject: Re: [PATCH 2/2] Xenbus remove event message information from INF f=
ile

On 14/04/2026 10:01, Owen Smith wrote:
> From: david ambu <david.preetham@citrix.com>
>
> 1876359a4fcdc7ee794f13ee190c05df6299d7a7 made the event message
> information in the INF file redundant.
>
> Signed-off-by: david ambu <david.preetham@citrix.com>
>
> Remove xenbus_monitor.dll from INF file
>
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

I'd prefer that the DLL is removed from the build/packaging altogether
due to the new rule on unreferenced files [1], but we can do that later.

Reviewed-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

[1]
https://techcommunity.microsoft.com/blog/hardware-dev-center/attention-hdc-=
is-changing-the-policy-on-signing-unreferenced-files-in-driver-pac/4495518

> ---
>   src/xenbus.inf | 11 +----------
>   1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/src/xenbus.inf b/src/xenbus.inf
> index adc70bd..5499791 100644
> --- a/src/xenbus.inf
> +++ b/src/xenbus.inf
> @@ -51,7 +51,6 @@ xen.sys=3D0,,
>   xenbus.sys=3D0,,
>   xenfilt.sys=3D0,,
>   xenbus_monitor.exe=3D0,,
> -xenbus_monitor.dll=3D0,,
>
>   [XenBus_CopyFiles]
>   xen.sys
> @@ -60,7 +59,6 @@ xenfilt.sys
>
>   [Monitor_CopyFiles]
>   xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_N=
UMBER@.exe,xenbus_monitor.exe
> -xenbus_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NU=
MBER@.dll,xenbus_monitor.dll
>
>   [Manufacturer]
>   %Vendor%=3DInst,NT@INF_ARCH@
> @@ -80,7 +78,7 @@ FeatureScore=3D0xFE
>   AddReg =3D XenBus_Interrupts
>
>   [XenBus_Inst.Services]
> -AddService=3Dxenbus_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Mo=
nitor_EventLog
> +AddService=3Dxenbus_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
>   AddService=3Dxenbus,%SPSVCINST_ASSOCSERVICE%,XenBus_Service
>   AddService=3Dxenfilt,,XenFilt_Service,
>
> @@ -148,13 +146,6 @@ HKR,"Parameters","DialogTitle",0x00000000,%DialogTit=
le%
>   HKR,"Parameters","DialogText",0x00000000,%DialogText%
>   HKR,"Parameters","DialogQuestion",0x00000000,%DialogQuestion%
>
> -[Monitor_EventLog]
> -AddReg=3DMonitor_EventLog_AddReg
> -
> -[Monitor_EventLog_AddReg]
> -HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xenbus_monitor=
_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
> -HKR,,TypesSupported,0x00010001,7
> -
>   [Strings]
>
>   Vendor=3D"@VENDOR_NAME@"



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:43:59 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:43:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281661.1564504 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcBR-0000sh-SY; Tue, 14 Apr 2026 11:43:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281661.1564504; Tue, 14 Apr 2026 11:43:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcBR-0000sa-Pm; Tue, 14 Apr 2026 11:43:57 +0000
Received: by outflank-mailman (input) for mailman id 1281661;
 Tue, 14 Apr 2026 11:43:57 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de287a.v1-81780cc8eae047c6bad503d93046307d@bounce.vates.tech>)
 id 1wCcBQ-0000sS-Us
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:43:57 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcBQ-009FUz-AG
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:43:56 +0200
Received: from [10.42.69.5] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de287a.v1-81780cc8eae047c6bad503d93046307d@bounce.vates.tech>)
 id 69de287c-2eae-0a2a0a5409dd-0a2a4505c174-0
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:43:56 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de287a.v1-81780cc8eae047c6bad503d93046307d@bounce.vates.tech>)
 id 69de287b-3760-0a2a45050019-c602bb0e8d84-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:43:56 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw2VL5kQxz8XSCWZ
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:43:54 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 81780cc8eae047c6bad503d93046307d; Tue, 14 Apr 2026 11:43:54 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167034; x=1776437034;
	bh=gfIHquaLvOfyuAEpULnIKryF4AX6N7UfILPZpk4ih9Y=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=B37AI8kxitrwEyIeeGlJqoew071jYX0as+RxsVyfLCiHDlEFQoBR8DOA0gZLY3acg
	 4JhOxFxyQ9ttvQADtiLv2ocd2gPM0wz1FjvTExulZPqeC9jTc9Ce00ywZ4hiIJYGyu
	 WTHAUWW8X7TsN1+ua0+6lUsLibU0nTSvls8M9v0fFh5XquWat9heX3lzgAKMSLbudt
	 hgZvv8Outz7CwRGVBdzsxaF+Rsrr+cei/u2vbBclbowxT1L/lcyFz9OQdBtZi/WFu4
	 6DGKQdG39AARdeAi/qGgkLlh3cortq8l+E7uTuhgLnJCcPEE03jncgY8eQUiOY29p/
	 w4oAseyAICqqg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167034; x=1776427534; i=ngoc-tu.dinh@vates.tech;
	bh=gfIHquaLvOfyuAEpULnIKryF4AX6N7UfILPZpk4ih9Y=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=bc00mqEl5CX7nKT/xq00dVFpojKrGuEmg12ANl8Wuj2H772nxPtXkfgZHGtKdeldA
	 Bcc7Gy0a2jF/HGP1cBJUngT4sUlN/5kiMBDCB6SWK1tIvejRhP2JnpM3cy3ZEKOQ1b
	 tSuN1jWNDcN7QYaIlhXRhYAq55kkbbd7z/E1YjOsOADT+O89L3CjRuhULUYkMNUGRM
	 DyOEzlfKPZyG9z3gw4iduSym7Ki94NygdSCD4b21+lpyKnOe/zgEVzW5GT3YQG7XCZ
	 h3zXD760ZjURckWB963hM/S5MCoS5GaXnAfp/Xbrr+84KLhXg5+gicPx+b/9nuvb8f
	 ppLow3QcnzTzg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH]=20Delete=20xenbus=5Fmonitor.dll?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167034056
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414114344.149-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.81780cc8eae047c6bad503d93046307d?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:43:54 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-c201ff/1776167036-3999196F-41388CCD/0/0
X-purgate-type: clean
X-purgate-size: 7160

Now that trace logging is used, the DLL is not needed any more. Remove
it from the build and package.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/messages.mc                      | 55 --------------------
 src/monitor/monitor.c                        |  2 -
 src/monitor/xenbus_monitor.rc                |  1 -
 vs2019/xenbus_monitor/xenbus_monitor.vcxproj | 17 ------
 vs2022/xenbus_monitor/xenbus_monitor.vcxproj | 12 -----
 5 files changed, 87 deletions(-)
 delete mode 100644 src/monitor/messages.mc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
deleted file mode 100644
index eb1d382..0000000
--- a/src/monitor/messages.mc
+++ /dev/null
@@ -1,55 +0,0 @@
-; // Copyright (c) Xen Project.
-; // Copyright (c) Cloud Software Group, Inc.
-; // All rights reserved.
-; //
-; // Redistribution and use in source and binary forms,
-; // with or without modification, are permitted provided
-; // that the following conditions are met:
-; //
-; // *   Redistributions of source code must retain the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer.
-; // *   Redistributions in binary form must reproduce the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer in the documentation and/or other
-; //     materials provided with the distribution.
-; //
-; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-; // SUCH DAMAGE.
-
-MessageIdTypedef=DWORD
-
-SeverityNames=(
-	Success=0x0:STATUS_SEVERITY_SUCCESS
-	Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
-	Warning=0x2:STATUS_SEVERITY_WARNING
-	Error=0x3:STATUS_SEVERITY_ERROR
-	)
-
-
-FacilityNames=(
-	System=0x0:FACILITY_SYSTEM
-	Runtime=0x2:FACILITY_RUNTIME
-	Stubs=0x3:FACILITY_STUBS
-	Io=0x4:FACILITY_IO_ERROR_CODE
-	)
-
-MessageId=0x1
-Severity=Informational
-Facility=System
-SymbolicName=MONITOR_LOG
-Language=English
-%1
-.
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 9bfb1f6..904badd 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -47,8 +47,6 @@
 
 #include <version.h>
 
-#include "messages.h"
-
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
 #define __MODULE__ stringify(PROJECT)
diff --git a/src/monitor/xenbus_monitor.rc b/src/monitor/xenbus_monitor.rc
index dc2fc19..e771dad 100644
--- a/src/monitor/xenbus_monitor.rc
+++ b/src/monitor/xenbus_monitor.rc
@@ -54,4 +54,3 @@
 #define VER_FILESUBTYPE		    VFT2_UNKNOWN
 
 #include "common.ver"
-#include "messages.rc"
diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
index c9eef03..9b20fce 100644
--- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
@@ -55,32 +52,18 @@
     <ClCompile>
       <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
     <FilesToPackage Include="$(OutDir)$(TargetName).map" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
     <FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
   </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
-  </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
   </ItemGroup>
diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
index 1d686df..7d30855 100644
--- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
+++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions>
@@ -55,22 +52,13 @@
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
     <FilesToPackage Include="$(OutDir)$(TargetName).map" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
     <FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
   </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
-  </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
   </ItemGroup>
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:44:31 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:44:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281662.1564507 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcBy-0000wC-Uf; Tue, 14 Apr 2026 11:44:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281662.1564507; Tue, 14 Apr 2026 11:44:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcBy-0000w5-SB; Tue, 14 Apr 2026 11:44:30 +0000
Received: by outflank-mailman (input) for mailman id 1281662;
 Tue, 14 Apr 2026 11:44:29 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289b.v1-0dcffd750bf345d28d6ab8ed39cdf7ec@bounce.vates.tech>)
 id 1wCcBx-0000vt-MT
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:44:29 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcBx-00Fzk5-2A
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:44:29 +0200
Received: from [10.42.69.10] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289b.v1-0dcffd750bf345d28d6ab8ed39cdf7ec@bounce.vates.tech>)
 id 69de288b-e002-0a2a0a5209dd-0a2a450a9c50-48
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:29 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289b.v1-0dcffd750bf345d28d6ab8ed39cdf7ec@bounce.vates.tech>)
 id 69de289b-ee98-0a2a450a0019-c602bb0ee6a9-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:28 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw2Vz3pjQz8XS3Fp
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:27 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 0dcffd750bf345d28d6ab8ed39cdf7ec; Tue, 14 Apr 2026 11:44:27 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167067; x=1776437067;
	bh=pK/8i/jK3IGFNq2K27WJDEirRa88dlM//xldhmjV/w8=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=y1vTQbAYtYrTSe9KHKU58ei7yudxNHWM+6rvDe/ZTj+l26f1Kt0GGAktqtX8jpViN
	 agiLlTOYYkMh9BeoX1OxxRiXcuq8YqOUfkWkq5+5j0Ar6SgVzH4ID7WrkNdDvSSOXH
	 Tb/TpFvYuoemAaFdywAWX30A0VyMsVQivFpb4Zwv5MnhOAjx8adSYTRlggqJXBX5Ml
	 VEf0YuQHCpt3bIoKRWFp3SfDbMG41rXsCRk1rwvEBj9KM4XM1Vq5WQAb0iludeZ+h9
	 WUdhtKGKDVrSnw599Cz+dJStf0hGYZeRl4BlZxCj32pVNnPrb52vHWBBvSEsjWPCz/
	 yYrArp0jp/O3A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167067; x=1776427567; i=ngoc-tu.dinh@vates.tech;
	bh=pK/8i/jK3IGFNq2K27WJDEirRa88dlM//xldhmjV/w8=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=oAQB8BL5X9SCN5yV8GfSsX9GDDtlnGAw3CnPhpSCEDXLCDgGp6dP3mFOwPt1PGc6V
	 25yw+8pyz7Dobv1VLhVY35+cyYa6h+LqmE28vbeU8ZEaCBf06aUGll8vD5Dq4v9Ydm
	 o4aOVJ7oys6RcS/xR4fpZWiblXE2FPf23mSsM0fE1RK2avHrQLpT6wNWYupnCXjPDY
	 3NekN55NlrOco4uZFz/zNuhnCpKLG2VCdMTZoaO3ZAqtnYvHOhP+JhbpKQf+6nFwyt
	 yZPFGtefYUG3lDbXoIvuFQQyh533K/XlsKkrPv7/Ja8maQggKON0V4K/u0jKlbjjHX
	 FR8Ju0i+VGdYA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=200/6]=20Port=20the=20TraceLoggingRegister=20series=20to=20XenCons?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167066873
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.0dcffd750bf345d28d6ab8ed39cdf7ec?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:27 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-4011c0/1776167069-BE94C0B1-1EE004CF/0/0
X-purgate-type: clean
X-purgate-size: 913

Tu Dinh (6):
  Use RegCloseKey for ParametersKey
  Replace RegisterEventSource with TraceLoggingRegister
  Fix inconsistent TCHAR handling
  Delete xencons_monitor.dll
  Use CHAR for pipe stream data
  Discover cmd.exe using GetSystemDirectory

 src/monitor/messages.mc                       |  55 --
 src/monitor/monitor.c                         | 539 ++++++++++--------
 src/monitor/xencons_monitor.rc                |   1 -
 src/tty/tty.c                                 | 182 +++---
 src/xencons.inf                               |  11 +-
 .../xencons_monitor/xencons_monitor.vcxproj   |  17 -
 .../xencons_monitor/xencons_monitor.vcxproj   |  12 -
 7 files changed, 401 insertions(+), 416 deletions(-)
 delete mode 100644 src/monitor/messages.mc

--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:44:32 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:44:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281663.1564512 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcC0-0000yI-2N; Tue, 14 Apr 2026 11:44:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281663.1564512; Tue, 14 Apr 2026 11:44:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcBz-0000yB-UB; Tue, 14 Apr 2026 11:44:31 +0000
Received: by outflank-mailman (input) for mailman id 1281663;
 Tue, 14 Apr 2026 11:44:30 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289c.v1-e8f9dc3368d3439f9eb89a0ce7a19ad7@bounce.vates.tech>)
 id 1wCcBy-0000vz-Ei
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:44:30 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcBx-009Fg7-Qx
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:44:29 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289c.v1-e8f9dc3368d3439f9eb89a0ce7a19ad7@bounce.vates.tech>)
 id 69de2890-2eae-0a2a0a5409dd-0a2a4508a6b2-36
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:29 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289c.v1-e8f9dc3368d3439f9eb89a0ce7a19ad7@bounce.vates.tech>)
 id 69de289c-fab6-0a2a45080019-c602bb0e4009-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:29 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw2W02s8Yz8XS3x7
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:28 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 e8f9dc3368d3439f9eb89a0ce7a19ad7; Tue, 14 Apr 2026 11:44:28 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167068; x=1776437068;
	bh=HjukQmyYiHX3Bu7WIWFlmKyU+FSaw/LYB/1usH3jW9w=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=qOpCXNiJrPF0m32v+7WCISy9+cEn/ShRb+9yIZK9kEJ7idvjqZvpnk9m/twSDFO6L
	 DHlUqwkzJMPLkZeXP/TfJJ16gKkiIyelDrf2e6D+GgtKVHqBn4PwGIG9hBFXnl4izf
	 bZf6MAf42ZEmZqYxYdpmIzv41EI4boJJMZWFw96eOQBohVjW6f9Lpjoi6MIbPyooZb
	 UORK+eoQDyozElZizCb5dbetjZ4emsV1vJGg6uKA1uQg0PI/iMZLir19219rlltBo3
	 TODV13nKE/XtzgEVXvdnYwIYto5i3UK8KI3Jnx4J3QvSBzKVE8glS3JzAMCwhckg87
	 FqaeEexEqlc6Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167068; x=1776427568; i=ngoc-tu.dinh@vates.tech;
	bh=HjukQmyYiHX3Bu7WIWFlmKyU+FSaw/LYB/1usH3jW9w=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=xKj2PEctbQPeHbu0y7VwqYCGFqI+ECuaUaDAulPOnWlecQvlDQXbPGRLauJ1rD9lN
	 q+SpyM9yPGwGfOQox+/N2+M3inMpiXyxhbhXp5vuMib+3yNjr8RNja8GSo3d5CeKG0
	 8MdLEx9eOXqTekdsNJlg3Fx0AgO4ndiFCZBH9JAblPo+KRsvEEQfqJfdOG216Z7Nl1
	 JiOZlveT1hp80yUwC8eN/VONsRt6+qXcnCdG/BoR71aGF8A5Db+UUxoe9GZ7tIJxU7
	 wmm8h538h5p39W8kG1k8mxRk0/wp21ZRCZGXQrY9DMb6jLa3SSa3uFyXZPvh1aqrS0
	 YEUAgvJYPhL0g==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=202/6]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167067504
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>, "david ambu" <david.preetham@cloud.com>
Message-Id: <20260414114416.1336-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.e8f9dc3368d3439f9eb89a0ce7a19ad7?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:28 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-c1860d/1776167069-7495D497-2C69ACB2/0/0
X-purgate-type: clean
X-purgate-size: 26613

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.
  This issue was raised by CodeQL 2.20.1,
  "RegisterEventSourceA has been marked deprecated as it is a legacy
   tracing API. Please migrate to modern Event Tracing for Windows APIs."
see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage

  Event Tracing logging needs to be captured using an ETW trace logger

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else
* Change __Log call to take a PCTSTR, and wrap format string with _T() in macros

Signed-off-by: Owen Smith <owen.smith@citrix.com>

Ported from Xenbus.

* Convert both xencons_monitor and xencons_tty.
* Removal of xencons_monitor.dll is done separately.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 274 ++++++++++++++++++++++--------------------
 src/tty/tty.c         |  74 +++++++++---
 2 files changed, 199 insertions(+), 149 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index b5e042a..381898f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -43,6 +43,8 @@
 #include <sddl.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>
 
 #include <xencons_device.h>
 #include <version.h>
@@ -59,7 +61,6 @@
 typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HKEY                    ParametersKey;
     HDEVNOTIFY              InterfaceNotification;
@@ -108,30 +109,43 @@ static MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"
 
+TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
+                             MONITOR_NAME,
+                             // {F1D4F89A-D4FC-5C76-865B-27532946CA0A}
+                             (0xF1D4F89A, 0xD4FC, 0x5C76, 0x86, 0x5B, 0x27, 0x53, 0x29, 0x46, 0xCA, 0x0A));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ PCSTR          Format,
+    _In_ LOG_LEVEL      Level,
+    _In_ PCTSTR         Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    const CHAR          *Strings[1];
-#endif
-    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
+    TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
     HRESULT             Result;
 
     va_start(Arguments, Format);
-    Result = StringCchVPrintfA(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
+    Result = StringCchVPrintf(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
     va_end(Arguments);
 
     if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
         return;
 
-    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
+    Result = StringCchLength(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
     if (Result != S_OK)
         return;
 
@@ -139,30 +153,35 @@ __Log(
 
     _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
     _Analysis_assume_(Length >= 2);
-    Buffer[Length] = '\0';
-    Buffer[Length - 1] = '\n';
-    Buffer[Length - 2] = '\r';
+    Buffer[Length] = _T('\0');
+    Buffer[Length - 1] = _T('\n');
+    Buffer[Length - 2] = _T('\r');
 
     OutputDebugString(Buffer);
 
-#if DBG
-    Strings[0] = Buffer;
-
-    if (Context->EventLog != NULL)
-        ReportEventA(Context->EventLog,
-                     EVENTLOG_INFORMATION_TYPE,
-                     0,
-                     MONITOR_LOG,
-                     NULL,
-                     ARRAYSIZE(Strings),
-                     0,
-                     Strings,
-                     NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Information",
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, "Info"));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Error",
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, "Error"));
+        break;
+    default:
+        break;
+    }
 }
 
-#define Log(_Format, ...) \
-    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
 
 static PSTR
 GetErrorMessage(
@@ -228,7 +247,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;
 
-    Log("====> (%s)", ServiceStateName(CurrentState));
+    LogInfo("====> (%s)", ServiceStateName(CurrentState));
 
     Context->Status.dwCurrentState = CurrentState;
     Context->Status.dwWin32ExitCode = Win32ExitCode;
@@ -252,7 +271,7 @@ ReportStatus(
     if (!Success)
         goto fail1;
 
-    Log("<====");
+    LogInfo("<====");
 
     return;
 
@@ -262,7 +281,7 @@ fail1:
     {
         PSTR    Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -348,7 +367,7 @@ ConnectionThread(
     DWORD               Object;
     HRESULT             Error;
 
-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);
 
     ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
     Overlapped.hEvent = CreateEvent(NULL,
@@ -406,7 +425,7 @@ ConnectionThread(
     CloseHandle(Connection->Thread);
     free(Connection);
 
-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);
 
     return 0;
 
@@ -416,7 +435,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -438,7 +457,7 @@ ServerThread(
     HRESULT             Error;
     SECURITY_ATTRIBUTES SecurityAttributes;
 
-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);
 
     ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
     Overlapped.hEvent = CreateEvent(NULL,
@@ -459,7 +478,7 @@ ServerThread(
     if (Error != S_OK && Error != STRSAFE_E_INSUFFICIENT_BUFFER)
         goto fail2;
 
-    Log("%s", PipeName);
+    LogInfo("%s", PipeName);
 
     ZeroMemory(&SecurityAttributes, sizeof(SECURITY_ATTRIBUTES));
     SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
@@ -517,30 +536,30 @@ ServerThread(
 
     CloseHandle(Overlapped.hEvent);
 
-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);
 
     return 0;
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
     free(Connection);
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
     CloseHandle(Pipe);
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     LocalFree(&SecurityAttributes.lpSecurityDescriptor);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     CloseHandle(Overlapped.hEvent);
 
@@ -550,7 +569,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -571,7 +590,7 @@ DeviceThread(
     HANDLE              Handles[2];
     DWORD               Error;
 
-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);
 
     ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
     Overlapped.hEvent = CreateEvent(NULL,
@@ -641,12 +660,12 @@ DeviceThread(
 
     CloseHandle(Overlapped.hEvent);
 
-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);
 
     return 0;
 
 fail2:
-    Log("fail2\n");
+    LogError("fail2\n");
 
     CloseHandle(Overlapped.hEvent);
 
@@ -656,7 +675,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -726,25 +745,25 @@ GetExecutable(
         goto fail5;
     }
 
-    Log("%s = %s", DeviceName, *Executable);
+    LogInfo("%s = %s", DeviceName, *Executable);
 
     RegCloseKey(Key);
 
     return TRUE;
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     free(*Executable);
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(Key);
 
@@ -754,7 +773,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -775,7 +794,7 @@ ExecutableThread(
     DWORD               Object;
     HRESULT             Error;
 
-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);
 
     // If there is no executable, this thread can finish now.
     if (!GetExecutable(Console->DeviceName,
@@ -789,7 +808,7 @@ again:
     ZeroMemory(&StartupInfo, sizeof (StartupInfo));
     StartupInfo.cb = sizeof (StartupInfo);
 
-    Log("Executing: %s", Executable);
+    LogInfo("Executing: %s", Executable);
 
 #pragma warning(suppress:6053) // CommandLine might not be NUL-terminated
     Success = CreateProcess(NULL,
@@ -839,7 +858,7 @@ again:
     free(Executable);
 
 done:
-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);
 
     return 0;
 
@@ -851,7 +870,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -871,7 +890,7 @@ ConsoleCreate(
     BOOL                    Success;
     HRESULT                 Error;
 
-    Log("====> %ws", DevicePath);
+    LogInfo("====> %ws", DevicePath);
 
     Console = malloc(sizeof(MONITOR_CONSOLE));
     if (Console == NULL)
@@ -975,48 +994,48 @@ ConsoleCreate(
     if (Console->ExecutableThread == NULL)
         goto fail12;
 
-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);
 
     return Console;
 
 fail12:
-    Log("fail12");
+    LogError("fail12");
 
     CloseHandle(Console->ExecutableEvent);
     Console->ExecutableEvent = NULL;
 
 fail11:
-    Log("fail11");
+    LogError("fail11");
 
     SetEvent(Console->ServerEvent);
     WaitForSingleObject(Console->ServerThread, INFINITE);
 
 fail10:
-    Log("fail10");
+    LogError("fail10");
 
     CloseHandle(Console->ServerEvent);
     Console->ServerEvent = NULL;
 
 fail9:
-    Log("fail9");
+    LogError("fail9");
 
     SetEvent(Console->DeviceEvent);
     WaitForSingleObject(Console->DeviceThread, INFINITE);
 
 fail8:
-    Log("fail8");
+    LogError("fail8");
 
     CloseHandle(Console->DeviceEvent);
     Console->DeviceEvent = NULL;
 
 fail7:
-    Log("fail7");
+    LogError("fail7");
 
     UnregisterDeviceNotification(Console->DeviceNotification);
     Console->DeviceNotification = NULL;
 
 fail6:
-    Log("fail6");
+    LogError("fail6");
 
     ECHO(Console->DeviceHandle, "\r\n[DETACHED]\r\n");
 
@@ -1024,22 +1043,22 @@ fail6:
     Console->DevicePath = NULL;
 
 fail5:
-    Log("fail5");
+    LogError("fail5");
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
     CloseHandle(Console->DeviceHandle);
     Console->DeviceHandle = INVALID_HANDLE_VALUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     free(Console->DevicePath);
     Console->DevicePath = NULL;
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     DeleteCriticalSection(&Console->CriticalSection);
     ZeroMemory(&Console->ListHead, sizeof(LIST_ENTRY));
@@ -1053,7 +1072,7 @@ fail1:
     {
         PSTR    Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1113,7 +1132,7 @@ ConsoleDestroy(
     _In_ PMONITOR_CONSOLE   Console
     )
 {
-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);
 
     SetEvent(Console->ExecutableEvent);
     WaitForSingleObject(Console->ExecutableThread, INFINITE);
@@ -1152,7 +1171,7 @@ ConsoleDestroy(
 
     free(Console);
 
-    Log("<====");
+    LogInfo("<====");
 }
 
 static BOOL
@@ -1163,7 +1182,7 @@ MonitorAdd(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     PMONITOR_CONSOLE    Console;
 
-    Log("=====> %ws", DevicePath);
+    LogInfo("=====> %ws", DevicePath);
 
     Console = ConsoleCreate(DevicePath);
     if (Console == NULL)
@@ -1174,12 +1193,12 @@ MonitorAdd(
     ++Context->ListCount;
     LeaveCriticalSection(&Context->CriticalSection);
 
-    Log("<===== %s", Console->DeviceName);
+    LogInfo("<===== %s", Console->DeviceName);
 
     return TRUE;
 
 fail1:
-    Log("fail1");
+    LogError("fail1");
 
     return FALSE;
 }
@@ -1193,7 +1212,7 @@ MonitorRemove(
     PMONITOR_CONSOLE    Console;
     PLIST_ENTRY         ListEntry;
 
-    Log("=====> 0x%p", DeviceHandle);
+    LogInfo("=====> 0x%p", DeviceHandle);
 
     EnterCriticalSection(&Context->CriticalSection);
     for (ListEntry = Context->ListHead.Flink;
@@ -1208,7 +1227,7 @@ MonitorRemove(
     }
     LeaveCriticalSection(&Context->CriticalSection);
 
-    Log("DeviceHandle 0x%p not found", DeviceHandle);
+    LogError("DeviceHandle 0x%p not found", DeviceHandle);
 
     return FALSE;
 
@@ -1219,7 +1238,7 @@ found:
 
     ConsoleDestroy(Console);
 
-    Log("<=====");
+    LogInfo("<=====");
 
     return TRUE;
 }
@@ -1239,7 +1258,7 @@ MonitorEnumerate(
     HRESULT                             Error;
     BOOL                                Success;
 
-    Log("====>");
+    LogInfo("====>");
 
     DeviceInfoSet = SetupDiGetClassDevs(&GUID_XENCONS_DEVICE,
                                         NULL,
@@ -1299,28 +1318,28 @@ MonitorEnumerate(
         continue;
 
     fail5:
-        Log("fail5");
+        LogError("fail5");
     fail4:
-        Log("fail4");
+        LogError("fail4");
 
         free(DeviceInterfaceDetail);
 
     fail3:
-        Log("fail3");
+        LogError("fail3");
     fail2:
         Error = GetLastError();
 
         {
             PSTR    Message;
             Message = GetErrorMessage(Error);
-            Log("fail2 (%s)", Message);
+            LogError("fail2 (%s)", Message);
             LocalFree(Message);
         }
     }
 
     SetupDiDestroyDeviceInfoList(DeviceInfoSet);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
@@ -1330,7 +1349,7 @@ fail1:
     {
         PSTR    Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1345,7 +1364,7 @@ MonitorRemoveAll(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     PMONITOR_CONSOLE    Console;
 
-    Log("=====>");
+    LogInfo("=====>");
 
     for (;;) {
         EnterCriticalSection(&Context->CriticalSection);
@@ -1365,7 +1384,7 @@ MonitorRemoveAll(
     }
     LeaveCriticalSection(&Context->CriticalSection);
 
-    Log("<=====");
+    LogInfo("<=====");
 }
 
 DWORD WINAPI
@@ -1439,7 +1458,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
 
-    Log("====>");
+    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("====>");
 
     Error = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
                          PARAMETERS_KEY(__MODULE__),
@@ -1455,11 +1477,6 @@ MonitorMain(
     if (Context->Service == NULL)
         goto fail2;
 
-    Context->EventLog = RegisterEventSourceA(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog == NULL)
-        goto fail3;
-
     Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode = 0;
 
@@ -1471,7 +1488,7 @@ MonitorMain(
                                      NULL);
 
     if (Context->StopEvent == NULL)
-        goto fail4;
+        goto fail3;
 
     ZeroMemory(&Interface, sizeof (Interface));
     Interface.dbcc_size = sizeof (Interface);
@@ -1483,7 +1500,7 @@ MonitorMain(
                                    &Interface,
                                    DEVICE_NOTIFY_SERVICE_HANDLE);
     if (Context->InterfaceNotification == NULL)
-        goto fail5;
+        goto fail4;
 
     ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
 
@@ -1492,9 +1509,9 @@ MonitorMain(
 
     MonitorEnumerate();
 
-    Log("Waiting...");
+    LogInfo("Waiting...");
     WaitForSingleObject(Context->StopEvent, INFINITE);
-    Log("Wait Complete");
+    LogInfo("Wait Complete");
 
     MonitorRemoveAll();
 
@@ -1507,31 +1524,26 @@ MonitorMain(
 
     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
 
-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);
 
-    Log("<====");
+    LogInfo("<====");
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 
     return;
 
-fail5:
-    Log("fail5");
+fail4:
+    LogError("fail4");
 
     CloseHandle(Context->StopEvent);
 
-fail4:
-    Log("fail4");
+fail3:
+    LogError("fail3");
 
     ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
 
-    (VOID) DeregisterEventSource(Context->EventLog);
-
-fail3:
-    Log("fail3");
-
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     RegCloseKey(Context->ParametersKey);
 
@@ -1541,9 +1553,11 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 }
 
 static BOOL
@@ -1556,7 +1570,7 @@ MonitorCreate(
     CHAR        Path[MAX_PATH];
     HRESULT     Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     if(!GetModuleFileNameA(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1588,17 +1602,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(SCManager);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
 fail1:
     Error = GetLastError();
@@ -1606,7 +1620,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1624,7 +1638,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;
 
-    Log("====>");
+    LogInfo("====>");
 
     SCManager = OpenSCManager(NULL,
                               NULL,
@@ -1655,20 +1669,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);
 
-    Log("<====");
+    LogInfo("<====");
 
     return TRUE;
 
 fail4:
-    Log("fail4");
+    LogError("fail4");
 
 fail3:
-    Log("fail3");
+    LogError("fail3");
 
     CloseServiceHandle(Service);
 
 fail2:
-    Log("fail2");
+    LogError("fail2");
 
     CloseServiceHandle(SCManager);
 
@@ -1678,7 +1692,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
@@ -1696,16 +1710,16 @@ MonitorEntry(
     };
     HRESULT             Error;
 
-    Log("%s (%s) ====>",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) ====>",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
-    Log("%s (%s) <====",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) <====",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);
 
     return TRUE;
 
@@ -1715,7 +1729,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 
diff --git a/src/tty/tty.c b/src/tty/tty.c
index 4bfd74d..d58bf96 100644
--- a/src/tty/tty.c
+++ b/src/tty/tty.c
@@ -34,6 +34,8 @@
 #include <tchar.h>
 #include <strsafe.h>
 #include <userenv.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>
 
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
@@ -59,29 +61,43 @@ typedef struct _TTY_CONTEXT {
 
 TTY_CONTEXT TtyContext;
 
+TRACELOGGING_DEFINE_PROVIDER(TtyTraceLoggingProvider,
+                             __MODULE__,
+                             // {B1C2BE46-E523-5BCF-548F-77C2F1B015C7}
+                             (0xB1C2BE46, 0xE523, 0x5BCF, 0x54, 0x8F, 0x77, 0xC2, 0xF1, 0xB0, 0x15, 0xC7));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ PCSTR          Format,
-    _In_ ...
+    _In_ LOG_LEVEL      Level,
+    _In_ PCTSTR         Format,
+    ...
     )
 {
-    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
+    TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
     HRESULT             Result;
 
     va_start(Arguments, Format);
-    Result = StringCchVPrintfA(Buffer,
-        MAXIMUM_BUFFER_SIZE,
-        Format,
-        Arguments);
+    Result = StringCchVPrintf(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
     va_end(Arguments);
 
     if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
         return;
 
-    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
+    Result = StringCchLength(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
     if (Result != S_OK)
         return;
 
@@ -89,15 +105,35 @@ __Log(
 
     _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
     _Analysis_assume_(Length >= 2);
-    Buffer[Length] = '\0';
-    Buffer[Length - 1] = '\n';
-    Buffer[Length - 2] = '\r';
+    Buffer[Length] = _T('\0');
+    Buffer[Length - 1] = _T('\n');
+    Buffer[Length - 2] = _T('\r');
 
     OutputDebugString(Buffer);
+
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(TtyTraceLoggingProvider,
+                          "Information",
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, "Info"));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(TtyTraceLoggingProvider,
+                          "Error",
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, "Error"));
+        break;
+    default:
+        break;
+    }
 }
 
-#define Log(_Format, ...) \
-    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
 
 static BOOL
 CreateChild(
@@ -427,7 +463,7 @@ TtyIn(
 
     UNREFERENCED_PARAMETER(Argument);
 
-    Log("====>");
+    LogInfo("====>");
 
     for (;;) {
         DWORD       Read;
@@ -461,7 +497,7 @@ TtyIn(
         }
     }
 
-    Log("<====");
+    LogInfo("<====");
 
     return 0;
 }
@@ -475,7 +511,7 @@ TtyOut(
 
     UNREFERENCED_PARAMETER(Argument);
 
-    Log("====>");
+    LogInfo("====>");
 
     for (;;) {
         DWORD       Read;
@@ -503,7 +539,7 @@ TtyOut(
             break;
     }
 
-    Log("<====");
+    LogInfo("<====");
 
     return 0;
 }
@@ -524,7 +560,7 @@ _tmain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);
 
-    Log("====>");
+    LogInfo("====>");
 
     if (!WaitNamedPipe(PIPE_NAME, NMPWAIT_USE_DEFAULT_WAIT))
         ExitProcess(1);
@@ -642,5 +678,5 @@ _tmain(
 
     CloseHandle(Context->ProcessInfo.hProcess);
 
-    Log("<====");
+    LogInfo("<====");
 }
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:44:33 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281664.1564516 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcC1-00010G-5A; Tue, 14 Apr 2026 11:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281664.1564516; Tue, 14 Apr 2026 11:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcC1-000109-0r; Tue, 14 Apr 2026 11:44:33 +0000
Received: by outflank-mailman (input) for mailman id 1281664;
 Tue, 14 Apr 2026 11:44:31 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289c.v1-20cf553c259f46ba9c120d451795dc4e@bounce.vates.tech>)
 id 1wCcBz-0000x4-78
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:44:31 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcBy-00AwwI-JM
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:44:30 +0200
Received: from [10.42.69.4] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289c.v1-20cf553c259f46ba9c120d451795dc4e@bounce.vates.tech>)
 id 69de2899-bab6-0a2a0a5309dd-0a2a4504a6ea-12
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:30 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289c.v1-20cf553c259f46ba9c120d451795dc4e@bounce.vates.tech>)
 id 69de289d-bb33-0a2a45040019-c602bb0e667a-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:30 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw2W05Br8z8XS3xj
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:28 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 20cf553c259f46ba9c120d451795dc4e; Tue, 14 Apr 2026 11:44:28 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167068; x=1776437068;
	bh=uu+DzCGtsDuBn5+B1mUsW1PbTxXiYOCblXfzuAGNEro=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=xLZggfhJmhcbCk3kcJvxpO0vSRxrDRNTU6bhM2TYxPYOSWnYj+bIJvXqTKHS4iovc
	 v8UcsUfkn0ZHRSN2I60jpbzc3uaXHt5cyzNsA8OXF7CZ/315bbDK/RcmqKNYUaKpMg
	 z4qLnVOlP0KiukHSZNvAcPuLAMTvs2hdwrh2V5eytK07Y8ceaiACuaPVKk4Ib0XArD
	 fehQulzCoZwdmmlUOr2468C8FAlc4ZrA1JKvcHshpBlBX6DKRlfzPbYjFZXx1j3Dxb
	 TOj7o0ICwabnQsk8M1kldD0pz2E5QIvZI9TRpGXja6sjWupcmd3BXrNCsAphqUOlPB
	 +rKrfMbTJiiTA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167068; x=1776427568; i=ngoc-tu.dinh@vates.tech;
	bh=uu+DzCGtsDuBn5+B1mUsW1PbTxXiYOCblXfzuAGNEro=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=sL2gQAw7mNUbzjw4U1ERP6amz8Xx95NkrrjnRlUhFta57JBoyVvPDLu5l/gHZ3NKN
	 2b0I1gKDmJDbzER5eGpheIcj/1l44spQtp10K+a0eSV51xVEfMvZ6jo8vGdjpi0JbR
	 N4cZlS166Jkhjl42AmiJ721OOWNGWo0N4CqKCQRlqzTEFJMk0m48oVfv1VlbAl5YPm
	 9I7qtxvGDZoxNK6GLWy8avrUFANCXXkxeGh7vlAgTwW7i2IV3zDPtksR3X8ifoAw4O
	 Yg4vPH7XMCdQVZIqPDoslk67iHaI08A25Q4npEhKZujxMhhO4DFP5QrYnsnrEpvR2z
	 ugpvFzErrGvvA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=204/6]=20Delete=20xencons=5Fmonitor.dll?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167068061
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414114416.1336-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.20cf553c259f46ba9c120d451795dc4e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:28 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-ebf023/1776167070-30B2851B-B3A27430/0/0
X-purgate-type: clean
X-purgate-size: 8549

Now that trace logging is used, the DLL is not needed any more. Remove
it from the build and package.

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/messages.mc                       | 55 -------------------
 src/monitor/monitor.c                         |  2 -
 src/monitor/xencons_monitor.rc                |  1 -
 src/xencons.inf                               | 11 +---
 .../xencons_monitor/xencons_monitor.vcxproj   | 17 ------
 .../xencons_monitor/xencons_monitor.vcxproj   | 12 ----
 6 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 src/monitor/messages.mc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
deleted file mode 100644
index eb1d382..0000000
--- a/src/monitor/messages.mc
+++ /dev/null
@@ -1,55 +0,0 @@
-; // Copyright (c) Xen Project.
-; // Copyright (c) Cloud Software Group, Inc.
-; // All rights reserved.
-; //
-; // Redistribution and use in source and binary forms,
-; // with or without modification, are permitted provided
-; // that the following conditions are met:
-; //
-; // *   Redistributions of source code must retain the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer.
-; // *   Redistributions in binary form must reproduce the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer in the documentation and/or other
-; //     materials provided with the distribution.
-; //
-; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-; // SUCH DAMAGE.
-
-MessageIdTypedef=DWORD
-
-SeverityNames=(
-	Success=0x0:STATUS_SEVERITY_SUCCESS
-	Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
-	Warning=0x2:STATUS_SEVERITY_WARNING
-	Error=0x3:STATUS_SEVERITY_ERROR
-	)
-
-
-FacilityNames=(
-	System=0x0:FACILITY_SYSTEM
-	Runtime=0x2:FACILITY_RUNTIME
-	Stubs=0x3:FACILITY_STUBS
-	Io=0x4:FACILITY_IO_ERROR_CODE
-	)
-
-MessageId=0x1
-Severity=Informational
-Facility=System
-SymbolicName=MONITOR_LOG
-Language=English
-%1
-.
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 78d67e1..3ff7d7c 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -50,8 +50,6 @@
 #include <xencons_device.h>
 #include <version.h>
 
-#include "messages.h"
-
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
 #define __MODULE__ stringify(PROJECT)
diff --git a/src/monitor/xencons_monitor.rc b/src/monitor/xencons_monitor.rc
index 3fba041..6c077f8 100644
--- a/src/monitor/xencons_monitor.rc
+++ b/src/monitor/xencons_monitor.rc
@@ -54,4 +54,3 @@
 #define VER_FILESUBTYPE		    VFT2_UNKNOWN
 
 #include "common.ver"
-#include "messages.rc"
diff --git a/src/xencons.inf b/src/xencons.inf
index 6bbd83b..6f9b361 100644
--- a/src/xencons.inf
+++ b/src/xencons.inf
@@ -51,12 +51,10 @@ Tty_CopyFiles=11
 [SourceDisksFiles]
 xencons.sys=0,,
 xencons_monitor.exe=0,,
-xencons_monitor.dll=0,,
 xencons_tty.exe=0,,
 
 [Monitor_CopyFiles]
 xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_monitor.exe
-xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xencons_monitor.dll
 
 [Tty_CopyFiles]
 xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_tty.exe
@@ -81,7 +79,7 @@ FeatureScore=0xFE
 xencons.sys
 
 [XenCons_Inst.Services]
-AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Monitor_EventLog
+AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
 AddService=xencons,%SPSVCINST_ASSOCSERVICE%,XenCons_Service
 
 [XenCons_Service]
@@ -109,13 +107,6 @@ AddReg = Monitor_Parameters
 HKR,"Parameters",,0x00000010
 HKR,"Parameters\default","Executable",0x00000000,"xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe"
 
-[Monitor_EventLog]
-AddReg=Monitor_EventLog_AddReg
-
-[Monitor_EventLog_AddReg]
-HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
-HKR,,TypesSupported,0x00010001,7
-
 [Strings]
 
 Vendor="@VENDOR_NAME@"
diff --git a/vs2019/xencons_monitor/xencons_monitor.vcxproj b/vs2019/xencons_monitor/xencons_monitor.vcxproj
index 0bbf600..41424d5 100644
--- a/vs2019/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2019/xencons_monitor/xencons_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -50,29 +47,15 @@
     <ClCompile>
       <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
diff --git a/vs2022/xencons_monitor/xencons_monitor.vcxproj b/vs2022/xencons_monitor/xencons_monitor.vcxproj
index af0fbb4..e5e02b0 100644
--- a/vs2022/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2022/xencons_monitor/xencons_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -50,19 +47,10 @@
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:44:33 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281665.1564521 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcC1-00010Y-8C; Tue, 14 Apr 2026 11:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281665.1564521; Tue, 14 Apr 2026 11:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcC1-00010L-2c; Tue, 14 Apr 2026 11:44:33 +0000
Received: by outflank-mailman (input) for mailman id 1281665;
 Tue, 14 Apr 2026 11:44:31 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289d.v1-b4738bfe8c654ec1887c5bac3f135df3@bounce.vates.tech>)
 id 1wCcBz-0000y0-St
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:44:31 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcBz-00Fzqj-8z
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:44:31 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289d.v1-b4738bfe8c654ec1887c5bac3f135df3@bounce.vates.tech>)
 id 69de2891-e002-0a2a0a5209dd-0a2a4509b7e6-10
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:31 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289d.v1-b4738bfe8c654ec1887c5bac3f135df3@bounce.vates.tech>)
 id 69de289e-bf79-0a2a45090019-c602bb0e613e-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:44:31 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw2W10yjnz8XS3xW
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:29 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b4738bfe8c654ec1887c5bac3f135df3; Tue, 14 Apr 2026 11:44:29 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167069; x=1776437069;
	bh=21kdKP1x4ILBEmU5TXYS05/4cIKUXeIs0Xu797J6dSE=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=tba/M2KqPEdVe8LS2tVBCccTWWtnpqLs43hmzsf77MQOE4GVCKaCOmtUDSrfEsrDf
	 4t3wwPn9edCcDo/JBZWcDvXyelc6BiKTgYyh7F9QBl/GwFRR118JpDwaletO1gCFHk
	 EG5Iq1iEWfueD9psdhLbp0qNzHE7twwSfacVTur9LDtz6EwkizIv8tk0txrIbuSsfo
	 JxSlZa52t3YwjS+nENS2OZRuoHGf87uWHFjVmoRZBybd4i1fkqvgjw7cKqhM0BVVcI
	 225C/XsumenKGjprLlfyJ+ApKmmp8vjcR2vnCxBIf6ofgklh9pcPquwKNJOcgXemGj
	 m535JmOnMM08Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167069; x=1776427569; i=ngoc-tu.dinh@vates.tech;
	bh=21kdKP1x4ILBEmU5TXYS05/4cIKUXeIs0Xu797J6dSE=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=P/YaZmUrDxvCRw8IwfuUF6B1eo4fMmIjTycT5gb5JusD8KAQcqr6q4VxFAQUwcwmi
	 KUA2LrCe4g9PUXP5zEl3XRYQim8FW/cMQZ0gXOBvJqMyTTabKWmVN1EkMD9Zsyeqpd
	 R1tKVCoh09lqCDhDTNldI76Fw+a5yHUr48xdRU8xsBnbBPbAtjdhAWvr3jnJCepyqM
	 j0m2XzvQmds/7XIanT4rKxORKsBNXMzhPOdQrh/FjavR88dJQi3DzIU7ZWRIzHGOZJ
	 aqOq/dCNBvuwWQLdxlwOp+ObVd9XRrf7CagwknLv3dYsDv2FTRR8rmPcJzAn447QkD
	 6ebITT5okZ+jg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=206/6]=20Discover=20cmd.exe=20using=20GetSystemDirectory?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167068501
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414114416.1336-7-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b4738bfe8c654ec1887c5bac3f135df3?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:29 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-bad1c0/1776167071-56949152-903CA05B/0/0
X-purgate-type: clean
X-purgate-size: 1498

Don't assume that the system directory is always c:\windows\system32.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/tty/tty.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/tty/tty.c b/src/tty/tty.c
index a04c2ea..be6815c 100644
--- a/src/tty/tty.c
+++ b/src/tty/tty.c
@@ -141,7 +141,8 @@ CreateChild(
     )
 {
     PTTY_CONTEXT            Context = &TtyContext;
-    CHAR                    CommandLine[] = "c:\\windows\\system32\\cmd.exe /q /a";
+    CHAR                    SystemDir[MAX_PATH];
+    CHAR                    CommandLine[MAX_PATH];
     PVOID                   Environment;
     PROFILEINFOA            ProfileInfo;
     DWORD                   Size;
@@ -149,6 +150,15 @@ CreateChild(
     STARTUPINFOA            StartupInfo;
     BOOL                    Success;
 
+    if (!GetSystemDirectoryA(SystemDir, sizeof(SystemDir)))
+        return FALSE;
+
+    if (!SUCCEEDED(StringCchPrintfA(CommandLine,
+                                    sizeof(CommandLine),
+                                    "%s\\cmd.exe /q /a",
+                                    SystemDir)))
+        return FALSE;
+
     Success = CreateEnvironmentBlock(&Environment,
                                      Context->Token,
                                      FALSE);
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:49:30 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:49:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281678.1564533 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcGn-0001pK-NR; Tue, 14 Apr 2026 11:49:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281678.1564533; Tue, 14 Apr 2026 11:49:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcGn-0001pD-KY; Tue, 14 Apr 2026 11:49:29 +0000
Received: by outflank-mailman (input) for mailman id 1281678;
 Tue, 14 Apr 2026 11:49:28 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289b.v1-468c7c5e097641b5929513cf08da51be@bounce.vates.tech>)
 id 1wCcGm-0001p1-6w
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:49:28 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcGl-008c0S-Jr
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:49:27 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289b.v1-468c7c5e097641b5929513cf08da51be@bounce.vates.tech>)
 id 69de29c2-5cb7-0a2a0a5109dd-0a2a45028ca8-26
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:49:27 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289b.v1-468c7c5e097641b5929513cf08da51be@bounce.vates.tech>)
 id 69de29c6-42fa-0a2a45020019-c602bb0114f1-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:49:27 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fw2Vz75HtzBsXHFQ
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:27 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 468c7c5e097641b5929513cf08da51be; Tue, 14 Apr 2026 11:44:27 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167068; x=1776437068;
	bh=F2MPSCEMuKipo8ujAGqMUfEdbC/IXStUamTkIMdNr2Y=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=H3TvUYPvT7D+TdlT3hgpbsR2c/xW+aEAAyCei2fNAqAumhqi+cWpETuF7ggmuTIKX
	 armSRUkwgZgtagB1PMg9PHLEGX3nApQNG7/x4+KRIWHx/jeqqyloXRdmWpwhNeTncH
	 Ps7t3YEn4apeKqenKS/caCzKyEq/peW9aMEQ6Bo7kNaqFUyYAeJ23IsSCcEKJWNqkW
	 RNl2y1jN6yvEhoNRl3Xy2BoXhssrKwWep5vPSzWoexrWv67mW2Pg15j+Eh0/8zg2s8
	 66uYOFDJuty4SEuQZQBhEbRfcrk1M0+4rdi8T8zShM98NAiy3wzR6j8yGRrL43XOC4
	 gfcWtNM4HTtzQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167068; x=1776427568; i=ngoc-tu.dinh@vates.tech;
	bh=F2MPSCEMuKipo8ujAGqMUfEdbC/IXStUamTkIMdNr2Y=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=mKHuz1zk5hHRqMa4NubhhZM3l67HgCFQLdw77pN+EtDXkL3Oe3fmxogPcymqyL+Y/
	 HmI5grwopMd4AbcQxZ3XHITR+0ZuBYULupN0PHUV0sz1F+tRPOZRzYoQ1FsSaw0zVY
	 YQWMWh1LZm0lAvGuC4MGc1G5LI9i6xK2sN/NgHRvth8aeS+2GVNwQvjWfJmt4Wa0/N
	 MbTUud7kdP7ERcRjOjOeEVITNvzuFu6W7sesnrTv+GdbPzpquLGDvZZGupP5y6YCkL
	 8V1lyCPFTBUh713WhGAtuaOT20cxO5CCZl+Dfvi/IllAuWxSLnTWpH+6l506HH6dS7
	 jvgwRTw44875Q==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=201/6]=20Use=20RegCloseKey=20for=20ParametersKey?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167067121
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>, "david ambu" <david.preetham@cloud.com>
Message-Id: <20260414114416.1336-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.468c7c5e097641b5929513cf08da51be?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:27 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-720697/1776167367-AE926CD1-9090C316/0/0
X-purgate-type: clean
X-purgate-size: 952

CloseHandle silently fails for HKEY.

Signed-off-by: david ambu <david.preetham@cloud.com>

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 772bbf4..b5e042a 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1509,7 +1509,7 @@ MonitorMain(
 
     (VOID) DeregisterEventSource(Context->EventLog);
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
     Log("<====");
 
@@ -1533,7 +1533,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
 fail1:
     Error = GetLastError();
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:49:30 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:49:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281679.1564537 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcGo-0001qn-PE; Tue, 14 Apr 2026 11:49:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281679.1564537; Tue, 14 Apr 2026 11:49:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcGo-0001qd-Lw; Tue, 14 Apr 2026 11:49:30 +0000
Received: by outflank-mailman (input) for mailman id 1281679;
 Tue, 14 Apr 2026 11:49:29 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289c.v1-ec0ba8f22277494a9f3a45506d3956c3@bounce.vates.tech>)
 id 1wCcGn-0001p7-AC
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:49:29 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcGm-00GIsS-ND
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:49:28 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289c.v1-ec0ba8f22277494a9f3a45506d3956c3@bounce.vates.tech>)
 id 69de29c6-e002-0a2a0a5209dd-0a2a450b8cb0-20
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:49:28 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289c.v1-ec0ba8f22277494a9f3a45506d3956c3@bounce.vates.tech>)
 id 69de29c7-bca8-0a2a450b0019-c602bb012717-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:49:28 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fw2W03XBjzBsVd0P
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:28 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 ec0ba8f22277494a9f3a45506d3956c3; Tue, 14 Apr 2026 11:44:28 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167068; x=1776437068;
	bh=UZ4kSFdEfn0OiwndEBiPz6VQT2g9uEByPQEy6LmQM8c=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=T1fzQ6Ha2AjRtulo2VyDxAFXY9T5bHLggFQJj69CuUvkkQXWbzyK9ioNGfy+dvTch
	 MSdXyN6/DxZRuAxwTDeiyPt9TJoESH6QKAKh0HqNzKcw0qrleh17u/dvpWITj9BaQM
	 3JKt/gecWzY+zRBym7aQivki3bKRLiPtSVZii5cjl1x7pgltuTHp7kFibIzrPxL2wz
	 rFZqhRo0wl9ld5vSKuUgVzG5Zzf/9a2o1Yv8ozyT4OsQSGD3geS4lVBjKPtZy6mSzU
	 LaSw3fCBdQQDPO+sBMwlcAPQRRQKt8yXwm0VpQXSvf4XxVwdbHgl0m+b1QHzPguq5I
	 CLUMAS1HJ9kjA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167068; x=1776427568; i=ngoc-tu.dinh@vates.tech;
	bh=UZ4kSFdEfn0OiwndEBiPz6VQT2g9uEByPQEy6LmQM8c=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=RFTtj4gENkAeTo5JdGtvC9eYejWZYuCxtmdLrp5CmqbV2Iu4CKoZEUuXoQvYqPFQu
	 xekM8N+v9s6v3zGO8Kh8Mxk+d5HrXuG7WcAObVUuF3W6opia4KtDlX/nyR4HMoWjPJ
	 JghcoO8EUnaimQWNylStUYywOp3ELW035eq5/auWFzm8gnP+FTILvOdsuuMjpAfSH2
	 w7h3W+HYM7h0sZGbi7yO/nQ4CoDGoxTh3otHoevAFAgS5H0v7R5ZeJ8OlzzFAASJPX
	 now6L2p8fx3ESWeMKYK1uUrF6ZR4HwEoS1knzSWmuI/DBb/fOZlKWAZgCFvUoAD2cs
	 eY2BqCirOUSUw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=203/6]=20Fix=20inconsistent=20TCHAR=20handling?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167067846
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414114416.1336-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.ec0ba8f22277494a9f3a45506d3956c3?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:28 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-42698a/1776167368-EC55B2A1-D25E2192/0/0
X-purgate-type: clean
X-purgate-size: 24565

* Wrap strings with _T()
* Fix ServiceStateName and WTSStateName to return PCTSTR
* Use 'Length' for character counts, and 'Size' for byte counts
  when calling StringCch* and StringCb* functions
* Fix _tWinMain to use LPTSTR

Signed-off-by: Owen Smith <owen.smith@citrix.com>

Ported from Xenbus.

* Convert DeviceInterfaceDetail/DeviceName to TCHAR equivalents
* Convert the output of IOCTL_XENCONS_GET_NAME to Unicode strings
* Remove explicit uses of A/W functions

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 279 +++++++++++++++++++++++-------------------
 1 file changed, 150 insertions(+), 129 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 381898f..78d67e1 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -33,6 +33,7 @@
 #define INITGUID 1
 
 #include <windows.h>
+#include <tchar.h>
 #include <winioctl.h>
 #include <stdlib.h>
 #include <strsafe.h>
@@ -71,10 +72,10 @@ typedef struct _MONITOR_CONTEXT {
 
 typedef struct _MONITOR_CONSOLE {
     LIST_ENTRY              ListEntry;
-    PWCHAR                  DevicePath;
+    PTSTR                   DevicePath;
     HANDLE                  DeviceHandle;
     HDEVNOTIFY              DeviceNotification;
-    PSTR                    DeviceName; // protocol and instance?
+    PTSTR                   DeviceName; // protocol and instance?
     HANDLE                  ExecutableThread;
     HANDLE                  ExecutableEvent;
     HANDLE                  DeviceThread;
@@ -183,28 +184,28 @@ __Log(
 #define LogError(_Format, ...) \
         __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
 
-static PSTR
+static PTSTR
 GetErrorMessage(
-    _In_ HRESULT    Error
+    _In_  HRESULT   Error
     )
 {
-    PSTR            Message;
+    PTSTR           Message;
     ULONG           Index;
 
-    if (!FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                        FORMAT_MESSAGE_FROM_SYSTEM |
-                        FORMAT_MESSAGE_IGNORE_INSERTS,
-                        NULL,
-                        Error,
-                        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                        (LPSTR)&Message,
-                        0,
-                        NULL))
+    if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                       FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS,
+                       NULL,
+                       Error,
+                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                       (LPTSTR)&Message,
+                       0,
+                       NULL))
         return NULL;
 
-    for (Index = 0; Message[Index] != '\0'; Index++) {
-        if (Message[Index] == '\r' || Message[Index] == '\n') {
-            Message[Index] = '\0';
+    for (Index = 0; Message[Index] != _T('\0'); Index++) {
+        if (Message[Index] == _T('\r') || Message[Index] == _T('\n')) {
+            Message[Index] = _T('\0');
             break;
         }
     }
@@ -212,14 +213,14 @@ GetErrorMessage(
     return Message;
 }
 
-static PCSTR
+static PCTSTR
 ServiceStateName(
     _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
     case SERVICE_ ## _State: \
-        return #_State
+        return _T(#_State)
 
     switch (State) {
     _STATE_NAME(START_PENDING);
@@ -230,7 +231,7 @@ ServiceStateName(
         break;
     }
 
-    return "UNKNOWN";
+    return _T("UNKNOWN");
 
 #undef  _STATE_NAME
 }
@@ -279,7 +280,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PSTR    Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -433,7 +434,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -448,7 +449,7 @@ ServerThread(
     )
 {
     PMONITOR_CONSOLE    Console = (PMONITOR_CONSOLE)Argument;
-    CHAR                PipeName[MAXIMUM_BUFFER_SIZE];
+    TCHAR               PipeName[MAXIMUM_BUFFER_SIZE];
     OVERLAPPED          Overlapped;
     HANDLE              Handle[2];
     HANDLE              Pipe;
@@ -470,11 +471,11 @@ ServerThread(
     Handle[0] = Console->ServerEvent;
     Handle[1] = Overlapped.hEvent;
 
-    Error = StringCchPrintfA(PipeName,
-                             MAXIMUM_BUFFER_SIZE,
-                             "%s%s",
-                             PIPE_BASE_NAME,
-                             Console->DeviceName);
+    Error = StringCchPrintf(PipeName,
+                            MAXIMUM_BUFFER_SIZE,
+                            _T("%s%s"),
+                            _T(PIPE_BASE_NAME),
+                            Console->DeviceName);
     if (Error != S_OK && Error != STRSAFE_E_INSUFFICIENT_BUFFER)
         goto fail2;
 
@@ -483,10 +484,10 @@ ServerThread(
     ZeroMemory(&SecurityAttributes, sizeof(SECURITY_ATTRIBUTES));
     SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
     SecurityAttributes.bInheritHandle = FALSE;
-    if (!ConvertStringSecurityDescriptorToSecurityDescriptorA(PIPE_SDDL,
-                                                              SDDL_REVISION_1,
-                                                              &SecurityAttributes.lpSecurityDescriptor,
-                                                              NULL))
+    if (!ConvertStringSecurityDescriptorToSecurityDescriptor(_T(PIPE_SDDL),
+                                                             SDDL_REVISION_1,
+                                                             &SecurityAttributes.lpSecurityDescriptor,
+                                                             NULL))
         goto fail3;
 
     for (;;) {
@@ -567,7 +568,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -603,13 +604,13 @@ DeviceThread(
     Handles[0] = Console->DeviceEvent;
     Handles[1] = Overlapped.hEvent;
 
-    Device = CreateFileW(Console->DevicePath,
-                         GENERIC_READ,
-                         FILE_SHARE_READ | FILE_SHARE_WRITE,
-                         NULL,
-                         OPEN_EXISTING,
-                         FILE_FLAG_OVERLAPPED,
-                         NULL);
+    Device = CreateFile(Console->DevicePath,
+                        GENERIC_READ,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE,
+                        NULL,
+                        OPEN_EXISTING,
+                        FILE_FLAG_OVERLAPPED,
+                        NULL);
     if (Device == INVALID_HANDLE_VALUE)
         goto fail2;
 
@@ -673,7 +674,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -685,8 +686,8 @@ fail1:
 _Success_(return != FALSE)
 static BOOL
 GetExecutable(
-    _In_ PSTR               DeviceName,
-    _Outptr_result_z_ PSTR  *Executable
+    _In_ PTSTR              DeviceName,
+    _Outptr_result_z_ PTSTR *Executable
     )
 {
     PMONITOR_CONTEXT        Context = &MonitorContext;
@@ -696,11 +697,11 @@ GetExecutable(
     DWORD                   Type;
     HRESULT                 Error;
 
-    Error = RegOpenKeyExA(Context->ParametersKey,
-                          DeviceName,
-                          0,
-                          KEY_READ,
-                          &Key);
+    Error = RegOpenKeyEx(Context->ParametersKey,
+                         DeviceName,
+                         0,
+                         KEY_READ,
+                         &Key);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail1;
@@ -723,18 +724,18 @@ GetExecutable(
         goto fail2;
     }
 
-    ExecutableLength = MaxValueLength;
+    ExecutableLength = (MaxValueLength + 1) * sizeof(TCHAR);
 
     *Executable = calloc(1, ExecutableLength);
     if (*Executable == NULL)
         goto fail3;
 
-    Error = RegQueryValueExA(Key,
-                             "Executable",
-                             NULL,
-                             &Type,
-                             (LPBYTE)(*Executable),
-                             &ExecutableLength);
+    Error = RegQueryValueEx(Key,
+                            _T("Executable"),
+                            NULL,
+                            &Type,
+                            (LPBYTE)(*Executable),
+                            &ExecutableLength);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail4;
@@ -771,7 +772,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -786,7 +787,7 @@ ExecutableThread(
     )
 {
     PMONITOR_CONSOLE    Console = (PMONITOR_CONSOLE)Argument;
-    PSTR                Executable;
+    PTSTR               Executable;
     PROCESS_INFORMATION ProcessInfo;
     STARTUPINFO         StartupInfo;
     BOOL                Success;
@@ -868,7 +869,7 @@ fail1:
     free(Executable);
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -879,18 +880,24 @@ fail1:
 
 static PMONITOR_CONSOLE
 ConsoleCreate(
-    _In_ PWCHAR             DevicePath
+    _In_ PTSTR              DevicePath
     )
 {
     PMONITOR_CONTEXT        Context = &MonitorContext;
     PMONITOR_CONSOLE        Console;
     DEV_BROADCAST_HANDLE    Handle;
     CHAR                    DeviceName[MAX_PATH];
+#ifdef UNICODE
+    TCHAR                   DeviceNameString[MAX_PATH];
+    errno_t                 StringError;
+#else
+#define DeviceNameString    DeviceName
+#endif
     DWORD                   Bytes;
     BOOL                    Success;
     HRESULT                 Error;
 
-    LogInfo("====> %ws", DevicePath);
+    LogInfo("====> %s", DevicePath);
 
     Console = malloc(sizeof(MONITOR_CONSOLE));
     if (Console == NULL)
@@ -901,17 +908,17 @@ ConsoleCreate(
     __InitializeListHead(&Console->ListEntry);
     InitializeCriticalSection(&Console->CriticalSection);
 
-    Console->DevicePath = _wcsdup(DevicePath);
+    Console->DevicePath = _tcsdup(DevicePath);
     if (Console->DevicePath == NULL)
         goto fail2;
 
-    Console->DeviceHandle = CreateFileW(DevicePath,
-                                        GENERIC_READ | GENERIC_WRITE,
-                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
-                                        NULL,
-                                        OPEN_EXISTING,
-                                        FILE_ATTRIBUTE_NORMAL,
-                                        NULL);
+    Console->DeviceHandle = CreateFile(DevicePath,
+                                       GENERIC_READ | GENERIC_WRITE,
+                                       FILE_SHARE_READ | FILE_SHARE_WRITE,
+                                       NULL,
+                                       OPEN_EXISTING,
+                                       FILE_ATTRIBUTE_NORMAL,
+                                       NULL);
     if (Console->DeviceHandle == INVALID_HANDLE_VALUE)
         goto fail3;
 
@@ -927,10 +934,19 @@ ConsoleCreate(
         goto fail4;
 
     DeviceName[MAX_PATH - 1] = '\0';
+#ifdef UNICODE
+    StringError = mbstowcs_s(NULL,
+                             DeviceNameString,
+                             sizeof(DeviceNameString) / sizeof(TCHAR),
+                             DeviceName,
+                             strlen(DeviceName));
+    if (StringError != 0)
+        goto fail5;
+#endif
 
-    Console->DeviceName = _strdup(DeviceName);
+    Console->DeviceName = _tcsdup(DeviceNameString);
     if (Console->DeviceName == NULL)
-        goto fail5;
+        goto fail6;
 
     ECHO(Console->DeviceHandle, "\r\n[ATTACHED]\r\n");
 
@@ -944,14 +960,14 @@ ConsoleCreate(
                                     &Handle,
                                     DEVICE_NOTIFY_SERVICE_HANDLE);
     if (Console->DeviceNotification == NULL)
-        goto fail6;
+        goto fail7;
 
     Console->DeviceEvent = CreateEvent(NULL,
                                        TRUE,
                                        FALSE,
                                        NULL);
     if (Console->DeviceEvent == NULL)
-        goto fail7;
+        goto fail8;
 
     Console->DeviceThread = CreateThread(NULL,
                                          0,
@@ -960,14 +976,14 @@ ConsoleCreate(
                                          0,
                                          NULL);
     if (Console->DeviceThread == NULL)
-        goto fail8;
+        goto fail9;
 
     Console->ServerEvent = CreateEvent(NULL,
                                        TRUE,
                                        FALSE,
                                        NULL);
     if (Console->ServerEvent == NULL)
-        goto fail9;
+        goto fail10;
 
     Console->ServerThread = CreateThread(NULL,
                                          0,
@@ -976,14 +992,14 @@ ConsoleCreate(
                                          0,
                                          NULL);
     if (Console->ServerThread == NULL)
-        goto fail10;
+        goto fail11;
 
     Console->ExecutableEvent = CreateEvent(NULL,
                                            TRUE,
                                            FALSE,
                                            NULL);
     if (Console->ExecutableEvent == NULL)
-        goto fail11;
+        goto fail12;
 
     Console->ExecutableThread = CreateThread(NULL,
                                              0,
@@ -992,58 +1008,63 @@ ConsoleCreate(
                                              0,
                                              NULL);
     if (Console->ExecutableThread == NULL)
-        goto fail12;
+        goto fail13;
 
     LogInfo("<==== %s", Console->DeviceName);
 
     return Console;
 
-fail12:
-    LogError("fail12");
+fail13:
+    LogError("fail13");
 
     CloseHandle(Console->ExecutableEvent);
     Console->ExecutableEvent = NULL;
 
-fail11:
-    LogError("fail11");
+fail12:
+    LogError("fail12");
 
     SetEvent(Console->ServerEvent);
     WaitForSingleObject(Console->ServerThread, INFINITE);
 
-fail10:
-    LogError("fail10");
+fail11:
+    LogError("fail11");
 
     CloseHandle(Console->ServerEvent);
     Console->ServerEvent = NULL;
 
-fail9:
-    LogError("fail9");
+fail10:
+    LogError("fail10");
 
     SetEvent(Console->DeviceEvent);
     WaitForSingleObject(Console->DeviceThread, INFINITE);
 
-fail8:
-    LogError("fail8");
+fail9:
+    LogError("fail9");
 
     CloseHandle(Console->DeviceEvent);
     Console->DeviceEvent = NULL;
 
-fail7:
-    LogError("fail7");
+fail8:
+    LogError("fail8");
 
     UnregisterDeviceNotification(Console->DeviceNotification);
     Console->DeviceNotification = NULL;
 
-fail6:
-    LogError("fail6");
+fail7:
+    LogError("fail7");
 
     ECHO(Console->DeviceHandle, "\r\n[DETACHED]\r\n");
 
     free(Console->DevicePath);
     Console->DevicePath = NULL;
 
+fail6:
+    LogError("fail6");
+
+#ifdef UNICODE
 fail5:
     LogError("fail5");
+#endif
 
 fail4:
     LogError("fail4");
@@ -1070,7 +1091,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PSTR    Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1176,13 +1197,13 @@ ConsoleDestroy(
 
 static BOOL
 MonitorAdd(
-    _In_ PWCHAR         DevicePath
+    _In_ PTCHAR         DevicePath
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     PMONITOR_CONSOLE    Console;
 
-    LogInfo("=====> %ws", DevicePath);
+    LogInfo("=====> %s", DevicePath);
 
     Console = ConsoleCreate(DevicePath);
     if (Console == NULL)
@@ -1251,7 +1272,7 @@ MonitorEnumerate(
     PMONITOR_CONTEXT                    Context = &MonitorContext;
     HDEVINFO                            DeviceInfoSet;
     SP_DEVICE_INTERFACE_DATA            DeviceInterfaceData;
-    PSP_DEVICE_INTERFACE_DETAIL_DATA_W  DeviceInterfaceDetail;
+    PSP_DEVICE_INTERFACE_DETAIL_DATA    DeviceInterfaceDetail;
     PMONITOR_CONSOLE                    Console;
     DWORD                               Size;
     DWORD                               Index;
@@ -1279,7 +1300,7 @@ MonitorEnumerate(
         if (!Success)
             break;
 
-        Success = SetupDiGetDeviceInterfaceDetailW(DeviceInfoSet,
+        Success = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet,
                                                   &DeviceInterfaceData,
                                                   NULL,
                                                   0,
@@ -1293,14 +1314,14 @@ MonitorEnumerate(
             goto fail3;
 
         DeviceInterfaceDetail->cbSize =
-            sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA_W);
-
-        Success = SetupDiGetDeviceInterfaceDetailW(DeviceInfoSet,
-                                                   &DeviceInterfaceData,
-                                                   DeviceInterfaceDetail,
-                                                   Size,
-                                                   NULL,
-                                                   NULL);
+            sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+        Success = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet,
+                                                  &DeviceInterfaceData,
+                                                  DeviceInterfaceDetail,
+                                                  Size,
+                                                  NULL,
+                                                  NULL);
         if (!Success)
             goto fail4;
 
@@ -1330,7 +1351,7 @@ MonitorEnumerate(
         Error = GetLastError();
 
         {
-            PSTR    Message;
+            PTSTR   Message;
             Message = GetErrorMessage(Error);
             LogError("fail2 (%s)", Message);
             LocalFree(Message);
@@ -1347,7 +1368,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PSTR    Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1416,7 +1437,7 @@ MonitorCtrlHandlerEx(
         switch (EventType) {
         case DBT_DEVICEARRIVAL:
             if (Header->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
-                PDEV_BROADCAST_DEVICEINTERFACE_W Interface = EventData;
+                PDEV_BROADCAST_DEVICEINTERFACE  Interface = EventData;
 
                 if (IsEqualGUID(&Interface->dbcc_classguid,
                                 &GUID_XENCONS_DEVICE))
@@ -1463,15 +1484,15 @@ MonitorMain(
 
     LogInfo("====>");
 
-    Error = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
-                         PARAMETERS_KEY(__MODULE__),
+    Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                         _T(PARAMETERS_KEY(__MODULE__)),
                          0,
                          KEY_READ,
                          &Context->ParametersKey);
     if (Error != ERROR_SUCCESS)
         goto fail1;
 
-    Context->Service = RegisterServiceCtrlHandlerExA(MONITOR_NAME,
+    Context->Service = RegisterServiceCtrlHandlerEx(_T(MONITOR_NAME),
                                                     MonitorCtrlHandlerEx,
                                                     NULL);
     if (Context->Service == NULL)
@@ -1551,7 +1572,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1567,12 +1588,12 @@ MonitorCreate(
 {
     SC_HANDLE   SCManager;
     SC_HANDLE   Service;
-    CHAR        Path[MAX_PATH];
+    TCHAR       Path[MAX_PATH];
     HRESULT     Error;
 
     LogInfo("====>");
 
-    if(!GetModuleFileNameA(NULL, Path, MAX_PATH))
+    if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;
 
     SCManager = OpenSCManager(NULL,
@@ -1583,8 +1604,8 @@ MonitorCreate(
         goto fail2;
 
     Service = CreateService(SCManager,
-                            MONITOR_NAME,
-                            MONITOR_DISPLAYNAME,
+                            _T(MONITOR_NAME),
+                            _T(MONITOR_DISPLAYNAME),
                             SERVICE_ALL_ACCESS,
                             SERVICE_WIN32_OWN_PROCESS,
                             SERVICE_AUTO_START,
@@ -1618,7 +1639,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1648,7 +1669,7 @@ MonitorDelete(
         goto fail1;
 
     Service = OpenService(SCManager,
-                          MONITOR_NAME,
+                          _T(MONITOR_NAME),
                           SERVICE_ALL_ACCESS);
 
     if (Service == NULL)
@@ -1690,7 +1711,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1705,21 +1726,21 @@ MonitorEntry(
     )
 {
     SERVICE_TABLE_ENTRY Table[] = {
-        { MONITOR_NAME, MonitorMain },
+        { _T(MONITOR_NAME), MonitorMain },
         { NULL, NULL }
     };
     HRESULT             Error;
 
     LogInfo("%s (%s) ====>",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
 
     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;
 
     LogInfo("%s (%s) <====",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));
 
     return TRUE;
 
@@ -1727,7 +1748,7 @@ fail1:
     Error = GetLastError();
 
     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1737,10 +1758,10 @@ fail1:
 }
 
 int CALLBACK
-WinMain(
+_tWinMain(
     _In_        HINSTANCE   Current,
     _In_opt_    HINSTANCE   Previous,
-    _In_        LPSTR       CmdLine,
+    _In_        LPTSTR      CmdLine,
     _In_        int         CmdShow
     )
 {
@@ -1750,10 +1771,10 @@ WinMain(
     UNREFERENCED_PARAMETER(Previous);
     UNREFERENCED_PARAMETER(CmdShow);
 
-    if (strlen(CmdLine) != 0) {
-         if (_stricmp(CmdLine, "create") == 0)
+    if (_tcslen(CmdLine) != 0) {
+         if (_tcsicmp(CmdLine, TEXT("create")) == 0)
              Success = MonitorCreate();
-         else if (_stricmp(CmdLine, "delete") == 0)
+         else if (_tcsicmp(CmdLine, TEXT("delete")) == 0)
              Success = MonitorDelete();
          else
              Success = FALSE;
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 11:49:31 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 11:49:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281680.1564541 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcGp-0001sl-R6; Tue, 14 Apr 2026 11:49:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281680.1564541; Tue, 14 Apr 2026 11:49:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcGp-0001se-OD; Tue, 14 Apr 2026 11:49:31 +0000
Received: by outflank-mailman (input) for mailman id 1281680;
 Tue, 14 Apr 2026 11:49:29 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de289c.v1-12fcd6f79a4843a0a7b21843f1f9b66a@bounce.vates.tech>)
 id 1wCcGn-0001pC-OC
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 11:49:29 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcGn-008c3I-4m
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 13:49:29 +0200
Received: from [10.42.69.10] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de289c.v1-12fcd6f79a4843a0a7b21843f1f9b66a@bounce.vates.tech>)
 id 69de29c7-5cb7-0a2a0a5109dd-0a2a450aec48-12
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:49:29 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de289c.v1-12fcd6f79a4843a0a7b21843f1f9b66a@bounce.vates.tech>)
 id 69de29c7-ee98-0a2a450a0019-c602bb017278-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 13:49:28 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fw2W06kFlzBsVd00
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 11:44:28 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 12fcd6f79a4843a0a7b21843f1f9b66a; Tue, 14 Apr 2026 11:44:28 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776167068; x=1776437068;
	bh=97smoQgV16Wo+fn4DrS5BzSxez8URAlfR90zucm0ve4=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=VF1LYP98ob+asnq4EeYpUCGrRnKqof18yfzkBYUnaCB9nlf28Jm/AfoQ07OWpLBl5
	 XzZr+OsNDPaCRQYeQT4IJ7ZN2qV3uG7Zy1SD82YtTz+Zqw3qUoCTNwxrTO53iDGdzL
	 yqjDUziAWD7qtqqO4UnJjD8G1MCpOulY8Qa8hokY2D3+UuZZspbE1LAKSB4fb1w7Lx
	 mAziIMxR+nX+jwzoMpNY++c5oWTiKRC7syPVK/+suMXHCkDv7HDvdnPEDeFmT7p5Lw
	 /j/rZ5jOnF1yPWeoTrPISO67MqHfts7o2bmlowA6m5dFisf2m2hlZwf0LEA8G3qcBJ
	 SGgnWarhuMyLw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776167068; x=1776427568; i=ngoc-tu.dinh@vates.tech;
	bh=97smoQgV16Wo+fn4DrS5BzSxez8URAlfR90zucm0ve4=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=cDGzdz6xjJ6Nm90gVDSZxyUupCcldtwmrQpXCnfXJIGRgXnOk7zkbpY9mz6nQ+DCl
	 3kyxWnyp+2K6WJj3BCM5DgFZwm6zlqm9oc4dHgSZK+MULrYNwNFIu5bwwpo4wiAPH8
	 HOKlFwpb+s4DXoBt7ktN5KImJqqKbbBsXpTA9cVFV8rGKGEduwdFN/tHPY0ouJJefe
	 I05KdLWAdDndBTN99DykUgahtuR7tR1h8ik3+DXWAjf7UhQF/VjQw7REAd37xAUMUQ
	 nOFsLvAsJyf1jvBOvPrl/Lvl7mrw/KjItee2q9T3dx+3DaIQOmyEl05y4jJiJmQR9X
	 FiJ9J0vAFu+wA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=205/6]=20Use=20CHAR=20for=20pipe=20stream=20data?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776167068291
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414114416.1336-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.12fcd6f79a4843a0a7b21843f1f9b66a?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 11:44:28 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-4011c0/1776167369-0DF530B1-299604A4/0/0
X-purgate-type: clean
X-purgate-size: 9924

As the console pipe is a byte stream, it should not use UCHAR or TCHAR.

Also convert the relevant API calls that use stream data to their A
variant.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c |  8 ++--
 src/tty/tty.c         | 98 +++++++++++++++++++++----------------------
 2 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 3ff7d7c..cd58207 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -326,7 +326,7 @@ __RemoveEntryList(
 static VOID
 PutString(
     _In_ HANDLE     Handle,
-    _In_ PUCHAR     Buffer,
+    _In_ PCHAR      Buffer,
     _In_ DWORD      Length
     )
 {
@@ -350,7 +350,7 @@ PutString(
 }
 
 #define ECHO(_Handle, _Buffer) \
-    PutString((_Handle), (PUCHAR)_Buffer, (DWORD)strlen((_Buffer)) * sizeof(CHAR))
+    PutString((_Handle), _Buffer, (DWORD)strlen((_Buffer)))
 
 DWORD WINAPI
 ConnectionThread(
@@ -359,7 +359,7 @@ ConnectionThread(
 {
     PMONITOR_CONNECTION Connection = (PMONITOR_CONNECTION)Argument;
     PMONITOR_CONSOLE    Console = Connection->Console;
-    UCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
+    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
     OVERLAPPED          Overlapped;
     HANDLE              Handle[2];
     DWORD               Length;
@@ -583,7 +583,7 @@ DeviceThread(
     PMONITOR_CONSOLE    Console = (PMONITOR_CONSOLE)Argument;
     OVERLAPPED          Overlapped;
     HANDLE              Device;
-    UCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
+    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
     DWORD               Length;
     DWORD               Wait;
     HANDLE              Handles[2];
diff --git a/src/tty/tty.c b/src/tty/tty.c
index d58bf96..a04c2ea 100644
--- a/src/tty/tty.c
+++ b/src/tty/tty.c
@@ -53,7 +53,7 @@ typedef struct _TTY_CONTEXT {
     TTY_STREAM          ChildStdIn;
     TTY_STREAM          ChildStdOut;
     TTY_STREAM          Device;
-    TCHAR               UserName[MAXIMUM_BUFFER_SIZE];
+    CHAR                UserName[MAXIMUM_BUFFER_SIZE];
     HANDLE              Token;
     HANDLE              OriginalToken;
     PROCESS_INFORMATION ProcessInfo;
@@ -141,12 +141,12 @@ CreateChild(
     )
 {
     PTTY_CONTEXT            Context = &TtyContext;
-    TCHAR                   CommandLine[] = TEXT("c:\\windows\\system32\\cmd.exe /q /a");
+    CHAR                    CommandLine[] = "c:\\windows\\system32\\cmd.exe /q /a";
     PVOID                   Environment;
-    PROFILEINFO             ProfileInfo;
+    PROFILEINFOA            ProfileInfo;
     DWORD                   Size;
-    TCHAR                   ProfileDir[MAXIMUM_BUFFER_SIZE];
-    STARTUPINFO             StartupInfo;
+    CHAR                    ProfileDir[MAXIMUM_BUFFER_SIZE];
+    STARTUPINFOA            StartupInfo;
     BOOL                    Success;
 
     Success = CreateEnvironmentBlock(&Environment,
@@ -159,15 +159,15 @@ CreateChild(
     ProfileInfo.dwSize = sizeof (ProfileInfo);
     ProfileInfo.lpUserName = Context->UserName;
 
-    Success = LoadUserProfile(Context->Token, &ProfileInfo);
+    Success = LoadUserProfileA(Context->Token, &ProfileInfo);
     if (!Success)
         return FALSE;
 
     Size = sizeof (ProfileDir);
 
-    Success = GetUserProfileDirectory(Context->Token,
-                                      ProfileDir,
-                                      &Size);
+    Success = GetUserProfileDirectoryA(Context->Token,
+                                       ProfileDir,
+                                       &Size);
     if (!Success)
         return FALSE;
 
@@ -185,17 +185,17 @@ CreateChild(
     StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
 
 #pragma warning(suppress:6335) // leaking handle information
-    Success = CreateProcessAsUser(Context->Token,
-                                  NULL,
-                                  CommandLine,
-                                  NULL,
-                                  NULL,
-                                  TRUE,
-                                  CREATE_UNICODE_ENVIRONMENT,
-                                  Environment,
-                                  ProfileDir,
-                                  &StartupInfo,
-                                  &Context->ProcessInfo);
+    Success = CreateProcessAsUserA(Context->Token,
+                                   NULL,
+                                   CommandLine,
+                                   NULL,
+                                   NULL,
+                                   TRUE,
+                                   CREATE_UNICODE_ENVIRONMENT,
+                                   Environment,
+                                   ProfileDir,
+                                   &StartupInfo,
+                                   &Context->ProcessInfo);
 
     DestroyEnvironmentBlock(Environment);
 
@@ -210,7 +210,7 @@ CreateChild(
 static VOID
 PutCharacter(
     _In_ PTTY_STREAM    Stream,
-    _In_ TCHAR          Character
+    _In_ CHAR           Character
     )
 {
     WriteFile(Stream->Write,
@@ -223,11 +223,11 @@ PutCharacter(
 static VOID
 PutString(
     _In_ PTTY_STREAM    Stream,
-    _In_ PTCHAR         Buffer,
+    _In_ PCHAR          Buffer,
     _In_ DWORD          Length
     )
 {
-    DWORD               Offset;
+    DWORD           Offset;
 
     Offset = 0;
     while (Offset < Length) {
@@ -247,12 +247,12 @@ PutString(
 }
 
 #define ECHO(_Stream, _Buffer) \
-    PutString((_Stream), TEXT(_Buffer), (DWORD)_tcslen(_Buffer))
+    PutString((_Stream), (_Buffer), (DWORD)strlen(_Buffer))
 
 static BOOL
 GetLine(
     _In_ PTTY_STREAM    Stream,
-    _In_ PTCHAR         Buffer,
+    _In_ PCHAR          Buffer,
     _In_ DWORD          NumberOfBytesToRead,
     _Out_ LPDWORD       NumberOfBytesRead,
     _In_ BOOL           NoEcho
@@ -263,8 +263,8 @@ GetLine(
 
     Offset = 0;
     while (Offset < NumberOfBytesToRead) {
-        TCHAR   Sequence[MAXIMUM_BUFFER_SIZE];
-        PTCHAR  Character;
+        CHAR    Sequence[MAXIMUM_BUFFER_SIZE];
+        PCHAR   Character;
         DWORD   Read;
 
         Success = ReadFile(Stream->Read,
@@ -326,20 +326,20 @@ GetLine(
 
 static BOOL
 GetCredentials(
-    _In_ PTCHAR     Password,
-    _In_ DWORD      PasswordSize
+    _Out_writes_z_(PasswordSize) PCHAR  Password,
+    _In_ DWORD                          PasswordSize
     )
 {
     PTTY_CONTEXT    Context = &TtyContext;
-    TCHAR           ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
-    PTCHAR          End;
+    CHAR            ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+    PCHAR           End;
     DWORD           Size;
     BOOL            Success;
 
     ZeroMemory(ComputerName, sizeof (ComputerName));
     Size = sizeof (ComputerName);
 
-    Success = GetComputerName(ComputerName, &Size);
+    Success = GetComputerNameA(ComputerName, &Size);
     if (!Success)
         return FALSE;
 
@@ -357,13 +357,13 @@ GetCredentials(
     if (!Success)
         return FALSE;
 
-    End = _tcschr(Context->UserName, TEXT('\r'));
+    End = strchr(Context->UserName, '\r');
     if (End == NULL)
         return FALSE;
 
-    *End = TEXT('\0');
+    *End = '\0';
 
-    if (_tcslen(Context->UserName) == 0)
+    if (strlen(Context->UserName) == 0)
         return FALSE;
 
     ECHO(&Context->Device, "Password: ");
@@ -378,7 +378,7 @@ GetCredentials(
     if (!Success)
         return FALSE;
 
-    End = _tcschr(Password, TEXT('\r'));
+    End = strchr(Password, TEXT('\r'));
     if (End == NULL)
         return FALSE;
 
@@ -395,8 +395,8 @@ RequestElevation(
     PTTY_CONTEXT            Context = &TtyContext;
     TOKEN_ELEVATION_TYPE    Elevation;
     DWORD                   Size;
-    TCHAR                   Buffer[MAXIMUM_BUFFER_SIZE];
-    PTCHAR                  End;
+    CHAR                    Buffer[MAXIMUM_BUFFER_SIZE];
+    PCHAR                   End;
     TOKEN_LINKED_TOKEN      LinkedToken;
     BOOL                    Success;
 
@@ -424,18 +424,18 @@ RequestElevation(
     if (!Success)
         return FALSE;
 
-    End = _tcschr(Buffer, TEXT('\r'));
+    End = strchr(Buffer, '\r');
     if (End == NULL)
         return FALSE;
 
-    *End = TEXT('\0');
+    *End = '\0';
 
-    if (_tcslen(Buffer) == 0)
+    if (strlen(Buffer) == 0)
         return FALSE;
 
     ECHO(&Context->Device, "\r\n");
 
-    if (_tcscmp(Buffer, TEXT("yes")) != 0)
+    if (strcmp(Buffer, "yes") != 0)
         return TRUE;
 
     Success = GetTokenInformation(Context->Token,
@@ -553,7 +553,7 @@ _tmain(
     PTTY_CONTEXT        Context = &TtyContext;
     SECURITY_ATTRIBUTES Attributes;
     HANDLE              Handle[3];
-    TCHAR               Password[MAXIMUM_BUFFER_SIZE];
+    CHAR                Password[MAXIMUM_BUFFER_SIZE];
     DWORD               Index;
     BOOL                Success;
 
@@ -594,12 +594,12 @@ _tmain(
     if (!Success)
         ExitProcess(1);
 
-    Success = LogonUser(Context->UserName,
-                        NULL,
-                        Password,
-                        LOGON32_LOGON_INTERACTIVE,
-                        LOGON32_PROVIDER_DEFAULT,
-                        &Context->Token);
+    Success = LogonUserA(Context->UserName,
+                         NULL,
+                         Password,
+                         LOGON32_LOGON_INTERACTIVE,
+                         LOGON32_PROVIDER_DEFAULT,
+                         &Context->Token);
 
     ZeroMemory(Password, sizeof(Password));
 
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:09:59 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:09:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281709.1564572 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcac-0006Ah-Tu; Tue, 14 Apr 2026 12:09:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281709.1564572; Tue, 14 Apr 2026 12:09:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcac-0006Aa-R8; Tue, 14 Apr 2026 12:09:58 +0000
Received: by outflank-mailman (input) for mailman id 1281709;
 Tue, 14 Apr 2026 12:09:57 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de2c54.v1-618ae58d29124aa2bb15b6d655512ca4@bounce.vates.tech>)
 id 1wCcaa-0006AS-Nn
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:09:57 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcaZ-009Lc2-Vg
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:09:56 +0200
Received: from [10.42.69.4] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de2c54.v1-618ae58d29124aa2bb15b6d655512ca4@bounce.vates.tech>)
 id 69de2e91-bab6-0a2a0a5309dd-0a2a4504dcf6-16
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:09:55 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de2c54.v1-618ae58d29124aa2bb15b6d655512ca4@bounce.vates.tech>)
 id 69de2e92-bb33-0a2a45040019-c602bb01d22a-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:09:55 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fw2sJ5fWVzBsXbNK
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:00:20 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 618ae58d29124aa2bb15b6d655512ca4; Tue, 14 Apr 2026 12:00:20 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776168020; x=1776438020;
	bh=QsRt5qVxSvYlYkP5F9bIhrcrQOyOkoSAdoF1tbjsD2o=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=QuELIOnXpYoH0llvySeY39vzehjAlE5vNrYa72UDOg55wGrM/4jxp0eaVPxJi5/vQ
	 T2unhZs5EAPjYadOr4A2emwpya0+CCWmOXTk03EfWPs+Lqw52hLmfRca6SZp/C9fwb
	 FcTI59uIIpauG9d7JI/hL0Dj//2nK2MlYwFlIgFGgfgHoG4fCavnYpG+N/9JmYVDSF
	 rGgj2HPSgZkQohjGkq8pUTHRGexgxf5HDRMa+c7DNIM7xJcFBTEtrk8xrUT/DSEeoH
	 d7Ovzigdm0pJKdU/4KICVoQgyjKkk58GiUrgGvj6LpdrIQEwnQ1Bf9AhPyOEleDFix
	 qSFVSNgRkSHOg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776168020; x=1776428520; i=ngoc-tu.dinh@vates.tech;
	bh=QsRt5qVxSvYlYkP5F9bIhrcrQOyOkoSAdoF1tbjsD2o=;
	h=From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=UfRjzNX2KiQu5gxK+3a0jqOEE1bw5hEow48KXCuFVfVSHlELQ6DN1cMVb7DpKXuAy
	 vpIaJB7aasLpCUmWRO1Ax9eV1Eb47LwlPQzVI69b2jAiPrfPMYj9Fcu6V5OjAWkbqj
	 OXC/ZzAZOR7ai2nsUC21bDbrpOcD+blGXGqOrMHrMphs6t8piC37IM3zRIVYcrEiu9
	 KAsytATFk/FoLUABl451sbnD28sr8jTTvLG/WLhLNUM7eO9hFX5WalWoY2pQg5J524
	 MB1ADVxyWIhGHTN5YsGYxwVJoYEbT6a8/QexhwKJ3L6+ishVTwSVLxU+cX7dBlNlqg
	 T5Kcsqkl1vOFw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=202/6]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776168016390
Message-Id: <19310232-4a06-46e4-ab0b-9a4fbc144908@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@citrix.com>, "david ambu" <david.preetham@cloud.com>
References: <20260414114416.1336-1-ngoc-tu.dinh@vates.tech> <20260414114416.1336-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114416.1336-3-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.618ae58d29124aa2bb15b6d655512ca4?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:00:20 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-ebf023/1776168595-32B3851B-4CB93590/0/0
X-purgate-type: clean
X-purgate-size: 29306

On 14/04/2026 13:44, Tu Dinh wrote:
> - Added TraceLogging levels for Information and Error events.
> - Replaced RegisterEventSource due to potential security issues.
>    This issue was raised by CodeQL 2.20.1,
>    "RegisterEventSourceA has been marked deprecated as it is a legacy
>     tracing API. Please migrate to modern Event Tracing for Windows APIs."
> see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage
> 
>    Event Tracing logging needs to be captured using an ETW trace logger
> 
> Signed-off-by: david ambu <david.preetham@cloud.com>
> 
> * defined seperate macros for Info and Error logging
> * use a switch on log level, rather than if/else
> * Change __Log call to take a PCTSTR, and wrap format string with _T() in macros
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> 
> Ported from Xenbus.
> 
> * Convert both xencons_monitor and xencons_tty.
> * Removal of xencons_monitor.dll is done separately.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>

Never mind this patch, I didn't realize Log() in xencons_tty uses 
OutputDebugString. I'll resend soon.

> ---
>   src/monitor/monitor.c | 274 ++++++++++++++++++++++--------------------
>   src/tty/tty.c         |  74 +++++++++---
>   2 files changed, 199 insertions(+), 149 deletions(-)
> 
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index b5e042a..381898f 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -43,6 +43,8 @@
>   #include <sddl.h>
>   #include <malloc.h>
>   #include <assert.h>
> +#include <TraceLoggingProvider.h>
> +#include <winmeta.h>
>   
>   #include <xencons_device.h>
>   #include <version.h>
> @@ -59,7 +61,6 @@
>   typedef struct _MONITOR_CONTEXT {
>       SERVICE_STATUS          Status;
>       SERVICE_STATUS_HANDLE   Service;
> -    HANDLE                  EventLog;
>       HANDLE                  StopEvent;
>       HKEY                    ParametersKey;
>       HDEVNOTIFY              InterfaceNotification;
> @@ -108,30 +109,43 @@ static MONITOR_CONTEXT MonitorContext;
>   #define PARAMETERS_KEY(_Service) \
>           SERVICE_KEY(_Service) ## "\\Parameters"
>   
> +TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
> +                             MONITOR_NAME,
> +                             // {F1D4F89A-D4FC-5C76-865B-27532946CA0A}
> +                             (0xF1D4F89A, 0xD4FC, 0x5C76, 0x86, 0x5B, 0x27, 0x53, 0x29, 0x46, 0xCA, 0x0A));
> +
> +typedef enum {
> +    LOG_INFO,
> +    LOG_ERROR
> +} LOG_LEVEL;
> +
> +#ifdef UNICODE
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
> +#else
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
> +#endif
> +
>   static VOID
>   #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
>   __Log(
> -    _In_ PCSTR          Format,
> +    _In_ LOG_LEVEL      Level,
> +    _In_ PCTSTR         Format,
>       ...
>       )
>   {
> -#if DBG
> -    PMONITOR_CONTEXT    Context = &MonitorContext;
> -    const CHAR          *Strings[1];
> -#endif
> -    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
> +    TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
>       va_list             Arguments;
>       size_t              Length;
>       HRESULT             Result;
>   
>       va_start(Arguments, Format);
> -    Result = StringCchVPrintfA(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
> +    Result = StringCchVPrintf(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
>       va_end(Arguments);
>   
>       if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
>           return;
>   
> -    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
> +    Result = StringCchLength(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
>       if (Result != S_OK)
>           return;
>   
> @@ -139,30 +153,35 @@ __Log(
>   
>       _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
>       _Analysis_assume_(Length >= 2);
> -    Buffer[Length] = '\0';
> -    Buffer[Length - 1] = '\n';
> -    Buffer[Length - 2] = '\r';
> +    Buffer[Length] = _T('\0');
> +    Buffer[Length - 1] = _T('\n');
> +    Buffer[Length - 2] = _T('\r');
>   
>       OutputDebugString(Buffer);
>   
> -#if DBG
> -    Strings[0] = Buffer;
> -
> -    if (Context->EventLog != NULL)
> -        ReportEventA(Context->EventLog,
> -                     EVENTLOG_INFORMATION_TYPE,
> -                     0,
> -                     MONITOR_LOG,
> -                     NULL,
> -                     ARRAYSIZE(Strings),
> -                     0,
> -                     Strings,
> -                     NULL);
> -#endif
> +    switch (Level) {
> +    case LOG_INFO:
> +        TraceLoggingWrite(MonitorTraceLoggingProvider,
> +                          "Information",
> +                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
> +                          TraceLoggingStringT(Buffer, "Info"));
> +        break;
> +    case LOG_ERROR:
> +        TraceLoggingWrite(MonitorTraceLoggingProvider,
> +                          "Error",
> +                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
> +                          TraceLoggingStringT(Buffer, "Error"));
> +        break;
> +    default:
> +        break;
> +    }
>   }
>   
> -#define Log(_Format, ...) \
> -    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +#define LogInfo(_Format, ...) \
> +        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
> +
> +#define LogError(_Format, ...) \
> +        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
>   
>   static PSTR
>   GetErrorMessage(
> @@ -228,7 +247,7 @@ ReportStatus(
>       BOOL                Success;
>       HRESULT             Error;
>   
> -    Log("====> (%s)", ServiceStateName(CurrentState));
> +    LogInfo("====> (%s)", ServiceStateName(CurrentState));
>   
>       Context->Status.dwCurrentState = CurrentState;
>       Context->Status.dwWin32ExitCode = Win32ExitCode;
> @@ -252,7 +271,7 @@ ReportStatus(
>       if (!Success)
>           goto fail1;
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return;
>   
> @@ -262,7 +281,7 @@ fail1:
>       {
>           PSTR    Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   }
> @@ -348,7 +367,7 @@ ConnectionThread(
>       DWORD               Object;
>       HRESULT             Error;
>   
> -    Log("====> %s", Console->DeviceName);
> +    LogInfo("====> %s", Console->DeviceName);
>   
>       ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
>       Overlapped.hEvent = CreateEvent(NULL,
> @@ -406,7 +425,7 @@ ConnectionThread(
>       CloseHandle(Connection->Thread);
>       free(Connection);
>   
> -    Log("<==== %s", Console->DeviceName);
> +    LogInfo("<==== %s", Console->DeviceName);
>   
>       return 0;
>   
> @@ -416,7 +435,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -438,7 +457,7 @@ ServerThread(
>       HRESULT             Error;
>       SECURITY_ATTRIBUTES SecurityAttributes;
>   
> -    Log("====> %s", Console->DeviceName);
> +    LogInfo("====> %s", Console->DeviceName);
>   
>       ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
>       Overlapped.hEvent = CreateEvent(NULL,
> @@ -459,7 +478,7 @@ ServerThread(
>       if (Error != S_OK && Error != STRSAFE_E_INSUFFICIENT_BUFFER)
>           goto fail2;
>   
> -    Log("%s", PipeName);
> +    LogInfo("%s", PipeName);
>   
>       ZeroMemory(&SecurityAttributes, sizeof(SECURITY_ATTRIBUTES));
>       SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
> @@ -517,30 +536,30 @@ ServerThread(
>   
>       CloseHandle(Overlapped.hEvent);
>   
> -    Log("<==== %s", Console->DeviceName);
> +    LogInfo("<==== %s", Console->DeviceName);
>   
>       return 0;
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
>       free(Connection);
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>       CloseHandle(Pipe);
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>       LocalFree(&SecurityAttributes.lpSecurityDescriptor);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       CloseHandle(Overlapped.hEvent);
>   
> @@ -550,7 +569,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -571,7 +590,7 @@ DeviceThread(
>       HANDLE              Handles[2];
>       DWORD               Error;
>   
> -    Log("====> %s", Console->DeviceName);
> +    LogInfo("====> %s", Console->DeviceName);
>   
>       ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
>       Overlapped.hEvent = CreateEvent(NULL,
> @@ -641,12 +660,12 @@ DeviceThread(
>   
>       CloseHandle(Overlapped.hEvent);
>   
> -    Log("<==== %s", Console->DeviceName);
> +    LogInfo("<==== %s", Console->DeviceName);
>   
>       return 0;
>   
>   fail2:
> -    Log("fail2\n");
> +    LogError("fail2\n");
>   
>       CloseHandle(Overlapped.hEvent);
>   
> @@ -656,7 +675,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -726,25 +745,25 @@ GetExecutable(
>           goto fail5;
>       }
>   
> -    Log("%s = %s", DeviceName, *Executable);
> +    LogInfo("%s = %s", DeviceName, *Executable);
>   
>       RegCloseKey(Key);
>   
>       return TRUE;
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>       free(*Executable);
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(Key);
>   
> @@ -754,7 +773,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -775,7 +794,7 @@ ExecutableThread(
>       DWORD               Object;
>       HRESULT             Error;
>   
> -    Log("====> %s", Console->DeviceName);
> +    LogInfo("====> %s", Console->DeviceName);
>   
>       // If there is no executable, this thread can finish now.
>       if (!GetExecutable(Console->DeviceName,
> @@ -789,7 +808,7 @@ again:
>       ZeroMemory(&StartupInfo, sizeof (StartupInfo));
>       StartupInfo.cb = sizeof (StartupInfo);
>   
> -    Log("Executing: %s", Executable);
> +    LogInfo("Executing: %s", Executable);
>   
>   #pragma warning(suppress:6053) // CommandLine might not be NUL-terminated
>       Success = CreateProcess(NULL,
> @@ -839,7 +858,7 @@ again:
>       free(Executable);
>   
>   done:
> -    Log("<==== %s", Console->DeviceName);
> +    LogInfo("<==== %s", Console->DeviceName);
>   
>       return 0;
>   
> @@ -851,7 +870,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -871,7 +890,7 @@ ConsoleCreate(
>       BOOL                    Success;
>       HRESULT                 Error;
>   
> -    Log("====> %ws", DevicePath);
> +    LogInfo("====> %ws", DevicePath);
>   
>       Console = malloc(sizeof(MONITOR_CONSOLE));
>       if (Console == NULL)
> @@ -975,48 +994,48 @@ ConsoleCreate(
>       if (Console->ExecutableThread == NULL)
>           goto fail12;
>   
> -    Log("<==== %s", Console->DeviceName);
> +    LogInfo("<==== %s", Console->DeviceName);
>   
>       return Console;
>   
>   fail12:
> -    Log("fail12");
> +    LogError("fail12");
>   
>       CloseHandle(Console->ExecutableEvent);
>       Console->ExecutableEvent = NULL;
>   
>   fail11:
> -    Log("fail11");
> +    LogError("fail11");
>   
>       SetEvent(Console->ServerEvent);
>       WaitForSingleObject(Console->ServerThread, INFINITE);
>   
>   fail10:
> -    Log("fail10");
> +    LogError("fail10");
>   
>       CloseHandle(Console->ServerEvent);
>       Console->ServerEvent = NULL;
>   
>   fail9:
> -    Log("fail9");
> +    LogError("fail9");
>   
>       SetEvent(Console->DeviceEvent);
>       WaitForSingleObject(Console->DeviceThread, INFINITE);
>   
>   fail8:
> -    Log("fail8");
> +    LogError("fail8");
>   
>       CloseHandle(Console->DeviceEvent);
>       Console->DeviceEvent = NULL;
>   
>   fail7:
> -    Log("fail7");
> +    LogError("fail7");
>   
>       UnregisterDeviceNotification(Console->DeviceNotification);
>       Console->DeviceNotification = NULL;
>   
>   fail6:
> -    Log("fail6");
> +    LogError("fail6");
>   
>       ECHO(Console->DeviceHandle, "\r\n[DETACHED]\r\n");
>   
> @@ -1024,22 +1043,22 @@ fail6:
>       Console->DevicePath = NULL;
>   
>   fail5:
> -    Log("fail5");
> +    LogError("fail5");
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>       CloseHandle(Console->DeviceHandle);
>       Console->DeviceHandle = INVALID_HANDLE_VALUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       free(Console->DevicePath);
>       Console->DevicePath = NULL;
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       DeleteCriticalSection(&Console->CriticalSection);
>       ZeroMemory(&Console->ListHead, sizeof(LIST_ENTRY));
> @@ -1053,7 +1072,7 @@ fail1:
>       {
>           PSTR    Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1113,7 +1132,7 @@ ConsoleDestroy(
>       _In_ PMONITOR_CONSOLE   Console
>       )
>   {
> -    Log("====> %s", Console->DeviceName);
> +    LogInfo("====> %s", Console->DeviceName);
>   
>       SetEvent(Console->ExecutableEvent);
>       WaitForSingleObject(Console->ExecutableThread, INFINITE);
> @@ -1152,7 +1171,7 @@ ConsoleDestroy(
>   
>       free(Console);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   }
>   
>   static BOOL
> @@ -1163,7 +1182,7 @@ MonitorAdd(
>       PMONITOR_CONTEXT    Context = &MonitorContext;
>       PMONITOR_CONSOLE    Console;
>   
> -    Log("=====> %ws", DevicePath);
> +    LogInfo("=====> %ws", DevicePath);
>   
>       Console = ConsoleCreate(DevicePath);
>       if (Console == NULL)
> @@ -1174,12 +1193,12 @@ MonitorAdd(
>       ++Context->ListCount;
>       LeaveCriticalSection(&Context->CriticalSection);
>   
> -    Log("<===== %s", Console->DeviceName);
> +    LogInfo("<===== %s", Console->DeviceName);
>   
>       return TRUE;
>   
>   fail1:
> -    Log("fail1");
> +    LogError("fail1");
>   
>       return FALSE;
>   }
> @@ -1193,7 +1212,7 @@ MonitorRemove(
>       PMONITOR_CONSOLE    Console;
>       PLIST_ENTRY         ListEntry;
>   
> -    Log("=====> 0x%p", DeviceHandle);
> +    LogInfo("=====> 0x%p", DeviceHandle);
>   
>       EnterCriticalSection(&Context->CriticalSection);
>       for (ListEntry = Context->ListHead.Flink;
> @@ -1208,7 +1227,7 @@ MonitorRemove(
>       }
>       LeaveCriticalSection(&Context->CriticalSection);
>   
> -    Log("DeviceHandle 0x%p not found", DeviceHandle);
> +    LogError("DeviceHandle 0x%p not found", DeviceHandle);
>   
>       return FALSE;
>   
> @@ -1219,7 +1238,7 @@ found:
>   
>       ConsoleDestroy(Console);
>   
> -    Log("<=====");
> +    LogInfo("<=====");
>   
>       return TRUE;
>   }
> @@ -1239,7 +1258,7 @@ MonitorEnumerate(
>       HRESULT                             Error;
>       BOOL                                Success;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       DeviceInfoSet = SetupDiGetClassDevs(&GUID_XENCONS_DEVICE,
>                                           NULL,
> @@ -1299,28 +1318,28 @@ MonitorEnumerate(
>           continue;
>   
>       fail5:
> -        Log("fail5");
> +        LogError("fail5");
>       fail4:
> -        Log("fail4");
> +        LogError("fail4");
>   
>           free(DeviceInterfaceDetail);
>   
>       fail3:
> -        Log("fail3");
> +        LogError("fail3");
>       fail2:
>           Error = GetLastError();
>   
>           {
>               PSTR    Message;
>               Message = GetErrorMessage(Error);
> -            Log("fail2 (%s)", Message);
> +            LogError("fail2 (%s)", Message);
>               LocalFree(Message);
>           }
>       }
>   
>       SetupDiDestroyDeviceInfoList(DeviceInfoSet);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
> @@ -1330,7 +1349,7 @@ fail1:
>       {
>           PSTR    Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1345,7 +1364,7 @@ MonitorRemoveAll(
>       PMONITOR_CONTEXT    Context = &MonitorContext;
>       PMONITOR_CONSOLE    Console;
>   
> -    Log("=====>");
> +    LogInfo("=====>");
>   
>       for (;;) {
>           EnterCriticalSection(&Context->CriticalSection);
> @@ -1365,7 +1384,7 @@ MonitorRemoveAll(
>       }
>       LeaveCriticalSection(&Context->CriticalSection);
>   
> -    Log("<=====");
> +    LogInfo("<=====");
>   }
>   
>   DWORD WINAPI
> @@ -1439,7 +1458,10 @@ MonitorMain(
>       UNREFERENCED_PARAMETER(argc);
>       UNREFERENCED_PARAMETER(argv);
>   
> -    Log("====>");
> +    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
> +        LogInfo("TraceLoggingRegister failed");
> +
> +    LogInfo("====>");
>   
>       Error = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
>                            PARAMETERS_KEY(__MODULE__),
> @@ -1455,11 +1477,6 @@ MonitorMain(
>       if (Context->Service == NULL)
>           goto fail2;
>   
> -    Context->EventLog = RegisterEventSourceA(NULL,
> -                                            MONITOR_NAME);
> -    if (Context->EventLog == NULL)
> -        goto fail3;
> -
>       Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
>       Context->Status.dwServiceSpecificExitCode = 0;
>   
> @@ -1471,7 +1488,7 @@ MonitorMain(
>                                        NULL);
>   
>       if (Context->StopEvent == NULL)
> -        goto fail4;
> +        goto fail3;
>   
>       ZeroMemory(&Interface, sizeof (Interface));
>       Interface.dbcc_size = sizeof (Interface);
> @@ -1483,7 +1500,7 @@ MonitorMain(
>                                      &Interface,
>                                      DEVICE_NOTIFY_SERVICE_HANDLE);
>       if (Context->InterfaceNotification == NULL)
> -        goto fail5;
> +        goto fail4;
>   
>       ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);
>   
> @@ -1492,9 +1509,9 @@ MonitorMain(
>   
>       MonitorEnumerate();
>   
> -    Log("Waiting...");
> +    LogInfo("Waiting...");
>       WaitForSingleObject(Context->StopEvent, INFINITE);
> -    Log("Wait Complete");
> +    LogInfo("Wait Complete");
>   
>       MonitorRemoveAll();
>   
> @@ -1507,31 +1524,26 @@ MonitorMain(
>   
>       ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);
>   
> -    (VOID) DeregisterEventSource(Context->EventLog);
> -
>       RegCloseKey(Context->ParametersKey);
>   
> -    Log("<====");
> +    LogInfo("<====");
> +
> +    TraceLoggingUnregister(MonitorTraceLoggingProvider);
>   
>       return;
>   
> -fail5:
> -    Log("fail5");
> +fail4:
> +    LogError("fail4");
>   
>       CloseHandle(Context->StopEvent);
>   
> -fail4:
> -    Log("fail4");
> +fail3:
> +    LogError("fail3");
>   
>       ReportStatus(SERVICE_STOPPED, GetLastError(), 0);
>   
> -    (VOID) DeregisterEventSource(Context->EventLog);
> -
> -fail3:
> -    Log("fail3");
> -
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       RegCloseKey(Context->ParametersKey);
>   
> @@ -1541,9 +1553,11 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
> +
> +    TraceLoggingUnregister(MonitorTraceLoggingProvider);
>   }
>   
>   static BOOL
> @@ -1556,7 +1570,7 @@ MonitorCreate(
>       CHAR        Path[MAX_PATH];
>       HRESULT     Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       if(!GetModuleFileNameA(NULL, Path, MAX_PATH))
>           goto fail1;
> @@ -1588,17 +1602,17 @@ MonitorCreate(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(SCManager);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>   fail1:
>       Error = GetLastError();
> @@ -1606,7 +1620,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1624,7 +1638,7 @@ MonitorDelete(
>       SERVICE_STATUS      Status;
>       HRESULT             Error;
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       SCManager = OpenSCManager(NULL,
>                                 NULL,
> @@ -1655,20 +1669,20 @@ MonitorDelete(
>       CloseServiceHandle(Service);
>       CloseServiceHandle(SCManager);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return TRUE;
>   
>   fail4:
> -    Log("fail4");
> +    LogError("fail4");
>   
>   fail3:
> -    Log("fail3");
> +    LogError("fail3");
>   
>       CloseServiceHandle(Service);
>   
>   fail2:
> -    Log("fail2");
> +    LogError("fail2");
>   
>       CloseServiceHandle(SCManager);
>   
> @@ -1678,7 +1692,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> @@ -1696,16 +1710,16 @@ MonitorEntry(
>       };
>       HRESULT             Error;
>   
> -    Log("%s (%s) ====>",
> -        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -        DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +    LogInfo("%s (%s) ====>",
> +            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> +            DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       if (!StartServiceCtrlDispatcher(Table))
>           goto fail1;
>   
> -    Log("%s (%s) <====",
> -        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> -        DAY_STR "/" MONTH_STR "/" YEAR_STR);
> +    LogInfo("%s (%s) <====",
> +            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
> +            DAY_STR "/" MONTH_STR "/" YEAR_STR);
>   
>       return TRUE;
>   
> @@ -1715,7 +1729,7 @@ fail1:
>       {
>           PTCHAR  Message;
>           Message = GetErrorMessage(Error);
> -        Log("fail1 (%s)", Message);
> +        LogError("fail1 (%s)", Message);
>           LocalFree(Message);
>       }
>   
> diff --git a/src/tty/tty.c b/src/tty/tty.c
> index 4bfd74d..d58bf96 100644
> --- a/src/tty/tty.c
> +++ b/src/tty/tty.c
> @@ -34,6 +34,8 @@
>   #include <tchar.h>
>   #include <strsafe.h>
>   #include <userenv.h>
> +#include <TraceLoggingProvider.h>
> +#include <winmeta.h>
>   
>   #define stringify_literal(_text) #_text
>   #define stringify(_text) stringify_literal(_text)
> @@ -59,29 +61,43 @@ typedef struct _TTY_CONTEXT {
>   
>   TTY_CONTEXT TtyContext;
>   
> +TRACELOGGING_DEFINE_PROVIDER(TtyTraceLoggingProvider,
> +                             __MODULE__,
> +                             // {B1C2BE46-E523-5BCF-548F-77C2F1B015C7}
> +                             (0xB1C2BE46, 0xE523, 0x5BCF, 0x54, 0x8F, 0x77, 0xC2, 0xF1, 0xB0, 0x15, 0xC7));
> +
> +typedef enum {
> +    LOG_INFO,
> +    LOG_ERROR
> +} LOG_LEVEL;
> +
> +#ifdef UNICODE
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
> +#else
> +#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
> +#endif
> +
>   static VOID
>   #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
>   __Log(
> -    _In_ PCSTR          Format,
> -    _In_ ...
> +    _In_ LOG_LEVEL      Level,
> +    _In_ PCTSTR         Format,
> +    ...
>       )
>   {
> -    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
> +    TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
>       va_list             Arguments;
>       size_t              Length;
>       HRESULT             Result;
>   
>       va_start(Arguments, Format);
> -    Result = StringCchVPrintfA(Buffer,
> -        MAXIMUM_BUFFER_SIZE,
> -        Format,
> -        Arguments);
> +    Result = StringCchVPrintf(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
>       va_end(Arguments);
>   
>       if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
>           return;
>   
> -    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
> +    Result = StringCchLength(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
>       if (Result != S_OK)
>           return;
>   
> @@ -89,15 +105,35 @@ __Log(
>   
>       _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
>       _Analysis_assume_(Length >= 2);
> -    Buffer[Length] = '\0';
> -    Buffer[Length - 1] = '\n';
> -    Buffer[Length - 2] = '\r';
> +    Buffer[Length] = _T('\0');
> +    Buffer[Length - 1] = _T('\n');
> +    Buffer[Length - 2] = _T('\r');
>   
>       OutputDebugString(Buffer);
> +
> +    switch (Level) {
> +    case LOG_INFO:
> +        TraceLoggingWrite(TtyTraceLoggingProvider,
> +                          "Information",
> +                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
> +                          TraceLoggingStringT(Buffer, "Info"));
> +        break;
> +    case LOG_ERROR:
> +        TraceLoggingWrite(TtyTraceLoggingProvider,
> +                          "Error",
> +                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
> +                          TraceLoggingStringT(Buffer, "Error"));
> +        break;
> +    default:
> +        break;
> +    }
>   }
>   
> -#define Log(_Format, ...) \
> -    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
> +#define LogInfo(_Format, ...) \
> +        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
> +
> +#define LogError(_Format, ...) \
> +        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
>   
>   static BOOL
>   CreateChild(
> @@ -427,7 +463,7 @@ TtyIn(
>   
>       UNREFERENCED_PARAMETER(Argument);
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       for (;;) {
>           DWORD       Read;
> @@ -461,7 +497,7 @@ TtyIn(
>           }
>       }
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return 0;
>   }
> @@ -475,7 +511,7 @@ TtyOut(
>   
>       UNREFERENCED_PARAMETER(Argument);
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       for (;;) {
>           DWORD       Read;
> @@ -503,7 +539,7 @@ TtyOut(
>               break;
>       }
>   
> -    Log("<====");
> +    LogInfo("<====");
>   
>       return 0;
>   }
> @@ -524,7 +560,7 @@ _tmain(
>       UNREFERENCED_PARAMETER(argc);
>       UNREFERENCED_PARAMETER(argv);
>   
> -    Log("====>");
> +    LogInfo("====>");
>   
>       if (!WaitNamedPipe(PIPE_NAME, NMPWAIT_USE_DEFAULT_WAIT))
>           ExitProcess(1);
> @@ -642,5 +678,5 @@ _tmain(
>   
>       CloseHandle(Context->ProcessInfo.hProcess);
>   
> -    Log("<====");
> +    LogInfo("<====");
>   }



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:17:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:17:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281711.1564576 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCchy-0007Rj-Gx; Tue, 14 Apr 2026 12:17:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281711.1564576; Tue, 14 Apr 2026 12:17:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCchy-0007Rc-Di; Tue, 14 Apr 2026 12:17:34 +0000
Received: by outflank-mailman (input) for mailman id 1281711;
 Tue, 14 Apr 2026 12:17:33 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305a.v1-2e9e0381847740129f771a226f59fb57@bounce.vates.tech>)
 id 1wCchw-0007RP-Vz
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:17:32 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCchw-008jPh-By
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:17:32 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305a.v1-2e9e0381847740129f771a226f59fb57@bounce.vates.tech>)
 id 69de305b-e002-0a2a0a5209dd-0a2a450cad7a-2
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:32 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de305a.v1-2e9e0381847740129f771a226f59fb57@bounce.vates.tech>)
 id 69de305b-f40c-0a2a450c0019-c602bb0ee74f-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:32 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw3F663SLz8XSCwX
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:30 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 2e9e0381847740129f771a226f59fb57; Tue, 14 Apr 2026 12:17:30 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169050; x=1776439050;
	bh=uLXUVji/PzJoLYgAEU3a2O70g8AgK+YCQgGi/OX0vCw=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=ppwURmN/2cFXGQZznAPQKezgEyyW2DpYMwkp8QtOpOOXjJ7jx8SquyhMAsd6onCfY
	 i0PRUlc0FMsdGTX7J3dpioLW4iSyYdPKWydIPbmTERGHwbX2RjMmKmDrBOHvIEa7O0
	 /y3r85bLW9qToUjNGKU4qdeEoerYm/zghFgtP3s6sP1rhuqL8jxdrhHwkMqZ1+5RHs
	 LVbez05R9W4TFiBgX3GbVLoWlh7oaFtBX9TiJnvEh997TuIIAXvSNZrikiKDTeWuOW
	 L5YpLGlVtTf6lvzFkAuFA4S3X7DI2ddP9Ft0KhM5I4deqPiRaElxp30hxQaneBf4KN
	 cDS4J5hrooS7g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169050; x=1776429550; i=ngoc-tu.dinh@vates.tech;
	bh=uLXUVji/PzJoLYgAEU3a2O70g8AgK+YCQgGi/OX0vCw=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=tP+I4/fmfMyQ158iQpPXVNZot4WM+IHBK4FI58xYnMpea5JhcL02KOiaoGeJ3u5vF
	 Xq4pgza1QGjZKFMUyEBf4L+09Cfj6KdEALnr0wkS6GOKgs8ag7iiR/cCKjD9SCsuVC
	 h+zSSFpcwJsMajzcFI+s80Nkmc1RGzCnZRYfqDMsYDEOAbcRcq805WmhArP+orTwCI
	 siu3FNXpwgc1s2bBEnrCSrIcN7VGuy6z4c1MOXPGr0lOwFzKNLn6adp0g2rmpczVRP
	 XPQo4fBw7NFHzxVZ/RTg6JL+EzR1r3Rc1f/nbcEYO2iRWYO4Bm8PLzQrfZDVAOkpBc
	 KtUqK56AT5rJA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=200/6]=20Port=20the=20TraceLoggingRegister=20series=20to=20XenCons?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169050186
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.2e9e0381847740129f771a226f59fb57?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:30 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-d25034/1776169052-A51BBA3D-CC4748CE/0/0
X-purgate-type: clean
X-purgate-size: 912

Tu Dinh (6):
  Use RegCloseKey for ParametersKey
  Replace RegisterEventSource with TraceLoggingRegister
  Fix inconsistent TCHAR handling
  Delete xencons_monitor.dll
  Use CHAR for pipe stream data
  Discover cmd.exe using GetSystemDirectory

 src/monitor/messages.mc                       |  55 --
 src/monitor/monitor.c                         | 539 ++++++++++--------
 src/monitor/xencons_monitor.rc                |   1 -
 src/tty/tty.c                                 | 127 +++--
 src/xencons.inf                               |  11 +-
 .../xencons_monitor/xencons_monitor.vcxproj   |  17 -
 .../xencons_monitor/xencons_monitor.vcxproj   |  12 -
 7 files changed, 354 insertions(+), 408 deletions(-)
 delete mode 100644 src/monitor/messages.mc

--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:17:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:17:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281712.1564580 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCchz-0007TJ-IK; Tue, 14 Apr 2026 12:17:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281712.1564580; Tue, 14 Apr 2026 12:17:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCchz-0007TB-Ev; Tue, 14 Apr 2026 12:17:35 +0000
Received: by outflank-mailman (input) for mailman id 1281712;
 Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305b.v1-39cebf9941664cf4a88f81168c65334f@bounce.vates.tech>)
 id 1wCchy-0007RV-6A
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCchx-00G5h0-If
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:17:33 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305b.v1-39cebf9941664cf4a88f81168c65334f@bounce.vates.tech>)
 id 69de305c-2eae-0a2a0a5409dd-0a2a4508aed8-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de305b.v1-39cebf9941664cf4a88f81168c65334f@bounce.vates.tech>)
 id 69de305c-fab6-0a2a45080019-c602ba01e149-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fw3F75Zb6zBsVB8w
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:31 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 39cebf9941664cf4a88f81168c65334f; Tue, 14 Apr 2026 12:17:31 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169051; x=1776439051;
	bh=od4200l4VbtlK43jWSdowV/7Geg4ScNjcSd/hFLO9W0=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=p7T2t54YrFa6g09Vi6PEX7zk99xvX5zP+bpOHEPZtl93qvc92FXWniKf4T4p9/YOf
	 JpGRLhgItkuX+puLFP5nm4QRmlM1mtDN6/FjKjk7U6KBMvKMLYeknW+CmWsJtpYE95
	 f621363iqmZ0EfqZdz4jFr/BAgR1l7HR7guf7DJS4UYSV7POkU8408MJhF32hCxkx7
	 Efn3cW+BJ4SCBJXk+MEcN7AZ4qtDhsvQzSq3Ga17y15NvNN1BtZfJYTLECYHA0Uqly
	 uhnDkmeAqb3nJk1jwP5jcQQGAcdXfW+FOpGe2ntQuf0v8TSzGKn8JGhHj9iLZ+7SZE
	 lwrmd2x+3AJzg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169051; x=1776429551; i=ngoc-tu.dinh@vates.tech;
	bh=od4200l4VbtlK43jWSdowV/7Geg4ScNjcSd/hFLO9W0=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=dex9AU9zYyFUSr0Ns9DlWdQNBOQW863GFGO5a3anEixKdya9AS9E2gRwQjmKe3Rx2
	 1aqrLQnYwKApJPJsb6STXpoVlZDX9pECazUYK15pS2Kg7FdNWgCxkVnKpH+ddLwd6q
	 bGdEnRPsWgb8Es05C8qZ7ITG6jlKLNYBPkjvx14ObB3yBr+aPC93qSSCzzNbC7XUAT
	 YRYoHfhPYYnmLiH8OdDG16j+cy5Do78XDLELqoKA6/uPOqAoDqn0QA6UV37P2zkyOU
	 fSo3+pUeLURuMpmvlqNSNbhvqm9+Ej5wOb1drG5g3o1g4nOJiO1QUYZHwGi4z+fWxQ
	 JaSGuoSJkbJvw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=202/6]=20Replace=20RegisterEventSource=20with=20TraceLoggingRegister?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169050875
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>, "david ambu" <david.preetham@cloud.com>
Message-Id: <20260414121727.668-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.39cebf9941664cf4a88f81168c65334f?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:31 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-c1860d/1776169053-F5159497-E6DB4DF1/0/0
X-purgate-type: clean
X-purgate-size: 22111

- Added TraceLogging levels for Information and Error events.
- Replaced RegisterEventSource due to potential security issues.
  This issue was raised by CodeQL 2.20.1,
  "RegisterEventSourceA has been marked deprecated as it is a legacy
   tracing API. Please migrate to modern Event Tracing for Windows APIs."
see: https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/28735-banned-crimson-api-usage

  Event Tracing logging needs to be captured using an ETW trace logger

Signed-off-by: david ambu <david.preetham@cloud.com>

* defined seperate macros for Info and Error logging
* use a switch on log level, rather than if/else
* Change __Log call to take a PCTSTR, and wrap format string with _T() in macros

Signed-off-by: Owen Smith <owen.smith@citrix.com>

Ported from Xenbus. Removal of xencons_monitor.dll is done separately.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v2: __Log() in tty.c only uses OutputDebugString instead of trace logging
---
 src/monitor/monitor.c | 274 ++++++++++++++++++++++--------------------
 1 file changed, 144 insertions(+), 130 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index b5e042a..381898f 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -43,6 +43,8 @@
 #include <sddl.h>
 #include <malloc.h>
 #include <assert.h>
+#include <TraceLoggingProvider.h>
+#include <winmeta.h>

 #include <xencons_device.h>
 #include <version.h>
@@ -59,7 +61,6 @@
 typedef struct _MONITOR_CONTEXT {
     SERVICE_STATUS          Status;
     SERVICE_STATUS_HANDLE   Service;
-    HANDLE                  EventLog;
     HANDLE                  StopEvent;
     HKEY                    ParametersKey;
     HDEVNOTIFY              InterfaceNotification;
@@ -108,30 +109,43 @@ static MONITOR_CONTEXT MonitorContext;
 #define PARAMETERS_KEY(_Service) \
         SERVICE_KEY(_Service) ## "\\Parameters"

+TRACELOGGING_DEFINE_PROVIDER(MonitorTraceLoggingProvider,
+                             MONITOR_NAME,
+                             // {F1D4F89A-D4FC-5C76-865B-27532946CA0A}
+                             (0xF1D4F89A, 0xD4FC, 0x5C76, 0x86, 0x5B, 0x27, 0x53, 0x29, 0x46, 0xCA, 0x0A));
+
+typedef enum {
+    LOG_INFO,
+    LOG_ERROR
+} LOG_LEVEL;
+
+#ifdef UNICODE
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingWideString(_buf, _name)
+#else
+#define TraceLoggingStringT(_buf, _name)    TraceLoggingString(_buf, _name)
+#endif
+
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ PCSTR          Format,
+    _In_ LOG_LEVEL      Level,
+    _In_ PCTSTR         Format,
     ...
     )
 {
-#if DBG
-    PMONITOR_CONTEXT    Context = &MonitorContext;
-    const CHAR          *Strings[1];
-#endif
-    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
+    TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
     HRESULT             Result;

     va_start(Arguments, Format);
-    Result = StringCchVPrintfA(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
+    Result = StringCchVPrintf(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
     va_end(Arguments);

     if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
         return;

-    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
+    Result = StringCchLength(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
     if (Result != S_OK)
         return;

@@ -139,30 +153,35 @@ __Log(

     _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
     _Analysis_assume_(Length >= 2);
-    Buffer[Length] = '\0';
-    Buffer[Length - 1] = '\n';
-    Buffer[Length - 2] = '\r';
+    Buffer[Length] = _T('\0');
+    Buffer[Length - 1] = _T('\n');
+    Buffer[Length - 2] = _T('\r');

     OutputDebugString(Buffer);

-#if DBG
-    Strings[0] = Buffer;
-
-    if (Context->EventLog != NULL)
-        ReportEventA(Context->EventLog,
-                     EVENTLOG_INFORMATION_TYPE,
-                     0,
-                     MONITOR_LOG,
-                     NULL,
-                     ARRAYSIZE(Strings),
-                     0,
-                     Strings,
-                     NULL);
-#endif
+    switch (Level) {
+    case LOG_INFO:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Information",
+                          TraceLoggingLevel(WINEVENT_LEVEL_INFO),
+                          TraceLoggingStringT(Buffer, "Info"));
+        break;
+    case LOG_ERROR:
+        TraceLoggingWrite(MonitorTraceLoggingProvider,
+                          "Error",
+                          TraceLoggingLevel(WINEVENT_LEVEL_ERROR),
+                          TraceLoggingStringT(Buffer, "Error"));
+        break;
+    default:
+        break;
+    }
 }

-#define Log(_Format, ...) \
-    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+#define LogInfo(_Format, ...) \
+        __Log(LOG_INFO, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)
+
+#define LogError(_Format, ...) \
+        __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)

 static PSTR
 GetErrorMessage(
@@ -228,7 +247,7 @@ ReportStatus(
     BOOL                Success;
     HRESULT             Error;

-    Log("====> (%s)", ServiceStateName(CurrentState));
+    LogInfo("====> (%s)", ServiceStateName(CurrentState));

     Context->Status.dwCurrentState = CurrentState;
     Context->Status.dwWin32ExitCode = Win32ExitCode;
@@ -252,7 +271,7 @@ ReportStatus(
     if (!Success)
         goto fail1;

-    Log("<====");
+    LogInfo("<====");

     return;

@@ -262,7 +281,7 @@ fail1:
     {
         PSTR    Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
 }
@@ -348,7 +367,7 @@ ConnectionThread(
     DWORD               Object;
     HRESULT             Error;

-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);

     ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
     Overlapped.hEvent = CreateEvent(NULL,
@@ -406,7 +425,7 @@ ConnectionThread(
     CloseHandle(Connection->Thread);
     free(Connection);

-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);

     return 0;

@@ -416,7 +435,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -438,7 +457,7 @@ ServerThread(
     HRESULT             Error;
     SECURITY_ATTRIBUTES SecurityAttributes;

-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);

     ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
     Overlapped.hEvent = CreateEvent(NULL,
@@ -459,7 +478,7 @@ ServerThread(
     if (Error != S_OK && Error != STRSAFE_E_INSUFFICIENT_BUFFER)
         goto fail2;

-    Log("%s", PipeName);
+    LogInfo("%s", PipeName);

     ZeroMemory(&SecurityAttributes, sizeof(SECURITY_ATTRIBUTES));
     SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
@@ -517,30 +536,30 @@ ServerThread(

     CloseHandle(Overlapped.hEvent);

-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);

     return 0;

 fail6:
-    Log("fail6");
+    LogError("fail6");

     free(Connection);

 fail5:
-    Log("fail5");
+    LogError("fail5");

     CloseHandle(Pipe);

 fail4:
-    Log("fail4");
+    LogError("fail4");

     LocalFree(&SecurityAttributes.lpSecurityDescriptor);

 fail3:
-    Log("fail3");
+    LogError("fail3");

 fail2:
-    Log("fail2");
+    LogError("fail2");

     CloseHandle(Overlapped.hEvent);

@@ -550,7 +569,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -571,7 +590,7 @@ DeviceThread(
     HANDLE              Handles[2];
     DWORD               Error;

-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);

     ZeroMemory(&Overlapped, sizeof(OVERLAPPED));
     Overlapped.hEvent = CreateEvent(NULL,
@@ -641,12 +660,12 @@ DeviceThread(

     CloseHandle(Overlapped.hEvent);

-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);

     return 0;

 fail2:
-    Log("fail2\n");
+    LogError("fail2\n");

     CloseHandle(Overlapped.hEvent);

@@ -656,7 +675,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -726,25 +745,25 @@ GetExecutable(
         goto fail5;
     }

-    Log("%s = %s", DeviceName, *Executable);
+    LogInfo("%s = %s", DeviceName, *Executable);

     RegCloseKey(Key);

     return TRUE;

 fail5:
-    Log("fail5");
+    LogError("fail5");

 fail4:
-    Log("fail4");
+    LogError("fail4");

     free(*Executable);

 fail3:
-    Log("fail3");
+    LogError("fail3");

 fail2:
-    Log("fail2");
+    LogError("fail2");

     RegCloseKey(Key);

@@ -754,7 +773,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -775,7 +794,7 @@ ExecutableThread(
     DWORD               Object;
     HRESULT             Error;

-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);

     // If there is no executable, this thread can finish now.
     if (!GetExecutable(Console->DeviceName,
@@ -789,7 +808,7 @@ again:
     ZeroMemory(&StartupInfo, sizeof (StartupInfo));
     StartupInfo.cb = sizeof (StartupInfo);

-    Log("Executing: %s", Executable);
+    LogInfo("Executing: %s", Executable);

 #pragma warning(suppress:6053) // CommandLine might not be NUL-terminated
     Success = CreateProcess(NULL,
@@ -839,7 +858,7 @@ again:
     free(Executable);

 done:
-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);

     return 0;

@@ -851,7 +870,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -871,7 +890,7 @@ ConsoleCreate(
     BOOL                    Success;
     HRESULT                 Error;

-    Log("====> %ws", DevicePath);
+    LogInfo("====> %ws", DevicePath);

     Console = malloc(sizeof(MONITOR_CONSOLE));
     if (Console == NULL)
@@ -975,48 +994,48 @@ ConsoleCreate(
     if (Console->ExecutableThread == NULL)
         goto fail12;

-    Log("<==== %s", Console->DeviceName);
+    LogInfo("<==== %s", Console->DeviceName);

     return Console;

 fail12:
-    Log("fail12");
+    LogError("fail12");

     CloseHandle(Console->ExecutableEvent);
     Console->ExecutableEvent = NULL;

 fail11:
-    Log("fail11");
+    LogError("fail11");

     SetEvent(Console->ServerEvent);
     WaitForSingleObject(Console->ServerThread, INFINITE);

 fail10:
-    Log("fail10");
+    LogError("fail10");

     CloseHandle(Console->ServerEvent);
     Console->ServerEvent = NULL;

 fail9:
-    Log("fail9");
+    LogError("fail9");

     SetEvent(Console->DeviceEvent);
     WaitForSingleObject(Console->DeviceThread, INFINITE);

 fail8:
-    Log("fail8");
+    LogError("fail8");

     CloseHandle(Console->DeviceEvent);
     Console->DeviceEvent = NULL;

 fail7:
-    Log("fail7");
+    LogError("fail7");

     UnregisterDeviceNotification(Console->DeviceNotification);
     Console->DeviceNotification = NULL;

 fail6:
-    Log("fail6");
+    LogError("fail6");

     ECHO(Console->DeviceHandle, "\r\n[DETACHED]\r\n");

@@ -1024,22 +1043,22 @@ fail6:
     Console->DevicePath = NULL;

 fail5:
-    Log("fail5");
+    LogError("fail5");

 fail4:
-    Log("fail4");
+    LogError("fail4");

     CloseHandle(Console->DeviceHandle);
     Console->DeviceHandle = INVALID_HANDLE_VALUE;

 fail3:
-    Log("fail3");
+    LogError("fail3");

     free(Console->DevicePath);
     Console->DevicePath = NULL;

 fail2:
-    Log("fail2");
+    LogError("fail2");

     DeleteCriticalSection(&Console->CriticalSection);
     ZeroMemory(&Console->ListHead, sizeof(LIST_ENTRY));
@@ -1053,7 +1072,7 @@ fail1:
     {
         PSTR    Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1113,7 +1132,7 @@ ConsoleDestroy(
     _In_ PMONITOR_CONSOLE   Console
     )
 {
-    Log("====> %s", Console->DeviceName);
+    LogInfo("====> %s", Console->DeviceName);

     SetEvent(Console->ExecutableEvent);
     WaitForSingleObject(Console->ExecutableThread, INFINITE);
@@ -1152,7 +1171,7 @@ ConsoleDestroy(

     free(Console);

-    Log("<====");
+    LogInfo("<====");
 }

 static BOOL
@@ -1163,7 +1182,7 @@ MonitorAdd(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     PMONITOR_CONSOLE    Console;

-    Log("=====> %ws", DevicePath);
+    LogInfo("=====> %ws", DevicePath);

     Console = ConsoleCreate(DevicePath);
     if (Console == NULL)
@@ -1174,12 +1193,12 @@ MonitorAdd(
     ++Context->ListCount;
     LeaveCriticalSection(&Context->CriticalSection);

-    Log("<===== %s", Console->DeviceName);
+    LogInfo("<===== %s", Console->DeviceName);

     return TRUE;

 fail1:
-    Log("fail1");
+    LogError("fail1");

     return FALSE;
 }
@@ -1193,7 +1212,7 @@ MonitorRemove(
     PMONITOR_CONSOLE    Console;
     PLIST_ENTRY         ListEntry;

-    Log("=====> 0x%p", DeviceHandle);
+    LogInfo("=====> 0x%p", DeviceHandle);

     EnterCriticalSection(&Context->CriticalSection);
     for (ListEntry = Context->ListHead.Flink;
@@ -1208,7 +1227,7 @@ MonitorRemove(
     }
     LeaveCriticalSection(&Context->CriticalSection);

-    Log("DeviceHandle 0x%p not found", DeviceHandle);
+    LogError("DeviceHandle 0x%p not found", DeviceHandle);

     return FALSE;

@@ -1219,7 +1238,7 @@ found:

     ConsoleDestroy(Console);

-    Log("<=====");
+    LogInfo("<=====");

     return TRUE;
 }
@@ -1239,7 +1258,7 @@ MonitorEnumerate(
     HRESULT                             Error;
     BOOL                                Success;

-    Log("====>");
+    LogInfo("====>");

     DeviceInfoSet = SetupDiGetClassDevs(&GUID_XENCONS_DEVICE,
                                         NULL,
@@ -1299,28 +1318,28 @@ MonitorEnumerate(
         continue;

     fail5:
-        Log("fail5");
+        LogError("fail5");
     fail4:
-        Log("fail4");
+        LogError("fail4");

         free(DeviceInterfaceDetail);

     fail3:
-        Log("fail3");
+        LogError("fail3");
     fail2:
         Error = GetLastError();

         {
             PSTR    Message;
             Message = GetErrorMessage(Error);
-            Log("fail2 (%s)", Message);
+            LogError("fail2 (%s)", Message);
             LocalFree(Message);
         }
     }

     SetupDiDestroyDeviceInfoList(DeviceInfoSet);

-    Log("<====");
+    LogInfo("<====");

     return TRUE;

@@ -1330,7 +1349,7 @@ fail1:
     {
         PSTR    Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1345,7 +1364,7 @@ MonitorRemoveAll(
     PMONITOR_CONTEXT    Context = &MonitorContext;
     PMONITOR_CONSOLE    Console;

-    Log("=====>");
+    LogInfo("=====>");

     for (;;) {
         EnterCriticalSection(&Context->CriticalSection);
@@ -1365,7 +1384,7 @@ MonitorRemoveAll(
     }
     LeaveCriticalSection(&Context->CriticalSection);

-    Log("<=====");
+    LogInfo("<=====");
 }

 DWORD WINAPI
@@ -1439,7 +1458,10 @@ MonitorMain(
     UNREFERENCED_PARAMETER(argc);
     UNREFERENCED_PARAMETER(argv);

-    Log("====>");
+    if (TraceLoggingRegister(MonitorTraceLoggingProvider) != ERROR_SUCCESS)
+        LogInfo("TraceLoggingRegister failed");
+
+    LogInfo("====>");

     Error = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
                          PARAMETERS_KEY(__MODULE__),
@@ -1455,11 +1477,6 @@ MonitorMain(
     if (Context->Service == NULL)
         goto fail2;

-    Context->EventLog = RegisterEventSourceA(NULL,
-                                            MONITOR_NAME);
-    if (Context->EventLog == NULL)
-        goto fail3;
-
     Context->Status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
     Context->Status.dwServiceSpecificExitCode = 0;

@@ -1471,7 +1488,7 @@ MonitorMain(
                                      NULL);

     if (Context->StopEvent == NULL)
-        goto fail4;
+        goto fail3;

     ZeroMemory(&Interface, sizeof (Interface));
     Interface.dbcc_size = sizeof (Interface);
@@ -1483,7 +1500,7 @@ MonitorMain(
                                    &Interface,
                                    DEVICE_NOTIFY_SERVICE_HANDLE);
     if (Context->InterfaceNotification == NULL)
-        goto fail5;
+        goto fail4;

     ReportStatus(SERVICE_RUNNING, NO_ERROR, 0);

@@ -1492,9 +1509,9 @@ MonitorMain(

     MonitorEnumerate();

-    Log("Waiting...");
+    LogInfo("Waiting...");
     WaitForSingleObject(Context->StopEvent, INFINITE);
-    Log("Wait Complete");
+    LogInfo("Wait Complete");

     MonitorRemoveAll();

@@ -1507,31 +1524,26 @@ MonitorMain(

     ReportStatus(SERVICE_STOPPED, NO_ERROR, 0);

-    (VOID) DeregisterEventSource(Context->EventLog);
-
     RegCloseKey(Context->ParametersKey);

-    Log("<====");
+    LogInfo("<====");
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);

     return;

-fail5:
-    Log("fail5");
+fail4:
+    LogError("fail4");

     CloseHandle(Context->StopEvent);

-fail4:
-    Log("fail4");
+fail3:
+    LogError("fail3");

     ReportStatus(SERVICE_STOPPED, GetLastError(), 0);

-    (VOID) DeregisterEventSource(Context->EventLog);
-
-fail3:
-    Log("fail3");
-
 fail2:
-    Log("fail2");
+    LogError("fail2");

     RegCloseKey(Context->ParametersKey);

@@ -1541,9 +1553,11 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }
+
+    TraceLoggingUnregister(MonitorTraceLoggingProvider);
 }

 static BOOL
@@ -1556,7 +1570,7 @@ MonitorCreate(
     CHAR        Path[MAX_PATH];
     HRESULT     Error;

-    Log("====>");
+    LogInfo("====>");

     if(!GetModuleFileNameA(NULL, Path, MAX_PATH))
         goto fail1;
@@ -1588,17 +1602,17 @@ MonitorCreate(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);

-    Log("<====");
+    LogInfo("<====");

     return TRUE;

 fail3:
-    Log("fail3");
+    LogError("fail3");

     CloseServiceHandle(SCManager);

 fail2:
-    Log("fail2");
+    LogError("fail2");

 fail1:
     Error = GetLastError();
@@ -1606,7 +1620,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1624,7 +1638,7 @@ MonitorDelete(
     SERVICE_STATUS      Status;
     HRESULT             Error;

-    Log("====>");
+    LogInfo("====>");

     SCManager = OpenSCManager(NULL,
                               NULL,
@@ -1655,20 +1669,20 @@ MonitorDelete(
     CloseServiceHandle(Service);
     CloseServiceHandle(SCManager);

-    Log("<====");
+    LogInfo("<====");

     return TRUE;

 fail4:
-    Log("fail4");
+    LogError("fail4");

 fail3:
-    Log("fail3");
+    LogError("fail3");

     CloseServiceHandle(Service);

 fail2:
-    Log("fail2");
+    LogError("fail2");

     CloseServiceHandle(SCManager);

@@ -1678,7 +1692,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

@@ -1696,16 +1710,16 @@ MonitorEntry(
     };
     HRESULT             Error;

-    Log("%s (%s) ====>",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) ====>",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);

     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;

-    Log("%s (%s) <====",
-        MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-        DAY_STR "/" MONTH_STR "/" YEAR_STR);
+    LogInfo("%s (%s) <====",
+            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
+            DAY_STR "/" MONTH_STR "/" YEAR_STR);

     return TRUE;

@@ -1715,7 +1729,7 @@ fail1:
     {
         PTCHAR  Message;
         Message = GetErrorMessage(Error);
-        Log("fail1 (%s)", Message);
+        LogError("fail1 (%s)", Message);
         LocalFree(Message);
     }

--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:17:36 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:17:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281713.1564583 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007VC-Kc; Tue, 14 Apr 2026 12:17:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281713.1564583; Tue, 14 Apr 2026 12:17:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007V3-Gw; Tue, 14 Apr 2026 12:17:36 +0000
Received: by outflank-mailman (input) for mailman id 1281713;
 Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305b.v1-8da0b151bc4041c3a2b14404fa33bf88@bounce.vates.tech>)
 id 1wCchy-0007RW-DZ
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCchx-00G5lH-QQ
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:17:33 +0200
Received: from [10.42.69.6] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305b.v1-8da0b151bc4041c3a2b14404fa33bf88@bounce.vates.tech>)
 id 69de305a-2eae-0a2a0a5409dd-0a2a4506e9be-26
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de305b.v1-8da0b151bc4041c3a2b14404fa33bf88@bounce.vates.tech>)
 id 69de305c-0df0-0a2a45060019-c602bb0e2c76-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw3F76RTjz8XTP7q
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:31 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 8da0b151bc4041c3a2b14404fa33bf88; Tue, 14 Apr 2026 12:17:31 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169051; x=1776439051;
	bh=/2bg6JulOUhwY7RvxkxHswTba4laGTKJrjvFG59Eocc=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=rD/DFTesfbOPvs+ut2LBj8sYtVj4zQkUZ+c3giO1X2obk1ku8OaGy6Jtls6Xb/a3W
	 n9MfqNnvbbrUCmGXLddtjqYpG85Zwc8lDqIcDqkK3r7HAgqoC6r9WbmwB7aVigRjjx
	 SYJ22DRDyDt1fbPxY8ahgsNvj2ZDdrUrmZI7z9HiFjRkk/xfX6UvauyNoObYsBInRM
	 m3HyTzSugJ0o79ih/GyFnBcyQJNt0HapAUSPP5X+JiaSVwbS3j4VZhw+yDH6d2+GW+
	 TLHhCRoEFp0vPThPwO2XFI2u0s+u4EBxQ9xDKHXNp/7Aebhbm86KZM80IL+wJOPn44
	 hEq5i7pDi+Uow==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169051; x=1776429551; i=ngoc-tu.dinh@vates.tech;
	bh=/2bg6JulOUhwY7RvxkxHswTba4laGTKJrjvFG59Eocc=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=fxYcQWxv2JA/o3Gox0VxSGt/OAb9eJvaxZYPT7fBD9xeAB733xYOoRmOVAb7wQpIy
	 d5o0srq3IF7ouK7kedTMmmrikkjxt371FVhhFdCwzxBzPCoylwP+t6o9q1m/TOG3Qj
	 +Cptlxd1N1tp6sySfMdQmjDFubhUGyM3o4Pku7YjZ06fOebOADeU/JaU5+cQdDC8qY
	 E3d3W5z7N+pJZ0n/Sx4f7krnFw23q958ODl/u9eQDfUqUU4W8Z7WQTL+lMqDtCJzYC
	 Ow0XiZortbgOW/J1tDYx8CU7FUDgNOY6ZD4m4W4HtPvbsWfnH8jHPESi/3C4JBHlyx
	 TJhs9QdeeQBtQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=203/6]=20Fix=20inconsistent=20TCHAR=20handling?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169051246
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414121727.668-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.8da0b151bc4041c3a2b14404fa33bf88?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:31 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-16d1c6/1776169053-AF93A3D8-8FB67793/0/0
X-purgate-type: clean
X-purgate-size: 26282

* Wrap strings with _T()
* Fix ServiceStateName and WTSStateName to return PCTSTR
* Use 'Length' for character counts, and 'Size' for byte counts
  when calling StringCch* and StringCb* functions
* Fix _tWinMain to use LPTSTR

Signed-off-by: Owen Smith <owen.smith@citrix.com>

Ported from Xenbus.

* Convert DeviceInterfaceDetail/DeviceName to TCHAR equivalents
* Convert the output of IOCTL_XENCONS_GET_NAME to Unicode strings
* Remove explicit uses of A/W functions
* Fix __Log() in tty.c as well

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v2: Fix __Log() in tty.c as well
---
 src/monitor/monitor.c | 279 +++++++++++++++++++++++-------------------
 src/tty/tty.c         |  19 ++-
 2 files changed, 158 insertions(+), 140 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 381898f..78d67e1 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -33,6 +33,7 @@
 #define INITGUID 1

 #include <windows.h>
+#include <tchar.h>
 #include <winioctl.h>
 #include <stdlib.h>
 #include <strsafe.h>
@@ -71,10 +72,10 @@ typedef struct _MONITOR_CONTEXT {

 typedef struct _MONITOR_CONSOLE {
     LIST_ENTRY              ListEntry;
-    PWCHAR                  DevicePath;
+    PTSTR                   DevicePath;
     HANDLE                  DeviceHandle;
     HDEVNOTIFY              DeviceNotification;
-    PSTR                    DeviceName; // protocol and instance?
+    PTSTR                   DeviceName; // protocol and instance?
     HANDLE                  ExecutableThread;
     HANDLE                  ExecutableEvent;
     HANDLE                  DeviceThread;
@@ -183,28 +184,28 @@ __Log(
 #define LogError(_Format, ...) \
         __Log(LOG_ERROR, _T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)

-static PSTR
+static PTSTR
 GetErrorMessage(
-    _In_ HRESULT    Error
+    _In_  HRESULT   Error
     )
 {
-    PSTR            Message;
+    PTSTR           Message;
     ULONG           Index;

-    if (!FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                        FORMAT_MESSAGE_FROM_SYSTEM |
-                        FORMAT_MESSAGE_IGNORE_INSERTS,
-                        NULL,
-                        Error,
-                        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                        (LPSTR)&Message,
-                        0,
-                        NULL))
+    if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                       FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS,
+                       NULL,
+                       Error,
+                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                       (LPTSTR)&Message,
+                       0,
+                       NULL))
         return NULL;

-    for (Index = 0; Message[Index] != '\0'; Index++) {
-        if (Message[Index] == '\r' || Message[Index] == '\n') {
-            Message[Index] = '\0';
+    for (Index = 0; Message[Index] != _T('\0'); Index++) {
+        if (Message[Index] == _T('\r') || Message[Index] == _T('\n')) {
+            Message[Index] = _T('\0');
             break;
         }
     }
@@ -212,14 +213,14 @@ GetErrorMessage(
     return Message;
 }

-static PCSTR
+static PCTSTR
 ServiceStateName(
     _In_ DWORD  State
     )
 {
 #define _STATE_NAME(_State) \
     case SERVICE_ ## _State: \
-        return #_State
+        return _T(#_State)

     switch (State) {
     _STATE_NAME(START_PENDING);
@@ -230,7 +231,7 @@ ServiceStateName(
         break;
     }

-    return "UNKNOWN";
+    return _T("UNKNOWN");

 #undef  _STATE_NAME
 }
@@ -279,7 +280,7 @@ fail1:
     Error = GetLastError();

     {
-        PSTR    Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -433,7 +434,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -448,7 +449,7 @@ ServerThread(
     )
 {
     PMONITOR_CONSOLE    Console = (PMONITOR_CONSOLE)Argument;
-    CHAR                PipeName[MAXIMUM_BUFFER_SIZE];
+    TCHAR               PipeName[MAXIMUM_BUFFER_SIZE];
     OVERLAPPED          Overlapped;
     HANDLE              Handle[2];
     HANDLE              Pipe;
@@ -470,11 +471,11 @@ ServerThread(
     Handle[0] = Console->ServerEvent;
     Handle[1] = Overlapped.hEvent;

-    Error = StringCchPrintfA(PipeName,
-                             MAXIMUM_BUFFER_SIZE,
-                             "%s%s",
-                             PIPE_BASE_NAME,
-                             Console->DeviceName);
+    Error = StringCchPrintf(PipeName,
+                            MAXIMUM_BUFFER_SIZE,
+                            _T("%s%s"),
+                            _T(PIPE_BASE_NAME),
+                            Console->DeviceName);
     if (Error != S_OK && Error != STRSAFE_E_INSUFFICIENT_BUFFER)
         goto fail2;

@@ -483,10 +484,10 @@ ServerThread(
     ZeroMemory(&SecurityAttributes, sizeof(SECURITY_ATTRIBUTES));
     SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
     SecurityAttributes.bInheritHandle = FALSE;
-    if (!ConvertStringSecurityDescriptorToSecurityDescriptorA(PIPE_SDDL,
-                                                              SDDL_REVISION_1,
-                                                              &SecurityAttributes.lpSecurityDescriptor,
-                                                              NULL))
+    if (!ConvertStringSecurityDescriptorToSecurityDescriptor(_T(PIPE_SDDL),
+                                                             SDDL_REVISION_1,
+                                                             &SecurityAttributes.lpSecurityDescriptor,
+                                                             NULL))
         goto fail3;

     for (;;) {
@@ -567,7 +568,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -603,13 +604,13 @@ DeviceThread(
     Handles[0] = Console->DeviceEvent;
     Handles[1] = Overlapped.hEvent;

-    Device = CreateFileW(Console->DevicePath,
-                         GENERIC_READ,
-                         FILE_SHARE_READ | FILE_SHARE_WRITE,
-                         NULL,
-                         OPEN_EXISTING,
-                         FILE_FLAG_OVERLAPPED,
-                         NULL);
+    Device = CreateFile(Console->DevicePath,
+                        GENERIC_READ,
+                        FILE_SHARE_READ | FILE_SHARE_WRITE,
+                        NULL,
+                        OPEN_EXISTING,
+                        FILE_FLAG_OVERLAPPED,
+                        NULL);
     if (Device == INVALID_HANDLE_VALUE)
         goto fail2;

@@ -673,7 +674,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -685,8 +686,8 @@ fail1:
 _Success_(return != FALSE)
 static BOOL
 GetExecutable(
-    _In_ PSTR               DeviceName,
-    _Outptr_result_z_ PSTR  *Executable
+    _In_ PTSTR              DeviceName,
+    _Outptr_result_z_ PTSTR *Executable
     )
 {
     PMONITOR_CONTEXT        Context = &MonitorContext;
@@ -696,11 +697,11 @@ GetExecutable(
     DWORD                   Type;
     HRESULT                 Error;

-    Error = RegOpenKeyExA(Context->ParametersKey,
-                          DeviceName,
-                          0,
-                          KEY_READ,
-                          &Key);
+    Error = RegOpenKeyEx(Context->ParametersKey,
+                         DeviceName,
+                         0,
+                         KEY_READ,
+                         &Key);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail1;
@@ -723,18 +724,18 @@ GetExecutable(
         goto fail2;
     }

-    ExecutableLength = MaxValueLength;
+    ExecutableLength = (MaxValueLength + 1) * sizeof(TCHAR);

     *Executable = calloc(1, ExecutableLength);
     if (*Executable == NULL)
         goto fail3;

-    Error = RegQueryValueExA(Key,
-                             "Executable",
-                             NULL,
-                             &Type,
-                             (LPBYTE)(*Executable),
-                             &ExecutableLength);
+    Error = RegQueryValueEx(Key,
+                            _T("Executable"),
+                            NULL,
+                            &Type,
+                            (LPBYTE)(*Executable),
+                            &ExecutableLength);
     if (Error != ERROR_SUCCESS) {
         SetLastError(Error);
         goto fail4;
@@ -771,7 +772,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -786,7 +787,7 @@ ExecutableThread(
     )
 {
     PMONITOR_CONSOLE    Console = (PMONITOR_CONSOLE)Argument;
-    PSTR                Executable;
+    PTSTR               Executable;
     PROCESS_INFORMATION ProcessInfo;
     STARTUPINFO         StartupInfo;
     BOOL                Success;
@@ -868,7 +869,7 @@ fail1:
     free(Executable);

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -879,18 +880,24 @@ fail1:

 static PMONITOR_CONSOLE
 ConsoleCreate(
-    _In_ PWCHAR             DevicePath
+    _In_ PTSTR              DevicePath
     )
 {
     PMONITOR_CONTEXT        Context = &MonitorContext;
     PMONITOR_CONSOLE        Console;
     DEV_BROADCAST_HANDLE    Handle;
     CHAR                    DeviceName[MAX_PATH];
+#ifdef UNICODE
+    TCHAR                   DeviceNameString[MAX_PATH];
+    errno_t                 StringError;
+#else
+#define DeviceNameString    DeviceName
+#endif
     DWORD                   Bytes;
     BOOL                    Success;
     HRESULT                 Error;

-    LogInfo("====> %ws", DevicePath);
+    LogInfo("====> %s", DevicePath);

     Console = malloc(sizeof(MONITOR_CONSOLE));
     if (Console == NULL)
@@ -901,17 +908,17 @@ ConsoleCreate(
     __InitializeListHead(&Console->ListEntry);
     InitializeCriticalSection(&Console->CriticalSection);

-    Console->DevicePath = _wcsdup(DevicePath);
+    Console->DevicePath = _tcsdup(DevicePath);
     if (Console->DevicePath == NULL)
         goto fail2;

-    Console->DeviceHandle = CreateFileW(DevicePath,
-                                        GENERIC_READ | GENERIC_WRITE,
-                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
-                                        NULL,
-                                        OPEN_EXISTING,
-                                        FILE_ATTRIBUTE_NORMAL,
-                                        NULL);
+    Console->DeviceHandle = CreateFile(DevicePath,
+                                       GENERIC_READ | GENERIC_WRITE,
+                                       FILE_SHARE_READ | FILE_SHARE_WRITE,
+                                       NULL,
+                                       OPEN_EXISTING,
+                                       FILE_ATTRIBUTE_NORMAL,
+                                       NULL);
     if (Console->DeviceHandle == INVALID_HANDLE_VALUE)
         goto fail3;

@@ -927,10 +934,19 @@ ConsoleCreate(
         goto fail4;

     DeviceName[MAX_PATH - 1] = '\0';
+#ifdef UNICODE
+    StringError = mbstowcs_s(NULL,
+                             DeviceNameString,
+                             sizeof(DeviceNameString) / sizeof(TCHAR),
+                             DeviceName,
+                             strlen(DeviceName));
+    if (StringError != 0)
+        goto fail5;
+#endif

-    Console->DeviceName = _strdup(DeviceName);
+    Console->DeviceName = _tcsdup(DeviceNameString);
     if (Console->DeviceName == NULL)
-        goto fail5;
+        goto fail6;

     ECHO(Console->DeviceHandle, "\r\n[ATTACHED]\r\n");

@@ -944,14 +960,14 @@ ConsoleCreate(
                                     &Handle,
                                     DEVICE_NOTIFY_SERVICE_HANDLE);
     if (Console->DeviceNotification == NULL)
-        goto fail6;
+        goto fail7;

     Console->DeviceEvent = CreateEvent(NULL,
                                        TRUE,
                                        FALSE,
                                        NULL);
     if (Console->DeviceEvent == NULL)
-        goto fail7;
+        goto fail8;

     Console->DeviceThread = CreateThread(NULL,
                                          0,
@@ -960,14 +976,14 @@ ConsoleCreate(
                                          0,
                                          NULL);
     if (Console->DeviceThread == NULL)
-        goto fail8;
+        goto fail9;

     Console->ServerEvent = CreateEvent(NULL,
                                        TRUE,
                                        FALSE,
                                        NULL);
     if (Console->ServerEvent == NULL)
-        goto fail9;
+        goto fail10;

     Console->ServerThread = CreateThread(NULL,
                                          0,
@@ -976,14 +992,14 @@ ConsoleCreate(
                                          0,
                                          NULL);
     if (Console->ServerThread == NULL)
-        goto fail10;
+        goto fail11;

     Console->ExecutableEvent = CreateEvent(NULL,
                                            TRUE,
                                            FALSE,
                                            NULL);
     if (Console->ExecutableEvent == NULL)
-        goto fail11;
+        goto fail12;

     Console->ExecutableThread = CreateThread(NULL,
                                              0,
@@ -992,58 +1008,63 @@ ConsoleCreate(
                                              0,
                                              NULL);
     if (Console->ExecutableThread == NULL)
-        goto fail12;
+        goto fail13;

     LogInfo("<==== %s", Console->DeviceName);

     return Console;

-fail12:
-    LogError("fail12");
+fail13:
+    LogError("fail13");

     CloseHandle(Console->ExecutableEvent);
     Console->ExecutableEvent = NULL;

-fail11:
-    LogError("fail11");
+fail12:
+    LogError("fail12");

     SetEvent(Console->ServerEvent);
     WaitForSingleObject(Console->ServerThread, INFINITE);

-fail10:
-    LogError("fail10");
+fail11:
+    LogError("fail11");

     CloseHandle(Console->ServerEvent);
     Console->ServerEvent = NULL;

-fail9:
-    LogError("fail9");
+fail10:
+    LogError("fail10");

     SetEvent(Console->DeviceEvent);
     WaitForSingleObject(Console->DeviceThread, INFINITE);

-fail8:
-    LogError("fail8");
+fail9:
+    LogError("fail9");

     CloseHandle(Console->DeviceEvent);
     Console->DeviceEvent = NULL;

-fail7:
-    LogError("fail7");
+fail8:
+    LogError("fail8");

     UnregisterDeviceNotification(Console->DeviceNotification);
     Console->DeviceNotification = NULL;

-fail6:
-    LogError("fail6");
+fail7:
+    LogError("fail7");

     ECHO(Console->DeviceHandle, "\r\n[DETACHED]\r\n");

     free(Console->DevicePath);
     Console->DevicePath = NULL;

+fail6:
+    LogError("fail6");
+
+#ifdef UNICODE
 fail5:
     LogError("fail5");
+#endif

 fail4:
     LogError("fail4");
@@ -1070,7 +1091,7 @@ fail1:
     Error = GetLastError();

     {
-        PSTR    Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1176,13 +1197,13 @@ ConsoleDestroy(

 static BOOL
 MonitorAdd(
-    _In_ PWCHAR         DevicePath
+    _In_ PTCHAR         DevicePath
     )
 {
     PMONITOR_CONTEXT    Context = &MonitorContext;
     PMONITOR_CONSOLE    Console;

-    LogInfo("=====> %ws", DevicePath);
+    LogInfo("=====> %s", DevicePath);

     Console = ConsoleCreate(DevicePath);
     if (Console == NULL)
@@ -1251,7 +1272,7 @@ MonitorEnumerate(
     PMONITOR_CONTEXT                    Context = &MonitorContext;
     HDEVINFO                            DeviceInfoSet;
     SP_DEVICE_INTERFACE_DATA            DeviceInterfaceData;
-    PSP_DEVICE_INTERFACE_DETAIL_DATA_W  DeviceInterfaceDetail;
+    PSP_DEVICE_INTERFACE_DETAIL_DATA    DeviceInterfaceDetail;
     PMONITOR_CONSOLE                    Console;
     DWORD                               Size;
     DWORD                               Index;
@@ -1279,7 +1300,7 @@ MonitorEnumerate(
         if (!Success)
             break;

-        Success = SetupDiGetDeviceInterfaceDetailW(DeviceInfoSet,
+        Success = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet,
                                                   &DeviceInterfaceData,
                                                   NULL,
                                                   0,
@@ -1293,14 +1314,14 @@ MonitorEnumerate(
             goto fail3;

         DeviceInterfaceDetail->cbSize =
-            sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA_W);
-
-        Success = SetupDiGetDeviceInterfaceDetailW(DeviceInfoSet,
-                                                   &DeviceInterfaceData,
-                                                   DeviceInterfaceDetail,
-                                                   Size,
-                                                   NULL,
-                                                   NULL);
+            sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
+
+        Success = SetupDiGetDeviceInterfaceDetail(DeviceInfoSet,
+                                                  &DeviceInterfaceData,
+                                                  DeviceInterfaceDetail,
+                                                  Size,
+                                                  NULL,
+                                                  NULL);
         if (!Success)
             goto fail4;

@@ -1330,7 +1351,7 @@ MonitorEnumerate(
         Error = GetLastError();

         {
-            PSTR    Message;
+            PTSTR   Message;
             Message = GetErrorMessage(Error);
             LogError("fail2 (%s)", Message);
             LocalFree(Message);
@@ -1347,7 +1368,7 @@ fail1:
     Error = GetLastError();

     {
-        PSTR    Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1416,7 +1437,7 @@ MonitorCtrlHandlerEx(
         switch (EventType) {
         case DBT_DEVICEARRIVAL:
             if (Header->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
-                PDEV_BROADCAST_DEVICEINTERFACE_W Interface = EventData;
+                PDEV_BROADCAST_DEVICEINTERFACE  Interface = EventData;

                 if (IsEqualGUID(&Interface->dbcc_classguid,
                                 &GUID_XENCONS_DEVICE))
@@ -1463,15 +1484,15 @@ MonitorMain(

     LogInfo("====>");

-    Error = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
-                         PARAMETERS_KEY(__MODULE__),
+    Error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                         _T(PARAMETERS_KEY(__MODULE__)),
                          0,
                          KEY_READ,
                          &Context->ParametersKey);
     if (Error != ERROR_SUCCESS)
         goto fail1;

-    Context->Service = RegisterServiceCtrlHandlerExA(MONITOR_NAME,
+    Context->Service = RegisterServiceCtrlHandlerEx(_T(MONITOR_NAME),
                                                     MonitorCtrlHandlerEx,
                                                     NULL);
     if (Context->Service == NULL)
@@ -1551,7 +1572,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1567,12 +1588,12 @@ MonitorCreate(
 {
     SC_HANDLE   SCManager;
     SC_HANDLE   Service;
-    CHAR        Path[MAX_PATH];
+    TCHAR       Path[MAX_PATH];
     HRESULT     Error;

     LogInfo("====>");

-    if(!GetModuleFileNameA(NULL, Path, MAX_PATH))
+    if(!GetModuleFileName(NULL, Path, MAX_PATH))
         goto fail1;

     SCManager = OpenSCManager(NULL,
@@ -1583,8 +1604,8 @@ MonitorCreate(
         goto fail2;

     Service = CreateService(SCManager,
-                            MONITOR_NAME,
-                            MONITOR_DISPLAYNAME,
+                            _T(MONITOR_NAME),
+                            _T(MONITOR_DISPLAYNAME),
                             SERVICE_ALL_ACCESS,
                             SERVICE_WIN32_OWN_PROCESS,
                             SERVICE_AUTO_START,
@@ -1618,7 +1639,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1648,7 +1669,7 @@ MonitorDelete(
         goto fail1;

     Service = OpenService(SCManager,
-                          MONITOR_NAME,
+                          _T(MONITOR_NAME),
                           SERVICE_ALL_ACCESS);

     if (Service == NULL)
@@ -1690,7 +1711,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1705,21 +1726,21 @@ MonitorEntry(
     )
 {
     SERVICE_TABLE_ENTRY Table[] = {
-        { MONITOR_NAME, MonitorMain },
+        { _T(MONITOR_NAME), MonitorMain },
         { NULL, NULL }
     };
     HRESULT             Error;

     LogInfo("%s (%s) ====>",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));

     if (!StartServiceCtrlDispatcher(Table))
         goto fail1;

     LogInfo("%s (%s) <====",
-            MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR,
-            DAY_STR "/" MONTH_STR "/" YEAR_STR);
+            _T(MAJOR_VERSION_STR "." MINOR_VERSION_STR "." MICRO_VERSION_STR "." BUILD_NUMBER_STR),
+            _T(DAY_STR "/" MONTH_STR "/" YEAR_STR));

     return TRUE;

@@ -1727,7 +1748,7 @@ fail1:
     Error = GetLastError();

     {
-        PTCHAR  Message;
+        PTSTR   Message;
         Message = GetErrorMessage(Error);
         LogError("fail1 (%s)", Message);
         LocalFree(Message);
@@ -1737,10 +1758,10 @@ fail1:
 }

 int CALLBACK
-WinMain(
+_tWinMain(
     _In_        HINSTANCE   Current,
     _In_opt_    HINSTANCE   Previous,
-    _In_        LPSTR       CmdLine,
+    _In_        LPTSTR      CmdLine,
     _In_        int         CmdShow
     )
 {
@@ -1750,10 +1771,10 @@ WinMain(
     UNREFERENCED_PARAMETER(Previous);
     UNREFERENCED_PARAMETER(CmdShow);

-    if (strlen(CmdLine) != 0) {
-         if (_stricmp(CmdLine, "create") == 0)
+    if (_tcslen(CmdLine) != 0) {
+         if (_tcsicmp(CmdLine, TEXT("create")) == 0)
              Success = MonitorCreate();
-         else if (_stricmp(CmdLine, "delete") == 0)
+         else if (_tcsicmp(CmdLine, TEXT("delete")) == 0)
              Success = MonitorDelete();
          else
              Success = FALSE;
diff --git a/src/tty/tty.c b/src/tty/tty.c
index 4bfd74d..78214bd 100644
--- a/src/tty/tty.c
+++ b/src/tty/tty.c
@@ -62,26 +62,23 @@ TTY_CONTEXT TtyContext;
 static VOID
 #pragma prefast(suppress:6262) // Function uses '1036' bytes of stack: exceeds /analyze:stacksize'1024'
 __Log(
-    _In_ PCSTR          Format,
+    _In_ PCTSTR         Format,
     _In_ ...
     )
 {
-    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
+    TCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
     va_list             Arguments;
     size_t              Length;
     HRESULT             Result;

     va_start(Arguments, Format);
-    Result = StringCchVPrintfA(Buffer,
-        MAXIMUM_BUFFER_SIZE,
-        Format,
-        Arguments);
+    Result = StringCchVPrintf(Buffer, MAXIMUM_BUFFER_SIZE, Format, Arguments);
     va_end(Arguments);

     if (Result != S_OK && Result != STRSAFE_E_INSUFFICIENT_BUFFER)
         return;

-    Result = StringCchLengthA(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
+    Result = StringCchLength(Buffer, MAXIMUM_BUFFER_SIZE, &Length);
     if (Result != S_OK)
         return;

@@ -89,15 +86,15 @@ __Log(

     _Analysis_assume_(Length < MAXIMUM_BUFFER_SIZE);
     _Analysis_assume_(Length >= 2);
-    Buffer[Length] = '\0';
-    Buffer[Length - 1] = '\n';
-    Buffer[Length - 2] = '\r';
+    Buffer[Length] = _T('\0');
+    Buffer[Length - 1] = _T('\n');
+    Buffer[Length - 2] = _T('\r');

     OutputDebugString(Buffer);
 }

 #define Log(_Format, ...) \
-    __Log(__MODULE__ "|" __FUNCTION__ ": " _Format, __VA_ARGS__)
+        __Log(_T(__MODULE__ "|" __FUNCTION__ ": " _Format), __VA_ARGS__)

 static BOOL
 CreateChild(
--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:17:36 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:17:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281714.1564589 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007VZ-RL; Tue, 14 Apr 2026 12:17:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281714.1564589; Tue, 14 Apr 2026 12:17:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007VH-IJ; Tue, 14 Apr 2026 12:17:36 +0000
Received: by outflank-mailman (input) for mailman id 1281714;
 Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305c.v1-b8be353b5f934440bd93c00b4a30c637@bounce.vates.tech>)
 id 1wCchy-0007RX-HV
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCchx-00G5k2-Tk
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:17:33 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305c.v1-b8be353b5f934440bd93c00b4a30c637@bounce.vates.tech>)
 id 69de305a-bab6-0a2a0a5309dd-0a2a450ba2dc-24
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de305c.v1-b8be353b5f934440bd93c00b4a30c637@bounce.vates.tech>)
 id 69de305c-bca8-0a2a450b0019-c602ba012ae0-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fw3F81HkKzBsVBYR
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:32 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 b8be353b5f934440bd93c00b4a30c637; Tue, 14 Apr 2026 12:17:32 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169052; x=1776439052;
	bh=uu+DzCGtsDuBn5+B1mUsW1PbTxXiYOCblXfzuAGNEro=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=fZWyHswDsyN1A88utMVeeG90hEBpXBIlZ2WbGm2f1j9AyswX/fPf/dfk1d3YLzph9
	 NZN2+x2+pAzrBBFuGZrV4flcp633cIqyH9lmdBsobWEpF2IlLUyBbXpTSg+zWiSss7
	 LXrwKEoMQQYrqOXGNaooBoHZHKr8aY9JuuxqZ5usalz5inixaxe8Rz+yYj+3iQu7VE
	 zjBYY1vxjSwRWhP/anKEF9yBa9D1jZYf7okA8cIWnt/Ap9KQQntCUnYY5jU7P3hSfw
	 FRIGd5ByGAmkwRAXBhf8SyNItZOs0efGvscG0HyGcBYXsgbIIY0ZGr+Sr9rPzx4Kj8
	 oNTX3QatwjGXw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169052; x=1776429552; i=ngoc-tu.dinh@vates.tech;
	bh=uu+DzCGtsDuBn5+B1mUsW1PbTxXiYOCblXfzuAGNEro=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=cbmBDXHfrk5iyCkBoC0jQOD8aV+46RNZUB3/iFJLo1k7Y6OuqhBmRQdg1BQ9rDtWG
	 ZEB2RFigwz9TPaNZnsTI3ym8WLi17o3kz7Zz8yp/+3O8vy+iFR+NvAzfYlyfVQE3/s
	 CxPAZQ+5miXEXCzsJQdzlcceJdkulX27aEtHI6W99YIbVVK2Bqm/X74SlTrI4KcXlQ
	 tGkvPbOXCx6ohI8kahT8WwQyqDZwh9rW2HoSP4XpHU24j5IYsokLp3p3GOXPqjEwkK
	 D7LQcU++uRX1QbOuGalPaBugEd8hQKJU4B82vp+JoGIfeWRitUAIdDkOxVi4VRztIm
	 1/7Zj5q0ezwMA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=204/6]=20Delete=20xencons=5Fmonitor.dll?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169051470
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414121727.668-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b8be353b5f934440bd93c00b4a30c637?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:32 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-42698a/1776169053-F59C32A1-A0016C76/0/0
X-purgate-type: clean
X-purgate-size: 8549

Now that trace logging is used, the DLL is not needed any more. Remove
it from the build and package.

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/messages.mc                       | 55 -------------------
 src/monitor/monitor.c                         |  2 -
 src/monitor/xencons_monitor.rc                |  1 -
 src/xencons.inf                               | 11 +---
 .../xencons_monitor/xencons_monitor.vcxproj   | 17 ------
 .../xencons_monitor/xencons_monitor.vcxproj   | 12 ----
 6 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 src/monitor/messages.mc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
deleted file mode 100644
index eb1d382..0000000
--- a/src/monitor/messages.mc
+++ /dev/null
@@ -1,55 +0,0 @@
-; // Copyright (c) Xen Project.
-; // Copyright (c) Cloud Software Group, Inc.
-; // All rights reserved.
-; //
-; // Redistribution and use in source and binary forms,
-; // with or without modification, are permitted provided
-; // that the following conditions are met:
-; //
-; // *   Redistributions of source code must retain the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer.
-; // *   Redistributions in binary form must reproduce the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer in the documentation and/or other
-; //     materials provided with the distribution.
-; //
-; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-; // SUCH DAMAGE.
-
-MessageIdTypedef=DWORD
-
-SeverityNames=(
-	Success=0x0:STATUS_SEVERITY_SUCCESS
-	Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
-	Warning=0x2:STATUS_SEVERITY_WARNING
-	Error=0x3:STATUS_SEVERITY_ERROR
-	)
-
-
-FacilityNames=(
-	System=0x0:FACILITY_SYSTEM
-	Runtime=0x2:FACILITY_RUNTIME
-	Stubs=0x3:FACILITY_STUBS
-	Io=0x4:FACILITY_IO_ERROR_CODE
-	)
-
-MessageId=0x1
-Severity=Informational
-Facility=System
-SymbolicName=MONITOR_LOG
-Language=English
-%1
-.
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 78d67e1..3ff7d7c 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -50,8 +50,6 @@
 #include <xencons_device.h>
 #include <version.h>
 
-#include "messages.h"
-
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
 #define __MODULE__ stringify(PROJECT)
diff --git a/src/monitor/xencons_monitor.rc b/src/monitor/xencons_monitor.rc
index 3fba041..6c077f8 100644
--- a/src/monitor/xencons_monitor.rc
+++ b/src/monitor/xencons_monitor.rc
@@ -54,4 +54,3 @@
 #define VER_FILESUBTYPE		    VFT2_UNKNOWN
 
 #include "common.ver"
-#include "messages.rc"
diff --git a/src/xencons.inf b/src/xencons.inf
index 6bbd83b..6f9b361 100644
--- a/src/xencons.inf
+++ b/src/xencons.inf
@@ -51,12 +51,10 @@ Tty_CopyFiles=11
 [SourceDisksFiles]
 xencons.sys=0,,
 xencons_monitor.exe=0,,
-xencons_monitor.dll=0,,
 xencons_tty.exe=0,,
 
 [Monitor_CopyFiles]
 xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_monitor.exe
-xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xencons_monitor.dll
 
 [Tty_CopyFiles]
 xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_tty.exe
@@ -81,7 +79,7 @@ FeatureScore=0xFE
 xencons.sys
 
 [XenCons_Inst.Services]
-AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Monitor_EventLog
+AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
 AddService=xencons,%SPSVCINST_ASSOCSERVICE%,XenCons_Service
 
 [XenCons_Service]
@@ -109,13 +107,6 @@ AddReg = Monitor_Parameters
 HKR,"Parameters",,0x00000010
 HKR,"Parameters\default","Executable",0x00000000,"xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe"
 
-[Monitor_EventLog]
-AddReg=Monitor_EventLog_AddReg
-
-[Monitor_EventLog_AddReg]
-HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
-HKR,,TypesSupported,0x00010001,7
-
 [Strings]
 
 Vendor="@VENDOR_NAME@"
diff --git a/vs2019/xencons_monitor/xencons_monitor.vcxproj b/vs2019/xencons_monitor/xencons_monitor.vcxproj
index 0bbf600..41424d5 100644
--- a/vs2019/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2019/xencons_monitor/xencons_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -50,29 +47,15 @@
     <ClCompile>
       <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
diff --git a/vs2022/xencons_monitor/xencons_monitor.vcxproj b/vs2022/xencons_monitor/xencons_monitor.vcxproj
index af0fbb4..e5e02b0 100644
--- a/vs2022/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2022/xencons_monitor/xencons_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -50,19 +47,10 @@
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:17:37 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:17:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281716.1564595 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci1-0007X3-04; Tue, 14 Apr 2026 12:17:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281716.1564595; Tue, 14 Apr 2026 12:17:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007WK-OF; Tue, 14 Apr 2026 12:17:36 +0000
Received: by outflank-mailman (input) for mailman id 1281716;
 Tue, 14 Apr 2026 12:17:35 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305c.v1-c2c5e515251a4e0b8aea05c9fb22037e@bounce.vates.tech>)
 id 1wCchz-0007Ue-Th
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:17:35 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCchz-00G5lH-AD
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:17:35 +0200
Received: from [10.42.69.1] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305c.v1-c2c5e515251a4e0b8aea05c9fb22037e@bounce.vates.tech>)
 id 69de3055-2eae-0a2a0a5409dd-0a2a4501c86c-32
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:35 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69de305c.v1-c2c5e515251a4e0b8aea05c9fb22037e@bounce.vates.tech>)
 id 69de305e-c1f2-0a2a45010019-c602bb0e047b-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:35 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw3F83n2Lz8XSCwX
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:32 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 c2c5e515251a4e0b8aea05c9fb22037e; Tue, 14 Apr 2026 12:17:32 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169052; x=1776439052;
	bh=W1ksXLcNRbjCp90eYDCNrcCRD+QZIq93FXJleqGGTsY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=MK6vwAJqR140PJT6DwD78e2JXpw+HYrG/Yz/krjvrtGNL3FxkqwTl2yj83QWyr8sL
	 csnV3qfCOq1HXLw1Itmbf4Hp/jbBg6mVvQmVOtVyzCCbVs19YBNlp3+PRXelDR3rRj
	 oojmy+rNnsavSPdRhDJlkgBQF8PayTlpH+Pdrp1/NxiLFpphxUU5t1fvWQXPj64lgY
	 pEyfql+RClHPGy0AtlUpEUmpXrdIBNm5BTckL5tVGa6TwrG2vDrifkz/riNHkW0v15
	 ElQVsD2S7iFKOORePimMls+CAK35B9bdcVrnixME9CiYJyulsa5OZdEYuMCiwx2tEd
	 H5j5/DUdXI7GQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169052; x=1776429552; i=ngoc-tu.dinh@vates.tech;
	bh=W1ksXLcNRbjCp90eYDCNrcCRD+QZIq93FXJleqGGTsY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=yZK2CYnnFsgLhp1R5Gwa6Dzd5wGv9z7Q8p9cMUGCQevth3BgQvS2jRgAvChTDPz7C
	 Th71TDFyObSDtoPc7zajUbBduSond/F/GZKRnwGdKSJ/BCJocwNbSJmjFaM78w1ilq
	 NlO37I5GKaL3ZLsT8tPqizvobT3VBVM8l0o2yio7+hh0Q+AB4lTGA+C6ip1zD01hi+
	 Cg2HaTQeMFf/niEJ8q0jYUmD0P9Btun1lMBO3EntKDvHxnNsfjYlwS4CRMG9/MBHI9
	 R/lwjIvl2Q2Iftiz3Ka3JlS+eqcLHv69jAubd2xWAtwhkVngw87czOmSlDaOdfXipr
	 hzx9G+2auwnMA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=206/6]=20Discover=20cmd.exe=20using=20GetSystemDirectory?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169051914
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414121727.668-7-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c2c5e515251a4e0b8aea05c9fb22037e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:32 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-d62444/1776169055-B5E6BFF4-CB02F8C8/0/0
X-purgate-type: clean
X-purgate-size: 1498

Don't assume that the system directory is always c:\windows\system32.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/tty/tty.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/tty/tty.c b/src/tty/tty.c
index 00ecb76..b8629d5 100644
--- a/src/tty/tty.c
+++ b/src/tty/tty.c
@@ -102,7 +102,8 @@ CreateChild(
     )
 {
     PTTY_CONTEXT            Context = &TtyContext;
-    CHAR                    CommandLine[] = "c:\\windows\\system32\\cmd.exe /q /a";
+    CHAR                    SystemDir[MAX_PATH];
+    CHAR                    CommandLine[MAX_PATH];
     PVOID                   Environment;
     PROFILEINFOA            ProfileInfo;
     DWORD                   Size;
@@ -110,6 +111,15 @@ CreateChild(
     STARTUPINFOA            StartupInfo;
     BOOL                    Success;
 
+    if (!GetSystemDirectoryA(SystemDir, sizeof(SystemDir)))
+        return FALSE;
+
+    if (!SUCCEEDED(StringCchPrintfA(CommandLine,
+                                    sizeof(CommandLine),
+                                    "%s\\cmd.exe /q /a",
+                                    SystemDir)))
+        return FALSE;
+
     Success = CreateEnvironmentBlock(&Environment,
                                      Context->Token,
                                      FALSE);
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:17:37 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:17:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281715.1564593 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007W6-Ux; Tue, 14 Apr 2026 12:17:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281715.1564593; Tue, 14 Apr 2026 12:17:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCci0-0007VU-KM; Tue, 14 Apr 2026 12:17:36 +0000
Received: by outflank-mailman (input) for mailman id 1281715;
 Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305c.v1-eb1a3ac0124e4bcca5b8a5bce8af72a4@bounce.vates.tech>)
 id 1wCchy-0007SU-Po
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:17:34 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCchy-008jPh-4d
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:17:34 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305c.v1-eb1a3ac0124e4bcca5b8a5bce8af72a4@bounce.vates.tech>)
 id 69de305b-e002-0a2a0a5209dd-0a2a450cad7a-8
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:34 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de305c.v1-eb1a3ac0124e4bcca5b8a5bce8af72a4@bounce.vates.tech>)
 id 69de305c-f40c-0a2a450c0019-c602bb0e9808-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:17:33 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fw3F82Tqyz8XT5mh
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:32 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 eb1a3ac0124e4bcca5b8a5bce8af72a4; Tue, 14 Apr 2026 12:17:32 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169052; x=1776439052;
	bh=j1IOumd57KKJ2ChF61/6PWErCjRtKfKfP+GrK9XHrwA=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=vC6Oe0VRHyrUYHllzTWneElI4R3Gk4ew09/54J68fE2AVM0GzD516ygBIEPCp/TuB
	 UCoXU84YBFNhmCDS8McshDWd2NZh/NODOWjFH/j7KDrR8BNsu/ub0zfooRJ4zJVy0N
	 hWB+DwW+plC2pkodDeII4XqOG3nZ/+6MJ+WAGaDIrQmZFFGQvO4Rni1vUIGWYzGlL4
	 jPeWKPrKu1TGNZzfMiGQU9eqBAIvJQEy0c4trjAUyT/Alf4fCigb1TKD7ugGjOPOV/
	 dnW7IKnQld/yHeOX0M6vcvxs4rR9z69ko6xncNIl9bk7M3k0PJ6+nCPcyBT7beLv0f
	 Q5uHZhaiATYrQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169052; x=1776429552; i=ngoc-tu.dinh@vates.tech;
	bh=j1IOumd57KKJ2ChF61/6PWErCjRtKfKfP+GrK9XHrwA=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=x0LV6Opfwy6PsRZoyewNVshBzm5hioe64oSjzjJTrzZhR9PaiRiKTgNJWUa5pYHoE
	 Qjv7xyqVfMX0FNY1LsLQzISUP31Mb9k7hGe5gwpeYmXccc7kC0Sdb8oXgkPfGQvAxx
	 iFbf/3BXZJpaOudfaWMBsACCzfcXOp47Bs4urJu/Qrr3OrVLFqBYkwQe3z1RreiVkE
	 SJfiobMSi/w9HClu/8XO6zi6Bg6R1BIV4SGG2uK15OMug9q0cnFUzF0veVNxgnCioS
	 Ol5wna8KabnZxbOOagU7/br9uYWdYhaIFIXiHkKntRWOyi0gtpNnQA8v3ZNTeZNPnO
	 EA+oDqtnKV1WQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=205/6]=20Use=20CHAR=20for=20pipe=20stream=20data?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169051691
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260414121727.668-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.eb1a3ac0124e4bcca5b8a5bce8af72a4?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:32 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-d25034/1776169053-80D5BA3D-38797864/0/0
X-purgate-type: clean
X-purgate-size: 9924

As the console pipe is a byte stream, it should not use UCHAR or TCHAR.

Also convert the relevant API calls that use stream data to their A
variant.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c |  8 ++--
 src/tty/tty.c         | 98 +++++++++++++++++++++----------------------
 2 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 3ff7d7c..cd58207 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -326,7 +326,7 @@ __RemoveEntryList(
 static VOID
 PutString(
     _In_ HANDLE     Handle,
-    _In_ PUCHAR     Buffer,
+    _In_ PCHAR      Buffer,
     _In_ DWORD      Length
     )
 {
@@ -350,7 +350,7 @@ PutString(
 }
 
 #define ECHO(_Handle, _Buffer) \
-    PutString((_Handle), (PUCHAR)_Buffer, (DWORD)strlen((_Buffer)) * sizeof(CHAR))
+    PutString((_Handle), _Buffer, (DWORD)strlen((_Buffer)))
 
 DWORD WINAPI
 ConnectionThread(
@@ -359,7 +359,7 @@ ConnectionThread(
 {
     PMONITOR_CONNECTION Connection = (PMONITOR_CONNECTION)Argument;
     PMONITOR_CONSOLE    Console = Connection->Console;
-    UCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
+    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
     OVERLAPPED          Overlapped;
     HANDLE              Handle[2];
     DWORD               Length;
@@ -583,7 +583,7 @@ DeviceThread(
     PMONITOR_CONSOLE    Console = (PMONITOR_CONSOLE)Argument;
     OVERLAPPED          Overlapped;
     HANDLE              Device;
-    UCHAR               Buffer[MAXIMUM_BUFFER_SIZE];
+    CHAR                Buffer[MAXIMUM_BUFFER_SIZE];
     DWORD               Length;
     DWORD               Wait;
     HANDLE              Handles[2];
diff --git a/src/tty/tty.c b/src/tty/tty.c
index 78214bd..00ecb76 100644
--- a/src/tty/tty.c
+++ b/src/tty/tty.c
@@ -51,7 +51,7 @@ typedef struct _TTY_CONTEXT {
     TTY_STREAM          ChildStdIn;
     TTY_STREAM          ChildStdOut;
     TTY_STREAM          Device;
-    TCHAR               UserName[MAXIMUM_BUFFER_SIZE];
+    CHAR                UserName[MAXIMUM_BUFFER_SIZE];
     HANDLE              Token;
     HANDLE              OriginalToken;
     PROCESS_INFORMATION ProcessInfo;
@@ -102,12 +102,12 @@ CreateChild(
     )
 {
     PTTY_CONTEXT            Context = &TtyContext;
-    TCHAR                   CommandLine[] = TEXT("c:\\windows\\system32\\cmd.exe /q /a");
+    CHAR                    CommandLine[] = "c:\\windows\\system32\\cmd.exe /q /a";
     PVOID                   Environment;
-    PROFILEINFO             ProfileInfo;
+    PROFILEINFOA            ProfileInfo;
     DWORD                   Size;
-    TCHAR                   ProfileDir[MAXIMUM_BUFFER_SIZE];
-    STARTUPINFO             StartupInfo;
+    CHAR                    ProfileDir[MAXIMUM_BUFFER_SIZE];
+    STARTUPINFOA            StartupInfo;
     BOOL                    Success;
 
     Success = CreateEnvironmentBlock(&Environment,
@@ -120,15 +120,15 @@ CreateChild(
     ProfileInfo.dwSize = sizeof (ProfileInfo);
     ProfileInfo.lpUserName = Context->UserName;
 
-    Success = LoadUserProfile(Context->Token, &ProfileInfo);
+    Success = LoadUserProfileA(Context->Token, &ProfileInfo);
     if (!Success)
         return FALSE;
 
     Size = sizeof (ProfileDir);
 
-    Success = GetUserProfileDirectory(Context->Token,
-                                      ProfileDir,
-                                      &Size);
+    Success = GetUserProfileDirectoryA(Context->Token,
+                                       ProfileDir,
+                                       &Size);
     if (!Success)
         return FALSE;
 
@@ -146,17 +146,17 @@ CreateChild(
     StartupInfo.dwFlags |= STARTF_USESTDHANDLES;
 
 #pragma warning(suppress:6335) // leaking handle information
-    Success = CreateProcessAsUser(Context->Token,
-                                  NULL,
-                                  CommandLine,
-                                  NULL,
-                                  NULL,
-                                  TRUE,
-                                  CREATE_UNICODE_ENVIRONMENT,
-                                  Environment,
-                                  ProfileDir,
-                                  &StartupInfo,
-                                  &Context->ProcessInfo);
+    Success = CreateProcessAsUserA(Context->Token,
+                                   NULL,
+                                   CommandLine,
+                                   NULL,
+                                   NULL,
+                                   TRUE,
+                                   CREATE_UNICODE_ENVIRONMENT,
+                                   Environment,
+                                   ProfileDir,
+                                   &StartupInfo,
+                                   &Context->ProcessInfo);
 
     DestroyEnvironmentBlock(Environment);
 
@@ -171,7 +171,7 @@ CreateChild(
 static VOID
 PutCharacter(
     _In_ PTTY_STREAM    Stream,
-    _In_ TCHAR          Character
+    _In_ CHAR           Character
     )
 {
     WriteFile(Stream->Write,
@@ -184,11 +184,11 @@ PutCharacter(
 static VOID
 PutString(
     _In_ PTTY_STREAM    Stream,
-    _In_ PTCHAR         Buffer,
+    _In_ PCHAR          Buffer,
     _In_ DWORD          Length
     )
 {
-    DWORD               Offset;
+    DWORD           Offset;
 
     Offset = 0;
     while (Offset < Length) {
@@ -208,12 +208,12 @@ PutString(
 }
 
 #define ECHO(_Stream, _Buffer) \
-    PutString((_Stream), TEXT(_Buffer), (DWORD)_tcslen(_Buffer))
+    PutString((_Stream), (_Buffer), (DWORD)strlen(_Buffer))
 
 static BOOL
 GetLine(
     _In_ PTTY_STREAM    Stream,
-    _In_ PTCHAR         Buffer,
+    _In_ PCHAR          Buffer,
     _In_ DWORD          NumberOfBytesToRead,
     _Out_ LPDWORD       NumberOfBytesRead,
     _In_ BOOL           NoEcho
@@ -224,8 +224,8 @@ GetLine(
 
     Offset = 0;
     while (Offset < NumberOfBytesToRead) {
-        TCHAR   Sequence[MAXIMUM_BUFFER_SIZE];
-        PTCHAR  Character;
+        CHAR    Sequence[MAXIMUM_BUFFER_SIZE];
+        PCHAR   Character;
         DWORD   Read;
 
         Success = ReadFile(Stream->Read,
@@ -287,20 +287,20 @@ GetLine(
 
 static BOOL
 GetCredentials(
-    _In_ PTCHAR     Password,
-    _In_ DWORD      PasswordSize
+    _Out_writes_z_(PasswordSize) PCHAR  Password,
+    _In_ DWORD                          PasswordSize
     )
 {
     PTTY_CONTEXT    Context = &TtyContext;
-    TCHAR           ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
-    PTCHAR          End;
+    CHAR            ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+    PCHAR           End;
     DWORD           Size;
     BOOL            Success;
 
     ZeroMemory(ComputerName, sizeof (ComputerName));
     Size = sizeof (ComputerName);
 
-    Success = GetComputerName(ComputerName, &Size);
+    Success = GetComputerNameA(ComputerName, &Size);
     if (!Success)
         return FALSE;
 
@@ -318,13 +318,13 @@ GetCredentials(
     if (!Success)
         return FALSE;
 
-    End = _tcschr(Context->UserName, TEXT('\r'));
+    End = strchr(Context->UserName, '\r');
     if (End == NULL)
         return FALSE;
 
-    *End = TEXT('\0');
+    *End = '\0';
 
-    if (_tcslen(Context->UserName) == 0)
+    if (strlen(Context->UserName) == 0)
         return FALSE;
 
     ECHO(&Context->Device, "Password: ");
@@ -339,7 +339,7 @@ GetCredentials(
     if (!Success)
         return FALSE;
 
-    End = _tcschr(Password, TEXT('\r'));
+    End = strchr(Password, TEXT('\r'));
     if (End == NULL)
         return FALSE;
 
@@ -356,8 +356,8 @@ RequestElevation(
     PTTY_CONTEXT            Context = &TtyContext;
     TOKEN_ELEVATION_TYPE    Elevation;
     DWORD                   Size;
-    TCHAR                   Buffer[MAXIMUM_BUFFER_SIZE];
-    PTCHAR                  End;
+    CHAR                    Buffer[MAXIMUM_BUFFER_SIZE];
+    PCHAR                   End;
     TOKEN_LINKED_TOKEN      LinkedToken;
     BOOL                    Success;
 
@@ -385,18 +385,18 @@ RequestElevation(
     if (!Success)
         return FALSE;
 
-    End = _tcschr(Buffer, TEXT('\r'));
+    End = strchr(Buffer, '\r');
     if (End == NULL)
         return FALSE;
 
-    *End = TEXT('\0');
+    *End = '\0';
 
-    if (_tcslen(Buffer) == 0)
+    if (strlen(Buffer) == 0)
         return FALSE;
 
     ECHO(&Context->Device, "\r\n");
 
-    if (_tcscmp(Buffer, TEXT("yes")) != 0)
+    if (strcmp(Buffer, "yes") != 0)
         return TRUE;
 
     Success = GetTokenInformation(Context->Token,
@@ -514,7 +514,7 @@ _tmain(
     PTTY_CONTEXT        Context = &TtyContext;
     SECURITY_ATTRIBUTES Attributes;
     HANDLE              Handle[3];
-    TCHAR               Password[MAXIMUM_BUFFER_SIZE];
+    CHAR                Password[MAXIMUM_BUFFER_SIZE];
     DWORD               Index;
     BOOL                Success;
 
@@ -555,12 +555,12 @@ _tmain(
     if (!Success)
         ExitProcess(1);
 
-    Success = LogonUser(Context->UserName,
-                        NULL,
-                        Password,
-                        LOGON32_LOGON_INTERACTIVE,
-                        LOGON32_PROVIDER_DEFAULT,
-                        &Context->Token);
+    Success = LogonUserA(Context->UserName,
+                         NULL,
+                         Password,
+                         LOGON32_LOGON_INTERACTIVE,
+                         LOGON32_PROVIDER_DEFAULT,
+                         &Context->Token);
 
     ZeroMemory(Password, sizeof(Password));
 
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 14 12:26:10 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 14 Apr 2026 12:26:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1281717.1564599 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcqH-0000LX-Ez; Tue, 14 Apr 2026 12:26:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1281717.1564599; Tue, 14 Apr 2026 12:26:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCcqH-0000LQ-CV; Tue, 14 Apr 2026 12:26:09 +0000
Received: by outflank-mailman (input) for mailman id 1281717;
 Tue, 14 Apr 2026 12:26:08 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69de305b.v1-051618a207284e8a954d74d14f159680@bounce.vates.tech>)
 id 1wCcqG-0000LK-0J
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 12:26:08 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCcqE-00G7Uu-3U
 for win-pv-devel@lists.xenproject.org; Tue, 14 Apr 2026 14:26:06 +0200
Received: from [10.42.69.4] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69de305b.v1-051618a207284e8a954d74d14f159680@bounce.vates.tech>)
 id 69de3249-5cb7-0a2a0a5109dd-0a2a4504ed76-46
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:26:05 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69de305b.v1-051618a207284e8a954d74d14f159680@bounce.vates.tech>)
 id 69de325c-bb33-0a2a45040019-c602bb01db81-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 14:26:05 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fw3F72bPYzBsXx5f
 for <win-pv-devel@lists.xenproject.org>; Tue, 14 Apr 2026 12:17:31 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 051618a207284e8a954d74d14f159680; Tue, 14 Apr 2026 12:17:31 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776169051; x=1776439051;
	bh=F2MPSCEMuKipo8ujAGqMUfEdbC/IXStUamTkIMdNr2Y=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=u2EM2soWH4kdT9IjhoVJKerNhSnp3ej1TZE+XT/RdN8eMDyG9Q97ABfA7eY2mhb0z
	 CU1uzJ98wuthkxwd1Sb9Sedmm1Rp1hBr7weZfnkChNgaEn3v7Ls53UP1kUw4JprZiG
	 LgN6zHn4gP8NJBSzMV5EzsLBhbd6zYZ8gzj11zbyOkq+B6ADgikebdDqOhPE5EPeqq
	 TijB2oxYXU/YawvQPLTyeHUSNQ3T8n7MszLkOv8E5LK+ahHAeyqAcCVrS1jGw8WgxZ
	 vxbtZ9FIycEVL1DSvbW2XUEd8wTvlsuUC8+m5ABwGyE8UP4XCChdhzZ7G5UNcRRoD7
	 odM3d+QF3cdVg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776169051; x=1776429551; i=ngoc-tu.dinh@vates.tech;
	bh=F2MPSCEMuKipo8ujAGqMUfEdbC/IXStUamTkIMdNr2Y=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=1Ns/sKmugNUKvPzg6QXQh/cHLsNUAoeFDUQSCLN4TwgMwz6NnY2a9I9CS9Yup2yov
	 BbWCjEJqBE+Ild0jcfpA72DsdT7hEA5tEVqQtTSFDLLw5ik5LXUzTIuKc1U04GEbVc
	 yYSF3W5DNcxChE+a7EFnpDkhTtPw+OlDQcSKp+9mbEZCDB4sdYtyyNapTTh4n5HXkn
	 96XUlewWmYSa/hU9sU+Hm2bC9PSF711VExYlqSNgaAXC3l19HEg9LPW7k2xlUyigF5
	 q1kcKIBMm0mmZyoPZBk+W7sABrKmsLY6PRU9o7i25VfIwlqodKc99GrQyFyc05n7OJ
	 tBCbcTagov/Nw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v2=201/6]=20Use=20RegCloseKey=20for=20ParametersKey?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776169050477
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>, "david ambu" <david.preetham@cloud.com>
Message-Id: <20260414121727.668-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.051618a207284e8a954d74d14f159680?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260414:md
Date: Tue, 14 Apr 2026 12:17:31 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-ebf023/1776169565-32F3E51B-8A785016/0/0
X-purgate-type: clean
X-purgate-size: 952

CloseHandle silently fails for HKEY.

Signed-off-by: david ambu <david.preetham@cloud.com>

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/monitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 772bbf4..b5e042a 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1509,7 +1509,7 @@ MonitorMain(
 
     (VOID) DeregisterEventSource(Context->EventLog);
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
     Log("<====");
 
@@ -1533,7 +1533,7 @@ fail3:
 fail2:
     Log("fail2");
 
-    CloseHandle(Context->ParametersKey);
+    RegCloseKey(Context->ParametersKey);
 
 fail1:
     Error = GetLastError();
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Apr 15 07:02:10 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 15 Apr 2026 07:02:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1282187.1564829 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCuGG-0001gi-Kh; Wed, 15 Apr 2026 07:02:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1282187.1564829; Wed, 15 Apr 2026 07:02:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCuGG-0001gb-He; Wed, 15 Apr 2026 07:02:08 +0000
Received: by outflank-mailman (input) for mailman id 1282187;
 Wed, 15 Apr 2026 07:02:07 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wCuGF-0001gV-C8
 for win-pv-devel@lists.xenproject.org; Wed, 15 Apr 2026 07:02:07 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCuGE-00BJia-5t
 for win-pv-devel@lists.xenproject.org; Wed, 15 Apr 2026 09:02:06 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69df37e8-e002-0a2a0a5209dd-0a2a4509c78e-32
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 09:02:06 +0200
Received: from [40.107.209.63]
 (helo=PH8PR06CU001.outbound.protection.outlook.com)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from <owen.smith@citrix.com>)
 id 69df37ec-bf79-0a2a45090019-286bd13f9371-4
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 09:02:05 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by BY5PR03MB5347.namprd03.prod.outlook.com (2603:10b6:a03:218::21)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.48; Wed, 15 Apr
 2026 07:02:01 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9769.046; Wed, 15 Apr 2026
 07:02:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=aIw8nJSz7YgcBtwwI317Ctk5KTab6AnTw4Xz458EXTPlKZHu2sh2MqhSJIujYG9b64yYzOazhGM09n5NfCMqE5QuO2AHc5DLfMzsaST7yDkQTZ4+4zKYKWt76lj41lSDkIg0uN4m8ZZqFaVTTKYu4r/BjAFwdrpHbvBf/jjCVuK+wHRc2rmu+0ic4bp3bkQUyB9EVaNgcytJHdPrvLq9N5dHquo2ol1qdaHFpCByJxzynBp3HvxQKGZhDTN/fT6Sg2CRk142mVljOUTNw3q1jG8KYPAspTVjsKREsr+DRTiuD2Qq3T69Od8GMB8giwFQuWoje+74mh0xE6PgHUw07w==
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=IL8Fht9KTjXEV/tvOw1bXkDRh0HT7mPr9x5gJJvtMmA=;
 b=cvIcsM1dl+x3jdJe9hnQ9a5AWuxB5TFsecjhpaXn9RTKtCn0dF7up/hNIk4diCFjZRSLCURMVwnA+aPLUrZmzpiaJqazC504LOnl8xjZ4DFa3/vyJLIrqLGn8fkstzYidrxVtLc2TZhuo4XnoxQ325Qfd2sq0/z6PiLySCPYp7IyTilbjT156QnhraiuPFQJR7ZL+3fn02AfQD307Q4n9GIP+sCIQzkDaIQNyyxDaMSxmd/LclbOXtQyl/3/FQgGPG8a5XbxkAEg3iDqn3Cbvxj71aLp0MBGlKCTI/6hFYHcqX4NXKs5WBa2zqNXyTiZhU/aEyo+uNB6CsqRKe3tQA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=IL8Fht9KTjXEV/tvOw1bXkDRh0HT7mPr9x5gJJvtMmA=;
 b=xucR7RsssHQiq18P0DI3o0FCQ71l8vJiDlYBjfn5P2DLHj4ogIgKuXleZbE1VHpaFqZ17itVaAlx4LNesSueiIbMRT6xV9+viOkKMfpS3Jyebd2Njc1vMsEsE1WUom292QkpC1Y+HLHoCYMGkeYE+kqQy6ug8f2STXMeTQHPieY=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 4/6] Delete xencons_monitor.dll
Thread-Topic: [PATCH v2 4/6] Delete xencons_monitor.dll
Thread-Index: AQHczAiuKr6K/i7YgkypQye1TRJHQ7Xfw2nI
Date: Wed, 15 Apr 2026 07:02:01 +0000
Message-ID:
 <SA6PR03MB776096243EDD3F062FD12E13FE222@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech>
 <20260414121727.668-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414121727.668-5-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|BY5PR03MB5347:EE_
x-ms-office365-filtering-correlation-id: c9d33bff-c53a-48dc-88c2-08de9abce4a2
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|366016|1800799024|376014|38070700021|56012099003|22082099003|18002099003;
x-microsoft-antispam-message-info:
 v8qcOxizlcejYdK82+PfCnVfh6POrYfv3v3KTWR09HlSf5UO6bYr41O1MSU2Rs11KLmrzeEc9jN9tAuNJsJonKp/A1DHKaE/UxPtz5k9ytsEZEUbcgMUqEMc95XqV32W/NCHQeWrFvOArhHpAG95FpUUSEiOTARFTsinlYRkf606I04LgM5ez68pwdpHX4VlrY40NGj4BLsef4lRop4lqJTkKQS0edCwPdpA82Xy4ETK9MLsNTfr+AxNOp8HnefGXnLeZN51QRxYf0c7Eynm9xS+PTG/S2HXuIolMxVk/tNWc8qbWJvfkJlbJmB4kmddMoGxG/WXdpRuzfSolW0mMpXak44WSvKqdySrxRGQuXYskzRRrJzyNmkrOPNx9n8XteXJCnPRSmEj9/oJfmKRZtGmh7q/RxwoSTp5bd1Xx8PecK+gtwkoWE1h22h7Mdy4317qbxLyZeNuDMcjM4obUYNSN0gA+OwL0OdTRL4YtBNr44tJ4QBaOjldw8QHXVdNobGKJfppgg82yrJBct13oxN3tQ16uKnbI6Ucwv8WLQl17S+mbiTVJpavLvZbQpEOeAGR1exKyADTzP/FC0zRc6u8RJZd4D9Dktbdf0R8P2yfaoO4xb542FraMKPq36FquEMUkNs+fwXgTNRiqSnkw9j7tlH8ze3wsF5YHho8Fiv3UDeDIJGh91eoeQGuOi3qiGPEwRowLVsSJWZ1lmLa7vAL0vXcImO5M+rdgzEqxzU=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(38070700021)(56012099003)(22082099003)(18002099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?4ILF7ZERA6soAK+82EoA0cJSb/60vSRcQvc6qljwG/C3gQgQ6fVLFSGAZm1w?=
 =?us-ascii?Q?4LPwh8C6g288IJIAZYp9V6iTMtD0CmuI1ZGegML8HmKSB/IGhKcZFEb4v1Qm?=
 =?us-ascii?Q?CvqXZeIxAUSeFLzhfp90XZZipS4r5KW49Dk/0J7UwbhtHMBxQ7Qc/7dars6w?=
 =?us-ascii?Q?sujPvOjRkwIAz7Sqe0UpF8AwOE2rWVSTfTsxWoCEcic4Kb2fqKeUFz27cfON?=
 =?us-ascii?Q?GAZyZ/XnMPy5KivqIUPIEHC22qgAf9E22SCF/cL5cjrY0MxIg6UlUmE1AXmO?=
 =?us-ascii?Q?Tkyhhs1HBekgtL1LcXQIpIMqasgq55/NYZFw3BGufNOAsaqGkf7EdMHNOmUr?=
 =?us-ascii?Q?pxivw+04U1p5bVB7ZI+Tztr2J37KswD7QgqjBRgf/707Cs5XlVpVnaAnNHyJ?=
 =?us-ascii?Q?C1pokG/3b9iSUZTOIulchr5neIrp1NaDJAMQvcx0SfpZFA/CCxrks95DeLiO?=
 =?us-ascii?Q?EGu4eIxw8UAECgLQmogWo5MzXMnkTeBqG2ivCR6pDZpf/0/mLtfa+wYhw0xX?=
 =?us-ascii?Q?Xe8BSDS4JuLgSuul4Wb9spQfyNy1WozFlzEb2BIiJerckdAb64JlfY0XZhSw?=
 =?us-ascii?Q?2x1SH/gTUXLRDBFCoD/SXJgO9kdmSQ6mdRq32P9plHMG3cNloas5UFzzcopI?=
 =?us-ascii?Q?zHi0CUWpDjnzDbUc0ylfAwcSxjNEoXnNpaRkDaxeZV/khrkqXNmjA79IBzXp?=
 =?us-ascii?Q?dtPqN/zgFkHVAFLS0C7NaUD8t1IJWCiR2TFmqTlD/GnA6b5WNJ3EfN9X1mFe?=
 =?us-ascii?Q?Pp1tBUI6BJsF+uEW/QiQEYIt6dJ8MKpjRPGg+NTFRjiS1RB0jZzlKOLq64ol?=
 =?us-ascii?Q?Y4Y2DMEXAq4I04X8bWmaOjwSKkbGsWCXBgQ6aYY2gT913Y2eeZblpuil0HI4?=
 =?us-ascii?Q?hufOc33DNfga8fbI9stLhNZ1VFuZxAPYfoFbC7Z7BjmELpJJm42FcrDBEGYv?=
 =?us-ascii?Q?tl5W9oTOt7YYe0C0l+ft6kSB+vXN0BIczz28sm9U/Iqvk4ssRY+XnbLR7I/w?=
 =?us-ascii?Q?n4pCwePXHDbHndTpjN9XEkQSbdWSZ4Nd+w+y9ffGS+nbu67Rz58FvN1kMnRM?=
 =?us-ascii?Q?83vH52y2fK7AgJRSsNw3oF6uWFcrzjVJha8E75OIM98uxaYZjsfSJ95faVQe?=
 =?us-ascii?Q?+cqXcqo8npCFB9LjIJ1deLiMvPr2i6fRWglj5F+3GlmLfyseTrqwKYXH2zRT?=
 =?us-ascii?Q?wlUXWrqRfNZTG1XQCnJZdUThrAiJXCxyIaOiq5qSKFKhA7L3WAfKJ3BbhGDL?=
 =?us-ascii?Q?HUHP6h+NfT8pIWhh3psNLXgXJO7ETIcMD7yZO/OgT0HF99wnCvybCpT2EZvP?=
 =?us-ascii?Q?HIqcy7mzKKs+sX5bOQWp2s/mm+CKuqJsLskK8wH6BqKEPyrmoRxj0uTc88EC?=
 =?us-ascii?Q?n6Ag6WtDcw6aqjZMnfE++h+GJyCQHTkX7Pm8J5gcM+R4bkhFFrxnShaaflYR?=
 =?us-ascii?Q?ySYi2bUuoHkLUrzmNakSFQGToVXMppLKBGujWRFS3P14SD7vtLkFckHoWw89?=
 =?us-ascii?Q?zMrxBTEVntnN/VnzPSAo+fYJTr/Ovay4f2MXxDxMnQu9tf+0Gf3/uWcm0vny?=
 =?us-ascii?Q?Ge7563peWUnfe3HclzWHju4afJJ3VXDHW75k9j3X1rqssHs4lWq5EMQ6MToo?=
 =?us-ascii?Q?WNFKqCcIi1DCxDvS4MFd495aRkjGlMHtjGwzD1glQHoWQyOCi9ZPPe4boZ8U?=
 =?us-ascii?Q?6e5cCdfuwsK1Ch0MsCN0lU2WPQ0NmvQS+tKoIiNC4tByvRH4Xl69AKjpStC4?=
 =?us-ascii?Q?xgtWf2KL4A=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: c9d33bff-c53a-48dc-88c2-08de9abce4a2
X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2026 07:02:01.2846
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: HMn7bRu81vrV0dxN4uX3HG+7aR1CJycAKa01gLUNkMIVmnKoz+6SiRF0k5EyQsHwOm7+bu5zvIz3mkWsQNFopw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR03MB5347
X-purgate-ID: tlsNG-bad1c0/1776236526-2F941152-C8107279/0/0
X-purgate-type: clean
X-purgate-size: 9507

There is a minor issue applying this patch - the vcxproj chunks dont apply =
as the
" <SpectreMitigation>Spectre</SpectreMitigation>" entries are not in the cu=
rrent
files. Removing this line an adjusting the patch indexes resolves this, but=
 this may
show a missing patch (did I miss a patch where this line was added? does th=
ere
need to be a patch to add SpectreMitigations before this series? should thi=
s patch
be reworked?)

Owen

________________________________________
From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of=
 Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 14 April 2026 1:17 PM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH v2 4/6] Delete xencons_monitor.dll

Now that trace logging is used, the DLL is not needed any more. Remove
it from the build and package.

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/monitor/messages.mc                       | 55 -------------------
 src/monitor/monitor.c                         |  2 -
 src/monitor/xencons_monitor.rc                |  1 -
 src/xencons.inf                               | 11 +---
 .../xencons_monitor/xencons_monitor.vcxproj   | 17 ------
 .../xencons_monitor/xencons_monitor.vcxproj   | 12 ----
 6 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 src/monitor/messages.mc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
deleted file mode 100644
index eb1d382..0000000
--- a/src/monitor/messages.mc
+++ /dev/null
@@ -1,55 +0,0 @@
-; // Copyright (c) Xen Project.
-; // Copyright (c) Cloud Software Group, Inc.
-; // All rights reserved.
-; //
-; // Redistribution and use in source and binary forms,
-; // with or without modification, are permitted provided
-; // that the following conditions are met:
-; //
-; // *   Redistributions of source code must retain the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer.
-; // *   Redistributions in binary form must reproduce the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer in the documentation and/or other
-; //     materials provided with the distribution.
-; //
-; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-; // SUCH DAMAGE.
-
-MessageIdTypedef=3DDWORD
-
-SeverityNames=3D(
-       Success=3D0x0:STATUS_SEVERITY_SUCCESS
-       Informational=3D0x1:STATUS_SEVERITY_INFORMATIONAL
-       Warning=3D0x2:STATUS_SEVERITY_WARNING
-       Error=3D0x3:STATUS_SEVERITY_ERROR
-       )
-
-
-FacilityNames=3D(
-       System=3D0x0:FACILITY_SYSTEM
-       Runtime=3D0x2:FACILITY_RUNTIME
-       Stubs=3D0x3:FACILITY_STUBS
-       Io=3D0x4:FACILITY_IO_ERROR_CODE
-       )
-
-MessageId=3D0x1
-Severity=3DInformational
-Facility=3DSystem
-SymbolicName=3DMONITOR_LOG
-Language=3DEnglish
-%1
-.
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 78d67e1..3ff7d7c 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -50,8 +50,6 @@
 #include <xencons_device.h>
 #include <version.h>

-#include "messages.h"
-
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
 #define __MODULE__ stringify(PROJECT)
diff --git a/src/monitor/xencons_monitor.rc b/src/monitor/xencons_monitor.r=
c
index 3fba041..6c077f8 100644
--- a/src/monitor/xencons_monitor.rc
+++ b/src/monitor/xencons_monitor.rc
@@ -54,4 +54,3 @@
 #define VER_FILESUBTYPE                    VFT2_UNKNOWN

 #include "common.ver"
-#include "messages.rc"
diff --git a/src/xencons.inf b/src/xencons.inf
index 6bbd83b..6f9b361 100644
--- a/src/xencons.inf
+++ b/src/xencons.inf
@@ -51,12 +51,10 @@ Tty_CopyFiles=3D11
 [SourceDisksFiles]
 xencons.sys=3D0,,
 xencons_monitor.exe=3D0,,
-xencons_monitor.dll=3D0,,
 xencons_tty.exe=3D0,,

 [Monitor_CopyFiles]
 xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUM=
BER@.exe,xencons_monitor.exe
-xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUM=
BER@.dll,xencons_monitor.dll

 [Tty_CopyFiles]
 xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@=
.exe,xencons_tty.exe
@@ -81,7 +79,7 @@ FeatureScore=3D0xFE
 xencons.sys

 [XenCons_Inst.Services]
-AddService=3Dxencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Mon=
itor_EventLog
+AddService=3Dxencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
 AddService=3Dxencons,%SPSVCINST_ASSOCSERVICE%,XenCons_Service

 [XenCons_Service]
@@ -109,13 +107,6 @@ AddReg =3D Monitor_Parameters
 HKR,"Parameters",,0x00000010
 HKR,"Parameters\default","Executable",0x00000000,"xencons_tty_@MAJOR_VERSI=
ON@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe"

-[Monitor_EventLog]
-AddReg=3DMonitor_EventLog_AddReg
-
-[Monitor_EventLog_AddReg]
-HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xencons_monitor_=
@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
-HKR,,TypesSupported,0x00010001,7
-
 [Strings]

 Vendor=3D"@VENDOR_NAME@"
diff --git a/vs2019/xencons_monitor/xencons_monitor.vcxproj b/vs2019/xencon=
s_monitor/xencons_monitor.vcxproj
index 0bbf600..41424d5 100644
--- a/vs2019/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2019/xencons_monitor/xencons_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalI=
ncludeDirectories)</AdditionalIncludeDirectories>
@@ -50,29 +47,15 @@
     <ClCompile>
       <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</Prepro=
cessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</=
Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition=3D"'$(Platform)'=3D=3D'x64'">
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</Prep=
rocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</=
Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include=3D"$(TargetPath)" />
     <FilesToPackage Include=3D"$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include=3D"$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include=3D"..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include=3D"..\..\src\monitor\monitor.c" />
diff --git a/vs2022/xencons_monitor/xencons_monitor.vcxproj b/vs2022/xencon=
s_monitor/xencons_monitor.vcxproj
index af0fbb4..e5e02b0 100644
--- a/vs2022/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2022/xencons_monitor/xencons_monitor.vcxproj
@@ -18,9 +18,6 @@
     <EnableInf2cat>false</EnableInf2cat>
     <SpectreMitigation>Spectre</SpectreMitigation>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalI=
ncludeDirectories)</AdditionalIncludeDirectories>
@@ -50,19 +47,10 @@
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</Prep=
rocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</=
Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include=3D"$(TargetPath)" />
     <FilesToPackage Include=3D"$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include=3D"$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include=3D"..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include=3D"..\..\src\monitor\monitor.c" />
--
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Wed Apr 15 07:19:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 15 Apr 2026 07:19:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1282189.1564839 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCuXL-0002zN-V6; Wed, 15 Apr 2026 07:19:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1282189.1564839; Wed, 15 Apr 2026 07:19:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCuXL-0002z7-PJ; Wed, 15 Apr 2026 07:19:47 +0000
Received: by outflank-mailman (input) for mailman id 1282189;
 Wed, 15 Apr 2026 07:19:46 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69df39f5.v1-e0c47d20aef2438e8c39fc684648fc73@bounce.vates.tech>)
 id 1wCuXK-0002yS-BW
 for win-pv-devel@lists.xenproject.org; Wed, 15 Apr 2026 07:19:46 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCuXH-00DhH0-Oa
 for win-pv-devel@lists.xenproject.org; Wed, 15 Apr 2026 09:19:43 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69df39f5.v1-e0c47d20aef2438e8c39fc684648fc73@bounce.vates.tech>)
 id 69df3c03-2eae-0a2a0a5409dd-0a2a4502c98c-40
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 09:19:43 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69df39f5.v1-e0c47d20aef2438e8c39fc684648fc73@bounce.vates.tech>)
 id 69df3c0e-42fa-0a2a45020019-c602bb01cd52-3
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 09:19:43 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fwXNj1Fj1zBsZ6wq
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 07:10:45 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 e0c47d20aef2438e8c39fc684648fc73; Wed, 15 Apr 2026 07:10:45 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776237045; x=1776507045;
	bh=bji//xMtddN/BqmD+CWzujOZJBvDqygB6KM0J8O3sQE=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=sdUGnw4xRaGIkCwGqsrOS6CwFRSbGX5BFI8jflUWMDgHjzoztoyHHaBFos7wpJI+o
	 O1Ei7dgQEjWn29som43x4X+C8GDITcbLvGABjq+IZcsUYbQaRNunc0To7FNzLjc6HZ
	 twCYpN1gR7ZsCZlGNSKtS4OjL8oCDCSMTYan4qCfk6Ie7dbWZJgFtOnApnsUIgHW1k
	 3N7XwldQbJt4skIaeYCQN6VppSLuWcdbGbnB/d4oWPPAb1XJglV8sKxPu3e/2ywnEX
	 qm3LJ+bWUMQNq7SQS5IaPNi3pJpbjHUiSttlJpPh8ZMuMevsBhJV83UuNOuNDv7mC6
	 k85HllwfV2EkA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776237045; x=1776497545; i=ngoc-tu.dinh@vates.tech;
	bh=bji//xMtddN/BqmD+CWzujOZJBvDqygB6KM0J8O3sQE=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=mT+pFny3sBY9xdgh8jyVjnW1BMZEkMUJBlFa/jdyowHjJr0OnOMu9aOHfANktvHUZ
	 M9c8bDgFocMdUp9o/6rdkU0/gMDT/JFvJEK2F+k+ocEjAIWzBVSHXNYHj33e+rH1uD
	 QcWARwnCjNKkj6rcQ9IJobrtSncuKQGjM4tWcw7MJwYPQWMBpEYAfyMAn3L08SvDgY
	 NKrikMaXjkUYKEeKu/YcMazfv+yZz5R9O3gIX8drbt8+BbweIZko4Cx0sGhnJHieCz
	 EWS9MzNRah2q66yPSoF6L/ZarBNCwFuEdlIeksmO1EmNvDQRO7u7VwWSKlwtdk3HIH
	 UvdBEKrHEMPDA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=20v2=204/6]=20Delete=20xencons=5Fmonitor.dll?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776237044339
Message-Id: <43ee6cfa-3599-437a-9252-5f20c9a1b9df@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260414121727.668-1-ngoc-tu.dinh@vates.tech> <20260414121727.668-5-ngoc-tu.dinh@vates.tech> <SA6PR03MB776096243EDD3F062FD12E13FE222@SA6PR03MB7760.namprd03.prod.outlook.com>
In-Reply-To: <SA6PR03MB776096243EDD3F062FD12E13FE222@SA6PR03MB7760.namprd03.prod.outlook.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.e0c47d20aef2438e8c39fc684648fc73?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260415:md
Date: Wed, 15 Apr 2026 07:10:45 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-720697/1776237583-4573DCD1-4B91A34F/0/0
X-purgate-type: clean
X-purgate-size: 10142

On 15/04/2026 09:02, Owen Smith wrote:
> There is a minor issue applying this patch - the vcxproj chunks dont apply as the
> " <SpectreMitigation>Spectre</SpectreMitigation>" entries are not in the current
> files. Removing this line an adjusting the patch indexes resolves this, but this may
> show a missing patch (did I miss a patch where this line was added? does there
> need to be a patch to add SpectreMitigations before this series? should this patch
> be reworked?)
> 
> Owen
> 

My bad, it's a local patch I had. I'll resend shortly.

> ________________________________________
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of Tu Dinh <ngoc-tu.dinh@vates.tech>
> Sent: 14 April 2026 1:17 PM
> To: win-pv-devel@lists.xenproject.org
> Cc: Tu Dinh; Owen Smith
> Subject: [PATCH v2 4/6] Delete xencons_monitor.dll
> 
> Now that trace logging is used, the DLL is not needed any more. Remove
> it from the build and package.
> 
> Ported from Xenbus.
> 
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/messages.mc                       | 55 -------------------
>   src/monitor/monitor.c                         |  2 -
>   src/monitor/xencons_monitor.rc                |  1 -
>   src/xencons.inf                               | 11 +---
>   .../xencons_monitor/xencons_monitor.vcxproj   | 17 ------
>   .../xencons_monitor/xencons_monitor.vcxproj   | 12 ----
>   6 files changed, 1 insertion(+), 97 deletions(-)
>   delete mode 100644 src/monitor/messages.mc
> 
> diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
> deleted file mode 100644
> index eb1d382..0000000
> --- a/src/monitor/messages.mc
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -; // Copyright (c) Xen Project.
> -; // Copyright (c) Cloud Software Group, Inc.
> -; // All rights reserved.
> -; //
> -; // Redistribution and use in source and binary forms,
> -; // with or without modification, are permitted provided
> -; // that the following conditions are met:
> -; //
> -; // *   Redistributions of source code must retain the above
> -; //     copyright notice, this list of conditions and the
> -; //     following disclaimer.
> -; // *   Redistributions in binary form must reproduce the above
> -; //     copyright notice, this list of conditions and the
> -; //     following disclaimer in the documentation and/or other
> -; //     materials provided with the distribution.
> -; //
> -; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> -; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
> -; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> -; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> -; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> -; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> -; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> -; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> -; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> -; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> -; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> -; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> -; // SUCH DAMAGE.
> -
> -MessageIdTypedef=DWORD
> -
> -SeverityNames=(
> -       Success=0x0:STATUS_SEVERITY_SUCCESS
> -       Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
> -       Warning=0x2:STATUS_SEVERITY_WARNING
> -       Error=0x3:STATUS_SEVERITY_ERROR
> -       )
> -
> -
> -FacilityNames=(
> -       System=0x0:FACILITY_SYSTEM
> -       Runtime=0x2:FACILITY_RUNTIME
> -       Stubs=0x3:FACILITY_STUBS
> -       Io=0x4:FACILITY_IO_ERROR_CODE
> -       )
> -
> -MessageId=0x1
> -Severity=Informational
> -Facility=System
> -SymbolicName=MONITOR_LOG
> -Language=English
> -%1
> -.
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 78d67e1..3ff7d7c 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -50,8 +50,6 @@
>   #include <xencons_device.h>
>   #include <version.h>
> 
> -#include "messages.h"
> -
>   #define stringify_literal(_text) #_text
>   #define stringify(_text) stringify_literal(_text)
>   #define __MODULE__ stringify(PROJECT)
> diff --git a/src/monitor/xencons_monitor.rc b/src/monitor/xencons_monitor.rc
> index 3fba041..6c077f8 100644
> --- a/src/monitor/xencons_monitor.rc
> +++ b/src/monitor/xencons_monitor.rc
> @@ -54,4 +54,3 @@
>   #define VER_FILESUBTYPE                    VFT2_UNKNOWN
> 
>   #include "common.ver"
> -#include "messages.rc"
> diff --git a/src/xencons.inf b/src/xencons.inf
> index 6bbd83b..6f9b361 100644
> --- a/src/xencons.inf
> +++ b/src/xencons.inf
> @@ -51,12 +51,10 @@ Tty_CopyFiles=11
>   [SourceDisksFiles]
>   xencons.sys=0,,
>   xencons_monitor.exe=0,,
> -xencons_monitor.dll=0,,
>   xencons_tty.exe=0,,
> 
>   [Monitor_CopyFiles]
>   xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_monitor.exe
> -xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xencons_monitor.dll
> 
>   [Tty_CopyFiles]
>   xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_tty.exe
> @@ -81,7 +79,7 @@ FeatureScore=0xFE
>   xencons.sys
> 
>   [XenCons_Inst.Services]
> -AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Monitor_EventLog
> +AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
>   AddService=xencons,%SPSVCINST_ASSOCSERVICE%,XenCons_Service
> 
>   [XenCons_Service]
> @@ -109,13 +107,6 @@ AddReg = Monitor_Parameters
>   HKR,"Parameters",,0x00000010
>   HKR,"Parameters\default","Executable",0x00000000,"xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe"
> 
> -[Monitor_EventLog]
> -AddReg=Monitor_EventLog_AddReg
> -
> -[Monitor_EventLog_AddReg]
> -HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
> -HKR,,TypesSupported,0x00010001,7
> -
>   [Strings]
> 
>   Vendor="@VENDOR_NAME@"
> diff --git a/vs2019/xencons_monitor/xencons_monitor.vcxproj b/vs2019/xencons_monitor/xencons_monitor.vcxproj
> index 0bbf600..41424d5 100644
> --- a/vs2019/xencons_monitor/xencons_monitor.vcxproj
> +++ b/vs2019/xencons_monitor/xencons_monitor.vcxproj
> @@ -18,9 +18,6 @@
>       <EnableInf2cat>false</EnableInf2cat>
>       <SpectreMitigation>Spectre</SpectreMitigation>
>     </PropertyGroup>
> -  <PropertyGroup>
> -    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
> -  </PropertyGroup>
>     <ItemDefinitionGroup>
>       <ClCompile>
>         <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
> @@ -50,29 +47,15 @@
>       <ClCompile>
>         <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName).res</Inputs>
> -      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
>       <ClCompile>
>         <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName).res</Inputs>
> -      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemGroup>
>       <FilesToPackage Include="$(TargetPath)" />
>       <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
> -    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
> -  </ItemGroup>
> -  <ItemGroup>
> -    <MessageCompile Include="..\..\src\monitor\messages.mc" />
>     </ItemGroup>
>     <ItemGroup>
>       <ClCompile Include="..\..\src\monitor\monitor.c" />
> diff --git a/vs2022/xencons_monitor/xencons_monitor.vcxproj b/vs2022/xencons_monitor/xencons_monitor.vcxproj
> index af0fbb4..e5e02b0 100644
> --- a/vs2022/xencons_monitor/xencons_monitor.vcxproj
> +++ b/vs2022/xencons_monitor/xencons_monitor.vcxproj
> @@ -18,9 +18,6 @@
>       <EnableInf2cat>false</EnableInf2cat>
>       <SpectreMitigation>Spectre</SpectreMitigation>
>     </PropertyGroup>
> -  <PropertyGroup>
> -    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
> -  </PropertyGroup>
>     <ItemDefinitionGroup>
>       <ClCompile>
>         <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
> @@ -50,19 +47,10 @@
>       <ClCompile>
>         <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName).res</Inputs>
> -      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemGroup>
>       <FilesToPackage Include="$(TargetPath)" />
>       <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
> -    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
> -  </ItemGroup>
> -  <ItemGroup>
> -    <MessageCompile Include="..\..\src\monitor\messages.mc" />
>     </ItemGroup>
>     <ItemGroup>
>       <ClCompile Include="..\..\src\monitor\monitor.c" />
> --
> 2.53.0.windows.2
> 
> 
> 
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
> 
> 
> 



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Apr 15 07:19:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 15 Apr 2026 07:19:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1282188.1564832 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCuXL-0002z2-Qn; Wed, 15 Apr 2026 07:19:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1282188.1564832; Wed, 15 Apr 2026 07:19:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wCuXL-0002yv-Nv; Wed, 15 Apr 2026 07:19:47 +0000
Received: by outflank-mailman (input) for mailman id 1282188;
 Wed, 15 Apr 2026 07:19:46 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69df3a09.v1-9eb6ab234b7f49c09abe2995d866151c@bounce.vates.tech>)
 id 1wCuXK-0002yk-BW
 for win-pv-devel@lists.xenproject.org; Wed, 15 Apr 2026 07:19:46 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wCuXI-00DhH0-JC
 for win-pv-devel@lists.xenproject.org; Wed, 15 Apr 2026 09:19:44 +0200
Received: from [10.42.69.7] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69df3a09.v1-9eb6ab234b7f49c09abe2995d866151c@bounce.vates.tech>)
 id 69df3c0c-2eae-0a2a0a5409dd-0a2a4507a162-28
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 09:19:44 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0)
 (envelope-from
 <bounce-md_30504962.69df3a09.v1-9eb6ab234b7f49c09abe2995d866151c@bounce.vates.tech>)
 id 69df3c0f-ba2d-0a2a45070019-c602bb01a61e-3
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 09:19:44 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fwXP56zPyzBsZ6xL
 for <win-pv-devel@lists.xenproject.org>; Wed, 15 Apr 2026 07:11:05 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 9eb6ab234b7f49c09abe2995d866151c; Wed, 15 Apr 2026 07:11:05 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776237066; x=1776507066;
	bh=Z18ieqbwC1ARQMA8uy7WzIDBt9Mn2E1HaNd1mqZ5jLQ=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=C6gIbM2lqs7Vbj5wjGwPYootY4D6FjLpTUTdRZadhLon0+Xg0HQqK07r8y7nEAFLY
	 0cxYQG7vhqjySVqFxLKi9h9YRCIziqZnS8TkRrzHk5iW2z+mGNRDFeKb7+0jQcFrfA
	 vWlmChNGIng1X5NDrnG5OWDXr/rdBQS2M2e+hsxQSc1f8rPRSwEH+bv69KplP2DmMR
	 GnE33qRpb1sPfcSNGgIpfyelvgYimg9/+jUKgDgU8VbdOFUQr4wHzb00R350V+N95u
	 3HLDeCWMV5U9GnSuXxhSP5S6s4bwjHOp6Lv6WJveF3cSioab4SA+PYdwKdbdp1IgYI
	 /XvRhyKVKzC5Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776237066; x=1776497566; i=ngoc-tu.dinh@vates.tech;
	bh=Z18ieqbwC1ARQMA8uy7WzIDBt9Mn2E1HaNd1mqZ5jLQ=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=GmJWHr+8NNtqYswf4bLsO4w6zheyncpWIkFfmQalT3xERxWvcLupe066dIE0dyr/E
	 o6FbbkhL4JGqu6mdaDPkkvRQddVKnxK3x1vSeZ82hiPD2Kr4YoMu8vQnd3sH8go5CU
	 W9UxW6gF+XLPcTKiubq0V7YMNVaWgCJ+eADVA7oA0s9juYrnB/0LA631JHXBjDTAQ4
	 gORlEDthicbmrr4HgGJbpkXsuvJj8zEBlycvMB/aSC8YX7XXcRmyJ/+sGbey4iZIy9
	 aIwbp+JDNGkICDmvA+AWixOr7ldTuXxG82Y6z4qWo/nZgmCkDznpJmpOo/OsaZ/qnb
	 q2cwdd4cHZY5g==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=20v3=204/6]=20Delete=20xencons=5Fmonitor.dll?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776237065324
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260415071102.1782-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <SA6PR03MB776096243EDD3F062FD12E13FE222@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <SA6PR03MB776096243EDD3F062FD12E13FE222@SA6PR03MB7760.namprd03.prod.outlook.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.9eb6ab234b7f49c09abe2995d866151c?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260415:md
Date: Wed, 15 Apr 2026 07:11:05 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-ef75cf/1776237584-11F5641E-00E97704/0/0
X-purgate-type: clean
X-purgate-size: 8558

Now that trace logging is used, the DLL is not needed any more. Remove
it from the build and package.

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v3: Rebase against upstream
---
 src/monitor/messages.mc                       | 55 -------------------
 src/monitor/monitor.c                         |  2 -
 src/monitor/xencons_monitor.rc                |  1 -
 src/xencons.inf                               | 11 +---
 .../xencons_monitor/xencons_monitor.vcxproj   | 17 ------
 .../xencons_monitor/xencons_monitor.vcxproj   | 12 ----
 6 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 src/monitor/messages.mc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
deleted file mode 100644
index eb1d382..0000000
--- a/src/monitor/messages.mc
+++ /dev/null
@@ -1,55 +0,0 @@
-; // Copyright (c) Xen Project.
-; // Copyright (c) Cloud Software Group, Inc.
-; // All rights reserved.
-; //
-; // Redistribution and use in source and binary forms,
-; // with or without modification, are permitted provided
-; // that the following conditions are met:
-; //
-; // *   Redistributions of source code must retain the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer.
-; // *   Redistributions in binary form must reproduce the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer in the documentation and/or other
-; //     materials provided with the distribution.
-; //
-; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-; // SUCH DAMAGE.
-
-MessageIdTypedef=DWORD
-
-SeverityNames=(
-	Success=0x0:STATUS_SEVERITY_SUCCESS
-	Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
-	Warning=0x2:STATUS_SEVERITY_WARNING
-	Error=0x3:STATUS_SEVERITY_ERROR
-	)
-
-
-FacilityNames=(
-	System=0x0:FACILITY_SYSTEM
-	Runtime=0x2:FACILITY_RUNTIME
-	Stubs=0x3:FACILITY_STUBS
-	Io=0x4:FACILITY_IO_ERROR_CODE
-	)
-
-MessageId=0x1
-Severity=Informational
-Facility=System
-SymbolicName=MONITOR_LOG
-Language=English
-%1
-.
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 78d67e1..3ff7d7c 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -50,8 +50,6 @@
 #include <xencons_device.h>
 #include <version.h>

-#include "messages.h"
-
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
 #define __MODULE__ stringify(PROJECT)
diff --git a/src/monitor/xencons_monitor.rc b/src/monitor/xencons_monitor.rc
index 3fba041..6c077f8 100644
--- a/src/monitor/xencons_monitor.rc
+++ b/src/monitor/xencons_monitor.rc
@@ -54,4 +54,3 @@
 #define VER_FILESUBTYPE		    VFT2_UNKNOWN

 #include "common.ver"
-#include "messages.rc"
diff --git a/src/xencons.inf b/src/xencons.inf
index 6bbd83b..6f9b361 100644
--- a/src/xencons.inf
+++ b/src/xencons.inf
@@ -51,12 +51,10 @@ Tty_CopyFiles=11
 [SourceDisksFiles]
 xencons.sys=0,,
 xencons_monitor.exe=0,,
-xencons_monitor.dll=0,,
 xencons_tty.exe=0,,

 [Monitor_CopyFiles]
 xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_monitor.exe
-xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll,xencons_monitor.dll

 [Tty_CopyFiles]
 xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,xencons_tty.exe
@@ -81,7 +79,7 @@ FeatureScore=0xFE
 xencons.sys

 [XenCons_Inst.Services]
-AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Monitor_EventLog
+AddService=xencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
 AddService=xencons,%SPSVCINST_ASSOCSERVICE%,XenCons_Service

 [XenCons_Service]
@@ -109,13 +107,6 @@ AddReg = Monitor_Parameters
 HKR,"Parameters",,0x00000010
 HKR,"Parameters\default","Executable",0x00000000,"xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe"

-[Monitor_EventLog]
-AddReg=Monitor_EventLog_AddReg
-
-[Monitor_EventLog_AddReg]
-HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
-HKR,,TypesSupported,0x00010001,7
-
 [Strings]

 Vendor="@VENDOR_NAME@"
diff --git a/vs2019/xencons_monitor/xencons_monitor.vcxproj b/vs2019/xencons_monitor/xencons_monitor.vcxproj
index ca1da4e..d0a601c 100644
--- a/vs2019/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2019/xencons_monitor/xencons_monitor.vcxproj
@@ -17,9 +17,6 @@
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -49,29 +46,15 @@
     <ClCompile>
       <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
diff --git a/vs2022/xencons_monitor/xencons_monitor.vcxproj b/vs2022/xencons_monitor/xencons_monitor.vcxproj
index 58e881d..66754d3 100644
--- a/vs2022/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2022/xencons_monitor/xencons_monitor.vcxproj
@@ -17,9 +17,6 @@
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -49,19 +46,10 @@
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include="$(TargetPath)" />
     <FilesToPackage Include="$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include="$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include="..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\monitor\monitor.c" />
--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:10:04 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:10:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283224.1565496 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbk-0001hD-4C; Thu, 16 Apr 2026 11:10:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283224.1565496; Thu, 16 Apr 2026 11:10:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbj-0001gs-TD; Thu, 16 Apr 2026 11:10:03 +0000
Received: by outflank-mailman (input) for mailman id 1283224;
 Thu, 16 Apr 2026 11:10:02 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c388.v1-450ba9d4f0d546f0af38db60f6db048e@bounce.vates.tech>)
 id 1wDKbi-0001My-KJ
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:10:02 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDKbg-00DmhJ-Dg
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:10:02 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c388.v1-450ba9d4f0d546f0af38db60f6db048e@bounce.vates.tech>)
 id 69e0c381-2eae-0a2a0a5409dd-0a2a4502bab4-28
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:01 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c388.v1-450ba9d4f0d546f0af38db60f6db048e@bounce.vates.tech>)
 id 69e0c388-af86-0a2a45020019-c602ba01f447-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:01 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfJ0RGkzBsV4fQ
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:00 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 450ba9d4f0d546f0af38db60f6db048e; Thu, 16 Apr 2026 11:10:00 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337800; x=1776607800;
	bh=QYX5yif5lYHeXfFxhkn4BqOpHeKuavEzQNRXLpgv1Qs=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=aNWgcxxeznhaoE6fWUqOlm6YiNoCXDjpTX97nMbF0WCGv7vGAAN/2lxawHt1fEbUn
	 uG2+YpO3Jw1Z56p/GA0Tl+xJy5OZEftL68m81JMJFC1na4LoeRmALMmOnUiX3u14Qz
	 QmqVMJ2ZHZZzIasuni0byvY1rWnqFEeCv+XhKLiyT5f+1F1hBo59iBTDVOQCoBPtAQ
	 wtBrJc8QOzcRNzzFAOeyXFwEz/dCSZ+xvU57rGb7MAA0T97XGpz09tXBdhM8Rw9qPz
	 72a0ddsxdCgZXnAAed8gqsDp2zGEmL2OAZ4mFuGNccQ77u+WOaqutpMsHoRcz90wXR
	 s6c8tzKEr4wbQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337800; x=1776598300; i=ngoc-tu.dinh@vates.tech;
	bh=QYX5yif5lYHeXfFxhkn4BqOpHeKuavEzQNRXLpgv1Qs=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=HEbRjSyO52jTUIFCsQTcmXtqt7Z5ZD4czRIMdDonJIfNxfBr01mUcyA7wlmqS987j
	 K3weFImrucbq10l74LXFcuGRlKIklUbXgL6hY41bApeMhHIzVzQiBXdbx05MeXfjet
	 iwfuaqftCUG4zpGIbuC6H8Gi8VbGGqmTZehg76o5I5MLHQM84f/c2hrju+rm/d849t
	 v9EA+tFRLeQ9F19mQqJhwvvhJYtV/QLdisuaR2PkTVjP8Tf2qxIQvUd/PcErPwHWBN
	 7bNaTT9hdD6BhdQMKQFqNaTDZYyb46DNFyZ4o9vdxeOlxbYCAJDkg0MAJBjz9QXepj
	 5m0C4CdLT1xGA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=201/5]=20Check=20Fragment->Entry=20before=20calling=20RevokeForeignAccess?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337799403
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416110952.355-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.450ba9d4f0d546f0af38db60f6db048e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:00 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-720697/1776337801-B3961161-32A3E065/0/0
X-purgate-type: clean
X-purgate-size: 1468

Fragments of type XENVIF_TRANSMITTER_FRAGMENT_TYPE_MULTICAST_CONTROL do
not have a gnttab entry, and so we must check for that here.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/transmitter.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 75b80f3..05a2002 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -1553,12 +1553,14 @@ __TransmitterRingUnprepareFragments(
         Fragment->Length = 0;
         Fragment->Offset = 0;
 
-        (VOID) XENBUS_GNTTAB(RevokeForeignAccess,
-                             &Transmitter->GnttabInterface,
-                             Ring->GnttabCache,
-                             TRUE,
-                             Fragment->Entry);
-        Fragment->Entry = NULL;
+        if (Fragment->Entry != NULL) {
+            (VOID) XENBUS_GNTTAB(RevokeForeignAccess,
+                                 &Transmitter->GnttabInterface,
+                                 Ring->GnttabCache,
+                                 TRUE,
+                                 Fragment->Entry);
+            Fragment->Entry = NULL;
+        }
 
         switch (Fragment->Type) {
         case XENVIF_TRANSMITTER_FRAGMENT_TYPE_BUFFER: {
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:10:04 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:10:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283223.1565489 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbi-0001T9-VF; Thu, 16 Apr 2026 11:10:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283223.1565489; Thu, 16 Apr 2026 11:10:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbi-0001SZ-Ro; Thu, 16 Apr 2026 11:10:02 +0000
Received: by outflank-mailman (input) for mailman id 1283223;
 Thu, 16 Apr 2026 11:10:02 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c387.v1-7ed04eb1f67f43bbb9f300e6ec6e2580@bounce.vates.tech>)
 id 1wDKbi-0001HF-5v
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:10:02 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDKbh-009SxB-FV
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:10:01 +0200
Received: from [10.42.69.10] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c387.v1-7ed04eb1f67f43bbb9f300e6ec6e2580@bounce.vates.tech>)
 id 69e0c37c-e002-0a2a0a5209dd-0a2a450ae120-36
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:01 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c387.v1-7ed04eb1f67f43bbb9f300e6ec6e2580@bounce.vates.tech>)
 id 69e0c388-56b3-0a2a450a0019-c602ba019367-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:01 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfH67dSzBsV4fX
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:09:59 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 7ed04eb1f67f43bbb9f300e6ec6e2580; Thu, 16 Apr 2026 11:09:59 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337799; x=1776607799;
	bh=/t/c+JCtEgryK5qghDcuZRhuKphLj+2LkPs4wdOstbA=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=vLso9P32ww2Zivluy1V5+nV7ciwyHMzTkIgTQSoFa60d4Z4I6q8pHNXXGk+HWdAEV
	 mulVptdWyaP/qHb3A2mBM1HJX1sAwVAq7w6s8ogcXfknFIp1rii4FUmGZrVhX5oYs7
	 HNXcxumK1i1kh2+1ZnQXEqcGgBqxDKg45MKCzeUyo6VsZMveeupsXsBCHiF0lxVujY
	 Yc8tq8YAZxkCLLA+ovuOJJkQ+12rpft1Utv0TXA574viS9pFvN6a4ncB7Fvlcam/cE
	 v8FMaYxo9mXDJqeUEpJNJMxVZGgpFvqIItPiOQLpKoEqIdi1ca1Twm2RrTpXfvhB0e
	 pBYHSsz0jDQ3Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337799; x=1776598299; i=ngoc-tu.dinh@vates.tech;
	bh=/t/c+JCtEgryK5qghDcuZRhuKphLj+2LkPs4wdOstbA=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=gz7+iPXEB5nf6WzxESBYLA8dSwBYkm1L2oai9OBvQecvRnKpr9febjovF3m2gvMWO
	 T42k6F2rFFk+8wBJOFMXLIN2bYEiy7FNDn2BuCVbmBtR5Y5ZPTPbNGEphVBw//Myhz
	 o1bZxi7b16Q3yOgcMbxJrywJCz+qATP/KoEHxEm0d+VclmQ8yz1XdIFVpcP1kEfGbG
	 lrcQ0IgYxWLKfRTMiniQGAQaB0CeOmCjdN6/h1Y0K1qTt3x7deVy09JZpCk1MpsbaS
	 9r3jBufh6VRqUIsuzYji4rAjw9/Gz+DadQ+o78Kz2RDS3C1U7Ujq/QqD7OsmgN9Pzn
	 FUf90g9dHQJBA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=200/5]=20Rundown=20MRSW=20lock=20and=20device=20removal=20fixes?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337799020
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.7ed04eb1f67f43bbb9f300e6ec6e2580?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:09:59 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-4011c0/1776337801-4616A8B7-BA5E17F9/0/0
X-purgate-type: clean
X-purgate-size: 1133

Patches 1 and 2 are fixes for various lockups encountered during
surprise removal.

Patch 3 is an annotation prerequisite for Patch 4, which replaces the
current MRSW lock with a simpler one.

Patch 5 is only for debugging purposes.

To be used together with matching Xennet surprise removal patches.

Tu Dinh (5):
  Check Fragment->Entry before calling RevokeForeignAccess
  Watch BACKEND/state key for eject status
  Update IRQL annotations
  Implement rundown-based MRSW lock
  Trace worker thread wake events

 src/xenvif/controller.c  |   5 +-
 src/xenvif/fdo.c         |   6 +-
 src/xenvif/frontend.c    |  36 +--
 src/xenvif/frontend.h    |  18 +-
 src/xenvif/mrsw.h        | 530 ++++++++++++++++++++++-----------------
 src/xenvif/receiver.c    |  24 +-
 src/xenvif/receiver.h    |  14 +-
 src/xenvif/transmitter.c |  25 +-
 src/xenvif/transmitter.h |   6 +-
 src/xenvif/vif.c         |  73 +++---
 10 files changed, 409 insertions(+), 328 deletions(-)

--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:10:04 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:10:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283225.1565497 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbk-0001hk-4D; Thu, 16 Apr 2026 11:10:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283225.1565497; Thu, 16 Apr 2026 11:10:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbj-0001hG-UV; Thu, 16 Apr 2026 11:10:03 +0000
Received: by outflank-mailman (input) for mailman id 1283225;
 Thu, 16 Apr 2026 11:10:03 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c389.v1-04732bd6a6d647e18b8292fe4597875b@bounce.vates.tech>)
 id 1wDKbj-0001Vf-95
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:10:03 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDKbh-00Dmmj-3s
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:10:02 +0200
Received: from [10.42.69.1] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c389.v1-04732bd6a6d647e18b8292fe4597875b@bounce.vates.tech>)
 id 69e0c386-bab6-0a2a0a5309dd-0a2a45019c1e-8
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:02 +0200
Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com)
 by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c389.v1-04732bd6a6d647e18b8292fe4597875b@bounce.vates.tech>)
 id 69e0c389-c1f2-0a2a45010019-c602bb0e56a5-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:02 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fxFfK1Ptlz8XS3fB
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:01 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 04732bd6a6d647e18b8292fe4597875b; Thu, 16 Apr 2026 11:10:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337801; x=1776607801;
	bh=csApJhiZ48z0tEqRAvFuvxsV6XxMpBvurmSkvVqrwzs=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=kcN3nvo9JRn+trxdVbxgFmfrFL3WlLzqZUnY875f99cv8d0tMxG/V3VcybP97u9FK
	 66+Jh6eQZ/+mpkM3Oq4WZ8zNmqxtuHS8vYoPzqTYka5t2rab//+borxsaW86zZk9+v
	 crfJ387auHGdY4iKh5s7I/w20avfSe1zboEdxFeJgiVnauWzhI4YvzhS+z7EGmJkav
	 ISBX60xPy9UEE9tK1fe/lwTfPWWL15+w+uZJWtygovdYjJjQaNWdRK3iILNK1jkK2s
	 it8B/O1aQxGNpuzO48hzesZh77swYxKpeypLZCUzvsV8YcpLdI2te0c1/dw1Go6TqF
	 cL43M7h41NQfw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337801; x=1776598301; i=ngoc-tu.dinh@vates.tech;
	bh=csApJhiZ48z0tEqRAvFuvxsV6XxMpBvurmSkvVqrwzs=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=A+rcbdC6zvEmANnfWA54pnJo/A0e7I4AmXG6V6JIBzvklFcExPs2Vz9qlqLub0CLQ
	 dFJUOssTqIE9r+iWwKTPWsKuhh4wRofJOJxPuGEBLZMPLVlcca7K/xvtlmmj5akvvx
	 HFSoUE/VVZlQvjraWazGlJsXy2sNtIkCB/7FZz8dr1ZUGFN5uPsFNDzfGrho7+fL7G
	 UsLhqtLJ6VUO/TPAOiV4bjZSmFbfmUd1PGvKpBPk9I7QOeGNwtBJSLuqmaoUHK5iUY
	 SdTPfcEmxD2hV2UrP/XZXKK2s64nlfSbl/CeqEYnWenl4/y3jDFmFr0WPXbiX24emh
	 KY6Frxz84QKkQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=205/5]=20Trace=20worker=20thread=20wake=20events?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337800566
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416110952.355-6-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.04732bd6a6d647e18b8292fe4597875b?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:01 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-d62444/1776337802-BD06EFF4-FDC9BFF4/0/0
X-purgate-type: clean
X-purgate-size: 2405

Distinguish between ThreadAlert and ThreadWake.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/fdo.c      |  6 +++++-
 src/xenvif/frontend.c | 14 ++++++++++----
 src/xenvif/vif.c      |  8 +++++---
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/xenvif/fdo.c b/src/xenvif/fdo.c
index 2499563..e0f793f 100644
--- a/src/xenvif/fdo.c
+++ b/src/xenvif/fdo.c
@@ -957,8 +957,12 @@ FdoScan(
                                      NULL);
         KeClearEvent(Event);
 
-        if (ThreadIsAlerted(Self))
+        if (ThreadIsAlerted(Self)) {
+            Trace("alerted\n");
             break;
+        }
+
+        Trace("awake\n");
 
         // It is not safe to use interfaces before this point
         if (__FdoGetDevicePnpState(Fdo) != Started) {
diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index f2665e8..b52596c 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -402,8 +402,12 @@ FrontendEject(
                               NULL);
         KeClearEvent(Event);
 
-        if (ThreadIsAlerted(Self))
+        if (ThreadIsAlerted(Self)) {
+            Trace("alerted\n");
             break;
+        }
+
+        Trace("awake\n");
 
         KeAcquireSpinLock(&Frontend->Lock, &Irql);
 
@@ -903,10 +907,12 @@ FrontendMib(
                                      NULL);
         KeClearEvent(Event);
 
-        Trace("awake\n");
-
-        if (ThreadIsAlerted(Self))
+        if (ThreadIsAlerted(Self)) {
+            Trace("alerted\n");
             break;
+        }
+
+        Trace("awake\n");
 
         IfTable = NULL;
         UnicastIpAddressTable = NULL;
diff --git a/src/xenvif/vif.c b/src/xenvif/vif.c
index cb4cf84..6782cc7 100644
--- a/src/xenvif/vif.c
+++ b/src/xenvif/vif.c
@@ -106,10 +106,12 @@ VifMac(
                                      NULL);
         KeClearEvent(Event);
 
-        Trace("awake\n");
-
-        if (ThreadIsAlerted(Self))
+        if (ThreadIsAlerted(Self)) {
+            Trace("alerted\n");
             break;
+        }
+
+        Trace("awake\n");
 
         if (Context->Enabled)
             Context->Callback(Context->Argument, XENVIF_MAC_STATE_CHANGE, NULL);
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:10:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:10:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283226.1565501 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbl-0001ru-2v; Thu, 16 Apr 2026 11:10:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283226.1565501; Thu, 16 Apr 2026 11:10:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbk-0001rb-Vj; Thu, 16 Apr 2026 11:10:04 +0000
Received: by outflank-mailman (input) for mailman id 1283226;
 Thu, 16 Apr 2026 11:10:03 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c388.v1-13f0a94c6af04fffbfdc51783d1e44d6@bounce.vates.tech>)
 id 1wDKbj-0001dX-Rs
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:10:03 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDKbh-00Dmmj-Mt
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:10:03 +0200
Received: from [10.42.69.10] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c388.v1-13f0a94c6af04fffbfdc51783d1e44d6@bounce.vates.tech>)
 id 69e0c38a-bab6-0a2a0a5309dd-0a2a450acaa0-4
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:03 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c388.v1-13f0a94c6af04fffbfdc51783d1e44d6@bounce.vates.tech>)
 id 69e0c389-56b3-0a2a450a0019-c602ba013ab6-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:02 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfJ3yb7zBsV7Pp
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:00 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 13f0a94c6af04fffbfdc51783d1e44d6; Thu, 16 Apr 2026 11:10:00 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337800; x=1776607800;
	bh=o5qfwkv21X0q/KpYs4wyF56Pwh04a1gwdusQCG/KhOY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=uJzQqMW3+Mov3Eol6UlDvZJ0JDQFX8p7FpPgtDSJhcp0dPCVT25o5nQsBrYEx7bkh
	 Iy9x3suZmvFsPiqNBmoihtNKRmUTgikEyL8q0n9wHHsoD+8G4NdzVRez5yye3Fx8by
	 +EzIjdc2g8OKFfIUhnYpn7ELXxEsytIA8ZvZdBC6YWRqHEI/CaZmhdYMgdN1eggFi/
	 i5jAzyJa8tl0AyAwXXILXKVxJHt3YAJdlkyFp+44fmXF6jOp8f6Rh+cEKyqJjms25y
	 5YHTpoG+1yrm/Ugge9wSmcgt6uUJkZYXQPl0f6hx6Si6BMTOAKmsYQ23zlJPVtj7Wd
	 MX3fscROhwHLg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337800; x=1776598300; i=ngoc-tu.dinh@vates.tech;
	bh=o5qfwkv21X0q/KpYs4wyF56Pwh04a1gwdusQCG/KhOY=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=feR1GbyAMQcUcM77enhPtamER5xqwf8XtP8CS9bfWhxZ6RCkGelP/LNMzTC8orLtg
	 HHiNlFek/ervvAjwi9SgoMJBOGCkYgz+S4c2PdG/hCUp+5avm3SGWfBcmm9OHqpNY3
	 GSBqiXKbIaBVQ0hwIn0pkiIgYQg3wPwlwY9eiarZ4yXXzkV9iN3vX1ZcxJCkNWoIRF
	 7qljXtdfYDgbrpm2kpmMhvfYXNAsKABtUfyPfNH4qMVMWpTKuQD5HmfQZll2Lwfugm
	 OEXTHCaX/22FQNq/7RpQ/xm8JQWv4/NKmnEZjmklmdzX54RfiIv/LaJTR6PetZXJOg
	 u+WS91jNbgcTw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=202/5]=20Watch=20BACKEND/state=20key=20for=20eject=20status?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337799679
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>, "Paul Durrant" <xadimgnik@gmail.com>
Message-Id: <20260416110952.355-3-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.13f0a94c6af04fffbfdc51783d1e44d6?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:00 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-4011c0/1776337802-46F718B7-2329E145/0/0
X-purgate-type: clean
X-purgate-size: 1448

The frontend eject thread watches for writes to BACKEND/online to detect
an orderly device eject. However, BACKEND/online is also written during
a forced removal of the VIF, where the entire backend key is removed
shortly after. This in turn causes NDIS to hang waiting for packets to
be returned, in the absence of hang detection.

Move the eject thread's watch onto BACKEND/state instead. This delays
the FrontendEject watch just enough that it fires after FdoScan, and so
leaves an opportunity for FdoScan to trigger a surprise removal.

Suggested-by: Paul Durrant <xadimgnik@gmail.com>
Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/frontend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index 5311dea..5cdb9a1 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -1603,7 +1603,7 @@ FrontendPrepare(
     status = XENBUS_STORE(WatchAdd,
                           &Frontend->StoreInterface,
                           __FrontendGetBackendPath(Frontend),
-                          "online",
+                          "state",
                           ThreadGetEvent(Frontend->EjectThread),
                           &Frontend->Watch);
     if (!NT_SUCCESS(status))
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:10:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:10:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283227.1565504 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbl-0001sM-64; Thu, 16 Apr 2026 11:10:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283227.1565504; Thu, 16 Apr 2026 11:10:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbl-0001s3-0m; Thu, 16 Apr 2026 11:10:05 +0000
Received: by outflank-mailman (input) for mailman id 1283227;
 Thu, 16 Apr 2026 11:10:04 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c388.v1-665a641b83424d7eb1d1644865cee35e@bounce.vates.tech>)
 id 1wDKbk-0001h0-3o
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:10:04 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDKbh-00DmqA-UY
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:10:03 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c388.v1-665a641b83424d7eb1d1644865cee35e@bounce.vates.tech>)
 id 69e0c381-2eae-0a2a0a5409dd-0a2a4502bab4-42
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:03 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c388.v1-665a641b83424d7eb1d1644865cee35e@bounce.vates.tech>)
 id 69e0c38a-af86-0a2a45020019-c602ba012712-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:03 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfJ5dBgzBsVR98
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:00 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 665a641b83424d7eb1d1644865cee35e; Thu, 16 Apr 2026 11:10:00 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337800; x=1776607800;
	bh=NioniNcJiCSUU8OraC7KSxjuSel5yGJPzJ88HtrHK80=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=UUL0NfcZy2wNdPBjgl9NOOHfzrNlhF01193QmQaQ3IbJ2RjkifXi4sTVDsbQsLqLp
	 jCBEaUoBWX86OgPWvuJ8mqDrZhCtWzs6FRMnflgNa0rABiA/vwOo0NmMN3BpJ/Ql/7
	 YXEy8YCiB0z+dZ9wVZOMrulswzqFxdMGt+tPO029Nf/cePsIJ+Zo3KWQCgoEWp8dx6
	 d5HZq6NstriAvBA8YrJ7A3uPoDRt2M5WElaOrkw5osp3abaCmaQ34/z7J1Ww4SEBJS
	 XLHMf3jk3iXv7+3ZRy8m/KshZiZ6itOaEsWNp5Do6pbNDjjSgtEAQPtuajj0nvqKDN
	 lAZpq9HF7yL/g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337800; x=1776598300; i=ngoc-tu.dinh@vates.tech;
	bh=NioniNcJiCSUU8OraC7KSxjuSel5yGJPzJ88HtrHK80=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=m+3Wz1UqKRZoaCZNyfXExyLY9qDpjpHAhLuDSf3oP8GoK8T+W0UGchTl48xEMkcH4
	 FuQhXNp0mGqAGyh2EADe6YNcj82V/zmD8+fokUt3SAinj98EU3I40iHCYZnHshj9zt
	 uaeA1rVL49RC6tvqytColoTp+FvhltZDY/N4JIn3sQNsT0VWVpcPCt+Wa7vmkWYlv6
	 3RYmfciPuOGXBXYT97GjFetxGC8SKlNMLl03uoPX7EBdgyxtrmRhpmrekfPwZgNRrp
	 1GiyOy74RFEsaXb9rIUtnOhjY1nMse922lMSLGwC0eWCyi1HB/ASfjRtFapEjyjYE6
	 kS5jXYMcjBYOg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=203/5]=20Update=20IRQL=20annotations?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337800015
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416110952.355-4-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.665a641b83424d7eb1d1644865cee35e?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:00 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-720697/1776337803-88CC9161-9D678A7D/0/0
X-purgate-type: clean
X-purgate-size: 12948

Many functions don't need to be called from DISPATCH_LEVEL, mostly the
ones that raise the IRQL on their own.

This also requires fixing IRQL and other annotations in various places.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/controller.c  |  5 ++++-
 src/xenvif/frontend.c    | 20 +++++++++++---------
 src/xenvif/frontend.h    | 18 +++++++++---------
 src/xenvif/receiver.c    | 24 ++++++++++++------------
 src/xenvif/receiver.h    | 14 +++++++-------
 src/xenvif/transmitter.c | 11 +++++++----
 src/xenvif/transmitter.h |  6 +++---
 7 files changed, 53 insertions(+), 45 deletions(-)

diff --git a/src/xenvif/controller.c b/src/xenvif/controller.c
index ca854ef..dac6952 100644
--- a/src/xenvif/controller.c
+++ b/src/xenvif/controller.c
@@ -118,10 +118,11 @@ __ControllerReleaseLock(
     IN  PXENVIF_CONTROLLER  Controller
     )
 {
-#pragma prefast(suppress:26110) // Caller failing to hold lock
     KeReleaseSpinLockFromDpcLevel(&Controller->Lock);
 }
 
+_Acquires_nonreentrant_lock_(Controller)
+_IRQL_requires_(DISPATCH_LEVEL)
 static VOID
 ControllerAcquireLock(
     IN  PXENVIF_CONTROLLER  Controller
@@ -130,6 +131,8 @@ ControllerAcquireLock(
     __ControllerAcquireLock(Controller);
 }
 
+_Requires_lock_held_(Controller)
+_IRQL_requires_(DISPATCH_LEVEL)
 static VOID
 ControllerReleaseLock(
     IN  PXENVIF_CONTROLLER  Controller
diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index 5cdb9a1..f2665e8 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -983,7 +983,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetMulticastAddresses(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -1151,7 +1151,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetFilterLevel(
     IN  PXENVIF_FRONTEND        Frontend,
@@ -1193,7 +1193,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 FrontendAdvertiseIpAddresses(
     IN  PXENVIF_FRONTEND    Frontend
@@ -1977,7 +1977,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetHashAlgorithm(
     IN  PXENVIF_FRONTEND                Frontend,
@@ -2044,7 +2044,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendQueryHashTypes(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -2084,7 +2084,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetHashMapping(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -2128,7 +2128,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetHashKey(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -2163,7 +2163,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetHashTypes(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -2533,7 +2533,7 @@ FrontendDisable(
     Trace("<====\n");
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 FrontendSetState(
     IN  PXENVIF_FRONTEND        Frontend,
@@ -2711,6 +2711,7 @@ __FrontendSuspend(
     (VOID) FrontendSetState(Frontend, FRONTEND_UNKNOWN);
 }
 
+_IRQL_requires_(HIGH_LEVEL)
 static DECLSPEC_NOINLINE VOID
 FrontendSuspendCallbackEarly(
     IN  PVOID           Argument
@@ -2721,6 +2722,7 @@ FrontendSuspendCallbackEarly(
     Frontend->Online = FALSE;
 }
 
+_IRQL_requires_(DISPATCH_LEVEL)
 static DECLSPEC_NOINLINE VOID
 FrontendSuspendCallbackLate(
     IN  PVOID           Argument
diff --git a/src/xenvif/frontend.h b/src/xenvif/frontend.h
index 5b84806..e062ed0 100644
--- a/src/xenvif/frontend.h
+++ b/src/xenvif/frontend.h
@@ -74,7 +74,7 @@ FrontendEjectFailed(
     IN PXENVIF_FRONTEND Frontend
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetState(
     IN  PXENVIF_FRONTEND        Frontend,
@@ -194,7 +194,7 @@ FrontendIncrementStatistic(
     IN  ULONGLONG               Delta
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetMulticastAddresses(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -202,7 +202,7 @@ FrontendSetMulticastAddresses(
     IN  ULONG               Count
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetFilterLevel(
     IN  PXENVIF_FRONTEND        Frontend,
@@ -210,27 +210,27 @@ FrontendSetFilterLevel(
     IN  XENVIF_MAC_FILTER_LEVEL Level
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 FrontendAdvertiseIpAddresses(
     IN  PXENVIF_FRONTEND    Frontend
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetHashAlgorithm(
     IN  PXENVIF_FRONTEND                Frontend,
     IN  XENVIF_PACKET_HASH_ALGORITHM    Algorithm
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendQueryHashTypes(
     IN  PXENVIF_FRONTEND    Frontend,
     OUT PULONG              Types
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetHashMapping(
     IN  PXENVIF_FRONTEND    Frontend,
@@ -238,14 +238,14 @@ FrontendSetHashMapping(
     IN  ULONG               Order
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetHashKey(
     IN  PXENVIF_FRONTEND    Frontend,
     IN  PUCHAR              Key
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern NTSTATUS
 FrontendSetHashTypes(
     IN  PXENVIF_FRONTEND    Frontend,
diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 8e6ec7f..0cd1867 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -2282,11 +2282,11 @@ __ReceiverRingUnmask(
                           Force);
 }
 
-__drv_functionClass(KDEFERRED_ROUTINE)
-__drv_maxIRQL(DISPATCH_LEVEL)
-__drv_minIRQL(DISPATCH_LEVEL)
-__drv_requiresIRQL(DISPATCH_LEVEL)
-__drv_sameIRQL
+_Function_class_(KDEFERRED_ROUTINE)
+_IRQL_requires_max_(DISPATCH_LEVEL)
+_IRQL_requires_min_(DISPATCH_LEVEL)
+_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_same_
 static VOID
 ReceiverRingPollDpc(
     IN  PKDPC               Dpc,
@@ -3694,7 +3694,7 @@ ReceiverTeardown(
     __ReceiverFree(Receiver);
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 ReceiverSetOffloadOptions(
     IN  PXENVIF_RECEIVER            Receiver,
@@ -3725,7 +3725,7 @@ ReceiverSetOffloadOptions(
     }    
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 ReceiverSetBackfillSize(
     IN  PXENVIF_RECEIVER    Receiver,
@@ -3752,7 +3752,7 @@ ReceiverSetBackfillSize(
     }
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 ReceiverQueryRingSize(
     IN  PXENVIF_RECEIVER    Receiver,
@@ -3875,7 +3875,7 @@ ReceiverSend(
     __ReceiverRingSend(Ring, FALSE);
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverSetHashAlgorithm(
     IN  PXENVIF_RECEIVER                Receiver,
@@ -3919,7 +3919,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverQueryHashCapabilities(
     IN  PXENVIF_RECEIVER    Receiver,
@@ -3943,7 +3943,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverUpdateHashParameters(
     IN  PXENVIF_RECEIVER    Receiver,
@@ -4039,7 +4039,7 @@ fail1:
     return status;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverUpdateHashMapping(
     IN  PXENVIF_RECEIVER    Receiver,
diff --git a/src/xenvif/receiver.h b/src/xenvif/receiver.h
index d093dd0..96cec02 100644
--- a/src/xenvif/receiver.h
+++ b/src/xenvif/receiver.h
@@ -91,21 +91,21 @@ ReceiverWaitForPackets(
     IN  PXENVIF_RECEIVER    Receiver
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 ReceiverQueryRingSize(
     IN  PXENVIF_RECEIVER    Receiver,
     OUT PULONG              Size
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 ReceiverSetOffloadOptions(
     IN  PXENVIF_RECEIVER            Receiver,
     IN  XENVIF_VIF_OFFLOAD_OPTIONS  Options
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 ReceiverSetBackfillSize(
     IN  PXENVIF_RECEIVER    Receiver,
@@ -133,21 +133,21 @@ ReceiverSend(
     IN  ULONG               Index
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverSetHashAlgorithm(
     IN  PXENVIF_RECEIVER                Receiver,
     IN  XENVIF_PACKET_HASH_ALGORITHM    Algorithm
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverQueryHashCapabilities(
     IN  PXENVIF_RECEIVER    Receiver,
     OUT PULONG              Types
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverUpdateHashParameters(
     IN  PXENVIF_RECEIVER    Receiver,
@@ -155,7 +155,7 @@ ReceiverUpdateHashParameters(
     IN  PUCHAR              Key
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 NTSTATUS
 ReceiverUpdateHashMapping(
     IN  PXENVIF_RECEIVER    Receiver,
diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 05a2002..0f7deb1 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -248,6 +248,8 @@ __TransmitterFree(
     __FreePoolWithTag(Buffer, XENVIF_TRANSMITTER_TAG);
 }
 
+_Acquires_nonreentrant_lock_(Argument)
+_IRQL_requires_(DISPATCH_LEVEL)
 static VOID
 TransmitterPacketAcquireLock(
     IN  PVOID           Argument
@@ -258,6 +260,8 @@ TransmitterPacketAcquireLock(
     KeAcquireSpinLockAtDpcLevel(&Transmitter->Lock);
 }
 
+_Requires_lock_held_(Argument)
+_IRQL_requires_(DISPATCH_LEVEL)
 static VOID
 TransmitterPacketReleaseLock(
     IN  PVOID           Argument
@@ -265,7 +269,6 @@ TransmitterPacketReleaseLock(
 {
     PXENVIF_TRANSMITTER Transmitter = Argument;
 
-#pragma prefast(suppress:26110)
     KeReleaseSpinLockFromDpcLevel(&Transmitter->Lock);
 }
 
@@ -5301,7 +5304,7 @@ TransmitterQueueMulticastControl(
     (VOID) __TransmitterRingQueueMulticastControl(Ring, Address, Add);
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 TransmitterQueryRingSize(
     IN  PXENVIF_TRANSMITTER Transmitter,
@@ -5332,7 +5335,7 @@ TransmitterNotify(
         Ring->PollDpcs++;
 }
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 TransmitterQueryOffloadOptions(
     IN  PXENVIF_TRANSMITTER         Transmitter,
@@ -5453,7 +5456,7 @@ TransmitterQueryOffloadOptions(
                                                          MAXIMUM_IPV6_OPTIONS_LENGTH -          \
                                                          MAXIMUM_TCP_HEADER_LENGTH)
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 VOID
 TransmitterQueryLargePacketSize(
     IN  PXENVIF_TRANSMITTER     Transmitter,
diff --git a/src/xenvif/transmitter.h b/src/xenvif/transmitter.h
index 30ef371..5e789f1 100644
--- a/src/xenvif/transmitter.h
+++ b/src/xenvif/transmitter.h
@@ -121,7 +121,7 @@ TransmitterQueueMulticastControl(
     IN  BOOLEAN                 Add
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 TransmitterQueryRingSize(
     IN  PXENVIF_TRANSMITTER Transmitter,
@@ -143,14 +143,14 @@ TransmitterQueuePacket(
     IN  PVOID                       Cookie
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 TransmitterQueryOffloadOptions(
     IN  PXENVIF_TRANSMITTER         Transmitter,
     OUT PXENVIF_VIF_OFFLOAD_OPTIONS Options
     );
 
-_IRQL_requires_(DISPATCH_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 extern VOID
 TransmitterQueryLargePacketSize(
     IN  PXENVIF_TRANSMITTER     Transmitter,
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:10:16 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:10:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283228.1565509 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbw-0002PK-7f; Thu, 16 Apr 2026 11:10:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283228.1565509; Thu, 16 Apr 2026 11:10:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDKbw-0002PF-4d; Thu, 16 Apr 2026 11:10:16 +0000
Received: by outflank-mailman (input) for mailman id 1283228;
 Thu, 16 Apr 2026 11:10:15 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c394.v1-abaa372eb67947a887fbe0c56e3e5376@bounce.vates.tech>)
 id 1wDKbv-0002Ow-3M
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:10:15 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDKbu-005Y2y-GN
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:10:14 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c394.v1-abaa372eb67947a887fbe0c56e3e5376@bounce.vates.tech>)
 id 69e0c392-e002-0a2a0a5209dd-0a2a450bc4c0-34
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:14 +0200
Received: from [198.2.186.1] (helo=mail186-1.suw21.mandrillapp.com)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c394.v1-abaa372eb67947a887fbe0c56e3e5376@bounce.vates.tech>)
 id 69e0c394-212f-0a2a450b0019-c602ba019690-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:10:13 +0200
Received: from pmta10.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail186-1.suw21.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfX3SQ7zBsV4fX
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:12 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 abaa372eb67947a887fbe0c56e3e5376; Thu, 16 Apr 2026 11:10:12 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337812; x=1776607812;
	bh=5H+zariwMv6W/mz617AHKIJtMHavqJF9tUW9brXmK9o=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=M5jdsCx6x8yf36/JQsRhexMVxuyMAIHlNyQMl2bSYYrrldPZsnuSFPNjgyphCkdcU
	 wAnIkSdk94NcW3lQ0ZM0oRdnDff5ponTz2zsPGPaLdYU8XefU/QBS3cH5Celvr5OM5
	 zOKQRzYK60DFYkidhap3DOgFRQhWA2k1kPMLwrZKIyXNis5LTrJnAZbkNJX8AJEnfa
	 h7rNYK3wKzYgIzV47k3n8AlhXZ2pxP/8aT877IxjqJGMjgrfcb76U+AL9QSh/MuSOw
	 tcNn+b/b+9/5bn9sJ7M/e2rNpmCf0ntTWPPU041w6PoyW9AdWvCdjuSd9N3Ih4pX2A
	 2FyXlBo+jXtyA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337812; x=1776598312; i=ngoc-tu.dinh@vates.tech;
	bh=5H+zariwMv6W/mz617AHKIJtMHavqJF9tUW9brXmK9o=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=aYNpnMUAlwsospbd9wYOmOgjRivk1HcwSBcIxLw3YqY3ByvkLYGi7G2uSBIUhzVkj
	 deiq0kdlaY09gv/rI0UtnQdaBUolKqamQgrZ/r8k1gRGpR/YYI/+IM65wwaB8FjEQp
	 FGeQPs/I9HifDhmDvRKkZpuvKfm3qvQBfvSdNSKPFADp/rIFiwh4Liii8k0NIpBqC5
	 AwKaR4/K3cGCGDQGfVFj7UQtlOFja9BE2ak/4EDgqHwJlWy9Euu/Q/SH+vW+RHP8ri
	 sX1BJjuZ9Wv9Hw7sKgM5qjVZz2Rm8UcrDtUbh5kjKpxEdrMsWopt2Lwv+iayl/yaEb
	 Ls8hnCtP74mtA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=201/2]=20Signal=20surprise=20removal=20support=20during=20registration?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337811739
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416111009.379-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.abaa372eb67947a887fbe0c56e3e5376?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:12 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-42698a/1776337813-04762F3B-DB79C1C7/0/0
X-purgate-type: clean
X-purgate-size: 5469

NDIS already provides NDIS_MINIPORT_ATTRIBUTES_SURPRISE_REMOVE_OK for
this purpose. Stop intercepting NdisDispatchPnp and use the provided
registration flag instead.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xennet/adapter.c |   1 +
 src/xennet/driver.c  | 128 -------------------------------------------
 2 files changed, 1 insertion(+), 128 deletions(-)

diff --git a/src/xennet/adapter.c b/src/xennet/adapter.c
index cbca7f0..f79c0c8 100644
--- a/src/xennet/adapter.c
+++ b/src/xennet/adapter.c
@@ -2967,6 +2967,7 @@ AdapterSetRegistrationAttributes(
     Attribs.MiniportAdapterContext = (NDIS_HANDLE)Adapter;
     Attribs.AttributeFlags = NDIS_MINIPORT_ATTRIBUTES_BUS_MASTER |
                              NDIS_MINIPORT_ATTRIBUTES_NO_HALT_ON_SUSPEND |
+                             NDIS_MINIPORT_ATTRIBUTES_SURPRISE_REMOVE_OK |
                              NDIS_MINIPORT_ATTRIBUTES_NDIS_WDM;
     Attribs.CheckForHangTimeInSeconds = 0;
     Attribs.InterfaceType = XENNET_INTERFACE_TYPE;
diff --git a/src/xennet/driver.c b/src/xennet/driver.c
index 96adde7..5f31ac2 100644
--- a/src/xennet/driver.c
+++ b/src/xennet/driver.c
@@ -46,118 +46,6 @@ typedef struct _XENNET_DRIVER {
 
 static XENNET_DRIVER Driver;
 
-typedef struct _XENNET_CONTEXT {
-    PDEVICE_CAPABILITIES    Capabilities;
-    PIO_COMPLETION_ROUTINE  CompletionRoutine;
-    PVOID                   CompletionContext;
-    UCHAR                   CompletionControl;
-} XENNET_CONTEXT, *PXENNET_CONTEXT;
-
-static NTSTATUS (*NdisDispatchPnp)(PDEVICE_OBJECT, PIRP);
-
-__drv_functionClass(IO_COMPLETION_ROUTINE)
-static NTSTATUS
-__QueryCapabilities(
-    IN  PDEVICE_OBJECT      DeviceObject,
-    IN  PIRP                Irp,
-    IN  PVOID               _Context
-    )
-{
-    PXENNET_CONTEXT         Context = _Context;
-    NTSTATUS                status;
-
-    Context->Capabilities->SurpriseRemovalOK = 1;
-
-    if (Context->CompletionRoutine != NULL &&
-        (Context->CompletionControl & SL_INVOKE_ON_SUCCESS))
-        status = Context->CompletionRoutine(DeviceObject, Irp, Context->CompletionContext);
-    else
-        status = STATUS_SUCCESS;
-
-    ExFreePool(Context);
-
-    return status;
-}
-
-NTSTATUS
-QueryCapabilities(
-    IN PDEVICE_OBJECT       DeviceObject,
-    IN PIRP                 Irp
-    )
-{
-    PIO_STACK_LOCATION      StackLocation;
-    PXENNET_CONTEXT         Context;
-    NTSTATUS                status;
-
-    Trace("====>\n");
-
-    Trace("%p\n", DeviceObject);
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
-    Context = __AllocatePoolWithTag(NonPagedPool, sizeof (XENNET_CONTEXT), ' TEN');
-    if (Context != NULL) {
-        Context->Capabilities = StackLocation->Parameters.DeviceCapabilities.Capabilities;
-        Context->CompletionRoutine = StackLocation->CompletionRoutine;
-        Context->CompletionContext = StackLocation->Context;
-        Context->CompletionControl = StackLocation->Control;
-
-        StackLocation->CompletionRoutine = __QueryCapabilities;
-        StackLocation->Context = Context;
-        StackLocation->Control = SL_INVOKE_ON_SUCCESS;
-    }
-
-    status = NdisDispatchPnp(DeviceObject, Irp);
-
-    Trace("<====\n");
-
-    return status;
-}
-
-DRIVER_DISPATCH DispatchPnp;
-
-NTSTATUS
-DispatchPnp(
-    IN PDEVICE_OBJECT   DeviceObject,
-    IN PIRP             Irp
-    )
-{
-    PIO_STACK_LOCATION  StackLocation;
-    UCHAR               MinorFunction;
-    NTSTATUS            status;
-
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-    MinorFunction = StackLocation->MinorFunction;
-
-    switch (StackLocation->MinorFunction) {
-    case IRP_MN_QUERY_CAPABILITIES:
-        status = QueryCapabilities(DeviceObject, Irp);
-        break;
-
-    default:
-        status = NdisDispatchPnp(DeviceObject, Irp);
-        break;
-    }
-
-    return status;
-}
-
-DRIVER_DISPATCH DispatchFail;
-
-NTSTATUS
-DispatchFail(
-    IN PDEVICE_OBJECT   DeviceObject,
-    IN PIRP             Irp
-    )
-{
-    UNREFERENCED_PARAMETER(DeviceObject);
-
-    Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
-    IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
-    return STATUS_UNSUCCESSFUL;
-}
-
 VOID
 DriverUnload(
     IN  PDRIVER_OBJECT  DriverObject
@@ -265,22 +153,6 @@ DriverEntry (
     NdisCloseConfiguration(ConfigurationHandle);
     ndisStatus = NDIS_STATUS_SUCCESS;
 
-    NdisDispatchPnp = DriverObject->MajorFunction[IRP_MJ_PNP];
-#pragma prefast(suppress:28168) // No matching __drv_dispatchType annotation
-    DriverObject->MajorFunction[IRP_MJ_PNP] = DispatchPnp;
-
-    if (FailCreateClose != 0) {
-#pragma prefast(suppress:28168) // No matching__drv_dispatchType annotation
-        DriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchFail;
-#pragma prefast(suppress:28168) // No matching __drv_dispatchType annotation
-        DriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchFail;
-    }
-
-    if (FailDeviceControl != 0) {
-#pragma prefast(suppress:28168) // No matching __drv_dispatchType annotation
-        DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchFail;
-    }
-
     Trace("<====\n");
     return ndisStatus;
 
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 11:56:32 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 11:56:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283285.1565562 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDLKh-0001GG-BA; Thu, 16 Apr 2026 11:56:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283285.1565562; Thu, 16 Apr 2026 11:56:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDLKh-0001G9-7D; Thu, 16 Apr 2026 11:56:31 +0000
Received: by outflank-mailman (input) for mailman id 1283285;
 Thu, 16 Apr 2026 11:56:29 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c389.v1-a4d7bbd4750b4596982d26ebbf653fdb@bounce.vates.tech>)
 id 1wDLKf-0001G3-H8
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 11:56:29 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDLKe-00GFCu-OW
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 13:56:28 +0200
Received: from [10.42.69.6] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c389.v1-a4d7bbd4750b4596982d26ebbf653fdb@bounce.vates.tech>)
 id 69e0ce66-5cb7-0a2a0a5109dd-0a2a45069d96-22
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:56:28 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c389.v1-a4d7bbd4750b4596982d26ebbf653fdb@bounce.vates.tech>)
 id 69e0ce6b-7371-0a2a45060019-c602bb0108f4-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 13:56:28 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfK38mCzBsdDfD
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:01 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 a4d7bbd4750b4596982d26ebbf653fdb; Thu, 16 Apr 2026 11:10:01 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337801; x=1776607801;
	bh=JDh4eWkILJ0bvFC4vzu2RS9uNWa40/QWhBnb1r6PY4U=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=NMbvTapMRnciDJglJZbcHZ4VMbZGbXVTa5XGsLCSexRlQT5+hTUOzFxe+1wggVeNu
	 ZdCS6OSno+eLc+hKQwiwIvr874jFR0urN4QqxT6YbstjpY6+Iuhbrc1sMDiHLan9gN
	 FcNT2HWzIrB8u1Uatxg3VNAC3whFm/gQb0YtM/+lzCDUrgQGY8bxl0JdCKkuNvorgh
	 A37JLriMsr3a9mzumjTnTrINLJP+iiV25yZ3XhmDFOJonD6dgr9dsRsKfnJinPgUdU
	 MDpUUO4jA1BGnNmRjFRO8GztnKX775iDkZV6e4zsGLW23TZUWcH0aPiB7Fu0dZ3jQb
	 PEOH9finY4WQA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337801; x=1776598301; i=ngoc-tu.dinh@vates.tech;
	bh=JDh4eWkILJ0bvFC4vzu2RS9uNWa40/QWhBnb1r6PY4U=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Wlz2dh8OrxfuZvmqsgE5kowuqxMJ2QQpK4rqCH1ie1XX0iGW2N1ccaRJHRIN5sFQH
	 iLq9Gq+aXUqzq9/8RAxSVbHtAeIxvY75OSZiJZQqOGgMoISp0lF7aMV4J3ZzUADd+T
	 ArHj/fcKQB2pfPXThnQSfQAtviMBCxIgiLDIfs8W16EJvoojZPV5tg9FFQLuFxTmWK
	 c8vSLycGFZfCgNyoXeIzJocq0H7MTPsZYObRLH1HYY7IQFcxNiMHjokmPuT9l8xWkn
	 a6S3lEyCcytoi48DKcvEpAQLNXk6E14zYojwxDFlZiakJxGgh2QS4AYxffiH+2iB+K
	 UBRq+tBN6FXgg==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=204/5]=20Implement=20rundown-based=20MRSW=20lock?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337800354
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416110952.355-5-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.a4d7bbd4750b4596982d26ebbf653fdb?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:01 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-16d1c6/1776340588-CDD6AD75-DA289DB0/0/0
X-purgate-type: clean
X-purgate-size: 28041

The current MRSW lock has a few downsides:
* Large size (have to store a 1KB holder list)
* Long fast-path acquire (~1KB of code) due to having to scan the holder
  list every acquire
* Limited to 64 holders
* Multiple IRQL operations per acquire
* Always raises the critical section to DISPATCH_LEVEL

It's currently only used as the cleanup lock for the VIF interface, so
replace it with something simpler.

Implement a read-write lock with the following properties:
* The reader section is protected by an EX_RUNDOWN_REF.
* Writer/cleanup section is implemented by running down the reference
  within a guarded mutex.
* It offers 3 read acquire flavors: try acquire, spin acquire (both of
  which can be used from DISPATCH_LEVEL) and sleeping acquire (using the
  guarded mutex).
* It makes the downgrade call explicit instead of overloading it via
  ReleaseMrswLockExclusive.
* Finally, the lock supports cache-aware mode, where EX_RUNDOWN_REF is
  replaced with EX_RUNDOWN_REF_CACHE_AWARE using the corresponding
  macros.

As the changes are only internal to vif.c, the VIF version doesn't need
to be increased.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/mrsw.h | 530 +++++++++++++++++++++++++---------------------
 src/xenvif/vif.c  |  65 +++---
 2 files changed, 327 insertions(+), 268 deletions(-)

diff --git a/src/xenvif/mrsw.h b/src/xenvif/mrsw.h
index e1ff056..8bfa441 100644
--- a/src/xenvif/mrsw.h
+++ b/src/xenvif/mrsw.h
@@ -1,289 +1,347 @@
 /* Copyright (c) Xen Project.
  * Copyright (c) Cloud Software Group, Inc.
+ * Copyright (c) Vates.
  * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, 
- * with or without modification, are permitted provided 
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
  * that the following conditions are met:
- * 
- * *   Redistributions of source code must retain the above 
- *     copyright notice, this list of conditions and the 
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
  *     following disclaimer.
- * *   Redistributions in binary form must reproduce the above 
- *     copyright notice, this list of conditions and the 
- *     following disclaimer in the documentation and/or other 
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
  *     materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
 
-#ifndef _XENVIF_MRSW_H
-#define _XENVIF_MRSW_H
+#ifndef _MRSW_H
+#define _MRSW_H
 
-#include <ntddk.h>
+#include <wdm.h>
 
 #include "assert.h"
 #include "util.h"
 
-#pragma warning(disable:4127)   // conditional expression is constant
-
-typedef struct _XENVIF_MRSW_HOLDER {
-    PKTHREAD    Thread;
-    LONG        Level;
-} XENVIF_MRSW_HOLDER, *PXENVIF_MRSW_HOLDER;
-
-typedef struct _XENVIF_MRSW_LOCK {
-    volatile LONG64 Mask;
-    XENVIF_MRSW_HOLDER     Holder[64];
-    KEVENT          Event;
-} XENVIF_MRSW_LOCK, *PXENVIF_MRSW_LOCK;
-
-C_ASSERT(RTL_FIELD_SIZE(XENVIF_MRSW_LOCK, Holder) == RTL_FIELD_SIZE(XENVIF_MRSW_LOCK, Mask) * 8 * sizeof (XENVIF_MRSW_HOLDER));
-
-#define XENVIF_MRSW_EXCLUSIVE_SLOT  0
-
-static FORCEINLINE VOID
-InitializeMrswLock(
-    IN  PXENVIF_MRSW_LOCK   Lock
+#pragma warning(push)
+#pragma warning(disable:4201) // nameless struct/union
+struct _MRSW_LOCK {
+    KGUARDED_MUTEX                  Mutex;
+    union {
+        EX_RUNDOWN_REF              Rundown;
+        PEX_RUNDOWN_REF_CACHE_AWARE RundownCacheAware;
+    };
+};
+#pragma warning(pop)
+
+typedef struct _MRSW_LOCK   MRSW_LOCK, *PMRSW_LOCK;
+typedef struct _MRSW_LOCK   MRSW_CACHE_AWARE_LOCK, *PMRSW_CACHE_AWARE_LOCK;
+
+static FORCEINLINE NTSTATUS
+__MrswRundownInitialize(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware,
+    _In_ ULONG                  Tag
     )
 {
-    LONG                    Slot;
-
-    RtlZeroMemory(Lock, sizeof (XENVIF_MRSW_LOCK));
-
-    for (Slot = 0; Slot < (LONG) sizeof (Lock->Mask) * 8; Slot++)
-        Lock->Holder[Slot].Level = -1;
+    if (CacheAware) {
+        Lock->RundownCacheAware = ExAllocateCacheAwareRundownProtection(NonPagedPoolNx,
+                                                                        Tag);
+        if (!Lock->RundownCacheAware)
+            return STATUS_NO_MEMORY;
+    } else {
+        ExInitializeRundownProtection(&Lock->Rundown);
+    }
 
-    KeInitializeEvent(&Lock->Event, NotificationEvent, FALSE);
+    return STATUS_SUCCESS;
 }
 
 static FORCEINLINE BOOLEAN
-__ClaimExclusive(
-    IN  PXENVIF_MRSW_LOCK   Lock
+__MrswRundownAcquire(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
     )
 {
-    LONG64                  Old;
-    LONG64                  New;
-
-    Old = 0;
-    New = 1ll << XENVIF_MRSW_EXCLUSIVE_SLOT;
-
-    return (InterlockedCompareExchange64(&Lock->Mask, New, Old) == Old) ? TRUE : FALSE;
+    if (CacheAware)
+        return ExAcquireRundownProtectionCacheAware(Lock->RundownCacheAware);
+    else
+        return ExAcquireRundownProtection(&Lock->Rundown);
 }
 
-static FORCEINLINE KIRQL
-__drv_maxIRQL(APC_LEVEL)
-__drv_raisesIRQL(DISPATCH_LEVEL)
-__drv_savesIRQL
-__AcquireMrswLockExclusive(
-    IN  PXENVIF_MRSW_LOCK   Lock
+static FORCEINLINE VOID
+__MrswRundownRelease(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
     )
 {
-    KIRQL                   Irql;
-    LONG                    Slot;
-    PKTHREAD                Self;
-    PXENVIF_MRSW_HOLDER     Holder;
-
-    ASSERT3U(KeGetCurrentIrql(), <, DISPATCH_LEVEL);
-    KeRaiseIrql(DISPATCH_LEVEL, &Irql);
-
-    Self = KeGetCurrentThread();
-
-    // Make sure we do not already hold the lock
-    for (Slot = 0; Slot < (LONG) sizeof (Lock->Mask) * 8; Slot++)
-        ASSERT(Lock->Holder[Slot].Thread != Self);
-
-    for (;;) {
-        if (__ClaimExclusive(Lock))
-            break;
-
-        KeLowerIrql(Irql);
-
-        (VOID) KeWaitForSingleObject(&Lock->Event,
-                                     Executive,
-                                     KernelMode,
-                                     FALSE,
-                                     NULL);
-        KeClearEvent(&Lock->Event);
-
-        KeRaiseIrql(DISPATCH_LEVEL, &Irql);
-    }
-
-    Holder = &Lock->Holder[XENVIF_MRSW_EXCLUSIVE_SLOT];
-
-    ASSERT3P(Holder->Thread, ==, NULL);
-    Holder->Thread = Self;
-    Holder->Level = 0;
-
-    return Irql;
+    if (CacheAware)
+        ExReleaseRundownProtectionCacheAware(Lock->RundownCacheAware);
+    else
+        ExReleaseRundownProtection(&Lock->Rundown);
 }
 
-#define AcquireMrswLockExclusive(_Lock, _Irql)              \
-        do {                                                \
-            *(_Irql) = __AcquireMrswLockExclusive(_Lock);   \
-        } while (FALSE)
-
 static FORCEINLINE VOID
-__drv_maxIRQL(DISPATCH_LEVEL)
-__drv_requiresIRQL(DISPATCH_LEVEL)
-ReleaseMrswLockExclusive(
-    IN  PXENVIF_MRSW_LOCK           Lock,
-    IN  __drv_restoresIRQL KIRQL    Irql,
-    IN  BOOLEAN                     Shared
+__MrswRundownWait(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
     )
 {
-    LONG                            Slot;
-    PKTHREAD                        Self;
-    LONG64                          Old;
-    LONG64                          New;
-    PXENVIF_MRSW_HOLDER             Holder;
-
-    ASSERT3U(KeGetCurrentIrql(), ==, DISPATCH_LEVEL);
-
-    Slot = XENVIF_MRSW_EXCLUSIVE_SLOT + 1; // Choose any slot other than the exclusive slot
-
-    Old = 1ll << XENVIF_MRSW_EXCLUSIVE_SLOT;
-    New = (Shared) ? (1ll << Slot) : 0;
-
-    Old = InterlockedCompareExchange64(&Lock->Mask, New, Old);
-    ASSERT3U(Old, == , 1ll << XENVIF_MRSW_EXCLUSIVE_SLOT);
-
-    Self = KeGetCurrentThread();
-
-    ASSERT3P(Lock->Holder[XENVIF_MRSW_EXCLUSIVE_SLOT].Thread, ==, Self);
-
-    // If we are leaving the lock held shared then we need to transfer
-    // our identity information into the hew slot.
-    if (Shared)
-        Lock->Holder[Slot] = Lock->Holder[XENVIF_MRSW_EXCLUSIVE_SLOT];
-
-    Holder = &Lock->Holder[XENVIF_MRSW_EXCLUSIVE_SLOT];
-
-    Holder->Thread = NULL;
-    Holder->Level = -1;
-
-    KeLowerIrql(Irql);
+    if (CacheAware)
+        ExWaitForRundownProtectionReleaseCacheAware(Lock->RundownCacheAware);
+    else
+        ExWaitForRundownProtectionRelease(&Lock->Rundown);
 }
 
-static FORCEINLINE LONG
-__ClaimShared(
-    IN  PXENVIF_MRSW_LOCK   Lock
+static FORCEINLINE VOID
+__MrswRundownCompleted(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
     )
 {
-    LONG                    Slot;
-    LONG64                  Old;
-    LONG64                  New;
-
-    // Make sure the exclusive bit is set so that we don't find it
-    Old = Lock->Mask | (1ll << XENVIF_MRSW_EXCLUSIVE_SLOT);
-
-    Slot = __ffu((ULONG64)Old);
-    ASSERT(Slot >= 0);
-    ASSERT3U(Slot, != , XENVIF_MRSW_EXCLUSIVE_SLOT);
+    if (CacheAware)
+        ExRundownCompletedCacheAware(Lock->RundownCacheAware);
+    else
+        ExRundownCompleted(&Lock->Rundown);
+}
 
-    Old &= ~(1ll << XENVIF_MRSW_EXCLUSIVE_SLOT);
-    New = Old | (1ll << Slot);
+static FORCEINLINE VOID
+__MrswRundownReInitialize(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+    if (CacheAware)
+        ExReInitializeRundownProtectionCacheAware(Lock->RundownCacheAware);
+    else
+        ExReInitializeRundownProtection(&Lock->Rundown);
+}
 
-    return (InterlockedCompareExchange64(&Lock->Mask, New, Old) == Old) ? Slot : -1;
+static FORCEINLINE VOID
+__MrswRundownTeardown(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+    if (CacheAware)
+        ExFreeCacheAwareRundownProtection(Lock->RundownCacheAware);
+    else
+        RtlZeroMemory(&Lock->Rundown, sizeof(Lock->Rundown));
 }
 
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(APC_LEVEL)
+static FORCEINLINE NTSTATUS
+__InitializeMrswLock(
+    _Out_ struct _MRSW_LOCK     *Lock,
+    _In_ BOOLEAN                CacheAware,
+    _In_ ULONG                  Tag
+    )
+{
+    KeInitializeGuardedMutex(&Lock->Mutex);
+    return __MrswRundownInitialize(Lock, CacheAware, Tag);
+}
+#define InitializeMrswLock(Lock, Tag) \
+    __InitializeMrswLock(Lock, FALSE, Tag)
+#define InitializeMrswCacheAwareLock(Lock, Tag) \
+    __InitializeMrswLock(Lock, TRUE, Tag)
+
+_Requires_lock_not_held_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(APC_LEVEL)
+static FORCEINLINE VOID
+__TeardownMrswLock(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+#if DBG
+    BUG_ON(!KeTryToAcquireGuardedMutex(&Lock->Mutex));
+    BUG_ON(!__MrswRundownAcquire(Lock, CacheAware));
+    KeReleaseGuardedMutex(&Lock->Mutex);
+    __MrswRundownRelease(Lock, CacheAware);
+#endif
+
+    __MrswRundownTeardown(Lock, CacheAware);
+    RtlZeroMemory(Lock, sizeof(MRSW_LOCK));
+}
+#define TeardownMrswLock(Lock) \
+    __TeardownMrswLock(Lock, FALSE)
+#define TeardownMrswCacheAwareLock(Lock) \
+    __TeardownMrswLock(Lock, TRUE)
+
+_Acquires_lock_(_Global_critical_region_)
+_Requires_lock_not_held_(*Lock)
+_Acquires_exclusive_lock_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(APC_LEVEL)
 static FORCEINLINE VOID
-AcquireMrswLockShared(
-    IN  PXENVIF_MRSW_LOCK   Lock
+__AcquireMrswLockExclusive(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
     )
 {
-    KIRQL                   Irql;
-    LONG                    Level;
-    LONG                    Slot;
-    PKTHREAD                Self;
-    PXENVIF_MRSW_HOLDER     Holder;
+    ASSERT3U(KeGetCurrentIrql(), <=, APC_LEVEL);
 
+    KeAcquireGuardedMutex(&Lock->Mutex);
+    __MrswRundownWait(Lock, CacheAware);
+    __MrswRundownCompleted(Lock, CacheAware);
+}
+#define AcquireMrswLockExclusive(Lock) \
+    __AcquireMrswLockExclusive(Lock, FALSE)
+#define AcquireMrswCacheAwareLockExclusive(Lock) \
+    __AcquireMrswLockExclusive(Lock, TRUE)
+
+_Releases_lock_(_Global_critical_region_)
+_Requires_exclusive_lock_held_(*Lock)
+_Releases_exclusive_lock_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(APC_LEVEL)
+static FORCEINLINE VOID
+__ReleaseMrswLockExclusive(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+    __MrswRundownReInitialize(Lock, CacheAware);
+    KeReleaseGuardedMutex(&Lock->Mutex);
+}
+#define ReleaseMrswLockExclusive(Lock) \
+    __ReleaseMrswLockExclusive(Lock, FALSE)
+#define ReleaseMrswCacheAwareLockExclusive(Lock) \
+    __ReleaseMrswLockExclusive(Lock, TRUE)
+
+_Releases_lock_(_Global_critical_region_)
+_Requires_exclusive_lock_held_(*Lock)
+_Releases_exclusive_lock_(*Lock)
+_Acquires_shared_lock_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(APC_LEVEL)
+static FORCEINLINE VOID
+__DowngradeMrswLockExclusive(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+    __MrswRundownReInitialize(Lock, CacheAware);
+    BUG_ON(!__MrswRundownAcquire(Lock, CacheAware));
+    KeReleaseGuardedMutex(&Lock->Mutex);
+}
+#define DowngradeMrswLockExclusive(Lock) \
+    __DowngradeMrswLockExclusive(Lock, FALSE)
+#define DowngradeMrswCacheAwareLockExclusive(Lock) \
+    __DowngradeMrswLockExclusive(Lock, TRUE)
+
+_When_(return, _Acquires_shared_lock_(*Lock))
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
+static FORCEINLINE BOOLEAN
+__TryAcquireMrswLockShared(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+#if DBG
     ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
-    KeRaiseIrql(DISPATCH_LEVEL, &Irql);
-
-    Self = KeGetCurrentThread();
-
-    // Do we already hold the lock? If so, get the nesting level
-    Level = -1;
-    for (Slot = 0; Slot < (LONG) sizeof (Lock->Mask) * 8; Slot++) {
-        if (Lock->Holder[Slot].Thread == Self && Lock->Holder[Slot].Level > Level)
-            Level = Lock->Holder[Slot].Level;
-    }
-    Level++;
+#endif
 
-    for (;;) {
-        Slot = __ClaimShared(Lock);
-        if (Slot >= 0)
-            break;
-
-        _mm_pause();
-    }
-
-    Holder = &Lock->Holder[Slot];
-
-    Holder->Thread = Self;
-    Holder->Level = Level;
-
-    KeLowerIrql(Irql);
+    return __MrswRundownAcquire(Lock, CacheAware);
 }
-
+#define TryAcquireMrswLockShared(Lock) \
+    __TryAcquireMrswLockShared(Lock, FALSE)
+#define TryAcquireMrswCacheAwareLockShared(Lock) \
+    __TryAcquireMrswLockShared(Lock, TRUE)
+
+_Acquires_shared_lock_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
 static FORCEINLINE VOID
-ReleaseMrswLockShared(
-    IN  PXENVIF_MRSW_LOCK   Lock
+__SpinAcquireMrswLockShared(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
     )
 {
-    KIRQL                   Irql;
-    PKTHREAD                Self;
-    LONG                    Level;
-    LONG                    Deepest;
-    LONG                    Slot;
-    LONG64                  Old;
-    LONG64                  New;
-    PXENVIF_MRSW_HOLDER     Holder;
-
+#if DBG
     ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
-    KeRaiseIrql(DISPATCH_LEVEL, &Irql);
-
-    Self = KeGetCurrentThread();
-
-    Level = -1;
-    Deepest = -1;
-    for (Slot = 0; Slot < (LONG) sizeof (Lock->Mask) * 8; Slot++) {
-        if (Lock->Holder[Slot].Thread == Self && Lock->Holder[Slot].Level > Level) {
-            Level = Lock->Holder[Slot].Level;
-            Deepest = Slot;
-        }
-    }
-    ASSERT(Level >= 0);
-
-    Slot = Deepest;
-    ASSERT3U(Slot, !=, XENVIF_MRSW_EXCLUSIVE_SLOT);
-
-    Holder = &Lock->Holder[Slot];
+#endif
 
-    Holder->Thread = NULL;
-    Holder->Level = -1;
-
-    do {
-        Old = Lock->Mask;
-        New = Old & ~(1ll << Slot);
-    } while (InterlockedCompareExchange64(&Lock->Mask, New, Old) != Old);
-
-    KeSetEvent(&Lock->Event, IO_NO_INCREMENT, FALSE);
-    KeLowerIrql(Irql);
+    while (!__MrswRundownAcquire(Lock, CacheAware))
+        YieldProcessor();
+}
+#define SpinAcquireMrswLockShared(Lock) \
+    __SpinAcquireMrswLockShared(Lock, FALSE)
+#define SpinAcquireMrswCacheAwareLockShared(Lock) \
+    __SpinAcquireMrswLockShared(Lock, TRUE)
+
+/*
+ * Unlike SpinAcquireMrswLockShared, AcquireMrswLockShared will
+ * sleep when the lock acquisition fails. Thus it cannot be used at
+ * DISPATCH_LEVEL.
+ */
+_Acquires_shared_lock_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(APC_LEVEL)
+static FORCEINLINE VOID
+__AcquireMrswLockShared(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+#if DBG
+    ASSERT3U(KeGetCurrentIrql(), <=, APC_LEVEL);
+#endif
+
+    if (__MrswRundownAcquire(Lock, CacheAware))
+        return;
+
+    /*
+     * Don't bother retrying, since it's most likely that another writer section
+     * is cleaning up and not ending any time soon. Just jump straight into
+     * sleep.
+     */
+    KeAcquireGuardedMutex(&Lock->Mutex);
+    /*
+     * Since we have the write mutex, we know that there are no writers. So this
+     * acquire must succeed.
+     */
+    BUG_ON(!__MrswRundownAcquire(Lock, CacheAware));
+    KeReleaseGuardedMutex(&Lock->Mutex);
+}
+#define AcquireMrswLockShared(Lock) \
+    __AcquireMrswLockShared(Lock, FALSE)
+#define AcquireMrswCacheAwareLockShared(Lock) \
+    __AcquireMrswLockShared(Lock, TRUE)
+
+_Requires_shared_lock_held_(*Lock)
+_Releases_shared_lock_(*Lock)
+_IRQL_requires_min_(PASSIVE_LEVEL)
+_IRQL_requires_max_(DISPATCH_LEVEL)
+static FORCEINLINE VOID
+__ReleaseMrswLockShared(
+    _Inout_ struct _MRSW_LOCK   *Lock,
+    _In_ BOOLEAN                CacheAware
+    )
+{
+    __MrswRundownRelease(Lock, CacheAware);
 }
+#define ReleaseMrswLockShared(Lock) \
+    __ReleaseMrswLockShared(Lock, FALSE)
+#define ReleaseMrswCacheAwareLockShared(Lock) \
+    __ReleaseMrswLockShared(Lock, TRUE)
 
-#endif  // _XENVIF_MRSW_H
+#endif  // _MRSW_H
diff --git a/src/xenvif/vif.c b/src/xenvif/vif.c
index 6f468ee..cb4cf84 100644
--- a/src/xenvif/vif.c
+++ b/src/xenvif/vif.c
@@ -47,7 +47,7 @@
 
 struct _XENVIF_VIF_CONTEXT {
     PXENVIF_PDO                 Pdo;
-    XENVIF_MRSW_LOCK            Lock;
+    MRSW_LOCK                   Lock;
     LONG                        References;
     PXENVIF_FRONTEND            Frontend;
     BOOLEAN                     Enabled;
@@ -150,13 +150,12 @@ VifEnable(
     )
 {
     PXENVIF_VIF_CONTEXT     Context = Interface->Context;
-    KIRQL                   Irql;
     BOOLEAN                 Exclusive;
     NTSTATUS                status;
 
     Trace("====>\n");
 
-    AcquireMrswLockExclusive(&Context->Lock, &Irql);
+    AcquireMrswLockExclusive(&Context->Lock);
     Exclusive = TRUE;
 
     if (Context->Enabled)
@@ -188,7 +187,7 @@ VifEnable(
 
 done:
     ASSERT(Exclusive);
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+    ReleaseMrswLockExclusive(&Context->Lock);
 
     Trace("<====\n");
 
@@ -199,7 +198,7 @@ fail3:
 
     (VOID) FrontendSetState(Context->Frontend, FRONTEND_CONNECTED);
 
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, TRUE);
+    DowngradeMrswLockExclusive(&Context->Lock);
     Exclusive = FALSE;
 
     ReceiverWaitForPackets(FrontendGetReceiver(Context->Frontend));
@@ -234,7 +233,7 @@ fail1:
     Context->Callback = NULL;
 
     if (Exclusive)
-        ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+        ReleaseMrswLockExclusive(&Context->Lock);
     else
         ReleaseMrswLockShared(&Context->Lock);
 
@@ -389,17 +388,16 @@ VifEnableVersion9(
     )
 {
     PXENVIF_VIF_CONTEXT             Context = Interface->Context;
-    KIRQL                           Irql;
     NTSTATUS                        status;
 
     Trace("====>\n");
 
-    AcquireMrswLockExclusive(&Context->Lock, &Irql);
+    AcquireMrswLockExclusive(&Context->Lock);
 
     Context->CallbackVersion9 = Callback;
     Context->ArgumentVersion9 = Argument;
 
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+    ReleaseMrswLockExclusive(&Context->Lock);
 
     status = VifEnable(Interface, VifCallbackVersion9, Context);
 
@@ -416,17 +414,16 @@ VifEnableVersion8(
     )
 {
     PXENVIF_VIF_CONTEXT             Context = Interface->Context;
-    KIRQL                           Irql;
     NTSTATUS                        status;
 
     Trace("====>\n");
 
-    AcquireMrswLockExclusive(&Context->Lock, &Irql);
+    AcquireMrswLockExclusive(&Context->Lock);
 
     Context->CallbackVersion8 = Callback;
     Context->ArgumentVersion8 = Argument;
 
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+    ReleaseMrswLockExclusive(&Context->Lock);
 
     status = VifEnableVersion9(Interface, VifCallbackVersion8, Context);
 
@@ -441,14 +438,13 @@ VifDisable(
     )
 {
     PXENVIF_VIF_CONTEXT Context = Interface->Context;
-    KIRQL               Irql;
 
     Trace("====>\n");
 
-    AcquireMrswLockExclusive(&Context->Lock, &Irql);
+    AcquireMrswLockExclusive(&Context->Lock);
 
     if (!Context->Enabled) {
-        ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+        ReleaseMrswLockExclusive(&Context->Lock);
         goto done;
     }
 
@@ -463,7 +459,7 @@ VifDisable(
 
     (VOID) FrontendSetState(Context->Frontend, FRONTEND_CONNECTED);
 
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, TRUE);
+    DowngradeMrswLockExclusive(&Context->Lock);
 
     ReceiverWaitForPackets(FrontendGetReceiver(Context->Frontend));
     TransmitterAbortPackets(FrontendGetTransmitter(Context->Frontend));
@@ -511,7 +507,7 @@ VifQueryStatistic(
     status = STATUS_INVALID_PARAMETER;
     if (Index >= XENVIF_VIF_STATISTIC_COUNT)
         goto done;
-        
+
     AcquireMrswLockShared(&Context->Lock);
 
     FrontendQueryStatistic(Context->Frontend, Index, Value);
@@ -567,7 +563,8 @@ VifReceiverReturnPacket(
 {
     PXENVIF_VIF_CONTEXT Context = Interface->Context;
 
-    AcquireMrswLockShared(&Context->Lock);
+    // Called from MINIPORT_RETURN_NET_BUFFER_LISTS
+    SpinAcquireMrswLockShared(&Context->Lock);
 
     ReceiverReturnPacket(FrontendGetReceiver(Context->Frontend),
                          Cookie);
@@ -592,9 +589,10 @@ VifTransmitterQueuePacket(
     PXENVIF_VIF_CONTEXT             Context = Interface->Context;
     NTSTATUS                        status;
 
-    AcquireMrswLockShared(&Context->Lock);
-
     status = STATUS_UNSUCCESSFUL;
+    if (!TryAcquireMrswLockShared(&Context->Lock))
+        return status;
+
     if (!Context->Enabled)
         goto done;
 
@@ -948,9 +946,8 @@ VifAcquire(
     )
 {
     PXENVIF_VIF_CONTEXT     Context = Interface->Context;
-    KIRQL                   Irql;
 
-    AcquireMrswLockExclusive(&Context->Lock, &Irql);
+    AcquireMrswLockExclusive(&Context->Lock);
 
     if (Context->References++ != 0)
         goto done;
@@ -963,7 +960,7 @@ VifAcquire(
     Trace("<====\n");
 
 done:
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+    ReleaseMrswLockExclusive(&Context->Lock);
 
     return STATUS_SUCCESS;
 }
@@ -974,9 +971,8 @@ VifRelease(
     )
 {
     PXENVIF_VIF_CONTEXT     Context = Interface->Context;
-    KIRQL                   Irql;
 
-    AcquireMrswLockExclusive(&Context->Lock, &Irql);
+    AcquireMrswLockExclusive(&Context->Lock);
 
     if (--Context->References > 0)
         goto done;
@@ -991,7 +987,7 @@ VifRelease(
     Trace("<====\n");
 
 done:
-    ReleaseMrswLockExclusive(&Context->Lock, Irql, FALSE);
+    ReleaseMrswLockExclusive(&Context->Lock);
 }
 
 static struct _XENVIF_VIF_INTERFACE_V8 VifInterfaceVersion8 = {
@@ -1100,7 +1096,9 @@ VifInitialize(
     if (*Context == NULL)
         goto fail1;
 
-    InitializeMrswLock(&(*Context)->Lock);
+    status = InitializeMrswLock(&(*Context)->Lock, XENVIF_VIF_TAG);
+    if (!NT_SUCCESS(status))
+        goto fail2;
 
     FdoGetSuspendInterface(PdoGetFdo(Pdo),&(*Context)->SuspendInterface);
 
@@ -1110,7 +1108,7 @@ VifInitialize(
                           *Context,
                           &(*Context)->MacThread);
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail3;
 
     (*Context)->Pdo = Pdo;
 
@@ -1118,7 +1116,7 @@ VifInitialize(
 
     return STATUS_SUCCESS;
 
-fail2:
+fail3:
     Error("fail3\n");
 
     RtlZeroMemory(&(*Context)->MacEvent, sizeof (KEVENT));
@@ -1126,7 +1124,10 @@ fail2:
     RtlZeroMemory(&(*Context)->SuspendInterface,
                   sizeof (XENBUS_SUSPEND_INTERFACE));
 
-    RtlZeroMemory(&(*Context)->Lock, sizeof (XENVIF_MRSW_LOCK));
+    TeardownMrswLock(&(*Context)->Lock);
+
+fail2:
+    Error("fail2\n");
 
     ASSERT(IsZeroMemory(*Context, sizeof (XENVIF_VIF_CONTEXT)));
     __VifFree(*Context);
@@ -1205,7 +1206,7 @@ VifGetInterface(
     }
 
     return status;
-}   
+}
 
 VOID
 VifTeardown(
@@ -1228,7 +1229,7 @@ VifTeardown(
     RtlZeroMemory(&Context->SuspendInterface,
                   sizeof (XENBUS_SUSPEND_INTERFACE));
 
-    RtlZeroMemory(&Context->Lock, sizeof (XENVIF_MRSW_LOCK));
+    TeardownMrswLock(&Context->Lock);
 
     ASSERT(IsZeroMemory(Context, sizeof (XENVIF_VIF_CONTEXT)));
     __VifFree(Context);
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Thu Apr 16 12:02:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 16 Apr 2026 12:02:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1283293.1565564 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDLQY-0002d5-TO; Thu, 16 Apr 2026 12:02:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1283293.1565564; Thu, 16 Apr 2026 12:02:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDLQY-0002cy-Qo; Thu, 16 Apr 2026 12:02:34 +0000
Received: by outflank-mailman (input) for mailman id 1283293;
 Thu, 16 Apr 2026 12:02:34 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e0c394.v1-13aadef973e149f1b00021aba5dc0a5b@bounce.vates.tech>)
 id 1wDLQY-0002cs-1F
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 12:02:34 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDLQX-00Gclt-Dy
 for win-pv-devel@lists.xenproject.org; Thu, 16 Apr 2026 14:02:33 +0200
Received: from [10.42.69.7] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e0c394.v1-13aadef973e149f1b00021aba5dc0a5b@bounce.vates.tech>)
 id 69e0cfd5-bab6-0a2a0a5309dd-0a2a4507ac2e-16
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 14:02:33 +0200
Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com)
 by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e0c394.v1-13aadef973e149f1b00021aba5dc0a5b@bounce.vates.tech>)
 id 69e0cfd7-229c-0a2a45070019-c602bb0150ba-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 14:02:32 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fxFfX4zrTzBsdDfY
 for <win-pv-devel@lists.xenproject.org>; Thu, 16 Apr 2026 11:10:12 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 13aadef973e149f1b00021aba5dc0a5b; Thu, 16 Apr 2026 11:10:12 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776337812; x=1776607812;
	bh=bT+aAUpKio5k65EN/gBcy5imBEPx8tEkcAJ0AU+YQIk=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=cQ4PlyWvMdUVWU2DSmxxRPek++tZt+l5IDKcTudqhueSbq0jHZErlKQSFgmk6KRpG
	 LqC+YhkyWshwAitxDr4Cd/lmkMuPqKvMZ4diFuMh4rf/UnM2RYQn9sSA9Oye2EkMFO
	 x3U/5XHNLb2vX5YL8ZNcD63wEPr/T4R/o0Jw4zpt6NSsyBZP68rddWPSmykZbkVFrb
	 UmOS2Z39kYhVUDkDkLVOsaNq6e358um+v4S7tGt1aZwrmNZKGKR/GgsDzh45dC3J7l
	 zCCktZeaR4XJZ7XgJ2LcjRejtKwfc/yGUX03VVHzancgNXJdyVVjf08ghl5ljG1/EM
	 wkABJuKZOQGug==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776337812; x=1776598312; i=ngoc-tu.dinh@vates.tech;
	bh=bT+aAUpKio5k65EN/gBcy5imBEPx8tEkcAJ0AU+YQIk=;
	h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=VmcTBCUuWNZAusyWBcmUJdeRLWCHlBi3NLsQXVA8dY42eAOH4dLnNjcZuKwD2Npud
	 q2ZztleWyYCptrFdDKA6kX86mUGXE5+WC2HAU/bkK+mU4JLvbPk4MyPu5PSyT/0FXp
	 VhwvDajzaAJOSERqkI1OBHY+nCX252OOu0yne0FpMILLhexqjDWvqvdzfn8RNOUftO
	 tc6nIdPGtjrooMawhH8CiTqwnIAKvz7d447pfKnTwEVhs/hcYwqfEJMbAx/Gld1oW5
	 MxUa0DPcj0HUEp2j+df/1pLbFqIcmOI7CbH78mzqAn7QxdDwyOXxVHgWAVrLsSr+Eh
	 5EeL+AJ1CotHw==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH=202/2]=20Call=20AdapterDisable=20during=20NdisDevicePnPEventSurpriseRemoved?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776337812072
To: win-pv-devel@lists.xenproject.org
Cc: "Tu Dinh" <ngoc-tu.dinh@vates.tech>, "Owen Smith" <owen.smith@citrix.com>
Message-Id: <20260416111009.379-2-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416111009.379-1-ngoc-tu.dinh@vates.tech>
References: <20260416111009.379-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.13aadef973e149f1b00021aba5dc0a5b?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260416:md
Date: Thu, 16 Apr 2026 11:10:12 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-ef75cf/1776340952-16C64C48-4022A53B/0/0
X-purgate-type: clean
X-purgate-size: 1550

During a surprise removal, NDIS performs the following sequence:
1. Call MiniportDevicePnPEventNotify(NdisDevicePnPEventSurpriseRemoved)
2. Pause protocol and filter drivers
3. Only then pause the miniport

Since MiniportPause is not called until after the protocols have been
paused, in the absence of hang detection, step 2 will hang indefinitely
while NDIS waits for transmitted packets to be returned even though the
backend's already gone.

MiniportDevicePnPEventNotify is currently the last opportunity for us to
disable the adapter, so do that here.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xennet/miniport.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/xennet/miniport.c b/src/xennet/miniport.c
index 3ec76a9..9f3a8c6 100644
--- a/src/xennet/miniport.c
+++ b/src/xennet/miniport.c
@@ -230,10 +230,16 @@ MiniportDevicePnPEventNotify(
     IN  PNET_DEVICE_PNP_EVENT   NetDevicePnPEvent
     )
 {
-    UNREFERENCED_PARAMETER(MiniportAdapterContext);
-    UNREFERENCED_PARAMETER(NetDevicePnPEvent);
+    PXENNET_ADAPTER             Adapter = (PXENNET_ADAPTER)MiniportAdapterContext;
 
-    Trace("<===>\n");
+    if (NetDevicePnPEvent->DevicePnPEvent != NdisDevicePnPEventSurpriseRemoved)
+        return;
+
+    Trace("====>\n");
+
+    AdapterDisable(Adapter);
+
+    Trace("<====\n");
 }
 
 static
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Apr 17 10:05:00 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 17 Apr 2026 10:05:00 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1284129.1566025 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDg4J-00013T-7C; Fri, 17 Apr 2026 10:04:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1284129.1566025; Fri, 17 Apr 2026 10:04:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDg4J-00013L-4M; Fri, 17 Apr 2026 10:04:59 +0000
Received: by outflank-mailman (input) for mailman id 1284129;
 Fri, 17 Apr 2026 10:04:57 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e205c6.v1-7a2ce5b2358f4b738404245f378920fd@bounce.vates.tech>)
 id 1wDg4H-00013F-C4
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 10:04:57 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDg4G-00288V-NA
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 12:04:56 +0200
Received: from [10.42.69.6] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e205c6.v1-7a2ce5b2358f4b738404245f378920fd@bounce.vates.tech>)
 id 69e205c3-bab6-0a2a0a5309dd-0a2a4506dd70-18
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 12:04:56 +0200
Received: from [198.2.187.30] (helo=mail187-30.suw11.mandrillapp.com)
 by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e205c6.v1-7a2ce5b2358f4b738404245f378920fd@bounce.vates.tech>)
 id 69e205c7-7371-0a2a45060019-c602bb1eeeee-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 12:04:56 +0200
Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1])
 by mail187-30.suw11.mandrillapp.com (Mailchimp) with ESMTP id
 4fxr8k5xV4zP0Jmty
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 10:04:54 +0000 (GMT)
Received: from [37.26.189.201] by mandrillapp.com id
 7a2ce5b2358f4b738404245f378920fd; Fri, 17 Apr 2026 10:04:54 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776420294; x=1776690294;
	bh=arqs5XKEBJ1OsqUNW2njIxxJB5MaKT/BKfQAElwjDDQ=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=AX0v/rnJZSrYnED/anEGlFWn3eWFtaWkmPz3hRvAzGfxgfeDm4vQFRBvG+GFpzYJL
	 l/6NUP+ByAzV8GF9Xx2nnebdJtSArw5ODWCmHSY4ITyyJM1NDhDq3Dg+xyG3yNk7ZA
	 HMyurtPQQjKUtGk5dArD/0dk2kXX6OtAsgs1k0ZZrN+U9Q1OcJ0vaekfBjrhLaBbvx
	 8zWmkxdghoNMXiIPTzxyiEkGTBsd9zr3kq94EOG4zv8bO9HtQSQHPMCAy2eMvlFUCO
	 VrX7Pa8Yso9tB2z9GBvZJcoi0+SXcC/KYKcZRwftSP7ZbwMIZzKdNCIfSRWivzRabR
	 xBqH1gwdexAIA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776420294; x=1776680794; i=ngoc-tu.dinh@vates.tech;
	bh=arqs5XKEBJ1OsqUNW2njIxxJB5MaKT/BKfQAElwjDDQ=;
	h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From;
	b=jZcu9h2uG82Le+GzzaPJc6JCFnmwHJH3C/9IDpq+ZYoSL6GBI1lhS8hfemF1gT+Lo
	 GmJuN6IxmkAi0W6WIt3cDlcMZMnZp4TxK0HAnP9E/9T4K6O79bsHnDFKab6Xj7pMDh
	 7pLBR/eJQpcV3LmEewktcgulgdUYyn/MkU4yWyfXfCLN5cUe/moBY4/bBbIVd8p8u2
	 FniR9A5VWNnr6shs9NnV2McfEE2qzFWMWtCNo3MgpqkPS5iyP3/6PUAmTkHIfbFffc
	 djg6HFofT7lmXfop9+nyX/Jtk4tOxD/DnALLymLbPbR74GFjqxvtHtn+GtuLjCyaxB
	 oQiNnW73cGjYA==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?[PATCH]=20Don't=20evaluate=20ASSERT3=20arguments=20in=20release=20build?=
X-Mailer: git-send-email 2.53.0.windows.2
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776420294053
To: win-pv-devel@lists.xenproject.org
Cc: "Owen Smith" <owen.smith@citrix.com>, "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Message-Id: <20260417100446.1623-1-ngoc-tu.dinh@vates.tech>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.7a2ce5b2358f4b738404245f378920fd?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260417:md
Date: Fri, 17 Apr 2026 10:04:54 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-16d1c6/1776420296-CF77FD75-CC359BC7/0/0
X-purgate-type: clean
X-purgate-size: 2230

Evaluating arguments to ASSERT3 may call functions that, even if they
don't have visible side effects (e.g. KeGetCurrentIrql), still cause
the function's code to be emitted into the binary.

Move the evaluation into inside the __analysis_assume expression to
avoid this.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/assert.h | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/xenvif/assert.h b/src/xenvif/assert.h
index d0cf3f2..c41dfed 100644
--- a/src/xenvif/assert.h
+++ b/src/xenvif/assert.h
@@ -136,29 +136,14 @@ __Bug(
             __analysis_assume(_EXP);    \
         } while (FALSE)
 
-#define ASSERT3U(_X, _OP, _Y)                       \
-        do {                                        \
-            ULONGLONG   _Lval = (ULONGLONG)(_X);    \
-            ULONGLONG   _Rval = (ULONGLONG)(_Y);    \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3U(_X, _OP, _Y)           \
+        ASSERT((ULONGLONG)(_X) _OP (ULONGLONG)(_Y))
 
-#define ASSERT3S(_X, _OP, _Y)                       \
-        do {                                        \
-            LONGLONG    _Lval = (LONGLONG)(_X);     \
-            LONGLONG    _Rval = (LONGLONG)(_Y);     \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3S(_X, _OP, _Y)           \
+        ASSERT((LONGLONG)(_X) _OP (LONGLONG)(_Y))
 
-#define ASSERT3P(_X, _OP, _Y)                       \
-        do {                                        \
-            PVOID   _Lval = (PVOID)(_X);            \
-            PVOID   _Rval = (PVOID)(_Y);            \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3P(_X, _OP, _Y)           \
+        ASSERT((PVOID)(_X) _OP (PVOID)(_Y))
 
 #endif  // DBG
 
-- 
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Apr 17 12:45:34 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 17 Apr 2026 12:45:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1284235.1566074 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDiZg-0005GY-Fr; Fri, 17 Apr 2026 12:45:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1284235.1566074; Fri, 17 Apr 2026 12:45:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDiZg-0005GR-Cp; Fri, 17 Apr 2026 12:45:32 +0000
Received: by outflank-mailman (input) for mailman id 1284235;
 Fri, 17 Apr 2026 12:45:31 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wDiZf-0005GL-72
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 12:45:31 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDiZe-009FkT-Jz
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 14:45:30 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e22b5c-e002-0a2a0a5209dd-0a2a45099e7c-38
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 14:45:30 +0200
Received: from [52.101.85.3]
 (helo=BYAPR05CU005.outbound.protection.outlook.com)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e22b67-2497-0a2a45090019-34655503780b-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 14:45:30 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by BLAPR03MB5411.namprd03.prod.outlook.com (2603:10b6:208:29e::8)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.25; Fri, 17 Apr
 2026 12:45:25 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9818.023; Fri, 17 Apr 2026
 12:45:25 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=AexgZ6/66hb4K0tOxF2sAIxYDEkwMWA9unBG9hLclEQrWJEL7uqm0Ruc4l+nYmOJWCyuHnWWKCutolFPsCPzrMoH5ES69LVWge1MIBYE5On7IShw0gvWmsKqE0rVEnrAUkRBo8sH5ueEbSsid7x4u/EN4+oZW5zy63ieALgoPOP1xNapDzHkNTq+w5qBAZskBmJzSwkTB3qJ/OJJ08au+ldtqDFU7JauKSyxPBDeykBr82AmRmgbxjayZCpND1uwogjzBJV+cfND5HMtuXFKMZT3mWqLI5KbIgboX12mEMpxq1fx25z8k3t+UbOHzvqtShtpb8rPRO5S6AM43qYmKA==
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=ZL1smkQLGPZBvTxCdApwQdzhsOX2LbatVeBPi8DUPuI=;
 b=gj/kyh1e+AbJRWVBkYcZdClyI5dS6FpszuM8fJsuNVcVuh7aMCFMQBjh4aBkP2jLo0IxMHNhC44SZmsdJUglitwHiAzQsXffXuOJZFOjNoTDimh1qYNA0Rf3pTAw2yAZd8iEWR63/1G7UW/B8Gx7NZPARrx0uEmuUQztVQjAY0I5TsMR9o9QYMJVcYUBulliQuLRr24NQJMGSdc9mJ0nN8ATNpbtV9olzJQwaCN2nAhWr4IkeNI5dM+32aI8WKMcMSpeSSxQ5J78agrfEsQLYnfkwvbcDDHNnZkg5yQ+y8dPxwJiHkcPYBlmoXKX2TaPSDCCorf5dBF7Lv9Nt4xpVA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=ZL1smkQLGPZBvTxCdApwQdzhsOX2LbatVeBPi8DUPuI=;
 b=sgLhnPCupFGV4AVriUUAIYjdJL8qwWhDx4x1poLbGP6ZbDVgPvQaSRlle0MtBbajaWMkyGoOf/UtKES3h6kKMp3eLaAkUWjKyJvjSEt8VBBSVZDhNvnQD7U96SNGXQc1iz5neSmm4AUCXs420B7up+XW/pA0er/ka39T1RKDfos=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 0/5] Rundown MRSW lock and device removal fixes
Thread-Topic: [PATCH 0/5] Rundown MRSW lock and device removal fixes
Thread-Index: AQHczZGYvU3wfsQTrUCw9JvrcGGgX7XjMZVX
Date: Fri, 17 Apr 2026 12:45:25 +0000
Message-ID:
 <SA6PR03MB7760942EB54250D0228FAB04FE202@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|BLAPR03MB5411:EE_
x-ms-office365-filtering-correlation-id: 6343fa6f-b6d8-4599-5dfa-08de9c7f3275
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|1800799024|376014|366016|38070700021|56012099003|18002099003|22082099003;
x-microsoft-antispam-message-info:
 kVyPVLixdbiG0Mw214argWHYl2gDp6b6kUkKg7knuWeq6HlTmFEMZdPHBLXN6NbMW+/wAqnwgI0q2M3VGIyh83KEXbqNISVP3Ra3oLC6n9VVYGp+LA99L9swCYwKc9RXpIwNjHhFN7ZvmQEGDsWXjNHdgSdIGrbC9DKylpqcpYmDWjmYB0DGiSB+keSRRYZYlvFR8QhRvQr17ighwLH58WWr6IKajQhhta5aNKUCe2f+hI2Qv1uG+i9DvsEmGrcupazgUs/xtNHZU50g+TzDhwObpqJxGsdMP5u4NlWuHdPrdctBd+cqWW5+m1QOOE/NwZci1az3svQ7v/tymKArHYwooJihKKhiws7CR9199yJehgNY/EE0OxC2eX6KVBeE0whZg4fdeFuWnM4RoMQJNb2qve+pp8m2OcQ2zdeuYFGe8oXwC4TVeMHolDoHdrcGXwFTtLsrQO5JaHBu4uLwOGabLdzrmryWQCbF8XZSTg22X31nn2ltDet8gXfbmZSKKQWoPk9Miya+HVrD2ENg+ySh8N+w1E+HH8VxF3NA4XBdzaQQ7SjZDLs3k0CEOmHebQHDLI3co7nhXkB7MbP7nfoVxnUrQrAyJxnmklDUAzj8dDTloZ+LqfpNN2UTxs2zlHebFGOmvjpVnhmofgr5/vhfyBpTTJlXldPjQ2atR5aAsU0rjbk84IR3ckhSiccapN0Apjsz4grc6PwSILJGaX8cKNq93m9Mep4oaLHa0bY=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(38070700021)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?husMwSaQQ/tOsEUGpKPaweFprtGOf9sXMpd10q4vgNT1SMuWTk9nPfGkTmNT?=
 =?us-ascii?Q?WHiblpCC8EZvEuJjkNQaA13T4ScjcIbe7I7WVxzjDMcyEJThHa/P6ff6/mGJ?=
 =?us-ascii?Q?FZR7dZv1q46UjnFCOZ8T9WXI9MwAWY/ugu25pynu7KawudvOLXkv8vwTCMVP?=
 =?us-ascii?Q?yGogvzeM77Jh42loPz1Q2RstRPmmPeD/ZFAlPaE0NqDU8foc79PlsHXcOtco?=
 =?us-ascii?Q?9u7pebEvjLND1brkjzYGDggBPuLSmwVi6eDGwflMnfV8xsb5XhdKopIUFTVU?=
 =?us-ascii?Q?e1i5p+pQsV/K6njRcGIzcdqPVo5R7eo8ZGCL+uKQ6+052Ji6BdYEDypyKHPF?=
 =?us-ascii?Q?b3bCRQewHR7DxigiqG7WYW5qQj0mRka7vgYJrH0mEPEWIDXDsDxwa7IQ88Uf?=
 =?us-ascii?Q?9rJC6kRXq+r/4WePeyB6lmCjNTxHe9VwjCsWGutzO8iQ1m9hR+SUYedYNrON?=
 =?us-ascii?Q?KMMiQiFFf/v+HmoR07RdeT10jVmj2OtQLCwcGorPs3FjFGL9DXEcMIAID7xc?=
 =?us-ascii?Q?YzmUV+xHHdAhSgcPkJjWz+544OnSF0rCDFmw36jEtkROUmx/D+T7NhwDNH9J?=
 =?us-ascii?Q?ZXZsaTLwUsIbnJ3tAxhqiDZqe5QNQSe0cJGq9RwlACMgVZmbVaZSjexYl9Im?=
 =?us-ascii?Q?Q0VbTuwMJqiH+6sw7agfn9gCJLtdBrwHRnhwzC5jAeEK9U4ZAKBk4s5m1N9i?=
 =?us-ascii?Q?jwqz06xv3BHOzvmmHlsDWoioU5N2dnxkN1E2Pe/bX18tmKsvzs9UqGbHCBA3?=
 =?us-ascii?Q?za/4xbZcM5rYCtJ2yJtV3Ikdb+/Nau3H9YnHXqMln4WMVu6PVL+ogBwZFuhr?=
 =?us-ascii?Q?IPIj+s3e2Jym3P6KSbhbgkhCS6V9TD2Q0RMxeiFqaHkkOOhtqda3DZ5e5jM7?=
 =?us-ascii?Q?gp6fNSSmEkxiCGUh6stMniMs6py2Y6td0jun8eombL5tMNya4h3KVlxaJomf?=
 =?us-ascii?Q?xYkFs9n7k5FVK8WuFY4TpP7MQWPRAs7zyIJbscp6Ru4gFVc3S1pFVgcJccqO?=
 =?us-ascii?Q?FSHga5Hsjbz76hHUHvvOKkVcTO8bHyBVqaBDBCYnF9XMFYvRMYmSdZSluBYf?=
 =?us-ascii?Q?m32+F7IGhfkUH/1+6VIMHWra1AZwtqOBK6WF3NxW3iA8UC0KfDNR/BgRIQZ2?=
 =?us-ascii?Q?HqYHPXWGJnZzgpAuJ6j6UjuCD+0tLG3zb0jNagUXLdFJagwqtxdnpTm7wOWb?=
 =?us-ascii?Q?f7smdeI25epuyPnmDUh8X2JTN5145DOA/fxeNvqcWqDC0gPMuW7kiSQWpXOc?=
 =?us-ascii?Q?QIA7zHOCjpOpQjON+sZM3irvf51IJgcSTJetkjIko4bTu2q7LTNujmRCiAdF?=
 =?us-ascii?Q?dEoKne0naZ5jJmXdCOf4XGGc5RgCijuHgfvEQZ3mfArqpZHvC4CPbabJcnWg?=
 =?us-ascii?Q?VX89qpKrsL9mImerA3Pa/1Lr7EIajoNusU7E/sRHJ21FTM+9UMYmd5KYw8kx?=
 =?us-ascii?Q?AYCFx/lTH7DxkwezP8YqlNCq7SIfCWTLFSgip1o6PeVxFaeRLQfgyVcia+/c?=
 =?us-ascii?Q?Jr429Gu5Q9nWTr1A4SEfZp32GkLLNlMa39PjzPDb9CgHVMlRuyHKyJk59eHS?=
 =?us-ascii?Q?2xMYkpZEJzV6o/poGlUCDzpg06e4+8U0zMEfbl2qeYeKFks1m7DSBwAJQ5UX?=
 =?us-ascii?Q?rT6Q0CH6SkekY6H3xUHBPfzNisOEft6F5bEjCkxr9gyr3B27tqhOiG3+4xig?=
 =?us-ascii?Q?J5yNLeDJ+m2hDvjbZvmF2K821SE2YUumZ6u0tetLCYmZmTtRojK6NhoEUIkK?=
 =?us-ascii?Q?xJ2LhQNsiA=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 6343fa6f-b6d8-4599-5dfa-08de9c7f3275
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2026 12:45:25.4216
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: dSbiOOYBDXCdrmJQGaazhXcdsVU8qPbd5kpbnnIrZLALevOVs7yMfMdKOZns50gyGOgCuPk1RCUuhpNHqoW5iA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR03MB5411
X-purgate-ID: tlsNG-bad1c0/1776429930-9216DA53-90447685/0/0
X-purgate-type: clean
X-purgate-size: 1688


Do these changes work without the matching xennet changes?
Do the xennet changes work without these changes?

(i.e. is it safe to apply these without the xennet patches or the xennet pa=
tches
 without these patches?)

Owen

________________________________________
From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of=
 Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 16 April 2026 12:09 PM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH 0/5] Rundown MRSW lock and device removal fixes

Patches 1 and 2 are fixes for various lockups encountered during
surprise removal.

Patch 3 is an annotation prerequisite for Patch 4, which replaces the
current MRSW lock with a simpler one.

Patch 5 is only for debugging purposes.

To be used together with matching Xennet surprise removal patches.

Tu Dinh (5):
  Check Fragment->Entry before calling RevokeForeignAccess
  Watch BACKEND/state key for eject status
  Update IRQL annotations
  Implement rundown-based MRSW lock
  Trace worker thread wake events

 src/xenvif/controller.c  |   5 +-
 src/xenvif/fdo.c         |   6 +-
 src/xenvif/frontend.c    |  36 +--
 src/xenvif/frontend.h    |  18 +-
 src/xenvif/mrsw.h        | 530 ++++++++++++++++++++++-----------------
 src/xenvif/receiver.c    |  24 +-
 src/xenvif/receiver.h    |  14 +-
 src/xenvif/transmitter.c |  25 +-
 src/xenvif/transmitter.h |   6 +-
 src/xenvif/vif.c         |  73 +++---
 10 files changed, 409 insertions(+), 328 deletions(-)

--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




From win-pv-devel-bounces@lists.xenproject.org Fri Apr 17 13:13:35 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 17 Apr 2026 13:13:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1284259.1566087 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDj0o-0000m8-KM; Fri, 17 Apr 2026 13:13:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1284259.1566087; Fri, 17 Apr 2026 13:13:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDj0o-0000m0-HT; Fri, 17 Apr 2026 13:13:34 +0000
Received: by outflank-mailman (input) for mailman id 1284259;
 Fri, 17 Apr 2026 13:13:33 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <bounce-md_30504962.69e231fa.v1-7ecd3792782f4ac1b2765c13196b1fbf@bounce.vates.tech>)
 id 1wDj0m-0000lu-V3
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 13:13:33 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDj0m-0007bg-A9
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 15:13:32 +0200
Received: from [10.42.69.10] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <bounce-md_30504962.69e231fa.v1-7ecd3792782f4ac1b2765c13196b1fbf@bounce.vates.tech>)
 id 69e231f5-2eae-0a2a0a5409dd-0a2a450ab924-14
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 15:13:32 +0200
Received: from [198.2.137.11] (helo=mail137-11.atl71.mandrillapp.com)
 by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <bounce-md_30504962.69e231fa.v1-7ecd3792782f4ac1b2765c13196b1fbf@bounce.vates.tech>)
 id 69e231fa-56b3-0a2a450a0019-c602890bd9a5-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 15:13:32 +0200
Received: from mta004-md-usw2.delv.a.intuit.com (localhost [127.0.0.1])
 by mail137-11.atl71.mandrillapp.com (Mailchimp) with ESMTP id
 4fxwLL1PKFzDRX4cx
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 13:13:30 +0000 (UTC)
Received: from [37.26.189.201] by mandrillapp.com id
 7ecd3792782f4ac1b2765c13196b1fbf; Fri, 17 Apr 2026 13:13:30 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="ngoc-tu.dinh@vates.tech" header.h="From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com;
	s=mte1; t=1776431610; x=1776701610;
	bh=bgoBCSGiBepAXQYtyVVEE5sDxecrZihgFYWoINxUFnc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=N2JnXM4dGMTsrnM9M3qm83aVA+UzGS/HD1ldZJdQWa086oXfk5uBTZxlE+I087LQ6
	 Km8pDs4swTkeG93fVsFgoUrFwJ6NUKV+AEXigNH0Eb8kuTyxSgPX3zkMl9zs6wxHsR
	 ujtaZblDt9f17MgpPGzG2ZeGco16iaRYbBdoivHdPoSrTYb/nuqHXOCwCPlq9PMuy6
	 GT+h4rlteATh//GA+HJFDgkVND7ic1B9UAWZbjjIm49vY1mwDdHmtS6CA4j3pRVjyZ
	 al5e6gmbYX61dwrogXm++ulUf01La7LIJELse6brfLRT/bT7EG5nq8Zrd4Tx0lE+Zw
	 Gv1OCluWG+Tcg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1;
	t=1776431610; x=1776692110; i=ngoc-tu.dinh@vates.tech;
	bh=bgoBCSGiBepAXQYtyVVEE5sDxecrZihgFYWoINxUFnc=;
	h=From:Subject:Message-Id:To:References:In-Reply-To:Feedback-ID:
	 Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date:
	 Subject:From;
	b=Hbtz0L5HJVbWE8f6OWGDulOBx3IhrPb8et5Lkv0fqFWDl7sYMehB4eyo4B6Y+6JHW
	 HuHDBmAaEXEexs8/BuT4Noip1uc/2qR67b5X66Ft1SaMFH8RJl8/EFjqtN/Q6sdK3g
	 4HSx8GLHyTVQboiIa+xb0z5UjQfWJHVmiHO3Rb9SriXuiRT3S4oRbOtf5teFoGTKjC
	 i72N8MoSS7IL3LlAglg9ruXM4W49Ay00+m09prloZm2ujk9/OkBy/BKKgpQIMRFTxd
	 y0OCdLBtYJyck345mggYusVyyGMt9Wa1NGo5W7LV2r60QrbCdQ2DoH+hYqk6uetOF0
	 q9A15RQ6HhDvQ==
From: "Tu Dinh" <ngoc-tu.dinh@vates.tech>
Subject: =?utf-8?Q?Re:=20[PATCH=200/5]=20Rundown=20MRSW=20lock=20and=20device=20removal=20fixes?=
X-Bm-Disclaimer: Yes
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776431605408
Message-Id: <b2ffe02e-08f5-4522-a81d-4ab4386ec65f@vates.tech>
To: "Owen Smith" <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech> <SA6PR03MB7760942EB54250D0228FAB04FE202@SA6PR03MB7760.namprd03.prod.outlook.com>
In-Reply-To: <SA6PR03MB7760942EB54250D0228FAB04FE202@SA6PR03MB7760.namprd03.prod.outlook.com>
X-Native-Encoded: 1
X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.7ecd3792782f4ac1b2765c13196b1fbf?=
X-Mandrill-User: md_30504962
Feedback-ID: 30504962:30504962.20260417:md
Date: Fri, 17 Apr 2026 13:13:30 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-purgate-ID: tlsNG-4011c0/1776431612-471728B7-EFEF2660/0/0
X-purgate-type: clean
X-purgate-size: 3840

Hi,

On 17/04/2026 14:45, Owen Smith wrote:
> 
> Do these changes work without the matching xennet changes?
> Do the xennet changes work without these changes?
> 
> (i.e. is it safe to apply these without the xennet patches or the xennet patches
>   without these patches?)
> 
> Owen
> 

I've only tested the xenvif and xennet changes together. Running them 
separately hasn't really been tested. But the lockup fixes should be 
independent of each other, as they fix different steps in the surprise 
removal process.

For information, the status of each patch should be as following 
(dependent patches are grouped together)

(xenvif)
* Check Fragment->Entry before calling RevokeForeignAccess
     - Self-contained.

* Watch BACKEND/state key for eject status
     - Lockup fix, self-contained. It triggers surprise removal instead 
of orderly removal when using `vif-unplug force=true`.

* Update IRQL annotations
     - Should go before the MRSW patch for IRQL correctness.
* Implement rundown-based MRSW lock
     - Self-contained except for "Update IRQL annotations". I haven't 
really tested this patch by itself without the lockup fixes. It's 
possible that running things at a lower IRQL would cause certain lockup 
problems to be easier to surface, but I can't confirm one way or another.

* Trace worker thread wake events
     - Self-contained.

(xennet)
* Signal surprise removal support during registration
     - Self-contained.

* Call AdapterDisable during NdisDevicePnPEventSurpriseRemoved
     - Lockup fix, self-contained, doesn't cause a dependency on xenvif 
or vice versa. But the surprise removal code path (fixed here) isn't 
entered without the xenvif patch "Watch BACKEND/state key for eject status".

NB: "Call AdapterDisable during NdisDevicePnPEventSurpriseRemoved" is 
very much a hack, since neither the MiniportDevicePnPEventNotify 
documentation nor the driver samples advocate stopping the datapath at 
this point. But given the lack of hang detection and response in 
xenvif/xennet, this is the best I could come up with to avoid lockups 
during surprise removal.

> ________________________________________
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of Tu Dinh <ngoc-tu.dinh@vates.tech>
> Sent: 16 April 2026 12:09 PM
> To: win-pv-devel@lists.xenproject.org
> Cc: Tu Dinh; Owen Smith
> Subject: [PATCH 0/5] Rundown MRSW lock and device removal fixes
> 
> Patches 1 and 2 are fixes for various lockups encountered during
> surprise removal.
> 
> Patch 3 is an annotation prerequisite for Patch 4, which replaces the
> current MRSW lock with a simpler one.
> 
> Patch 5 is only for debugging purposes.
> 
> To be used together with matching Xennet surprise removal patches.
> 
> Tu Dinh (5):
>    Check Fragment->Entry before calling RevokeForeignAccess
>    Watch BACKEND/state key for eject status
>    Update IRQL annotations
>    Implement rundown-based MRSW lock
>    Trace worker thread wake events
> 
>   src/xenvif/controller.c  |   5 +-
>   src/xenvif/fdo.c         |   6 +-
>   src/xenvif/frontend.c    |  36 +--
>   src/xenvif/frontend.h    |  18 +-
>   src/xenvif/mrsw.h        | 530 ++++++++++++++++++++++-----------------
>   src/xenvif/receiver.c    |  24 +-
>   src/xenvif/receiver.h    |  14 +-
>   src/xenvif/transmitter.c |  25 +-
>   src/xenvif/transmitter.h |   6 +-
>   src/xenvif/vif.c         |  73 +++---
>   10 files changed, 409 insertions(+), 328 deletions(-)
> 
> --
> 2.53.0.windows.2
> 
> 
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
> 
> XCP-ng & Xen Orchestra - Vates solutions
> 
> web: https://vates.tech
> 
> 



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Fri Apr 17 13:26:20 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 17 Apr 2026 13:26:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1284280.1566109 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDjDA-0002jL-3z; Fri, 17 Apr 2026 13:26:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1284280.1566109; Fri, 17 Apr 2026 13:26:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wDjDA-0002jE-0f; Fri, 17 Apr 2026 13:26:20 +0000
Received: by outflank-mailman (input) for mailman id 1284280;
 Fri, 17 Apr 2026 13:26:18 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wDjD8-0002ic-IT
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 13:26:18 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wDjD7-00DMvZ-VW
 for win-pv-devel@lists.xenproject.org; Fri, 17 Apr 2026 15:26:17 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e234f5-2eae-0a2a0a5409dd-0a2a45089780-16
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 15:26:17 +0200
Received: from [52.101.201.45]
 (helo=PH7PR06CU001.outbound.protection.outlook.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e234f8-63b5-0a2a45080019-3465c92d5a68-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 17 Apr 2026 15:26:17 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by PH0PR03MB989154.namprd03.prod.outlook.com (2603:10b6:510:3b7::7)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.21; Fri, 17 Apr
 2026 13:26:14 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9818.023; Fri, 17 Apr 2026
 13:26:14 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=TFyxPKt8YEtSVky4Bz3kcT2pqE2SKoicm97fBGXlgsyvBW3WlwNuGncRqxfxrGy+NytMvzbdF486wkllvceIET5ir/bKG1B8ldzQymTe7ZPT15tnwRBMXzor3cwcSVE/5PFR+rYB8pvKX4HTdu537Xo5q9yaoxjR3D4gQDRCYwL4iXBufHwJdYOhN+MRYPd2i32rwcJwZyKQyWFYtj9r706Fd5pmKYiHxIt4HusXFE8cvtepjdx5BeDc3Zu1zRi2b8p5JKlmFe1ZxpWLbvHMtSalbvyq705iWJW4283QKTZcKknOYSWBnsSgOXnrlr+dhyY1HPTJjJinZc53vAsy0w==
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=MMF04aEQfk52X4whxeLQal2kLeQSBPbGsPDaXxb6ROI=;
 b=dy/FTJjXTOJK46/4Zu1dYtZjmcFImw1f2+TbCve7v8NUvCK0JgsILz8N1ILQCMNqM5jGZwyT7kAWjDUZrKjs8eKplTrNwcPrMCdz6uK4flEXNxwEq6e0Ykp4RRARZtulwry5XrgYcG+qbSDaVbI/tf0RHo3mbwIw2tHz+7vug8+lsifcXtYVdLvbkzaRck7KTAuXFlrLzZ3SYxG0uKqHK+ABQi2h44sVO39T/4SNaawHSRW1Q2Uk0IWHNflHmpdwsy8Vh8HrLYQ8vyAjW9AJInxntu3DcS48ByjphswJn0k4zexh+iGW34gG8DenNU2P8b1FiEx9tJgePwWsaD30Fw==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=MMF04aEQfk52X4whxeLQal2kLeQSBPbGsPDaXxb6ROI=;
 b=Y4MaTjQr684eGRX7zJUSyyC0UcpCubnSHR6qShozJ5JXB5kMLYpmVWndTFDgYQ5cp7KK7pakVLYmkjoLvRdC+HvrZfxUbCMAxelg2RQhnu+graXbfb6HnwM1EGzyrrcAS/XRtTvS+FQJDE6ro0p+Dkm16diuLujngVksfRvBwMY=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 0/5] Rundown MRSW lock and device removal fixes
Thread-Topic: [PATCH 0/5] Rundown MRSW lock and device removal fixes
Thread-Index: AQHczZGYvU3wfsQTrUCw9JvrcGGgX7XjMZVXgAALPwCAAALWnw==
Date: Fri, 17 Apr 2026 13:26:14 +0000
Message-ID:
 <SA6PR03MB77606898874FE06812E7F16AFE202@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260416110952.355-1-ngoc-tu.dinh@vates.tech>
 <SA6PR03MB7760942EB54250D0228FAB04FE202@SA6PR03MB7760.namprd03.prod.outlook.com>
 <b2ffe02e-08f5-4522-a81d-4ab4386ec65f@vates.tech>
In-Reply-To: <b2ffe02e-08f5-4522-a81d-4ab4386ec65f@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|PH0PR03MB989154:EE_
x-ms-office365-filtering-correlation-id: e21fc07b-ded9-4600-3458-08de9c84e627
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|366016|1800799024|376014|38070700021|13003099007|56012099003|18002099003|22082099003;
x-microsoft-antispam-message-info:
 IHPXdOsh8QhYDC2xcODVNtX7yO59TIf/7SJgsbfdETSZaq8CtyllBa3mhDxsS/twtdzWdPB0TxDidN1lXyyfB3jWNn675ps7z2DGrDAoAay9VEfr/KwXEJAfPa0luOsxmhjiSQliO1TaN7qI/j+6sTjlnDc2azfOifIrTyHW+57WKVJLElGQDMKdXpxt+58fhc4MSHlel3XdKVZH3jStW9Vyg0Zvr3SUmZ36/XJNOlJCHiiO1OZFFN9YhRC5RIoslR9pY8dUpS6eg7nLlZELaRCHZ8l4kena1FMk6Pz2mTuJ6nH3Guyzmy2+HG15yxdCMOnVF4PZFg5/uv0Fl8ePxDpDjIuv+LdXdOzwWRnk2USS9ppwni9Mr9LCdmAug915uxRgk1jZFREGiAMcOVfDNCg4G3o4I4SgWL7FnQByYl7hS3xD7blg1KCRoG4zCRD3xN7+vZP7FFu0uka4cr/Y7Fq5fPs7p+KjIJREbOa0ff/2J9tG6Z1eJokfp/nDeUEl49Yn0e7t4Fr7mHGiFjYk/5IBSrml1zTJf4f0c892hb3BV29cebX9wObQMh61sQOrDCkunRQvIc+aA0C0cqLWOiLs1LgpqwnHlewb9DoVUGtCCe1u7Oc249Bc4Pnf6Le0SJ/Fsoz00v2qr6Hk9pXDKRLf9YsbvN7NnqZk8cMPX5eCea40W8/xcAhlAUTxWJ7fu5vEojcqJMfXJNHW65I2x+YWV2LSG5Zev/BtJAUrf0I=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(38070700021)(13003099007)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?suRDJZyn604nAtv/VEqMnZZ6O8/YIocG0FghjFnvf3pNh7Ajvm8t1swlizZ9?=
 =?us-ascii?Q?nxPFifS5WFwKCGtviC3ef8kCnKMay9EP0RaPmghx/FbB/KpSUuh/NK1WPZkk?=
 =?us-ascii?Q?Zsqy6B7aioTKUgLjAYsA+M8erb0B7RICkSBzo+twmjesLZ4r/Ztk33F+09qT?=
 =?us-ascii?Q?cw5MwQz4gEbN6VI5VZG3oc/EYc7OjsJLI6Q8yIjk7PQ/PKXfmUwx9KQMrp5C?=
 =?us-ascii?Q?O9cvLYyVo1xN1rIVixs7JWCW9J2Gm73NS7G88VV/GaBdIK+oNxFmcDrvin5f?=
 =?us-ascii?Q?gw5FPiPqq3yQzUuqwfDqhMcdrgV9VVWj+ggwFbFIc/z3Y8BkyKJ7DlVCwB7T?=
 =?us-ascii?Q?eXP5FpXz9DeXfRfZRLh8WoYws7VgsvBRW8v6CAktctaOq5TzRd6DqlCCle3z?=
 =?us-ascii?Q?d50RLHrFUGvv++iOgk8W9uHp9C/1Fn9HA15tFL76tZ5dyBKeIV0aBmbxhBrI?=
 =?us-ascii?Q?yhQh6Ra+lAeHoB34pNttE5I4Y16y+DEHKOmKncOmxjxhgFqbTwoHkuctrNj6?=
 =?us-ascii?Q?b830SGBWvWfmx2hx3lOhiKOts9mb6BzC/b0mY2sUWR9nHvSTWvhNr/tvpe6I?=
 =?us-ascii?Q?3zmi4lkb98/1ozAyqntOLGHWIaznRflcOTAp/+W6e1vA4nLk/dtmvZ6G6qlS?=
 =?us-ascii?Q?5H6HJ4b7SPMvKr6F856DiW6/7mUeKHUGrI0jYfvWSfKujNvnM5a83Tf43FuC?=
 =?us-ascii?Q?q4bfJIPril231uir6DYKXHjvw2lnSAeyYkygbeLjR2+Da3YKwbwSO3RvsJL5?=
 =?us-ascii?Q?oa1eOak/adHQVFK5bixeXATtQVfifDxkKcO4BdJmIyx4lA/3ipFyg9LRG1XN?=
 =?us-ascii?Q?Z263QmVyBOnXC6DeuuquMzMFkjB06JR4q6r4WAl48IPujPix3+OoO/QCe6yu?=
 =?us-ascii?Q?9y/b8rA4pKzUnrqUQAz6Es/mmCbPqnonLWcxJGqMaAvRQLTIq5iDBOqpdxkS?=
 =?us-ascii?Q?2OR/KJEeD8kjDyUPrjGvyzbEvwrW/q/vz9f31h7ZDHDY2wRFEexn1Xj1zTrn?=
 =?us-ascii?Q?n9lt+i9mInAUzNBjFZZHzNb33jTK52xWtqWKMGhxmD7Zwdtjt4BGZOQV/6If?=
 =?us-ascii?Q?ZSCaHNiIKxrG9x1+QEs2tbUEaeLBeKujFc4oI9MJTv/k9TmFiuQ2jma2QuE6?=
 =?us-ascii?Q?lhJ982s5YwKoZ6sorNcKlJafC5ltD/zQy1XWN8AdRBMiTwJ999o5kvsNNv7J?=
 =?us-ascii?Q?8RkDftumKb2OJkOdhI8jrRzV8xAzNg1gxBI8QIjzIOIX1r544D1mShGhN9lQ?=
 =?us-ascii?Q?Mw5NR/teEeh0Woud78JdUuY4d485R6msp3gfJA4ebs/FWXbMjhmoiqHqy03r?=
 =?us-ascii?Q?LFj8atjPMWMWABd46UvLEdWbDmR+FaUxfI+rXSCr0zkz2IRR8vpgLGdACtcZ?=
 =?us-ascii?Q?AgnOX+FMM1xecr3wIMm2akpAaBLPD5mP7G+/C9MZ+droLAnIxyN/3XpZrVkb?=
 =?us-ascii?Q?s0WPuFncCImH5GXmKlEmXnKLZCuw+o73iFS3SGQjoKUdWqzQsibBd8HBG+Wz?=
 =?us-ascii?Q?H23DHogwFti3aZZdgTPj2WgTQW3wItLjeJ1ojV3wtTPrEAIOxGXWV6nNAJMZ?=
 =?us-ascii?Q?DmLvLXZ+bXz5F1N+R7iCa6zWm0VQVavtA5oDaPUnm+Bw/dk09CoXZ4b314D5?=
 =?us-ascii?Q?zj+j+byAfIR6YQ1mEc8Ed2EyjEzm9eLxm20somGm2rMJaU6qbLuHpTyF9h5l?=
 =?us-ascii?Q?YbyYgifqOUoTz2uBxFGLmyVPAfdGPE2lGSNHRynCjwOjcjlC8DRnPyeE1sxw?=
 =?us-ascii?Q?ShK666ronw=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: e21fc07b-ded9-4600-3458-08de9c84e627
X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2026 13:26:14.4016
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 0JLdoEPzbfYOwCVLfVWWZ2AGXdIhb1H+b66RxFSnGQ7pcpWlZtwDx6JmH2ux2Ab2N2hxnchltM5H4GU1hskOhQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR03MB989154
X-purgate-ID: tlsNG-c1860d/1776432377-C2D73DB1-C6D186ED/0/0
X-purgate-type: clean
X-purgate-size: 4411


For the 5 xenvif and 2 xennet patches:
* 1/5 Check Fragment->Entry before...
* 2/5 Watcg BACKEND/state...
* 3/5 Update IRQL annotations
* 4/5 Implement rundown-based MRSW..
* 5/5 Trace worker thread wake events

and
* 1/2 Signal surprise removal support...
* 2/2 Call AdapterDisable during...

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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 17 April 2026 2:13 PM
To: Owen Smith; win-pv-devel@lists.xenproject.org
Subject: Re: [PATCH 0/5] Rundown MRSW lock and device removal fixes

Hi,

On 17/04/2026 14:45, Owen Smith wrote:
>
> Do these changes work without the matching xennet changes?
> Do the xennet changes work without these changes?
>
> (i.e. is it safe to apply these without the xennet patches or the xennet =
patches
>   without these patches?)
>
> Owen
>

I've only tested the xenvif and xennet changes together. Running them
separately hasn't really been tested. But the lockup fixes should be
independent of each other, as they fix different steps in the surprise
removal process.

For information, the status of each patch should be as following
(dependent patches are grouped together)

(xenvif)
* Check Fragment->Entry before calling RevokeForeignAccess
     - Self-contained.

* Watch BACKEND/state key for eject status
     - Lockup fix, self-contained. It triggers surprise removal instead
of orderly removal when using `vif-unplug force=3Dtrue`.

* Update IRQL annotations
     - Should go before the MRSW patch for IRQL correctness.
* Implement rundown-based MRSW lock
     - Self-contained except for "Update IRQL annotations". I haven't
really tested this patch by itself without the lockup fixes. It's
possible that running things at a lower IRQL would cause certain lockup
problems to be easier to surface, but I can't confirm one way or another.

* Trace worker thread wake events
     - Self-contained.

(xennet)
* Signal surprise removal support during registration
     - Self-contained.

* Call AdapterDisable during NdisDevicePnPEventSurpriseRemoved
     - Lockup fix, self-contained, doesn't cause a dependency on xenvif
or vice versa. But the surprise removal code path (fixed here) isn't
entered without the xenvif patch "Watch BACKEND/state key for eject status"=
.

NB: "Call AdapterDisable during NdisDevicePnPEventSurpriseRemoved" is
very much a hack, since neither the MiniportDevicePnPEventNotify
documentation nor the driver samples advocate stopping the datapath at
this point. But given the lack of hang detection and response in
xenvif/xennet, this is the best I could come up with to avoid lockups
during surprise removal.

> ________________________________________
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf =
of Tu Dinh <ngoc-tu.dinh@vates.tech>
> Sent: 16 April 2026 12:09 PM
> To: win-pv-devel@lists.xenproject.org
> Cc: Tu Dinh; Owen Smith
> Subject: [PATCH 0/5] Rundown MRSW lock and device removal fixes
>
> Patches 1 and 2 are fixes for various lockups encountered during
> surprise removal.
>
> Patch 3 is an annotation prerequisite for Patch 4, which replaces the
> current MRSW lock with a simpler one.
>
> Patch 5 is only for debugging purposes.
>
> To be used together with matching Xennet surprise removal patches.
>
> Tu Dinh (5):
>    Check Fragment->Entry before calling RevokeForeignAccess
>    Watch BACKEND/state key for eject status
>    Update IRQL annotations
>    Implement rundown-based MRSW lock
>    Trace worker thread wake events
>
>   src/xenvif/controller.c  |   5 +-
>   src/xenvif/fdo.c         |   6 +-
>   src/xenvif/frontend.c    |  36 +--
>   src/xenvif/frontend.h    |  18 +-
>   src/xenvif/mrsw.h        | 530 ++++++++++++++++++++++-----------------
>   src/xenvif/receiver.c    |  24 +-
>   src/xenvif/receiver.h    |  14 +-
>   src/xenvif/transmitter.c |  25 +-
>   src/xenvif/transmitter.h |   6 +-
>   src/xenvif/vif.c         |  73 +++---
>   10 files changed, 409 insertions(+), 328 deletions(-)
>
> --
> 2.53.0.windows.2
>
>
> --
> Ngoc Tu Dinh | Vates XCP-ng Developer
>
> XCP-ng & Xen Orchestra - Vates solutions
>
> web: https://vates.tech
>
>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Mon Apr 20 06:34:57 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 20 Apr 2026 06:34:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1285414.1566448 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wEiDf-0007qN-RT; Mon, 20 Apr 2026 06:34:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1285414.1566448; Mon, 20 Apr 2026 06:34:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wEiDf-0007qE-Nn; Mon, 20 Apr 2026 06:34:55 +0000
Received: by outflank-mailman (input) for mailman id 1285414;
 Mon, 20 Apr 2026 06:34:54 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wEiDd-0007q8-O4
 for win-pv-devel@lists.xenproject.org; Mon, 20 Apr 2026 06:34:54 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wEiDc-009eer-1Q
 for win-pv-devel@lists.xenproject.org; Mon, 20 Apr 2026 08:34:52 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e5c90b-e002-0a2a0a5209dd-0a2a450c9b76-0
 for <win-pv-devel@lists.xenproject.org>; Mon, 20 Apr 2026 08:34:51 +0200
Received: from [52.101.85.62]
 (helo=BYAPR05CU005.outbound.protection.outlook.com)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e5c909-62f1-0a2a450c0019-3465553ea6d9-3
 for <win-pv-devel@lists.xenproject.org>; Mon, 20 Apr 2026 08:34:51 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by DS4PR03MB8397.namprd03.prod.outlook.com (2603:10b6:8:328::21) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.32; Mon, 20 Apr
 2026 06:34:47 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9818.032; Mon, 20 Apr 2026
 06:34:47 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=FWc3XbfjTNCTmEOhK2nfNzZEm8XjjDeh9ICzcLG+g2L3S6qf+oXYCjN9vCl3vkYbLeg8BAIb6Tg8iy8OAQK1ik7JImPpTbASJF4OVu0fTjft+Hm61czRmzaW9DD8oc85Ihcui8KTrvKJUu63y93kG6k0BCY0Amxts6kfol7kK6j6fwch6yKs8drRJp0fLd/njQ4wmWJtXak8BDiyR/kI9L3Dt4kyaT1faRhq8imlwWKdUbd0B7vd6Aq018aFdYSKYUL6tYXcZtOrpNZHde9d4bI3Lg5HJFJ2NxJGva4GnwUxc4Xy8ZPyMe1W3QfDwNmqruivA4fL+7iAYGH6c0MsqQ==
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=a5wYjdjCW6B0H0vGiagRfiSV2C13ftuQ6joyUFghrWw=;
 b=PjQ4IgV02Xo8eXioT5oYxdMSNVQkP7gXvfqdQKO7VdO0PEH9BoKQ+YikbrkZrISYEVkGLuZwxBsqVHfEHqXMHb+pdRKwoiBXHBGujgnQv1ywGHjpz9m9tLqx+DdI7UA61cz5UbzioJDJlyYb+sDSwV+8KtEtw5I/OMB8ef6gBEYsS7OqUY0XYeTL7sn3wJc4OgsehAAZdV9M64wtnKZcTXS3/oZ6rzC5fVI3ZL139R2MwSHG0FhDwYk5iCz7K9V/c9XNbYzs4+qabBqAsKPCG+6t3LQGKFKTShkpJTZgry0v0nHuFPYUUoSKM3A3x2WdOs09N9x9eYzswz7/QJDa4A==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=a5wYjdjCW6B0H0vGiagRfiSV2C13ftuQ6joyUFghrWw=;
 b=gIj8SQPN6KfI9zm02pR4a2p1amkT8NVG+B65iNwRn576ohWVypYXRnwEWSPU1RyaLOMuaE8RfSRw3IzYbZFHe7CuyvWN35TZUSRd90QPFJBj0r8MwczZ+ICnO62wciKoixjMiBJrkEJIkJadU52NnRFehts4j7BSnZq/sX4xb1k=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH v3 4/6] Delete xencons_monitor.dll
Thread-Topic: [PATCH v3 4/6] Delete xencons_monitor.dll
Thread-Index: AQHczKcJ+ISIiXlvVEezB+/gD+VQDrXnhh24
Date: Mon, 20 Apr 2026 06:34:47 +0000
Message-ID:
 <SA6PR03MB7760DE0875897123B19C8DCAFE2F2@SA6PR03MB7760.namprd03.prod.outlook.com>
References:
 <SA6PR03MB776096243EDD3F062FD12E13FE222@SA6PR03MB7760.namprd03.prod.outlook.com>
 <20260415071102.1782-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260415071102.1782-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|DS4PR03MB8397:EE_
x-ms-office365-filtering-correlation-id: a74d6b34-65e7-4105-7654-08de9ea6eac1
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|366016|1800799024|376014|38070700021|56012099003|18002099003|22082099003;
x-microsoft-antispam-message-info:
 Kc6CQI2YJp8a0m42JM7lJ9OZ+C5BJPDPz+1ESgBsVuqddd5wMMQ90e8W+bxwEDxNrjHTfzeyoqnU4fDT21+63pUVKYlxzIB5Vc14I7BrT8aeRC7cXU6YDsBTqauacPKHSoQ/inlGgCX6PxgKxgy/2S6oy+ZrHLcTf+hX7MI03m/Yfs+h5nymzJTVJBrbn6Q384U6SXJcAHARXJSpzoPqNYtddKiBaqCEmN9YFu2uqS2mzPoJ2aOaDFvjyZG35Cwic5iVF/VAlf3nP/CZD8QKyjGqjUSpdSo+9FSedaPhkHIZ/vSK6Zb5H3gqrXG3T+JnqcgKwuEjf5nlanHUHRWCc/dpe+wsoNrK85stn3r9WRC8JpmU7myrrOxLgOs/U4AZd7nmA52WdIzLaV0iCsORr/u4bMIBfGB2U9byeLqpNLM4wfvkd9yrbWUUpPGYk5Y1UBoUyiPcdxNeadlnLpH8ZyxiWErZAtyLOROlbM7VxqqTvh1gZqd2DbN4xFc8xYXX00KGuPlCNR6LvUEsQq202SJBsXzGErauCqaSWzXNyYCRx7DUc104N388Dqc98ovvjHSBF0UUnpqqqNiB7lykip4JwGbUpIP3Ff7BqvuGBST5EVIa697EtXfs7KcxC+Z+4iWWtuXOj2cCynvgX/Hmeni8zOMy9GzfRO8mD8gYNlbni37QsqWQiRdsGieG88BHXtiRjF+GpnPSdixmuS2Ld+Kvf6z034mgaTBCR538/jI=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(38070700021)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?bJB7z6WfWpctziIoQYsLryMEiUjI1qGYvqD8Si9ZE/fUiSePTnNa2VW1NRDQ?=
 =?us-ascii?Q?MvyuGJjtpTK7zR/z7ufcu466dcH14roNwQUeCvz/2mQ4HM7ikjfReY2nkfke?=
 =?us-ascii?Q?02gkoUWseJF0pVak9jZWbu+SDaYbkD/NOKorloSc7l5i07JJC7X5LKg1Xwjj?=
 =?us-ascii?Q?B4YZqH2HecI5Bo9/8nCC82R61nLpGsjA1dSSq41h+VqdCXsktbbLHcOKVcNv?=
 =?us-ascii?Q?UNfWVy9Z5x0keJCXy9IkdOjxBRmyUtG9ewgXCKEdbJSCpJoPMgr5b1Uy+Xu8?=
 =?us-ascii?Q?xOCvfR1/mb02sHVnKc47z3pX0VxzrHX20bV5862VsncwuT7YidFQhL21mYk5?=
 =?us-ascii?Q?RTqvNlKIrLEnKaayNfjja03AZFbYbgLHolThTp42ExFW0PEHFLpiw51xHWM6?=
 =?us-ascii?Q?+OP/mMf0MDTsUjKfcrRWKGgpVukD36ZV8X9uwshaXjWKuMNZwsFZt5Mqh5dr?=
 =?us-ascii?Q?njBOmrlm+s2LlmZ+0Wz3s3kQMoo3TnOvOTY7diNF7/h4HiRMF6g3UbX7E6Gi?=
 =?us-ascii?Q?QchU+nlN89qQHBky7Co+0gNms1y8WhfOEyHOJpG8r7W2dzl2fXXWDzjo2yM/?=
 =?us-ascii?Q?gauJfatEGsQU0+h7eMQ8fwBxBrys7zGEfxehCw2AWXK5RSntljcBDQIUxqLR?=
 =?us-ascii?Q?EjOd8qkJgmshxsbyXIR7a6dL9j5etSqXQQNyQMEHCqyi9i4Cc4PNr+yXD7zl?=
 =?us-ascii?Q?AUV6jZrHUR2W/KZs6lgtNcYX3gbP6+0fDOd9lEMFFLhw+6J1i13mmv6XKaSZ?=
 =?us-ascii?Q?beVzunHBjWqRRM1lMfTFxqGkPsxVXfiEaiQ/MR8zs0xq2mODDJ0ruKU5o90a?=
 =?us-ascii?Q?3eAkfaRzNW7POnO/Pa63fMbTtAgtllhD1NWh7u9fXPlChXBgP08h1veZc2au?=
 =?us-ascii?Q?BiuWcA4bpLTOwt5/7NoHaJFCOwZ00JwViT6veZN0JdrnvVPj36JIK0URxORU?=
 =?us-ascii?Q?U3IOQMcik5VmV35lgpJCSS6eAsC4YTaSOlVGpIFKyKlbcZ+X/rj56m1MrRoV?=
 =?us-ascii?Q?9OOZd1+2kVJTTnLBDMfJB3nFPc2DvrNgR+vmJg/MFwQPy37Q5JUUpPL42afM?=
 =?us-ascii?Q?j+Sx5F0yw6ZzfwBKbNVrIhRNqGiTNDYeXkPOeBRjUDW3c9FKtCZ06M8ZmQWM?=
 =?us-ascii?Q?U84IqJ+SpbtgKV0Xbg7IjzzntT9rLNCi/ErCKt0WHHNJ8G5LM4et9KXNbonc?=
 =?us-ascii?Q?s3JEBV1ouQo49KQdRLY6AdDdSicRSZf1STePao9DNZURFp0btYmK4aIuZNNX?=
 =?us-ascii?Q?SmtLIVOXq4pMa6jZ6+VZwvoz/0JOnqjN+unjyhXCSgDrzBfKDf/s5mQbdjl7?=
 =?us-ascii?Q?IatNhC9p3fTfnvIBKn8b4SLg9yncy1GkQQkIw2v2j4MM2sa+eZsRm9sYM8e4?=
 =?us-ascii?Q?aIQm3cJjlqH2fiX1QL0fSZjDLFxXQD5FWtqPytsNXYBlkWpg/lks0Kxjd9zT?=
 =?us-ascii?Q?UZUCpmwbBB1gHyvNHgYjPIVZ5EgxiTUlhm4BgKyNcDdN2C4ALoKjeXkSCFI2?=
 =?us-ascii?Q?wMx8TRp7gjXKYIarRCLASLHV6NK1f6ekvBa/oGS7Evy8G/dkN5TuyK9RUDVa?=
 =?us-ascii?Q?roJ3kO+GVDL8ikeFpfHbJmiwdLwmWrbPPVNpUSj0t5QIp3O+c3sSVNqTFNdR?=
 =?us-ascii?Q?gRwys9E/qzOiaS7eYSjCVUPLsF/gU050nwVTEj6TegF7sDqXbM6tr5bxTbhW?=
 =?us-ascii?Q?/e7mIO33B8WJ0PDpxC4t97GyxGz6U+KYkPL4PtAZMUz+2dZZ?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: a74d6b34-65e7-4105-7654-08de9ea6eac1
X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2026 06:34:47.2944
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: O9Z/EvMW3ZWj6dVKJV3ULRJknyI2U+YvUpb0gtdldfaQGsOuILYy+s/4QOY08cqanynm3Dv7lp8/pFT+Hito/g==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PR03MB8397
X-purgate-ID: tlsNG-d25034/1776666891-F4C07CF5-21AAD7EB/0/0
X-purgate-type: clean
X-purgate-size: 9095

This, and all others in the series look good.

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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 15 April 2026 8:11 AM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH v3 4/6] Delete xencons_monitor.dll

Now that trace logging is used, the DLL is not needed any more. Remove
it from the build and package.

Ported from Xenbus.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
v3: Rebase against upstream
---
 src/monitor/messages.mc                       | 55 -------------------
 src/monitor/monitor.c                         |  2 -
 src/monitor/xencons_monitor.rc                |  1 -
 src/xencons.inf                               | 11 +---
 .../xencons_monitor/xencons_monitor.vcxproj   | 17 ------
 .../xencons_monitor/xencons_monitor.vcxproj   | 12 ----
 6 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 src/monitor/messages.mc

diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
deleted file mode 100644
index eb1d382..0000000
--- a/src/monitor/messages.mc
+++ /dev/null
@@ -1,55 +0,0 @@
-; // Copyright (c) Xen Project.
-; // Copyright (c) Cloud Software Group, Inc.
-; // All rights reserved.
-; //
-; // Redistribution and use in source and binary forms,
-; // with or without modification, are permitted provided
-; // that the following conditions are met:
-; //
-; // *   Redistributions of source code must retain the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer.
-; // *   Redistributions in binary form must reproduce the above
-; //     copyright notice, this list of conditions and the
-; //     following disclaimer in the documentation and/or other
-; //     materials provided with the distribution.
-; //
-; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
-; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-; // SUCH DAMAGE.
-
-MessageIdTypedef=3DDWORD
-
-SeverityNames=3D(
-       Success=3D0x0:STATUS_SEVERITY_SUCCESS
-       Informational=3D0x1:STATUS_SEVERITY_INFORMATIONAL
-       Warning=3D0x2:STATUS_SEVERITY_WARNING
-       Error=3D0x3:STATUS_SEVERITY_ERROR
-       )
-
-
-FacilityNames=3D(
-       System=3D0x0:FACILITY_SYSTEM
-       Runtime=3D0x2:FACILITY_RUNTIME
-       Stubs=3D0x3:FACILITY_STUBS
-       Io=3D0x4:FACILITY_IO_ERROR_CODE
-       )
-
-MessageId=3D0x1
-Severity=3DInformational
-Facility=3DSystem
-SymbolicName=3DMONITOR_LOG
-Language=3DEnglish
-%1
-.
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 78d67e1..3ff7d7c 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -50,8 +50,6 @@
 #include <xencons_device.h>
 #include <version.h>

-#include "messages.h"
-
 #define stringify_literal(_text) #_text
 #define stringify(_text) stringify_literal(_text)
 #define __MODULE__ stringify(PROJECT)
diff --git a/src/monitor/xencons_monitor.rc b/src/monitor/xencons_monitor.r=
c
index 3fba041..6c077f8 100644
--- a/src/monitor/xencons_monitor.rc
+++ b/src/monitor/xencons_monitor.rc
@@ -54,4 +54,3 @@
 #define VER_FILESUBTYPE                    VFT2_UNKNOWN

 #include "common.ver"
-#include "messages.rc"
diff --git a/src/xencons.inf b/src/xencons.inf
index 6bbd83b..6f9b361 100644
--- a/src/xencons.inf
+++ b/src/xencons.inf
@@ -51,12 +51,10 @@ Tty_CopyFiles=3D11
 [SourceDisksFiles]
 xencons.sys=3D0,,
 xencons_monitor.exe=3D0,,
-xencons_monitor.dll=3D0,,
 xencons_tty.exe=3D0,,

 [Monitor_CopyFiles]
 xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUM=
BER@.exe,xencons_monitor.exe
-xencons_monitor_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUM=
BER@.dll,xencons_monitor.dll

 [Tty_CopyFiles]
 xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@=
.exe,xencons_tty.exe
@@ -81,7 +79,7 @@ FeatureScore=3D0xFE
 xencons.sys

 [XenCons_Inst.Services]
-AddService=3Dxencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service,Mon=
itor_EventLog
+AddService=3Dxencons_monitor,%SPSVCSINST_STARTSERVICE%,Monitor_Service
 AddService=3Dxencons,%SPSVCINST_ASSOCSERVICE%,XenCons_Service

 [XenCons_Service]
@@ -109,13 +107,6 @@ AddReg =3D Monitor_Parameters
 HKR,"Parameters",,0x00000010
 HKR,"Parameters\default","Executable",0x00000000,"xencons_tty_@MAJOR_VERSI=
ON@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe"

-[Monitor_EventLog]
-AddReg=3DMonitor_EventLog_AddReg
-
-[Monitor_EventLog_AddReg]
-HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\xencons_monitor_=
@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll"
-HKR,,TypesSupported,0x00010001,7
-
 [Strings]

 Vendor=3D"@VENDOR_NAME@"
diff --git a/vs2019/xencons_monitor/xencons_monitor.vcxproj b/vs2019/xencon=
s_monitor/xencons_monitor.vcxproj
index ca1da4e..d0a601c 100644
--- a/vs2019/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2019/xencons_monitor/xencons_monitor.vcxproj
@@ -17,9 +17,6 @@
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalI=
ncludeDirectories)</AdditionalIncludeDirectories>
@@ -49,29 +46,15 @@
     <ClCompile>
       <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</Prepro=
cessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)</=
Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition=3D"'$(Platform)'=3D=3D'x64'">
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</Prep=
rocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</=
Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include=3D"$(TargetPath)" />
     <FilesToPackage Include=3D"$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include=3D"$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include=3D"..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include=3D"..\..\src\monitor\monitor.c" />
diff --git a/vs2022/xencons_monitor/xencons_monitor.vcxproj b/vs2022/xencon=
s_monitor/xencons_monitor.vcxproj
index 58e881d..66754d3 100644
--- a/vs2022/xencons_monitor/xencons_monitor.vcxproj
+++ b/vs2022/xencons_monitor/xencons_monitor.vcxproj
@@ -17,9 +17,6 @@
     <RunCodeAnalysis>true</RunCodeAnalysis>
     <EnableInf2cat>false</EnableInf2cat>
   </PropertyGroup>
-  <PropertyGroup>
-    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
-  </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
       <AdditionalIncludeDirectories>$(SolutionDir)..\include;%(AdditionalI=
ncludeDirectories)</AdditionalIncludeDirectories>
@@ -49,19 +46,10 @@
     <ClCompile>
       <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</Prep=
rocessorDefinitions>
     </ClCompile>
-    <CustomBuildStep>
-      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
-      <Inputs>$(IntDir)$(TargetName).res</Inputs>
-      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)</=
Command>
-    </CustomBuildStep>
   </ItemDefinitionGroup>
   <ItemGroup>
     <FilesToPackage Include=3D"$(TargetPath)" />
     <FilesToPackage Include=3D"$(OutDir)$(TargetName).pdb" />
-    <FilesToPackage Include=3D"$(OutDir)$(TargetName).dll" />
-  </ItemGroup>
-  <ItemGroup>
-    <MessageCompile Include=3D"..\..\src\monitor\messages.mc" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include=3D"..\..\src\monitor\monitor.c" />
--
2.53.0.windows.2


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Tue Apr 21 12:46:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 21 Apr 2026 12:46:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1288958.1569180 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFAUO-0001BR-7r; Tue, 21 Apr 2026 12:46:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1288958.1569180; Tue, 21 Apr 2026 12:46:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFAUO-0001BK-58; Tue, 21 Apr 2026 12:46:04 +0000
Received: by outflank-mailman (input) for mailman id 1288958;
 Tue, 21 Apr 2026 12:46:03 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wFAUM-0001Ay-Vo
 for win-pv-devel@lists.xenproject.org; Tue, 21 Apr 2026 12:46:03 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wFAUM-00Ec6d-6u
 for win-pv-devel@lists.xenproject.org; Tue, 21 Apr 2026 14:46:02 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e77185-2eae-0a2a0a5409dd-0a2a450bc0f4-22
 for <win-pv-devel@lists.xenproject.org>; Tue, 21 Apr 2026 14:46:02 +0200
Received: from [52.101.62.12]
 (helo=DM5PR21CU001.outbound.protection.outlook.com)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e77188-212f-0a2a450b0019-34653e0c9b08-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 21 Apr 2026 14:46:01 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by BN9PR03MB6009.namprd03.prod.outlook.com (2603:10b6:408:132::21)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.21; Tue, 21 Apr
 2026 12:45:56 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9818.033; Tue, 21 Apr 2026
 12:45:56 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=hd0QI5s8ajMuSNlNl6RJrUQb7yGfPcYUOaQ03cwmXxWBJd0fjWATRDk6F5SLO7DpQkc3dxGyBRCFI3LprJyp/EKyWg2YCVAocMsc/VOT3C/UJSq2EqK8w4l4Y3hJoBgrOkZ8/MgDfCnK0Niz0BHDu3tXpDAx21VCrFziUvHy8dkorjlorryXs+22aO5kTA54uVK5jzM+di5AmXCnUUTXvVvfZuH6AtJbp5bEDUCrbpbkwWPsqlrrSDC3X5yG0cjrQ44QfK42YVOqT7DQlQPoErLYzriqA0B4/MvCbQt+LSlfk3ocPWpWytrYgrGRA25qyktd9QQ7UG7wS5ykIhZDFQ==
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=SMA3AahEajPv6YWy2lhdwN6t4fogm1+NPLnivGq785c=;
 b=P5ZXaVsvh+Y4s0/Ns6ciwBgMoIkjxv6kGRrxf6S24f5AjVs5zPTWoTL4n4Kk7/clp1vdOSTmrii2z8U4Mw2AM9rrgGmd6mhjWIHMGC4mwm1TsEgsz3JxfYoXrx7Gwh1fh09H5ge6xBgiwppMtuB5GQAC2aiT1A2LaWahXRZkcIUvdLGg5n0y5ZmAmvyMt6T1lBburQOg7k5fq162kr+IhJQ0Y3VsmYhWQdOKZ6cQmPxJrHjSf0Yj5ZvDOjAJyOGh3N5GQN/LuHbe/smBeblUcgHbnPW7sQIkjnfwZkQaol1vs+m4bhxN6hoQWoMHaKoXz1uT4Cotjj7d2CCPN0VhXw==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=SMA3AahEajPv6YWy2lhdwN6t4fogm1+NPLnivGq785c=;
 b=EDu0ABAsZIjMf7TRHy+gG+wFgQCTZ6+i/seCf+PWS38m8bmWM6bPiYtI7O1ZMwgfm0FrImQIE0/KUNtbMWO6nUTiaQOYdFexonp0SPNQRFkJzApNzQTs/76vNO0IyAGlqjeCy4te2m/OfbpmeKRko11ROXQezG4gbn1Gn+9RK/E=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH] Don't evaluate ASSERT3 arguments in release build
Thread-Topic: [PATCH] Don't evaluate ASSERT3 arguments in release build
Thread-Index: AQHczlGlrhoyoimptUWb3l+JWCmJkrXpfN6K
Date: Tue, 21 Apr 2026 12:45:56 +0000
Message-ID:
 <SA6PR03MB7760463F31EFB322F58459CDFE2C2@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260417100446.1623-1-ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260417100446.1623-1-ngoc-tu.dinh@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|BN9PR03MB6009:EE_
x-ms-office365-filtering-correlation-id: 9b1e701d-f1f9-4658-22a0-08de9fa3ee9f
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|366016|1800799024|376014|38070700021|18002099003|22082099003|56012099003;
x-microsoft-antispam-message-info:
 b6U6zmnYqB9BjhcZrMv/duZdFtanm5dNt4qmoDeY5MLoNQfhplRUsPH/KFw4/MfZ7oQPzDA0X/k0QoCuPqlmsLp8r0YJoJKz69EVAD07f39b2oJTZ8d/OkXB+ZiZLvCaPd1p5ozpmyyhORi22K6PCgH5eHL78LTV5GsQf00bfStOurkj5RjiOOri4Pl8wvZRxaKDDATtEkeNUkkrFNg/PSBwkAc81k1obfIkm3XhIWJEPd3VXP6dNJZaPWW63BnTgF3xKjREQJRVJ/gpNKXzqddNTqibcCT05xckE6mtHWMK7UiH7qURMuRKV6JHRRQJxLgVo9lUe1W1KaZ/I3YMLm6Kx78Fg3GNRCtGqAHeTmNYD2Fk/5qfQXJtuGgBM3HJwUMcHfhcTiXsGAT9I9BOhG6ajvIyWPqN+4GdRCW6iupIfo2M5/vYpw6zViXvODPJQkdRfLCg3jnBTW5hla07sVXRTf5RVcCxdh57+lmEOViVSo5lwi6HKLy6+zw51sKDfGn9/tt+5bIi/4oNPHsgBUcQfzMGfVy3B3ZqP5MdpUqpOce21lXil+cAQ7vyzWRhGE1ey5eMHRM/D91bm+IQ0DluZoB13xNc1UXoz2QanVrmy4U6yUSRztWLwKj6TYa0qdh4AuJXJVcnoLMAYETacNFKvCBgCIewH4geTJAc+9YJrpcbVriqqby10r7ZJCEqLKyyS+dEm7o2tqmWQiaLwOnTqrc9pA7Nc4dvOXa2ozk=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(38070700021)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?cx5GaGy5cfzuQk7gW2wAh68Oq//JxhiWHhLT/vswpnA3nNWsw7K+zQBujJF2?=
 =?us-ascii?Q?CwjYVzk5VArlUS109IYsowwZl0+/jggx7LybFXe1FfT9occ4tz8Kve1fMw28?=
 =?us-ascii?Q?iw/LHuIyTgXOKOG3BXDkXXgKcoM/E3hDKYuTH9U4Hb+0GYh0AWQ2MawEFXnE?=
 =?us-ascii?Q?6bSv4tMhO9xkbcTZxfbYHXrN9YuqmRNtExruCw8zY1JuTmwcG5fwifQWp0/Z?=
 =?us-ascii?Q?hzxfV3ACGUhYKZoIkRQegGdzlxRs8esWFMNJhl595+wse90OpQxD0ll6Dpm8?=
 =?us-ascii?Q?pTIeKD/COr5jMEajSiiM+dcOn3Sga3KAK30zzlzHz46jGXayFJ1X92LYTDSR?=
 =?us-ascii?Q?2LUW4wmAsbSE02qtj0jhLQuyKSBXT0grBjhQC3mRG/zHcjdgIzbTdcYXt9C4?=
 =?us-ascii?Q?prI84dd07mZs0T7n32yEhnyIALprBeT3oEwj2R2T+c6u1Ro2MPwKjIZBdq9n?=
 =?us-ascii?Q?1yEFFTAHFA+N128jtgXx8gLLL2ejn62/iUQGaPkySzGy6dCKkHtbqGu+/dlt?=
 =?us-ascii?Q?GpFdYWGKpD2EyYiauq3H3pVH9tT0fh8T2TRL+nPVLCJk4DdftnEmbs9VZIeL?=
 =?us-ascii?Q?Vnn3hRHsqQBMeQ8kXNKvbYLxrfooljn5lM3fndLENTkMn+eYagxNyUPa1Ha+?=
 =?us-ascii?Q?4vlceOqHD6A/qSgObh91KQTgNONqI/xYzTAli1qCdIz9ilck4KQJrT1/r0RE?=
 =?us-ascii?Q?tjTELPSCuoIwskBup97gf2Hkc7FBPXIRdDKlGIJLN6mSxPtI6uj7fx7+SINn?=
 =?us-ascii?Q?0LUhfApiG4tzmCru4JIF5uYlgM9EMG4F+HOVpC4H8pOFOIUxcCctOrkmAWgh?=
 =?us-ascii?Q?dufs8i0pTkb5bTaDDUkhIjuI3ZvWhV+sIsRxLBjKrUUW4kfXIVyjxphzRL0z?=
 =?us-ascii?Q?ZzXKskx7ynkKDioQ5f790wEdf1420XSI8nw2V+o25mnk/B7wM9oumz9y8Zle?=
 =?us-ascii?Q?Acix79Eo/4eFhSraO7fszyTAC04YCmzDGSEsRwCWzyG0z2LU1NhWOb1sYkL7?=
 =?us-ascii?Q?wCMlba2nRbdtc9ThA4Si/bfrRQPcF9/A36zQ1tm1k3mYPaE+gTzjAMLzmU6l?=
 =?us-ascii?Q?IFHGMQKBugxF0VUqfzAtcChUjS7yIcteZkTZG8rj2tw6d+51wLqGnVsXRmtk?=
 =?us-ascii?Q?gZdtkUb0X8Q0ph6Ta6vkncvzhohhTW8W7WukneOz9H0Zv3oDy+JrCNniTzjD?=
 =?us-ascii?Q?Caf+wMiXuyzgIR+9jBKh6TDuzxfEqntsz1ToKLTlEHd3w/IJUcnz6yeO52Yd?=
 =?us-ascii?Q?kOAqsPJk8kueOnD11IcpQbdkN1LDkCKlhb/gtkqcUXL6kAO1nf1O88MrB2oo?=
 =?us-ascii?Q?WcvdVw0qFp4NO7dLhTZPTjIsQBfbzXt9GMUw0iccKmPW6VUtLNT0oiYQIMSI?=
 =?us-ascii?Q?eUuYt1Mh6Tac1kH8DTowDjwLe5UkBY4Tcfo9CyX+dMc29U2V7LN4p+5aro54?=
 =?us-ascii?Q?OTS4nltY/cTbjPtbsO3eGZn+2NeApVaN0mP45BxAF/ZeYEc8lKlTRwvJdA4q?=
 =?us-ascii?Q?jwjaSaz+B6md46BbPOM6zaEM0O0KLuR1Q1Y2P5uNlYV3x8YXx8X77NUeTDD9?=
 =?us-ascii?Q?wCzdQIK4nsH0UvSxdvH2q0ZUanm7s61eQGoaNURG45c2tVEIxfxnNNlvM61Y?=
 =?us-ascii?Q?ig/9RssHOONHV/L/SHYPCTv1PPcKPAfDK3RSi6rDGZu+FWnv5ykz3olbbEnk?=
 =?us-ascii?Q?nHnYbXpPj2RzUDyijHUGHGqcAm/r4XQ5xuWJWypOqWqcd9uy?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 9b1e701d-f1f9-4658-22a0-08de9fa3ee9f
X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Apr 2026 12:45:56.4686
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: UGYs2QIuLVnalyh29PzNDzyISh7+AvfezUJt+1WBkdGb8hrMGfq+6NCawOTdciWEHXgYN01HN1GDYS+ZIEeYKw==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR03MB6009
X-purgate-ID: tlsNG-42698a/1776775561-7E573F3B-31647B7F/0/0
X-purgate-type: clean
X-purgate-size: 2534

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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 17 April 2026 11:04 AM
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith; Tu Dinh
Subject: [PATCH] Don't evaluate ASSERT3 arguments in release build

Evaluating arguments to ASSERT3 may call functions that, even if they
don't have visible side effects (e.g. KeGetCurrentIrql), still cause
the function's code to be emitted into the binary.

Move the evaluation into inside the __analysis_assume expression to
avoid this.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenvif/assert.h | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/xenvif/assert.h b/src/xenvif/assert.h
index d0cf3f2..c41dfed 100644
--- a/src/xenvif/assert.h
+++ b/src/xenvif/assert.h
@@ -136,29 +136,14 @@ __Bug(
             __analysis_assume(_EXP);    \
         } while (FALSE)

-#define ASSERT3U(_X, _OP, _Y)                       \
-        do {                                        \
-            ULONGLONG   _Lval =3D (ULONGLONG)(_X);    \
-            ULONGLONG   _Rval =3D (ULONGLONG)(_Y);    \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3U(_X, _OP, _Y)           \
+        ASSERT((ULONGLONG)(_X) _OP (ULONGLONG)(_Y))

-#define ASSERT3S(_X, _OP, _Y)                       \
-        do {                                        \
-            LONGLONG    _Lval =3D (LONGLONG)(_X);     \
-            LONGLONG    _Rval =3D (LONGLONG)(_Y);     \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3S(_X, _OP, _Y)           \
+        ASSERT((LONGLONG)(_X) _OP (LONGLONG)(_Y))

-#define ASSERT3P(_X, _OP, _Y)                       \
-        do {                                        \
-            PVOID   _Lval =3D (PVOID)(_X);            \
-            PVOID   _Rval =3D (PVOID)(_Y);            \
-                                                    \
-            __analysis_assume(_Lval _OP _Rval);     \
-        } while (FALSE)
+#define ASSERT3P(_X, _OP, _Y)           \
+        ASSERT((PVOID)(_X) _OP (PVOID)(_Y))

 #endif  // DBG

--
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



From win-pv-devel-bounces@lists.xenproject.org Wed Apr 22 09:30:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 22 Apr 2026 09:30:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1290071.1569760 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFTuJ-0000e9-5O; Wed, 22 Apr 2026 09:30:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1290071.1569760; Wed, 22 Apr 2026 09:30:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFTuJ-0000e1-20; Wed, 22 Apr 2026 09:30:07 +0000
Received: by outflank-mailman (input) for mailman id 1290071;
 Wed, 22 Apr 2026 09:30:05 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wFTuH-0000ME-4L
 for win-pv-devel@lists.xenproject.org; Wed, 22 Apr 2026 09:30:05 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wFTuG-00HKgM-Gu
 for win-pv-devel@lists.xenproject.org; Wed, 22 Apr 2026 11:30:04 +0200
Received: from [10.42.69.10] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e89518-5cb7-0a2a0a5109dd-0a2a450aa5a4-28
 for <win-pv-devel@lists.xenproject.org>; Wed, 22 Apr 2026 11:30:04 +0200
Received: from [160.101.131.9] (helo=na1pdmzitismtp02.tibco.com)
 by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69e8951b-56b3-0a2a450a0019-a0658309ebb0-3
 for <win-pv-devel@lists.xenproject.org>; Wed, 22 Apr 2026 11:30:04 +0200
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id 94A4781C6F29;
 Wed, 22 Apr 2026 05:29:06 -0400 (EDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; none
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Check Fragment is non-null
Date: Wed, 22 Apr 2026 10:29:59 +0100
Message-ID: <20260422092959.779-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-purgate-ID: tlsNG-4011c0/1776850204-CE9768B7-E8861CE4/0/0
X-purgate-type: clean
X-purgate-size: 1160

When processing a response, the id value should indicate the index into
the Pending array, of the relevant Fragment. In some situations, its
possible that the Pending array entry has already been NULLed, likely
due to a backend inserted response coinciding with a frontend faked
response. If the Fragment returned from the Pending array is NULL, then
any attempt to access this NULL Fragment will result in a bugcheck.
Skip any responses where the related Pending entry has already been NULLed.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xenvif/transmitter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 0f7deb1..58f8575 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -2525,7 +2525,9 @@ TransmitterRingPoll(
             Fragment = Ring->Pending[id];
             Ring->Pending[id] = NULL;
 
-            ASSERT(Fragment != NULL);
+            if (Fragment == NULL)
+                continue;
+
             ASSERT3U(Fragment->Id, ==, id);
 
             switch (Fragment->Type) {
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Apr 22 11:49:42 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 22 Apr 2026 11:49:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1290398.1569997 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFW5N-0003bm-8g; Wed, 22 Apr 2026 11:49:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1290398.1569997; Wed, 22 Apr 2026 11:49:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFW5N-0003bf-5y; Wed, 22 Apr 2026 11:49:41 +0000
Received: by outflank-mailman (input) for mailman id 1290398;
 Wed, 22 Apr 2026 11:49:39 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19db506312d000f373@swg.vates.tech>)
 id 1wFW5L-0003bZ-MY
 for win-pv-devel@lists.xenproject.org; Wed, 22 Apr 2026 11:49:39 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wFW5L-0036Y2-3D
 for win-pv-devel@lists.xenproject.org; Wed, 22 Apr 2026 13:49:39 +0200
Received: from [10.42.69.7] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19db506312d000f373@swg.vates.tech>)
 id 69e8b5cf-5cb7-0a2a0a5109dd-0a2a4507e2e8-16
 for <win-pv-devel@lists.xenproject.org>; Wed, 22 Apr 2026 13:49:38 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19db506312d000f373@swg.vates.tech>)
 id 69e8b5d2-229c-0a2a45070019-b9ff1c22804b-3
 for <win-pv-devel@lists.xenproject.org>; Wed, 22 Apr 2026 13:49:38 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19db506312d000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Wed, 22 Apr 2026 11:49:35 +0000
Received: from [192.168.1.61] (155.223.66.37.rev.sfr.net [37.66.223.155])
 (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 7FE4886360;
 Wed, 22 Apr 2026 13:49:34 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=oWPckG0GgqECijRnT+5Xlweh0wPbkmQ9+sKac5ueTxI=;
 h=from:subject:date:message-id:to:mime-version:content-type:in-reply-to:references:feedback-id;
 b=Pfl9x1b4un3/wYFAVT9OnJXFNyLaHMoxJ1iWynSJZBRmMG9z3GFki9Mmhr1DSdkkUGalwUtP1
 4aq8I2Y0bjt/EJuP6dg/Fm/mdLTHl+mXLvHROfmNiT3EvsWqONrNBkMujtn+P0RKdHN3sPhAE1z
 J+4OuPagjk6euEeoyVwhu+XKbQK+9hmnlvmyQon7LGr5x9iHSSzg3+MKKP6XaLlrCQhjB74p9LF
 MgeYi1rWBX1EE9QmBdMHZ6ro5KWZx4ITUSbeuVZHXbFiuvHaW1lmFq4tWb0qGzHITTuCFnNRQE4
 Msva2lzq4mAg3IZxAvNH2gLHZapd2NRyBEm+1fs1kbyQ==
X-Zone-Loop: e38491fb798ca4c848176ef7c65af9439336d0e54392
x-campaign-type: default
x-transaction-id: 3a306ca8-7d40-4763-ba42-b956bb20cae6
x-swg-uid: 01-d87f89e0-2ab0-4f29-8c60-7ffa01139dae
X-Mailer: Sweego
Message-ID:
 <1776858575.8631fc262581453bbf619ec5b2062170.19db506312d000f373@vates.tech>
x-swg-bid: 1776858575.8631fc262581453bbf619ec5b2062170.19db506312d000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
Date: Wed, 22 Apr 2026 13:49:34 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] Check Fragment is non-null
To: Owen Smith <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260422092959.779-1-owen.smith@citrix.com>
Content-Language: en-US
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260422092959.779-1-owen.smith@citrix.com>
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.2587.3f5be9280ff5f079.19db5062efa.31e4e24e2d33329=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1776858574586
X-purgate-ID: tlsNG-ef75cf/1776858578-15E5FC48-94F88480/0/0
X-purgate-type: clean
X-purgate-size: 1895

---=Part.2587.3f5be9280ff5f079.19db5062efa.31e4e24e2d33329=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 22/04/2026 11:30, Owen Smith wrote:
> When processing a response, the id value should indicate the index into
> the Pending array, of the relevant Fragment=2E In some situations, its
> possible that the Pending array entry has already been NULLed, likely
> due to a backend inserted response coinciding with a frontend faked
> response=2E If the Fragment returned from the Pending array is NULL, the=
n
> any attempt to access this NULL Fragment will result in a bugcheck=2E
> Skip any responses where the related Pending entry has already been NULL=
ed=2E
>=20
> Signed-off-by: Owen Smith <owen=2Esmith@citrix=2Ecom>

Reviewed-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>

Thanks,

NB: IMO while we're not faking receiver responses, we may eventually=20
need a similar adjustment in ReceiverRingPoll and some other places=20
given that a backend can give out bogus IDs=2E

> ---
>   src/xenvif/transmitter=2Ec | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>=20
> diff --git a/src/xenvif/transmitter=2Ec b/src/xenvif/transmitter=2Ec
> index 0f7deb1=2E=2E58f8575 100644
> --- a/src/xenvif/transmitter=2Ec
> +++ b/src/xenvif/transmitter=2Ec
> @@ -2525,7 +2525,9 @@ TransmitterRingPoll(
>               Fragment =3D Ring->Pending[id];
>               Ring->Pending[id] =3D NULL;
>  =20
> -            ASSERT(Fragment !=3D NULL);
> +            if (Fragment =3D=3D NULL)
> +                continue;
> +
>               ASSERT3U(Fragment->Id, =3D=3D, id);
>  =20
>               switch (Fragment->Type) {



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.2587.3f5be9280ff5f079.19db5062efa.31e4e24e2d33329=---


From win-pv-devel-bounces@lists.xenproject.org Thu Apr 23 14:08:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 23 Apr 2026 14:08:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1292151.1570711 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFuip-00061Z-PQ; Thu, 23 Apr 2026 14:08:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1292151.1570711; Thu, 23 Apr 2026 14:08:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wFuip-00061S-MU; Thu, 23 Apr 2026 14:08:03 +0000
Received: by outflank-mailman (input) for mailman id 1292151;
 Thu, 23 Apr 2026 14:08:02 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wFuio-00061M-3h
 for win-pv-devel@lists.xenproject.org; Thu, 23 Apr 2026 14:08:02 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wFuin-00B6Gt-Gd
 for win-pv-devel@lists.xenproject.org; Thu, 23 Apr 2026 16:08:01 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69ea27b4-bab6-0a2a0a5309dd-0a2a4508ea4c-32
 for <win-pv-devel@lists.xenproject.org>; Thu, 23 Apr 2026 16:08:01 +0200
Received: from [160.101.131.9] (helo=na1pdmzitismtp02.tibco.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69ea27c0-63b5-0a2a45080019-a06583098114-3
 for <win-pv-devel@lists.xenproject.org>; Thu, 23 Apr 2026 16:08:01 +0200
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id C7EBF81E1A02;
 Thu, 23 Apr 2026 10:07:02 -0400 (EDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; none
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Use direct hypercall instead of hypercall page
Date: Thu, 23 Apr 2026 15:07:55 +0100
Message-ID: <20260423140755.950-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-purgate-ID: tlsNG-c1860d/1776953281-C1B6CDB1-1D27F1A3/0/0
X-purgate-type: clean
X-purgate-size: 21958

XSA-466 "Xen hypercall page unsafe against speculative attacks"
recommends that OSes avoid using the hypercall page, since that breaks
the use of return thunks and CET IBT.

While Windows doesn't support return thunks or CET IBT, the current
hypercall code uses a naked indirect call to call into the hypercall
page. This call is not protected by Windows CFG, and cannot be patched
by Windows's Retpoline implementation.

Convert the hypercall code to detect CPU vendor and use the appropriate
hypercall instructions.

Ported from xenbus 2635e7c08ee8df3e3c1be427926a53fe1b345c96
by Tu Dinh <ngoc-tu.dinh@vates.tech>

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xencrsh/amd64/hypercall.asm | 109 ++++++++++++------
 src/xencrsh/hvm.c               | 120 +-------------------
 src/xencrsh/hypercall.h         |   6 +-
 src/xencrsh/hypercall_stub.c    | 189 +++++++++++++++++++++++++++++++-
 src/xencrsh/i386/hypercall.asm  | 119 +++++++++++++-------
 5 files changed, 341 insertions(+), 202 deletions(-)

diff --git a/src/xencrsh/amd64/hypercall.asm b/src/xencrsh/amd64/hypercall.asm
index 1ceda85..de430e7 100644
--- a/src/xencrsh/amd64/hypercall.asm
+++ b/src/xencrsh/amd64/hypercall.asm
@@ -1,41 +1,78 @@
-                page    ,132
-                title   Hypercall Gates
+                        page    ,132
+                        title   Hypercall Thunks
 
-                .code
+                        .code
 
-                extrn   Hypercall:qword
+                        ; uintptr_t __stdcall hypercall2_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public hypercall2_vmcall
+hypercall2_vmcall       proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        vmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall2_vmcall       endp
 
-                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
-                public asm___hypercall2
-asm___hypercall2 proc
-	        push rdi
-	        push rsi
-	        mov rdi, rdx                            ; arg1
-	        mov rax, qword ptr [Hypercall]
-	        shl rcx, 5                              ; ord
-	        add rax, rcx
-	        mov rsi, r8                             ; arg2
-	        call rax
-	        pop rsi
-	        pop rdi
-	        ret
-asm___hypercall2 endp
+                        ; uintptr_t __stdcall hypercall2_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public hypercall2_vmmcall
+hypercall2_vmmcall      proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        vmmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall2_vmmcall      endp
 
-                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
-                public asm___hypercall3
-asm___hypercall3 proc
-	        push rdi
-	        push rsi
-	        mov rdi, rdx                            ; arg1
-	        mov rax, qword ptr [Hypercall]
-	        shl rcx, 5                              ; ord
-	        add rax, rcx
-	        mov rsi, r8                             ; arg2
-	        mov rdx, r9                             ; arg3
-	        call rax
-	        pop rsi
-	        pop rdi
-	        ret
-asm___hypercall3 endp
+                        ; uintptr_t __stdcall hypercall3_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public hypercall3_vmcall
+hypercall3_vmcall       proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        mov     rdx, r9                             ; arg3
+                        vmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall3_vmcall       endp
 
-                end
+                        ; uintptr_t __stdcall hypercall3_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public hypercall3_vmmcall
+hypercall3_vmmcall      proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        mov     rdx, r9                             ; arg3
+                        vmmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall3_vmmcall      endp
+
+                        end
diff --git a/src/xencrsh/hvm.c b/src/xencrsh/hvm.c
index 04da4e3..82230ef 100644
--- a/src/xencrsh/hvm.c
+++ b/src/xencrsh/hvm.c
@@ -50,22 +50,6 @@
 #include "log.h"
 #include "assert.h"
 
-#define MAXIMUM_HYPERCALL_PFN_COUNT 2
-
-#pragma code_seg("hypercall")
-__declspec(allocate("hypercall"))
-static UCHAR    __HypercallSection[(MAXIMUM_HYPERCALL_PFN_COUNT + 1) * PAGE_SIZE];
-
-#define XEN_SIGNATURE   "XenVMMXenVMM"
-
-static ULONG            __BaseLeaf = 0x40000000;
-static USHORT           __MajorVersion;
-static USHORT           __MinorVersion;
-static PFN_NUMBER       __Pfn[MAXIMUM_HYPERCALL_PFN_COUNT];
-static ULONG            __PfnCount;
-
-PHYPERCALL_GATE         Hypercall;
-
 //#pragma code_seg("sharedinfo")
 //__declspec(allocate("sharedinfo"))
 //static UCHAR    __SharedInfoSection[(1 + 1) * PAGE_SIZE];
@@ -95,102 +79,6 @@ fail:
     return Status;
 }
 
-static FORCEINLINE VOID
-CpuId(
-    IN  ULONG   Leaf,
-    OUT PULONG  EAX OPTIONAL,
-    OUT PULONG  EBX OPTIONAL,
-    OUT PULONG  ECX OPTIONAL,
-    OUT PULONG  EDX OPTIONAL
-    )
-{
-    int         Value[4] = {0};
-
-    __cpuid(Value, Leaf);
-
-    if (EAX)
-        *EAX = (ULONG)Value[0];
-
-    if (EBX)
-        *EBX = (ULONG)Value[1];
-
-    if (ECX)
-        *ECX = (ULONG)Value[2];
-
-    if (EDX)
-        *EDX = (ULONG)Value[3];
-}
-
-static FORCEINLINE NTSTATUS
-__InitHypercallPage()
-{
-    ULONG       eax = 'DEAD';
-    ULONG       ebx = 'DEAD';
-    ULONG       ecx = 'DEAD';
-    ULONG       edx = 'DEAD';
-    ULONG_PTR   Index;
-    ULONG       HypercallMsr;
-
-    NTSTATUS    Status;
-
-    Status = STATUS_UNSUCCESSFUL;
-    for (;;) {
-        CHAR Signature[13] = { 0 };
-
-        CpuId(__BaseLeaf, &eax, &ebx, &ecx, &edx);
-        *((PULONG)(Signature + 0)) = ebx;
-        *((PULONG)(Signature + 4)) = ecx;
-        *((PULONG)(Signature + 8)) = edx;
-
-        if (strcmp(Signature, XEN_SIGNATURE) == 0 &&
-            eax >= __BaseLeaf + 2)
-            break;
-
-        __BaseLeaf += 0x100;
-
-        if (__BaseLeaf > 0x40000100)
-            goto fail1;
-    }
-
-    CpuId(__BaseLeaf + 1, &eax, NULL, NULL, NULL);
-    __MajorVersion = (USHORT)(eax >> 16);
-    __MinorVersion = (USHORT)(eax & 0xFFFF);
-
-    LogVerbose("XEN %d.%d\n", __MajorVersion, __MinorVersion);
-    LogVerbose("INTERFACE 0x%08x\n", __XEN_INTERFACE_VERSION__);
-
-    if ((ULONG_PTR)__HypercallSection & (PAGE_SIZE - 1))
-        Hypercall = (PVOID)(((ULONG_PTR)__HypercallSection + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1));
-    else
-        Hypercall = (PVOID)__HypercallSection;
-
-    ASSERT3U(((ULONG_PTR)Hypercall & (PAGE_SIZE - 1)), ==, 0);
-
-    for (Index = 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; Index++) {
-        PHYSICAL_ADDRESS    PhysicalAddress;
-
-        PhysicalAddress = MmGetPhysicalAddress((PUCHAR)Hypercall + (Index << PAGE_SHIFT));
-        __Pfn[Index] = (PFN_NUMBER)(PhysicalAddress.QuadPart >> PAGE_SHIFT);
-    }
-
-    CpuId(__BaseLeaf + 2, &eax, &ebx, NULL, NULL);
-    __PfnCount = eax;
-    ASSERT(__PfnCount <= MAXIMUM_HYPERCALL_PFN_COUNT);
-    HypercallMsr = ebx;
-
-    for (Index = 0; Index < __PfnCount; Index++) {
-        LogVerbose("HypercallPfn[%d]: %p\n", Index, (PVOID)__Pfn[Index]);
-        __writemsr(HypercallMsr, (ULONG64)__Pfn[Index] << PAGE_SHIFT);
-    }
-
-    return STATUS_SUCCESS;
-
-fail1:
-    LogError("fail1 (%08x)", Status);
-
-    return Status;
-}
-
 //static NTSTATUS
 //__InitSharedInfo()
 //{
@@ -235,7 +123,7 @@ HvmInitialize()
 {
     NTSTATUS    Status;
 
-    Status = __InitHypercallPage();
+    Status = HypercallInitialize();
     if (!NT_SUCCESS(Status))
         goto fail;
 
@@ -258,12 +146,6 @@ fail:
 VOID
 HvmTerminate()
 {
-    ULONG Index;
-
-    Hypercall = NULL;
-    for (Index = 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; ++Index) {
-        __Pfn[Index] = 0;
-    }
     //SharedInfo = NULL;
 }
 
diff --git a/src/xencrsh/hypercall.h b/src/xencrsh/hypercall.h
index 762ecf8..6b055fa 100644
--- a/src/xencrsh/hypercall.h
+++ b/src/xencrsh/hypercall.h
@@ -35,8 +35,10 @@
 
 #include "driver.h"
 
-typedef UCHAR           HYPERCALL_GATE[32];
-typedef HYPERCALL_GATE  *PHYPERCALL_GATE;
+extern NTSTATUS
+HypercallInitialize(
+    VOID
+    );
 
 extern ULONG_PTR
 ___Hypercall2(
diff --git a/src/xencrsh/hypercall_stub.c b/src/xencrsh/hypercall_stub.c
index 1741850..7339c88 100644
--- a/src/xencrsh/hypercall_stub.c
+++ b/src/xencrsh/hypercall_stub.c
@@ -39,9 +39,157 @@
          
 #include <xen-types.h>
 
+#include "log.h"
+#include "assert.h"
+
 #include "hypercall.h"
 
-extern uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
+typedef enum _HYPERCALL_INSTRUCTION {
+    HYPERCALL_INSTRUCTION_UNKNOWN,
+    HYPERCALL_INSTRUCTION_VMCALL,
+    HYPERCALL_INSTRUCTION_VMMCALL,
+} HYPERCALL_INSTRUCTION;
+
+typedef struct _CPU_VENDOR_DATA {
+    ULONG                   EBX;
+    ULONG                   ECX;
+    ULONG                   EDX;
+    HYPERCALL_INSTRUCTION   Instruction;
+} CPU_VENDOR_DATA;
+
+static const CPU_VENDOR_DATA    HypercallVendorData[] = {
+    // Note that the vendor data goes EBX-ECX-EDX
+    {
+        // "GenuineIntel"
+        0x756E6547, 0x6C65746E, 0x49656E69,
+        HYPERCALL_INSTRUCTION_VMCALL
+    },
+    {
+        // "AuthenticAMD"
+        0x68747541, 0x444D4163, 0x69746E65,
+        HYPERCALL_INSTRUCTION_VMMCALL
+    },
+    {
+        // "CentaurHauls"
+        0x746E6543, 0x736C7561, 0x48727561,
+        HYPERCALL_INSTRUCTION_VMCALL
+    },
+    {
+        // "  Shanghai  "
+        0x68532020, 0x20206961, 0x68676E61,
+        HYPERCALL_INSTRUCTION_VMCALL
+    },
+    {
+        // "HygonGenuine"
+        0x6F677948, 0x656E6975, 0x6E65476E,
+        HYPERCALL_INSTRUCTION_VMMCALL
+    },
+};
+
+static HYPERCALL_INSTRUCTION    HypercallInstruction
+    = HYPERCALL_INSTRUCTION_UNKNOWN;
+
+static FORCEINLINE VOID
+__CpuId(
+    IN  ULONG   Leaf,
+    OUT PULONG  EAX OPTIONAL,
+    OUT PULONG  EBX OPTIONAL,
+    OUT PULONG  ECX OPTIONAL,
+    OUT PULONG  EDX OPTIONAL
+    )
+{
+    int         Value[4] = {0};
+
+    __cpuid(Value, Leaf);
+
+    if (EAX)
+        *EAX = (ULONG)Value[0];
+
+    if (EBX)
+        *EBX = (ULONG)Value[1];
+
+    if (ECX)
+        *ECX = (ULONG)Value[2];
+
+    if (EDX)
+        *EDX = (ULONG)Value[3];
+}
+
+NTSTATUS
+HypercallInitialize(
+    VOID
+    )
+{
+    ULONG                   XenBaseLeaf = 0x40000000;
+    ULONG                   EAX = 'DEAD';
+    ULONG                   EBX = 'DEAD';
+    ULONG                   ECX = 'DEAD';
+    ULONG                   EDX = 'DEAD';
+    HYPERCALL_INSTRUCTION   Instruction = HYPERCALL_INSTRUCTION_UNKNOWN;
+    ULONG                   Index;
+
+    for (;;) {
+        CHAR    Signature[13] = {0};
+
+        __CpuId(XenBaseLeaf, &EAX, &EBX, &ECX, &EDX);
+        *((PULONG)(Signature + 0)) = EBX;
+        *((PULONG)(Signature + 4)) = ECX;
+        *((PULONG)(Signature + 8)) = EDX;
+
+        if (strcmp(Signature, "XenVMMXenVMM") == 0 &&
+            EAX >= XenBaseLeaf + 2)
+            break;
+
+        XenBaseLeaf += 0x100;
+
+        if (XenBaseLeaf > 0x40000100) {
+            LogVerbose("XEN: BASE CPUID LEAF NOT FOUND\n");
+            return STATUS_NOT_SUPPORTED;
+        }
+    }
+
+    LogVerbose("XEN: BASE CPUID LEAF @ %08x\n",
+               XenBaseLeaf);
+
+    __CpuId(0, &EAX, &EBX, &ECX, &EDX);
+    for (Index = 0; Index < ARRAYSIZE(HypercallVendorData); Index++) {
+        const CPU_VENDOR_DATA   *CurrentData = &HypercallVendorData[Index];
+
+        if (EBX == CurrentData->EBX &&
+            ECX == CurrentData->ECX &&
+            EDX == CurrentData->EDX) {
+            Instruction = CurrentData->Instruction;
+            break;
+        }
+    }
+
+    if (Instruction == HYPERCALL_INSTRUCTION_UNKNOWN) {
+        LogVerbose("XEN: CANNOT DETECT HYPERCALL INSTRUCTION\n");
+        return STATUS_NOT_SUPPORTED;
+    }
+
+    HypercallInstruction = Instruction;
+    return STATUS_SUCCESS;
+}
+
+extern uintptr_t __stdcall hypercall2_vmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2);
+extern uintptr_t __stdcall hypercall2_vmmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2);
+extern uintptr_t __stdcall hypercall3_vmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2,
+    uintptr_t   arg3);
+extern uintptr_t __stdcall hypercall3_vmmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2,
+    uintptr_t   arg3);
 
 ULONG_PTR
 ___Hypercall2(
@@ -50,10 +198,24 @@ ___Hypercall2(
     ULONG_PTR   Argument2
     )
 {
-    return asm___hypercall2(Ordinal, Argument1, Argument2);
-}
+    ULONG_PTR   Value;
 
-extern uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
+    switch (HypercallInstruction) {
+    case HYPERCALL_INSTRUCTION_VMCALL:
+        Value = hypercall2_vmcall(Ordinal, Argument1, Argument2);
+        break;
+
+    case HYPERCALL_INSTRUCTION_VMMCALL:
+        Value = hypercall2_vmmcall(Ordinal, Argument1, Argument2);
+        break;
+
+    default:
+        Value = 0;
+        BUG("NO HYPERCALL INSTRUCTION");
+    }
+
+    return Value;
+}
 
 ULONG_PTR
 ___Hypercall3(
@@ -63,5 +225,22 @@ ___Hypercall3(
     ULONG_PTR   Argument3
     )
 {
-    return asm___hypercall3(Ordinal, Argument1, Argument2, Argument3);
+    ULONG_PTR   Value;
+
+    switch (HypercallInstruction) {
+    case HYPERCALL_INSTRUCTION_VMCALL:
+        Value = hypercall3_vmcall(Ordinal, Argument1, Argument2, Argument3);
+        break;
+
+    case HYPERCALL_INSTRUCTION_VMMCALL:
+        Value = hypercall3_vmmcall(Ordinal, Argument1, Argument2, Argument3);
+        break;
+
+    default:
+        Value = 0;
+        BUG("NO HYPERCALL INSTRUCTION");
+    }
+
+    return Value;
+
 }
diff --git a/src/xencrsh/i386/hypercall.asm b/src/xencrsh/i386/hypercall.asm
index 51094be..be68db3 100644
--- a/src/xencrsh/i386/hypercall.asm
+++ b/src/xencrsh/i386/hypercall.asm
@@ -1,45 +1,84 @@
-                page    ,132
-                title   Hypercall Gates
+                        page    ,132
+                        title   Hypercall Thunks
 
-                .686p
-                .model  FLAT
-                .code
+                        .686p
+                        .model  FLAT
+                        .code
 
-                extrn   _Hypercall:dword
+                        ; uintptr_t __stdcall hypercall2_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public _hypercall2_vmcall@12
+_hypercall2_vmcall@12   proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        vmcall
+                        pop     ebx
+                        leave
+                        ret     0Ch
+_hypercall2_vmcall@12   endp
 
-                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
-                public _asm___hypercall2@12
-_asm___hypercall2@12 proc
-                push    ebp
-                mov     ebp, esp
-                push    ebx
-                mov     eax, [ebp + 08h]                ; ord
-                mov     ebx, [ebp + 0ch]                ; arg1
-                mov     ecx, [ebp + 10h]                ; arg2
-                shl     eax, 5
-                add     eax, dword ptr [_Hypercall]
-                call    eax
-                pop     ebx
-                leave
-                ret     0Ch
-_asm___hypercall2@12 endp
+                        ; uintptr_t __stdcall hypercall2_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public _hypercall2_vmmcall@12
+_hypercall2_vmmcall@12  proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        vmmcall
+                        pop     ebx
+                        leave
+                        ret     0Ch
+_hypercall2_vmmcall@12  endp
 
-                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
-                public _asm___hypercall3@16
-_asm___hypercall3@16 proc
-                push    ebp
-                mov     ebp, esp
-                push    ebx
-                mov     eax, [ebp + 08h]                ; ord
-                mov     ebx, [ebp + 0ch]                ; arg1
-                mov     ecx, [ebp + 10h]                ; arg2
-                mov     edx, [ebp + 14h]                ; arg3
-                shl     eax, 5
-                add     eax, dword ptr [_Hypercall]
-                call    eax
-                pop     ebx
-                leave
-                ret     10h
-_asm___hypercall3@16 endp
+                        ; uintptr_t __stdcall hypercall3_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public _hypercall3_vmcall@16
+_hypercall3_vmcall@16   proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        mov     edx, [ebp + 14h]                ; arg3
+                        vmcall
+                        pop     ebx
+                        leave
+                        ret     10h
+_hypercall3_vmcall@16   endp
 
-                end
+                        ; uintptr_t __stdcall hypercall3_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public _hypercall3_vmmcall@16
+_hypercall3_vmmcall@16  proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        mov     edx, [ebp + 14h]                ; arg3
+                        vmmcall
+                        pop     ebx
+                        leave
+                        ret     10h
+_hypercall3_vmmcall@16  endp
+
+                        end
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Apr 24 09:09:08 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 24 Apr 2026 09:09:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1293330.1571127 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wGCX5-00062A-Sy; Fri, 24 Apr 2026 09:09:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1293330.1571127; Fri, 24 Apr 2026 09:09:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wGCX5-000623-Pg; Fri, 24 Apr 2026 09:09:07 +0000
Received: by outflank-mailman (input) for mailman id 1293330;
 Fri, 24 Apr 2026 09:09:06 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dbebfe920000f373@swg.vates.tech>)
 id 1wGCX3-00061s-8F
 for win-pv-devel@lists.xenproject.org; Fri, 24 Apr 2026 09:09:06 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wGCX2-006qDe-Ky
 for win-pv-devel@lists.xenproject.org; Fri, 24 Apr 2026 11:09:04 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dbebfe920000f373@swg.vates.tech>)
 id 69eb3314-5cb7-0a2a0a5109dd-0a2a4508cf8c-44
 for <win-pv-devel@lists.xenproject.org>; Fri, 24 Apr 2026 11:09:04 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dbebfe920000f373@swg.vates.tech>)
 id 69eb3330-63b5-0a2a45080019-b9ff1c22b249-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 24 Apr 2026 11:09:04 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dbebfe920000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Fri, 24 Apr 2026 09:09:01 +0000
Received: from [192.168.1.61] (155.223.66.37.rev.sfr.net [37.66.223.155])
 (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id B030287069;
 Fri, 24 Apr 2026 11:09:00 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=FZybo1cjGOJ1WcNg33j6M8iCmY/8bexMa0nvzU+EPeg=;
 h=from:subject:date:message-id:to:mime-version:content-type:in-reply-to:references:feedback-id;
 b=fZQpErXFgp4mVcOzubcIGWvGi9XHECGh/H2KiP2ZqMDywJWulX7Zz614GKGxrSl6PkZqRAaJg
 n4JoroBeJQ0QtNrKhZnRTS94wR01G4NDfeQMl8juM3n1fLM9zieveD9lUnf6okwEnexGNJBR2vi
 9kfnooPqRI3vqZ2Ys48Kw/nlQGEHQ2v7L5XM2go0u0o7b+1LPzoJqCzhzMGkyRTqHC0dYIqtaAg
 sBodv9TBvGUD1eex2bKl4lkU5Fc+fuuqQqEU2XbMTkz1vpZoIHUDrqgHhoBJPDXRY15kI05lXl8
 MjOw7rqFIaPZTIT5P83XSRkG+8tBgDEnwySf+nbmM5AQ==
X-Zone-Loop: adcb2e56d4c4ff874f485848288b8914413837997ea8
x-campaign-type: default
x-transaction-id: d9c75488-919e-46a7-a44f-719b30cafc96
x-swg-uid: 01-6e4e11b5-3ae3-4d24-b068-add3bd7d7418
X-Mailer: Sweego
Message-ID:
 <1777021741.8631fc262581453bbf619ec5b2062170.19dbebfe920000f373@vates.tech>
x-swg-bid: 1777021741.8631fc262581453bbf619ec5b2062170.19dbebfe920000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
Date: Fri, 24 Apr 2026 11:09:00 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] Use direct hypercall instead of hypercall page
To: Owen Smith <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260423140755.950-1-owen.smith@citrix.com>
Content-Language: en-US
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260423140755.950-1-owen.smith@citrix.com>
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.2803.29d1e1fadbc8c2f7.19dbebfe6f1.43fac78d407f52d7=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777021740785
X-purgate-ID: tlsNG-c1860d/1777021744-3A368DB1-911A23A7/0/0
X-purgate-type: clean
X-purgate-size: 24348

---=Part.2803.29d1e1fadbc8c2f7.19dbebfe6f1.43fac78d407f52d7=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 23/04/2026 16:08, Owen Smith wrote:
> XSA-466 "Xen hypercall page unsafe against speculative attacks"
> recommends that OSes avoid using the hypercall page, since that breaks
> the use of return thunks and CET IBT=2E
>=20
> While Windows doesn't support return thunks or CET IBT, the current
> hypercall code uses a naked indirect call to call into the hypercall
> page=2E This call is not protected by Windows CFG, and cannot be patched
> by Windows's Retpoline implementation=2E
>=20
> Convert the hypercall code to detect CPU vendor and use the appropriate
> hypercall instructions=2E
>=20
> Ported from xenbus 2635e7c08ee8df3e3c1be427926a53fe1b345c96
> by Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
>=20
> Signed-off-by: Owen Smith <owen=2Esmith@citrix=2Ecom>

Hi,

I'm getting a "hypercall_stub=2Ec(103,5): warning C5250: '__cpuid':=20
intrinsic function not declared" build error with this patch=2E

hypercall_stub=2Ec just needs a "#include <intrin=2Eh>" to fix this=2E

> ---
>   src/xencrsh/amd64/hypercall=2Easm | 109 ++++++++++++------
>   src/xencrsh/hvm=2Ec               | 120 +-------------------
>   src/xencrsh/hypercall=2Eh         |   6 +-
>   src/xencrsh/hypercall_stub=2Ec    | 189 ++++++++++++++++++++++++++++++=
+-
>   src/xencrsh/i386/hypercall=2Easm  | 119 +++++++++++++-------
>   5 files changed, 341 insertions(+), 202 deletions(-)
>=20
> diff --git a/src/xencrsh/amd64/hypercall=2Easm b/src/xencrsh/amd64/hyper=
call=2Easm
> index 1ceda85=2E=2Ede430e7 100644
> --- a/src/xencrsh/amd64/hypercall=2Easm
> +++ b/src/xencrsh/amd64/hypercall=2Easm
> @@ -1,41 +1,78 @@
> -                page    ,132
> -                title   Hypercall Gates
> +                        page    ,132
> +                        title   Hypercall Thunks
>  =20
> -                =2Ecode
> +                        =2Ecode
>  =20
> -                extrn   Hypercall:qword
> +                        ; uintptr_t __stdcall hypercall2_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public hypercall2_vmcall
> +hypercall2_vmcall       proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        vmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall2_vmcall       endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2);
> -                public asm___hypercall2
> -asm___hypercall2 proc
> -	        push rdi
> -	        push rsi
> -	        mov rdi, rdx                            ; arg1
> -	        mov rax, qword ptr [Hypercall]
> -	        shl rcx, 5                              ; ord
> -	        add rax, rcx
> -	        mov rsi, r8                             ; arg2
> -	        call rax
> -	        pop rsi
> -	        pop rdi
> -	        ret
> -asm___hypercall2 endp
> +                        ; uintptr_t __stdcall hypercall2_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public hypercall2_vmmcall
> +hypercall2_vmmcall      proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        vmmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall2_vmmcall      endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2, uintptr_t arg3);
> -                public asm___hypercall3
> -asm___hypercall3 proc
> -	        push rdi
> -	        push rsi
> -	        mov rdi, rdx                            ; arg1
> -	        mov rax, qword ptr [Hypercall]
> -	        shl rcx, 5                              ; ord
> -	        add rax, rcx
> -	        mov rsi, r8                             ; arg2
> -	        mov rdx, r9                             ; arg3
> -	        call rax
> -	        pop rsi
> -	        pop rdi
> -	        ret
> -asm___hypercall3 endp
> +                        ; uintptr_t __stdcall hypercall3_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public hypercall3_vmcall
> +hypercall3_vmcall       proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        mov     rdx, r9                             ; a=
rg3
> +                        vmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall3_vmcall       endp
>  =20
> -                end
> +                        ; uintptr_t __stdcall hypercall3_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public hypercall3_vmmcall
> +hypercall3_vmmcall      proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        mov     rdx, r9                             ; a=
rg3
> +                        vmmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall3_vmmcall      endp
> +
> +                        end
> diff --git a/src/xencrsh/hvm=2Ec b/src/xencrsh/hvm=2Ec
> index 04da4e3=2E=2E82230ef 100644
> --- a/src/xencrsh/hvm=2Ec
> +++ b/src/xencrsh/hvm=2Ec
> @@ -50,22 +50,6 @@
>   #include "log=2Eh"
>   #include "assert=2Eh"
>  =20
> -#define MAXIMUM_HYPERCALL_PFN_COUNT 2
> -
> -#pragma code_seg("hypercall")
> -__declspec(allocate("hypercall"))
> -static UCHAR    __HypercallSection[(MAXIMUM_HYPERCALL_PFN_COUNT + 1) * =
PAGE_SIZE];
> -
> -#define XEN_SIGNATURE   "XenVMMXenVMM"
> -
> -static ULONG            __BaseLeaf =3D 0x40000000;
> -static USHORT           __MajorVersion;
> -static USHORT           __MinorVersion;
> -static PFN_NUMBER       __Pfn[MAXIMUM_HYPERCALL_PFN_COUNT];
> -static ULONG            __PfnCount;
> -
> -PHYPERCALL_GATE         Hypercall;
> -
>   //#pragma code_seg("sharedinfo")
>   //__declspec(allocate("sharedinfo"))
>   //static UCHAR    __SharedInfoSection[(1 + 1) * PAGE_SIZE];
> @@ -95,102 +79,6 @@ fail:
>       return Status;
>   }
>  =20
> -static FORCEINLINE VOID
> -CpuId(
> -    IN  ULONG   Leaf,
> -    OUT PULONG  EAX OPTIONAL,
> -    OUT PULONG  EBX OPTIONAL,
> -    OUT PULONG  ECX OPTIONAL,
> -    OUT PULONG  EDX OPTIONAL
> -    )
> -{
> -    int         Value[4] =3D {0};
> -
> -    __cpuid(Value, Leaf);
> -
> -    if (EAX)
> -        *EAX =3D (ULONG)Value[0];
> -
> -    if (EBX)
> -        *EBX =3D (ULONG)Value[1];
> -
> -    if (ECX)
> -        *ECX =3D (ULONG)Value[2];
> -
> -    if (EDX)
> -        *EDX =3D (ULONG)Value[3];
> -}
> -
> -static FORCEINLINE NTSTATUS
> -__InitHypercallPage()
> -{
> -    ULONG       eax =3D 'DEAD';
> -    ULONG       ebx =3D 'DEAD';
> -    ULONG       ecx =3D 'DEAD';
> -    ULONG       edx =3D 'DEAD';
> -    ULONG_PTR   Index;
> -    ULONG       HypercallMsr;
> -
> -    NTSTATUS    Status;
> -
> -    Status =3D STATUS_UNSUCCESSFUL;
> -    for (;;) {
> -        CHAR Signature[13] =3D { 0 };
> -
> -        CpuId(__BaseLeaf, &eax, &ebx, &ecx, &edx);
> -        *((PULONG)(Signature + 0)) =3D ebx;
> -        *((PULONG)(Signature + 4)) =3D ecx;
> -        *((PULONG)(Signature + 8)) =3D edx;
> -
> -        if (strcmp(Signature, XEN_SIGNATURE) =3D=3D 0 &&
> -            eax >=3D __BaseLeaf + 2)
> -            break;
> -
> -        __BaseLeaf +=3D 0x100;
> -
> -        if (__BaseLeaf > 0x40000100)
> -            goto fail1;
> -    }
> -
> -    CpuId(__BaseLeaf + 1, &eax, NULL, NULL, NULL);
> -    __MajorVersion =3D (USHORT)(eax >> 16);
> -    __MinorVersion =3D (USHORT)(eax & 0xFFFF);
> -
> -    LogVerbose("XEN %d=2E%d\n", __MajorVersion, __MinorVersion);
> -    LogVerbose("INTERFACE 0x%08x\n", __XEN_INTERFACE_VERSION__);
> -
> -    if ((ULONG_PTR)__HypercallSection & (PAGE_SIZE - 1))
> -        Hypercall =3D (PVOID)(((ULONG_PTR)__HypercallSection + PAGE_SIZ=
E - 1) & ~(PAGE_SIZE - 1));
> -    else
> -        Hypercall =3D (PVOID)__HypercallSection;
> -
> -    ASSERT3U(((ULONG_PTR)Hypercall & (PAGE_SIZE - 1)), =3D=3D, 0);
> -
> -    for (Index =3D 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; Index++) {
> -        PHYSICAL_ADDRESS    PhysicalAddress;
> -
> -        PhysicalAddress =3D MmGetPhysicalAddress((PUCHAR)Hypercall + (I=
ndex << PAGE_SHIFT));
> -        __Pfn[Index] =3D (PFN_NUMBER)(PhysicalAddress=2EQuadPart >> PAG=
E_SHIFT);
> -    }
> -
> -    CpuId(__BaseLeaf + 2, &eax, &ebx, NULL, NULL);
> -    __PfnCount =3D eax;
> -    ASSERT(__PfnCount <=3D MAXIMUM_HYPERCALL_PFN_COUNT);
> -    HypercallMsr =3D ebx;
> -
> -    for (Index =3D 0; Index < __PfnCount; Index++) {
> -        LogVerbose("HypercallPfn[%d]: %p\n", Index, (PVOID)__Pfn[Index]=
);
> -        __writemsr(HypercallMsr, (ULONG64)__Pfn[Index] << PAGE_SHIFT);
> -    }
> -
> -    return STATUS_SUCCESS;
> -
> -fail1:
> -    LogError("fail1 (%08x)", Status);
> -
> -    return Status;
> -}
> -
>   //static NTSTATUS
>   //__InitSharedInfo()
>   //{
> @@ -235,7 +123,7 @@ HvmInitialize()
>   {
>       NTSTATUS    Status;
>  =20
> -    Status =3D __InitHypercallPage();
> +    Status =3D HypercallInitialize();
>       if (!NT_SUCCESS(Status))
>           goto fail;
>  =20
> @@ -258,12 +146,6 @@ fail:
>   VOID
>   HvmTerminate()
>   {
> -    ULONG Index;
> -
> -    Hypercall =3D NULL;
> -    for (Index =3D 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; ++Index) {
> -        __Pfn[Index] =3D 0;
> -    }
>       //SharedInfo =3D NULL;
>   }
>  =20
> diff --git a/src/xencrsh/hypercall=2Eh b/src/xencrsh/hypercall=2Eh
> index 762ecf8=2E=2E6b055fa 100644
> --- a/src/xencrsh/hypercall=2Eh
> +++ b/src/xencrsh/hypercall=2Eh
> @@ -35,8 +35,10 @@
>  =20
>   #include "driver=2Eh"
>  =20
> -typedef UCHAR           HYPERCALL_GATE[32];
> -typedef HYPERCALL_GATE  *PHYPERCALL_GATE;
> +extern NTSTATUS
> +HypercallInitialize(
> +    VOID
> +    );
>  =20
>   extern ULONG_PTR
>   ___Hypercall2(
> diff --git a/src/xencrsh/hypercall_stub=2Ec b/src/xencrsh/hypercall_stub=
=2Ec
> index 1741850=2E=2E7339c88 100644
> --- a/src/xencrsh/hypercall_stub=2Ec
> +++ b/src/xencrsh/hypercall_stub=2Ec
> @@ -39,9 +39,157 @@
>           =20
>   #include <xen-types=2Eh>
>  =20
> +#include "log=2Eh"
> +#include "assert=2Eh"
> +
>   #include "hypercall=2Eh"
>  =20
> -extern uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg=
1, uintptr_t arg2);
> +typedef enum _HYPERCALL_INSTRUCTION {
> +    HYPERCALL_INSTRUCTION_UNKNOWN,
> +    HYPERCALL_INSTRUCTION_VMCALL,
> +    HYPERCALL_INSTRUCTION_VMMCALL,
> +} HYPERCALL_INSTRUCTION;
> +
> +typedef struct _CPU_VENDOR_DATA {
> +    ULONG                   EBX;
> +    ULONG                   ECX;
> +    ULONG                   EDX;
> +    HYPERCALL_INSTRUCTION   Instruction;
> +} CPU_VENDOR_DATA;
> +
> +static const CPU_VENDOR_DATA    HypercallVendorData[] =3D {
> +    // Note that the vendor data goes EBX-ECX-EDX
> +    {
> +        // "GenuineIntel"
> +        0x756E6547, 0x6C65746E, 0x49656E69,
> +        HYPERCALL_INSTRUCTION_VMCALL
> +    },
> +    {
> +        // "AuthenticAMD"
> +        0x68747541, 0x444D4163, 0x69746E65,
> +        HYPERCALL_INSTRUCTION_VMMCALL
> +    },
> +    {
> +        // "CentaurHauls"
> +        0x746E6543, 0x736C7561, 0x48727561,
> +        HYPERCALL_INSTRUCTION_VMCALL
> +    },
> +    {
> +        // "  Shanghai  "
> +        0x68532020, 0x20206961, 0x68676E61,
> +        HYPERCALL_INSTRUCTION_VMCALL
> +    },
> +    {
> +        // "HygonGenuine"
> +        0x6F677948, 0x656E6975, 0x6E65476E,
> +        HYPERCALL_INSTRUCTION_VMMCALL
> +    },
> +};
> +
> +static HYPERCALL_INSTRUCTION    HypercallInstruction
> +    =3D HYPERCALL_INSTRUCTION_UNKNOWN;
> +
> +static FORCEINLINE VOID
> +__CpuId(
> +    IN  ULONG   Leaf,
> +    OUT PULONG  EAX OPTIONAL,
> +    OUT PULONG  EBX OPTIONAL,
> +    OUT PULONG  ECX OPTIONAL,
> +    OUT PULONG  EDX OPTIONAL
> +    )
> +{
> +    int         Value[4] =3D {0};
> +
> +    __cpuid(Value, Leaf);
> +
> +    if (EAX)
> +        *EAX =3D (ULONG)Value[0];
> +
> +    if (EBX)
> +        *EBX =3D (ULONG)Value[1];
> +
> +    if (ECX)
> +        *ECX =3D (ULONG)Value[2];
> +
> +    if (EDX)
> +        *EDX =3D (ULONG)Value[3];
> +}
> +
> +NTSTATUS
> +HypercallInitialize(
> +    VOID
> +    )
> +{
> +    ULONG                   XenBaseLeaf =3D 0x40000000;
> +    ULONG                   EAX =3D 'DEAD';
> +    ULONG                   EBX =3D 'DEAD';
> +    ULONG                   ECX =3D 'DEAD';
> +    ULONG                   EDX =3D 'DEAD';
> +    HYPERCALL_INSTRUCTION   Instruction =3D HYPERCALL_INSTRUCTION_UNKNO=
WN;
> +    ULONG                   Index;
> +
> +    for (;;) {
> +        CHAR    Signature[13] =3D {0};
> +
> +        __CpuId(XenBaseLeaf, &EAX, &EBX, &ECX, &EDX);
> +        *((PULONG)(Signature + 0)) =3D EBX;
> +        *((PULONG)(Signature + 4)) =3D ECX;
> +        *((PULONG)(Signature + 8)) =3D EDX;
> +
> +        if (strcmp(Signature, "XenVMMXenVMM") =3D=3D 0 &&
> +            EAX >=3D XenBaseLeaf + 2)
> +            break;
> +
> +        XenBaseLeaf +=3D 0x100;
> +
> +        if (XenBaseLeaf > 0x40000100) {
> +            LogVerbose("XEN: BASE CPUID LEAF NOT FOUND\n");
> +            return STATUS_NOT_SUPPORTED;
> +        }
> +    }
> +
> +    LogVerbose("XEN: BASE CPUID LEAF @ %08x\n",
> +               XenBaseLeaf);
> +
> +    __CpuId(0, &EAX, &EBX, &ECX, &EDX);
> +    for (Index =3D 0; Index < ARRAYSIZE(HypercallVendorData); Index++) =
{
> +        const CPU_VENDOR_DATA   *CurrentData =3D &HypercallVendorData[I=
ndex];
> +
> +        if (EBX =3D=3D CurrentData->EBX &&
> +            ECX =3D=3D CurrentData->ECX &&
> +            EDX =3D=3D CurrentData->EDX) {
> +            Instruction =3D CurrentData->Instruction;
> +            break;
> +        }
> +    }
> +
> +    if (Instruction =3D=3D HYPERCALL_INSTRUCTION_UNKNOWN) {
> +        LogVerbose("XEN: CANNOT DETECT HYPERCALL INSTRUCTION\n");
> +        return STATUS_NOT_SUPPORTED;
> +    }
> +
> +    HypercallInstruction =3D Instruction;
> +    return STATUS_SUCCESS;
> +}
> +
> +extern uintptr_t __stdcall hypercall2_vmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2);
> +extern uintptr_t __stdcall hypercall2_vmmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2);
> +extern uintptr_t __stdcall hypercall3_vmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2,
> +    uintptr_t   arg3);
> +extern uintptr_t __stdcall hypercall3_vmmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2,
> +    uintptr_t   arg3);
>  =20
>   ULONG_PTR
>   ___Hypercall2(
> @@ -50,10 +198,24 @@ ___Hypercall2(
>       ULONG_PTR   Argument2
>       )
>   {
> -    return asm___hypercall2(Ordinal, Argument1, Argument2);
> -}
> +    ULONG_PTR   Value;
>  =20
> -extern uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg=
1, uintptr_t arg2, uintptr_t arg3);
> +    switch (HypercallInstruction) {
> +    case HYPERCALL_INSTRUCTION_VMCALL:
> +        Value =3D hypercall2_vmcall(Ordinal, Argument1, Argument2);
> +        break;
> +
> +    case HYPERCALL_INSTRUCTION_VMMCALL:
> +        Value =3D hypercall2_vmmcall(Ordinal, Argument1, Argument2);
> +        break;
> +
> +    default:
> +        Value =3D 0;
> +        BUG("NO HYPERCALL INSTRUCTION");
> +    }
> +
> +    return Value;
> +}
>  =20
>   ULONG_PTR
>   ___Hypercall3(
> @@ -63,5 +225,22 @@ ___Hypercall3(
>       ULONG_PTR   Argument3
>       )
>   {
> -    return asm___hypercall3(Ordinal, Argument1, Argument2, Argument3);
> +    ULONG_PTR   Value;
> +
> +    switch (HypercallInstruction) {
> +    case HYPERCALL_INSTRUCTION_VMCALL:
> +        Value =3D hypercall3_vmcall(Ordinal, Argument1, Argument2, Argu=
ment3);
> +        break;
> +
> +    case HYPERCALL_INSTRUCTION_VMMCALL:
> +        Value =3D hypercall3_vmmcall(Ordinal, Argument1, Argument2, Arg=
ument3);
> +        break;
> +
> +    default:
> +        Value =3D 0;
> +        BUG("NO HYPERCALL INSTRUCTION");
> +    }
> +
> +    return Value;
> +
>   }
> diff --git a/src/xencrsh/i386/hypercall=2Easm b/src/xencrsh/i386/hyperca=
ll=2Easm
> index 51094be=2E=2Ebe68db3 100644
> --- a/src/xencrsh/i386/hypercall=2Easm
> +++ b/src/xencrsh/i386/hypercall=2Easm
> @@ -1,45 +1,84 @@
> -                page    ,132
> -                title   Hypercall Gates
> +                        page    ,132
> +                        title   Hypercall Thunks
>  =20
> -                =2E686p
> -                =2Emodel  FLAT
> -                =2Ecode
> +                        =2E686p
> +                        =2Emodel  FLAT
> +                        =2Ecode
>  =20
> -                extrn   _Hypercall:dword
> +                        ; uintptr_t __stdcall hypercall2_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public _hypercall2_vmcall@12
> +_hypercall2_vmcall@12   proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        vmcall
> +                        pop     ebx
> +                        leave
> +                        ret     0Ch
> +_hypercall2_vmcall@12   endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2);
> -                public _asm___hypercall2@12
> -_asm___hypercall2@12 proc
> -                push    ebp
> -                mov     ebp, esp
> -                push    ebx
> -                mov     eax, [ebp + 08h]                ; ord
> -                mov     ebx, [ebp + 0ch]                ; arg1
> -                mov     ecx, [ebp + 10h]                ; arg2
> -                shl     eax, 5
> -                add     eax, dword ptr [_Hypercall]
> -                call    eax
> -                pop     ebx
> -                leave
> -                ret     0Ch
> -_asm___hypercall2@12 endp
> +                        ; uintptr_t __stdcall hypercall2_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public _hypercall2_vmmcall@12
> +_hypercall2_vmmcall@12  proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        vmmcall
> +                        pop     ebx
> +                        leave
> +                        ret     0Ch
> +_hypercall2_vmmcall@12  endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2, uintptr_t arg3);
> -                public _asm___hypercall3@16
> -_asm___hypercall3@16 proc
> -                push    ebp
> -                mov     ebp, esp
> -                push    ebx
> -                mov     eax, [ebp + 08h]                ; ord
> -                mov     ebx, [ebp + 0ch]                ; arg1
> -                mov     ecx, [ebp + 10h]                ; arg2
> -                mov     edx, [ebp + 14h]                ; arg3
> -                shl     eax, 5
> -                add     eax, dword ptr [_Hypercall]
> -                call    eax
> -                pop     ebx
> -                leave
> -                ret     10h
> -_asm___hypercall3@16 endp
> +                        ; uintptr_t __stdcall hypercall3_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public _hypercall3_vmcall@16
> +_hypercall3_vmcall@16   proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        mov     edx, [ebp + 14h]                ; arg3
> +                        vmcall
> +                        pop     ebx
> +                        leave
> +                        ret     10h
> +_hypercall3_vmcall@16   endp
>  =20
> -                end
> +                        ; uintptr_t __stdcall hypercall3_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public _hypercall3_vmmcall@16
> +_hypercall3_vmmcall@16  proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        mov     edx, [ebp + 14h]                ; arg3
> +                        vmmcall
> +                        pop     ebx
> +                        leave
> +                        ret     10h
> +_hypercall3_vmmcall@16  endp
> +
> +                        end



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.2803.29d1e1fadbc8c2f7.19dbebfe6f1.43fac78d407f52d7=---


From win-pv-devel-bounces@lists.xenproject.org Fri Apr 24 09:17:51 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 24 Apr 2026 09:17:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1293335.1571131 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wGCfW-0008If-HD; Fri, 24 Apr 2026 09:17:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1293335.1571131; Fri, 24 Apr 2026 09:17:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wGCfW-0008IX-EC; Fri, 24 Apr 2026 09:17:50 +0000
Received: by outflank-mailman (input) for mailman id 1293335;
 Fri, 24 Apr 2026 09:17:49 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wGCfV-0008IR-CC
 for win-pv-devel@lists.xenproject.org; Fri, 24 Apr 2026 09:17:49 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wGCfU-00EBa2-PU
 for win-pv-devel@lists.xenproject.org; Fri, 24 Apr 2026 11:17:48 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69eb3536-5cb7-0a2a0a5109dd-0a2a450bbe8a-28
 for <win-pv-devel@lists.xenproject.org>; Fri, 24 Apr 2026 11:17:48 +0200
Received: from [160.101.131.9] (helo=na1pdmzitismtp02.tibco.com)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69eb353b-212f-0a2a450b0019-a0658309d86c-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 24 Apr 2026 11:17:48 +0200
Received: from mewpvdipd2033.citrite.net (unknown [10.113.48.64])
 by na1pdmzitismtp02.tibco.com (Postfix) with ESMTP id C2D80820BC0F;
 Fri, 24 Apr 2026 05:16:49 -0400 (EDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Authentication-Results: eu.smtp.expurgate.cloud; none
From: Owen Smith <owen.smith@citrix.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Use direct hypercall instead of hypercall page
Date: Fri, 24 Apr 2026 10:17:33 +0100
Message-ID: <20260424091734.1560-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.51.2.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-purgate-ID: tlsNG-42698a/1777022268-240B6F3B-EA93A849/0/0
X-purgate-type: clean
X-purgate-size: 22097

XSA-466 "Xen hypercall page unsafe against speculative attacks"
recommends that OSes avoid using the hypercall page, since that breaks
the use of return thunks and CET IBT.

While Windows doesn't support return thunks or CET IBT, the current
hypercall code uses a naked indirect call to call into the hypercall
page. This call is not protected by Windows CFG, and cannot be patched
by Windows's Retpoline implementation.

Convert the hypercall code to detect CPU vendor and use the appropriate
hypercall instructions.

Ported from xenbus 2635e7c08ee8df3e3c1be427926a53fe1b345c96
by Tu Dinh <ngoc-tu.dinh@vates.tech>

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xencrsh/amd64/hypercall.asm | 109 ++++++++++++------
 src/xencrsh/hvm.c               | 120 +-------------------
 src/xencrsh/hypercall.h         |   6 +-
 src/xencrsh/hypercall_stub.c    | 191 +++++++++++++++++++++++++++++++-
 src/xencrsh/i386/hypercall.asm  | 119 +++++++++++++-------
 5 files changed, 342 insertions(+), 203 deletions(-)

diff --git a/src/xencrsh/amd64/hypercall.asm b/src/xencrsh/amd64/hypercall.asm
index 1ceda85..de430e7 100644
--- a/src/xencrsh/amd64/hypercall.asm
+++ b/src/xencrsh/amd64/hypercall.asm
@@ -1,41 +1,78 @@
-                page    ,132
-                title   Hypercall Gates
+                        page    ,132
+                        title   Hypercall Thunks
 
-                .code
+                        .code
 
-                extrn   Hypercall:qword
+                        ; uintptr_t __stdcall hypercall2_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public hypercall2_vmcall
+hypercall2_vmcall       proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        vmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall2_vmcall       endp
 
-                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
-                public asm___hypercall2
-asm___hypercall2 proc
-	        push rdi
-	        push rsi
-	        mov rdi, rdx                            ; arg1
-	        mov rax, qword ptr [Hypercall]
-	        shl rcx, 5                              ; ord
-	        add rax, rcx
-	        mov rsi, r8                             ; arg2
-	        call rax
-	        pop rsi
-	        pop rdi
-	        ret
-asm___hypercall2 endp
+                        ; uintptr_t __stdcall hypercall2_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public hypercall2_vmmcall
+hypercall2_vmmcall      proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        vmmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall2_vmmcall      endp
 
-                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
-                public asm___hypercall3
-asm___hypercall3 proc
-	        push rdi
-	        push rsi
-	        mov rdi, rdx                            ; arg1
-	        mov rax, qword ptr [Hypercall]
-	        shl rcx, 5                              ; ord
-	        add rax, rcx
-	        mov rsi, r8                             ; arg2
-	        mov rdx, r9                             ; arg3
-	        call rax
-	        pop rsi
-	        pop rdi
-	        ret
-asm___hypercall3 endp
+                        ; uintptr_t __stdcall hypercall3_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public hypercall3_vmcall
+hypercall3_vmcall       proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        mov     rdx, r9                             ; arg3
+                        vmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall3_vmcall       endp
 
-                end
+                        ; uintptr_t __stdcall hypercall3_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public hypercall3_vmmcall
+hypercall3_vmmcall      proc
+                        push    rdi
+                        push    rsi
+                        mov     eax, ecx                            ; ord
+                        mov     rdi, rdx                            ; arg1
+                        mov     rsi, r8                             ; arg2
+                        mov     rdx, r9                             ; arg3
+                        vmmcall
+                        pop     rsi
+                        pop     rdi
+                        ret
+hypercall3_vmmcall      endp
+
+                        end
diff --git a/src/xencrsh/hvm.c b/src/xencrsh/hvm.c
index 04da4e3..82230ef 100644
--- a/src/xencrsh/hvm.c
+++ b/src/xencrsh/hvm.c
@@ -50,22 +50,6 @@
 #include "log.h"
 #include "assert.h"
 
-#define MAXIMUM_HYPERCALL_PFN_COUNT 2
-
-#pragma code_seg("hypercall")
-__declspec(allocate("hypercall"))
-static UCHAR    __HypercallSection[(MAXIMUM_HYPERCALL_PFN_COUNT + 1) * PAGE_SIZE];
-
-#define XEN_SIGNATURE   "XenVMMXenVMM"
-
-static ULONG            __BaseLeaf = 0x40000000;
-static USHORT           __MajorVersion;
-static USHORT           __MinorVersion;
-static PFN_NUMBER       __Pfn[MAXIMUM_HYPERCALL_PFN_COUNT];
-static ULONG            __PfnCount;
-
-PHYPERCALL_GATE         Hypercall;
-
 //#pragma code_seg("sharedinfo")
 //__declspec(allocate("sharedinfo"))
 //static UCHAR    __SharedInfoSection[(1 + 1) * PAGE_SIZE];
@@ -95,102 +79,6 @@ fail:
     return Status;
 }
 
-static FORCEINLINE VOID
-CpuId(
-    IN  ULONG   Leaf,
-    OUT PULONG  EAX OPTIONAL,
-    OUT PULONG  EBX OPTIONAL,
-    OUT PULONG  ECX OPTIONAL,
-    OUT PULONG  EDX OPTIONAL
-    )
-{
-    int         Value[4] = {0};
-
-    __cpuid(Value, Leaf);
-
-    if (EAX)
-        *EAX = (ULONG)Value[0];
-
-    if (EBX)
-        *EBX = (ULONG)Value[1];
-
-    if (ECX)
-        *ECX = (ULONG)Value[2];
-
-    if (EDX)
-        *EDX = (ULONG)Value[3];
-}
-
-static FORCEINLINE NTSTATUS
-__InitHypercallPage()
-{
-    ULONG       eax = 'DEAD';
-    ULONG       ebx = 'DEAD';
-    ULONG       ecx = 'DEAD';
-    ULONG       edx = 'DEAD';
-    ULONG_PTR   Index;
-    ULONG       HypercallMsr;
-
-    NTSTATUS    Status;
-
-    Status = STATUS_UNSUCCESSFUL;
-    for (;;) {
-        CHAR Signature[13] = { 0 };
-
-        CpuId(__BaseLeaf, &eax, &ebx, &ecx, &edx);
-        *((PULONG)(Signature + 0)) = ebx;
-        *((PULONG)(Signature + 4)) = ecx;
-        *((PULONG)(Signature + 8)) = edx;
-
-        if (strcmp(Signature, XEN_SIGNATURE) == 0 &&
-            eax >= __BaseLeaf + 2)
-            break;
-
-        __BaseLeaf += 0x100;
-
-        if (__BaseLeaf > 0x40000100)
-            goto fail1;
-    }
-
-    CpuId(__BaseLeaf + 1, &eax, NULL, NULL, NULL);
-    __MajorVersion = (USHORT)(eax >> 16);
-    __MinorVersion = (USHORT)(eax & 0xFFFF);
-
-    LogVerbose("XEN %d.%d\n", __MajorVersion, __MinorVersion);
-    LogVerbose("INTERFACE 0x%08x\n", __XEN_INTERFACE_VERSION__);
-
-    if ((ULONG_PTR)__HypercallSection & (PAGE_SIZE - 1))
-        Hypercall = (PVOID)(((ULONG_PTR)__HypercallSection + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1));
-    else
-        Hypercall = (PVOID)__HypercallSection;
-
-    ASSERT3U(((ULONG_PTR)Hypercall & (PAGE_SIZE - 1)), ==, 0);
-
-    for (Index = 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; Index++) {
-        PHYSICAL_ADDRESS    PhysicalAddress;
-
-        PhysicalAddress = MmGetPhysicalAddress((PUCHAR)Hypercall + (Index << PAGE_SHIFT));
-        __Pfn[Index] = (PFN_NUMBER)(PhysicalAddress.QuadPart >> PAGE_SHIFT);
-    }
-
-    CpuId(__BaseLeaf + 2, &eax, &ebx, NULL, NULL);
-    __PfnCount = eax;
-    ASSERT(__PfnCount <= MAXIMUM_HYPERCALL_PFN_COUNT);
-    HypercallMsr = ebx;
-
-    for (Index = 0; Index < __PfnCount; Index++) {
-        LogVerbose("HypercallPfn[%d]: %p\n", Index, (PVOID)__Pfn[Index]);
-        __writemsr(HypercallMsr, (ULONG64)__Pfn[Index] << PAGE_SHIFT);
-    }
-
-    return STATUS_SUCCESS;
-
-fail1:
-    LogError("fail1 (%08x)", Status);
-
-    return Status;
-}
-
 //static NTSTATUS
 //__InitSharedInfo()
 //{
@@ -235,7 +123,7 @@ HvmInitialize()
 {
     NTSTATUS    Status;
 
-    Status = __InitHypercallPage();
+    Status = HypercallInitialize();
     if (!NT_SUCCESS(Status))
         goto fail;
 
@@ -258,12 +146,6 @@ fail:
 VOID
 HvmTerminate()
 {
-    ULONG Index;
-
-    Hypercall = NULL;
-    for (Index = 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; ++Index) {
-        __Pfn[Index] = 0;
-    }
     //SharedInfo = NULL;
 }
 
diff --git a/src/xencrsh/hypercall.h b/src/xencrsh/hypercall.h
index 762ecf8..6b055fa 100644
--- a/src/xencrsh/hypercall.h
+++ b/src/xencrsh/hypercall.h
@@ -35,8 +35,10 @@
 
 #include "driver.h"
 
-typedef UCHAR           HYPERCALL_GATE[32];
-typedef HYPERCALL_GATE  *PHYPERCALL_GATE;
+extern NTSTATUS
+HypercallInitialize(
+    VOID
+    );
 
 extern ULONG_PTR
 ___Hypercall2(
diff --git a/src/xencrsh/hypercall_stub.c b/src/xencrsh/hypercall_stub.c
index 1741850..5183f58 100644
--- a/src/xencrsh/hypercall_stub.c
+++ b/src/xencrsh/hypercall_stub.c
@@ -32,16 +32,164 @@
 
 #include <wdm.h>
 #include <xenvbd-storport.h>
-
+#include <intrin.h>
 
 #include <xen-version.h>
 #include <xen\xen-compat.h>
          
 #include <xen-types.h>
 
+#include "log.h"
+#include "assert.h"
+
 #include "hypercall.h"
 
-extern uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
+typedef enum _HYPERCALL_INSTRUCTION {
+    HYPERCALL_INSTRUCTION_UNKNOWN,
+    HYPERCALL_INSTRUCTION_VMCALL,
+    HYPERCALL_INSTRUCTION_VMMCALL,
+} HYPERCALL_INSTRUCTION;
+
+typedef struct _CPU_VENDOR_DATA {
+    ULONG                   EBX;
+    ULONG                   ECX;
+    ULONG                   EDX;
+    HYPERCALL_INSTRUCTION   Instruction;
+} CPU_VENDOR_DATA;
+
+static const CPU_VENDOR_DATA    HypercallVendorData[] = {
+    // Note that the vendor data goes EBX-ECX-EDX
+    {
+        // "GenuineIntel"
+        0x756E6547, 0x6C65746E, 0x49656E69,
+        HYPERCALL_INSTRUCTION_VMCALL
+    },
+    {
+        // "AuthenticAMD"
+        0x68747541, 0x444D4163, 0x69746E65,
+        HYPERCALL_INSTRUCTION_VMMCALL
+    },
+    {
+        // "CentaurHauls"
+        0x746E6543, 0x736C7561, 0x48727561,
+        HYPERCALL_INSTRUCTION_VMCALL
+    },
+    {
+        // "  Shanghai  "
+        0x68532020, 0x20206961, 0x68676E61,
+        HYPERCALL_INSTRUCTION_VMCALL
+    },
+    {
+        // "HygonGenuine"
+        0x6F677948, 0x656E6975, 0x6E65476E,
+        HYPERCALL_INSTRUCTION_VMMCALL
+    },
+};
+
+static HYPERCALL_INSTRUCTION    HypercallInstruction
+    = HYPERCALL_INSTRUCTION_UNKNOWN;
+
+static FORCEINLINE VOID
+__CpuId(
+    IN  ULONG   Leaf,
+    OUT PULONG  EAX OPTIONAL,
+    OUT PULONG  EBX OPTIONAL,
+    OUT PULONG  ECX OPTIONAL,
+    OUT PULONG  EDX OPTIONAL
+    )
+{
+    int         Value[4] = {0};
+
+    __cpuid(Value, Leaf);
+
+    if (EAX)
+        *EAX = (ULONG)Value[0];
+
+    if (EBX)
+        *EBX = (ULONG)Value[1];
+
+    if (ECX)
+        *ECX = (ULONG)Value[2];
+
+    if (EDX)
+        *EDX = (ULONG)Value[3];
+}
+
+NTSTATUS
+HypercallInitialize(
+    VOID
+    )
+{
+    ULONG                   XenBaseLeaf = 0x40000000;
+    ULONG                   EAX = 'DEAD';
+    ULONG                   EBX = 'DEAD';
+    ULONG                   ECX = 'DEAD';
+    ULONG                   EDX = 'DEAD';
+    HYPERCALL_INSTRUCTION   Instruction = HYPERCALL_INSTRUCTION_UNKNOWN;
+    ULONG                   Index;
+
+    for (;;) {
+        CHAR    Signature[13] = {0};
+
+        __CpuId(XenBaseLeaf, &EAX, &EBX, &ECX, &EDX);
+        *((PULONG)(Signature + 0)) = EBX;
+        *((PULONG)(Signature + 4)) = ECX;
+        *((PULONG)(Signature + 8)) = EDX;
+
+        if (strcmp(Signature, "XenVMMXenVMM") == 0 &&
+            EAX >= XenBaseLeaf + 2)
+            break;
+
+        XenBaseLeaf += 0x100;
+
+        if (XenBaseLeaf > 0x40000100) {
+            LogVerbose("XEN: BASE CPUID LEAF NOT FOUND\n");
+            return STATUS_NOT_SUPPORTED;
+        }
+    }
+
+    LogVerbose("XEN: BASE CPUID LEAF @ %08x\n",
+               XenBaseLeaf);
+
+    __CpuId(0, &EAX, &EBX, &ECX, &EDX);
+    for (Index = 0; Index < ARRAYSIZE(HypercallVendorData); Index++) {
+        const CPU_VENDOR_DATA   *CurrentData = &HypercallVendorData[Index];
+
+        if (EBX == CurrentData->EBX &&
+            ECX == CurrentData->ECX &&
+            EDX == CurrentData->EDX) {
+            Instruction = CurrentData->Instruction;
+            break;
+        }
+    }
+
+    if (Instruction == HYPERCALL_INSTRUCTION_UNKNOWN) {
+        LogVerbose("XEN: CANNOT DETECT HYPERCALL INSTRUCTION\n");
+        return STATUS_NOT_SUPPORTED;
+    }
+
+    HypercallInstruction = Instruction;
+    return STATUS_SUCCESS;
+}
+
+extern uintptr_t __stdcall hypercall2_vmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2);
+extern uintptr_t __stdcall hypercall2_vmmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2);
+extern uintptr_t __stdcall hypercall3_vmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2,
+    uintptr_t   arg3);
+extern uintptr_t __stdcall hypercall3_vmmcall(
+    uint32_t    ord,
+    uintptr_t   arg1,
+    uintptr_t   arg2,
+    uintptr_t   arg3);
 
 ULONG_PTR
 ___Hypercall2(
@@ -50,10 +198,24 @@ ___Hypercall2(
     ULONG_PTR   Argument2
     )
 {
-    return asm___hypercall2(Ordinal, Argument1, Argument2);
-}
+    ULONG_PTR   Value;
 
-extern uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
+    switch (HypercallInstruction) {
+    case HYPERCALL_INSTRUCTION_VMCALL:
+        Value = hypercall2_vmcall(Ordinal, Argument1, Argument2);
+        break;
+
+    case HYPERCALL_INSTRUCTION_VMMCALL:
+        Value = hypercall2_vmmcall(Ordinal, Argument1, Argument2);
+        break;
+
+    default:
+        Value = 0;
+        BUG("NO HYPERCALL INSTRUCTION");
+    }
+
+    return Value;
+}
 
 ULONG_PTR
 ___Hypercall3(
@@ -63,5 +225,22 @@ ___Hypercall3(
     ULONG_PTR   Argument3
     )
 {
-    return asm___hypercall3(Ordinal, Argument1, Argument2, Argument3);
+    ULONG_PTR   Value;
+
+    switch (HypercallInstruction) {
+    case HYPERCALL_INSTRUCTION_VMCALL:
+        Value = hypercall3_vmcall(Ordinal, Argument1, Argument2, Argument3);
+        break;
+
+    case HYPERCALL_INSTRUCTION_VMMCALL:
+        Value = hypercall3_vmmcall(Ordinal, Argument1, Argument2, Argument3);
+        break;
+
+    default:
+        Value = 0;
+        BUG("NO HYPERCALL INSTRUCTION");
+    }
+
+    return Value;
+
 }
diff --git a/src/xencrsh/i386/hypercall.asm b/src/xencrsh/i386/hypercall.asm
index 51094be..be68db3 100644
--- a/src/xencrsh/i386/hypercall.asm
+++ b/src/xencrsh/i386/hypercall.asm
@@ -1,45 +1,84 @@
-                page    ,132
-                title   Hypercall Gates
+                        page    ,132
+                        title   Hypercall Thunks
 
-                .686p
-                .model  FLAT
-                .code
+                        .686p
+                        .model  FLAT
+                        .code
 
-                extrn   _Hypercall:dword
+                        ; uintptr_t __stdcall hypercall2_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public _hypercall2_vmcall@12
+_hypercall2_vmcall@12   proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        vmcall
+                        pop     ebx
+                        leave
+                        ret     0Ch
+_hypercall2_vmcall@12   endp
 
-                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg1, uintptr_t arg2);
-                public _asm___hypercall2@12
-_asm___hypercall2@12 proc
-                push    ebp
-                mov     ebp, esp
-                push    ebx
-                mov     eax, [ebp + 08h]                ; ord
-                mov     ebx, [ebp + 0ch]                ; arg1
-                mov     ecx, [ebp + 10h]                ; arg2
-                shl     eax, 5
-                add     eax, dword ptr [_Hypercall]
-                call    eax
-                pop     ebx
-                leave
-                ret     0Ch
-_asm___hypercall2@12 endp
+                        ; uintptr_t __stdcall hypercall2_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2);
+                        public _hypercall2_vmmcall@12
+_hypercall2_vmmcall@12  proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        vmmcall
+                        pop     ebx
+                        leave
+                        ret     0Ch
+_hypercall2_vmmcall@12  endp
 
-                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3);
-                public _asm___hypercall3@16
-_asm___hypercall3@16 proc
-                push    ebp
-                mov     ebp, esp
-                push    ebx
-                mov     eax, [ebp + 08h]                ; ord
-                mov     ebx, [ebp + 0ch]                ; arg1
-                mov     ecx, [ebp + 10h]                ; arg2
-                mov     edx, [ebp + 14h]                ; arg3
-                shl     eax, 5
-                add     eax, dword ptr [_Hypercall]
-                call    eax
-                pop     ebx
-                leave
-                ret     10h
-_asm___hypercall3@16 endp
+                        ; uintptr_t __stdcall hypercall3_vmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public _hypercall3_vmcall@16
+_hypercall3_vmcall@16   proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        mov     edx, [ebp + 14h]                ; arg3
+                        vmcall
+                        pop     ebx
+                        leave
+                        ret     10h
+_hypercall3_vmcall@16   endp
 
-                end
+                        ; uintptr_t __stdcall hypercall3_vmmcall(
+                        ;     uint32_t    ord,
+                        ;     uintptr_t   arg1,
+                        ;     uintptr_t   arg2,
+                        ;     uintptr_t   arg3);
+                        public _hypercall3_vmmcall@16
+_hypercall3_vmmcall@16  proc
+                        push    ebp
+                        mov     ebp, esp
+                        push    ebx
+                        mov     eax, [ebp + 08h]                ; ord
+                        mov     ebx, [ebp + 0ch]                ; arg1
+                        mov     ecx, [ebp + 10h]                ; arg2
+                        mov     edx, [ebp + 14h]                ; arg3
+                        vmmcall
+                        pop     ebx
+                        leave
+                        ret     10h
+_hypercall3_vmmcall@16  endp
+
+                        end
-- 
2.51.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Apr 24 11:52:54 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 24 Apr 2026 11:52:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1293475.1571170 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wGF5Z-0002iy-0H; Fri, 24 Apr 2026 11:52:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1293475.1571170; Fri, 24 Apr 2026 11:52:52 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wGF5Y-0002ir-Tu; Fri, 24 Apr 2026 11:52:52 +0000
Received: by outflank-mailman (input) for mailman id 1293475;
 Fri, 24 Apr 2026 11:52:51 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dbf55cf03000f373@swg.vates.tech>)
 id 1wGF5W-0002il-U2
 for win-pv-devel@lists.xenproject.org; Fri, 24 Apr 2026 11:52:51 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wGF5W-004JzJ-Aw
 for win-pv-devel@lists.xenproject.org; Fri, 24 Apr 2026 13:52:50 +0200
Received: from [10.42.69.5] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dbf55cf03000f373@swg.vates.tech>)
 id 69eb597b-2eae-0a2a0a5409dd-0a2a450594f2-20
 for <win-pv-devel@lists.xenproject.org>; Fri, 24 Apr 2026 13:52:50 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dbf55cf03000f373@swg.vates.tech>)
 id 69eb5991-aaa8-0a2a45050019-b9ff1c229e8d-3
 for <win-pv-devel@lists.xenproject.org>; Fri, 24 Apr 2026 13:52:50 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dbf55cf03000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Fri, 24 Apr 2026 11:52:45 +0000
Received: from [192.168.1.61] (155.223.66.37.rev.sfr.net [37.66.223.155])
 (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 54505862E8;
 Fri, 24 Apr 2026 13:52:44 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=JWSZk5DXjZM8xYsNAvUHp1NQJT7WjyP7DW5M29H/QNs=;
 h=from:subject:date:message-id:to:mime-version:content-type:in-reply-to:references:feedback-id;
 b=h/0Dmn0hrrllaXzgFaT1nh7xIvtPOfABwIBWtu+yFnTr8jevzvl53Ivk24r/dvkEHGoDy/qgS
 GRldSYyJQY8+2m5f0nnGCGWJEQ9zm33xV7O6jOSMGBXT7JZ4S5DZFIb30LbyLOOBr6oZRnHVdUd
 acyWM/azxVTN+KmRpd8ol6yUYQFKvmRpW5YBsDQY41d9II6jc8EeoPSMMCwGvuy3o1sFl48pzfv
 CecvY/9o1/xNToGC08XPBvyFfFpuMZHBX08kCqMpgqZ76eAyRIWL7OFniMUWGknLUnyvN2yaoJL
 LPRroTsXu93fJnbr5DpDTEPQITG0VTR5sAVC4vbySRBA==
X-Zone-Loop: 32ca97a9b83cc836468e9f4632d4bfd87907f2578813
x-campaign-type: default
x-transaction-id: d8d4471c-9b22-4e6f-bea8-28af422b98ec
x-swg-uid: 01-832f2dba-b047-42d1-9722-a6b8a1dfc48f
X-Mailer: Sweego
Message-ID:
 <1777031565.8631fc262581453bbf619ec5b2062170.19dbf55cf03000f373@vates.tech>
x-swg-bid: 1777031565.8631fc262581453bbf619ec5b2062170.19dbf55cf03000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
Date: Fri, 24 Apr 2026 13:52:43 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] Use direct hypercall instead of hypercall page
To: Owen Smith <owen.smith@citrix.com>, win-pv-devel@lists.xenproject.org
References: <20260424091734.1560-1-owen.smith@citrix.com>
Content-Language: en-US
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260424091734.1560-1-owen.smith@citrix.com>
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.283a.931d6d131446643d.19dbf55cc9c.e91e8c3243f06be4=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777031564444
X-purgate-ID: tlsNG-c201ff/1777031570-2B16D443-8ACF391B/0/0
X-purgate-type: clean
X-purgate-size: 24368

---=Part.283a.931d6d131446643d.19dbf55cc9c.e91e8c3243f06be4=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 24/04/2026 11:17, Owen Smith wrote:
> XSA-466 "Xen hypercall page unsafe against speculative attacks"
> recommends that OSes avoid using the hypercall page, since that breaks
> the use of return thunks and CET IBT=2E
>=20
> While Windows doesn't support return thunks or CET IBT, the current
> hypercall code uses a naked indirect call to call into the hypercall
> page=2E This call is not protected by Windows CFG, and cannot be patched
> by Windows's Retpoline implementation=2E
>=20
> Convert the hypercall code to detect CPU vendor and use the appropriate
> hypercall instructions=2E
>=20
> Ported from xenbus 2635e7c08ee8df3e3c1be427926a53fe1b345c96
> by Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
>=20
> Signed-off-by: Owen Smith <owen=2Esmith@citrix=2Ecom>

Reviewed-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>

Thanks,

> ---
>   src/xencrsh/amd64/hypercall=2Easm | 109 ++++++++++++------
>   src/xencrsh/hvm=2Ec               | 120 +-------------------
>   src/xencrsh/hypercall=2Eh         |   6 +-
>   src/xencrsh/hypercall_stub=2Ec    | 191 ++++++++++++++++++++++++++++++=
+-
>   src/xencrsh/i386/hypercall=2Easm  | 119 +++++++++++++-------
>   5 files changed, 342 insertions(+), 203 deletions(-)
>=20
> diff --git a/src/xencrsh/amd64/hypercall=2Easm b/src/xencrsh/amd64/hyper=
call=2Easm
> index 1ceda85=2E=2Ede430e7 100644
> --- a/src/xencrsh/amd64/hypercall=2Easm
> +++ b/src/xencrsh/amd64/hypercall=2Easm
> @@ -1,41 +1,78 @@
> -                page    ,132
> -                title   Hypercall Gates
> +                        page    ,132
> +                        title   Hypercall Thunks
>  =20
> -                =2Ecode
> +                        =2Ecode
>  =20
> -                extrn   Hypercall:qword
> +                        ; uintptr_t __stdcall hypercall2_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public hypercall2_vmcall
> +hypercall2_vmcall       proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        vmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall2_vmcall       endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2);
> -                public asm___hypercall2
> -asm___hypercall2 proc
> -	        push rdi
> -	        push rsi
> -	        mov rdi, rdx                            ; arg1
> -	        mov rax, qword ptr [Hypercall]
> -	        shl rcx, 5                              ; ord
> -	        add rax, rcx
> -	        mov rsi, r8                             ; arg2
> -	        call rax
> -	        pop rsi
> -	        pop rdi
> -	        ret
> -asm___hypercall2 endp
> +                        ; uintptr_t __stdcall hypercall2_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public hypercall2_vmmcall
> +hypercall2_vmmcall      proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        vmmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall2_vmmcall      endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2, uintptr_t arg3);
> -                public asm___hypercall3
> -asm___hypercall3 proc
> -	        push rdi
> -	        push rsi
> -	        mov rdi, rdx                            ; arg1
> -	        mov rax, qword ptr [Hypercall]
> -	        shl rcx, 5                              ; ord
> -	        add rax, rcx
> -	        mov rsi, r8                             ; arg2
> -	        mov rdx, r9                             ; arg3
> -	        call rax
> -	        pop rsi
> -	        pop rdi
> -	        ret
> -asm___hypercall3 endp
> +                        ; uintptr_t __stdcall hypercall3_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public hypercall3_vmcall
> +hypercall3_vmcall       proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        mov     rdx, r9                             ; a=
rg3
> +                        vmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall3_vmcall       endp
>  =20
> -                end
> +                        ; uintptr_t __stdcall hypercall3_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public hypercall3_vmmcall
> +hypercall3_vmmcall      proc
> +                        push    rdi
> +                        push    rsi
> +                        mov     eax, ecx                            ; o=
rd
> +                        mov     rdi, rdx                            ; a=
rg1
> +                        mov     rsi, r8                             ; a=
rg2
> +                        mov     rdx, r9                             ; a=
rg3
> +                        vmmcall
> +                        pop     rsi
> +                        pop     rdi
> +                        ret
> +hypercall3_vmmcall      endp
> +
> +                        end
> diff --git a/src/xencrsh/hvm=2Ec b/src/xencrsh/hvm=2Ec
> index 04da4e3=2E=2E82230ef 100644
> --- a/src/xencrsh/hvm=2Ec
> +++ b/src/xencrsh/hvm=2Ec
> @@ -50,22 +50,6 @@
>   #include "log=2Eh"
>   #include "assert=2Eh"
>  =20
> -#define MAXIMUM_HYPERCALL_PFN_COUNT 2
> -
> -#pragma code_seg("hypercall")
> -__declspec(allocate("hypercall"))
> -static UCHAR    __HypercallSection[(MAXIMUM_HYPERCALL_PFN_COUNT + 1) * =
PAGE_SIZE];
> -
> -#define XEN_SIGNATURE   "XenVMMXenVMM"
> -
> -static ULONG            __BaseLeaf =3D 0x40000000;
> -static USHORT           __MajorVersion;
> -static USHORT           __MinorVersion;
> -static PFN_NUMBER       __Pfn[MAXIMUM_HYPERCALL_PFN_COUNT];
> -static ULONG            __PfnCount;
> -
> -PHYPERCALL_GATE         Hypercall;
> -
>   //#pragma code_seg("sharedinfo")
>   //__declspec(allocate("sharedinfo"))
>   //static UCHAR    __SharedInfoSection[(1 + 1) * PAGE_SIZE];
> @@ -95,102 +79,6 @@ fail:
>       return Status;
>   }
>  =20
> -static FORCEINLINE VOID
> -CpuId(
> -    IN  ULONG   Leaf,
> -    OUT PULONG  EAX OPTIONAL,
> -    OUT PULONG  EBX OPTIONAL,
> -    OUT PULONG  ECX OPTIONAL,
> -    OUT PULONG  EDX OPTIONAL
> -    )
> -{
> -    int         Value[4] =3D {0};
> -
> -    __cpuid(Value, Leaf);
> -
> -    if (EAX)
> -        *EAX =3D (ULONG)Value[0];
> -
> -    if (EBX)
> -        *EBX =3D (ULONG)Value[1];
> -
> -    if (ECX)
> -        *ECX =3D (ULONG)Value[2];
> -
> -    if (EDX)
> -        *EDX =3D (ULONG)Value[3];
> -}
> -
> -static FORCEINLINE NTSTATUS
> -__InitHypercallPage()
> -{
> -    ULONG       eax =3D 'DEAD';
> -    ULONG       ebx =3D 'DEAD';
> -    ULONG       ecx =3D 'DEAD';
> -    ULONG       edx =3D 'DEAD';
> -    ULONG_PTR   Index;
> -    ULONG       HypercallMsr;
> -
> -    NTSTATUS    Status;
> -
> -    Status =3D STATUS_UNSUCCESSFUL;
> -    for (;;) {
> -        CHAR Signature[13] =3D { 0 };
> -
> -        CpuId(__BaseLeaf, &eax, &ebx, &ecx, &edx);
> -        *((PULONG)(Signature + 0)) =3D ebx;
> -        *((PULONG)(Signature + 4)) =3D ecx;
> -        *((PULONG)(Signature + 8)) =3D edx;
> -
> -        if (strcmp(Signature, XEN_SIGNATURE) =3D=3D 0 &&
> -            eax >=3D __BaseLeaf + 2)
> -            break;
> -
> -        __BaseLeaf +=3D 0x100;
> -
> -        if (__BaseLeaf > 0x40000100)
> -            goto fail1;
> -    }
> -
> -    CpuId(__BaseLeaf + 1, &eax, NULL, NULL, NULL);
> -    __MajorVersion =3D (USHORT)(eax >> 16);
> -    __MinorVersion =3D (USHORT)(eax & 0xFFFF);
> -
> -    LogVerbose("XEN %d=2E%d\n", __MajorVersion, __MinorVersion);
> -    LogVerbose("INTERFACE 0x%08x\n", __XEN_INTERFACE_VERSION__);
> -
> -    if ((ULONG_PTR)__HypercallSection & (PAGE_SIZE - 1))
> -        Hypercall =3D (PVOID)(((ULONG_PTR)__HypercallSection + PAGE_SIZ=
E - 1) & ~(PAGE_SIZE - 1));
> -    else
> -        Hypercall =3D (PVOID)__HypercallSection;
> -
> -    ASSERT3U(((ULONG_PTR)Hypercall & (PAGE_SIZE - 1)), =3D=3D, 0);
> -
> -    for (Index =3D 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; Index++) {
> -        PHYSICAL_ADDRESS    PhysicalAddress;
> -
> -        PhysicalAddress =3D MmGetPhysicalAddress((PUCHAR)Hypercall + (I=
ndex << PAGE_SHIFT));
> -        __Pfn[Index] =3D (PFN_NUMBER)(PhysicalAddress=2EQuadPart >> PAG=
E_SHIFT);
> -    }
> -
> -    CpuId(__BaseLeaf + 2, &eax, &ebx, NULL, NULL);
> -    __PfnCount =3D eax;
> -    ASSERT(__PfnCount <=3D MAXIMUM_HYPERCALL_PFN_COUNT);
> -    HypercallMsr =3D ebx;
> -
> -    for (Index =3D 0; Index < __PfnCount; Index++) {
> -        LogVerbose("HypercallPfn[%d]: %p\n", Index, (PVOID)__Pfn[Index]=
);
> -        __writemsr(HypercallMsr, (ULONG64)__Pfn[Index] << PAGE_SHIFT);
> -    }
> -
> -    return STATUS_SUCCESS;
> -
> -fail1:
> -    LogError("fail1 (%08x)", Status);
> -
> -    return Status;
> -}
> -
>   //static NTSTATUS
>   //__InitSharedInfo()
>   //{
> @@ -235,7 +123,7 @@ HvmInitialize()
>   {
>       NTSTATUS    Status;
>  =20
> -    Status =3D __InitHypercallPage();
> +    Status =3D HypercallInitialize();
>       if (!NT_SUCCESS(Status))
>           goto fail;
>  =20
> @@ -258,12 +146,6 @@ fail:
>   VOID
>   HvmTerminate()
>   {
> -    ULONG Index;
> -
> -    Hypercall =3D NULL;
> -    for (Index =3D 0; Index < MAXIMUM_HYPERCALL_PFN_COUNT; ++Index) {
> -        __Pfn[Index] =3D 0;
> -    }
>       //SharedInfo =3D NULL;
>   }
>  =20
> diff --git a/src/xencrsh/hypercall=2Eh b/src/xencrsh/hypercall=2Eh
> index 762ecf8=2E=2E6b055fa 100644
> --- a/src/xencrsh/hypercall=2Eh
> +++ b/src/xencrsh/hypercall=2Eh
> @@ -35,8 +35,10 @@
>  =20
>   #include "driver=2Eh"
>  =20
> -typedef UCHAR           HYPERCALL_GATE[32];
> -typedef HYPERCALL_GATE  *PHYPERCALL_GATE;
> +extern NTSTATUS
> +HypercallInitialize(
> +    VOID
> +    );
>  =20
>   extern ULONG_PTR
>   ___Hypercall2(
> diff --git a/src/xencrsh/hypercall_stub=2Ec b/src/xencrsh/hypercall_stub=
=2Ec
> index 1741850=2E=2E5183f58 100644
> --- a/src/xencrsh/hypercall_stub=2Ec
> +++ b/src/xencrsh/hypercall_stub=2Ec
> @@ -32,16 +32,164 @@
>  =20
>   #include <wdm=2Eh>
>   #include <xenvbd-storport=2Eh>
> -
> +#include <intrin=2Eh>
>  =20
>   #include <xen-version=2Eh>
>   #include <xen\xen-compat=2Eh>
>           =20
>   #include <xen-types=2Eh>
>  =20
> +#include "log=2Eh"
> +#include "assert=2Eh"
> +
>   #include "hypercall=2Eh"
>  =20
> -extern uintptr_t __stdcall asm___hypercall2(uint32_t ord, uintptr_t arg=
1, uintptr_t arg2);
> +typedef enum _HYPERCALL_INSTRUCTION {
> +    HYPERCALL_INSTRUCTION_UNKNOWN,
> +    HYPERCALL_INSTRUCTION_VMCALL,
> +    HYPERCALL_INSTRUCTION_VMMCALL,
> +} HYPERCALL_INSTRUCTION;
> +
> +typedef struct _CPU_VENDOR_DATA {
> +    ULONG                   EBX;
> +    ULONG                   ECX;
> +    ULONG                   EDX;
> +    HYPERCALL_INSTRUCTION   Instruction;
> +} CPU_VENDOR_DATA;
> +
> +static const CPU_VENDOR_DATA    HypercallVendorData[] =3D {
> +    // Note that the vendor data goes EBX-ECX-EDX
> +    {
> +        // "GenuineIntel"
> +        0x756E6547, 0x6C65746E, 0x49656E69,
> +        HYPERCALL_INSTRUCTION_VMCALL
> +    },
> +    {
> +        // "AuthenticAMD"
> +        0x68747541, 0x444D4163, 0x69746E65,
> +        HYPERCALL_INSTRUCTION_VMMCALL
> +    },
> +    {
> +        // "CentaurHauls"
> +        0x746E6543, 0x736C7561, 0x48727561,
> +        HYPERCALL_INSTRUCTION_VMCALL
> +    },
> +    {
> +        // "  Shanghai  "
> +        0x68532020, 0x20206961, 0x68676E61,
> +        HYPERCALL_INSTRUCTION_VMCALL
> +    },
> +    {
> +        // "HygonGenuine"
> +        0x6F677948, 0x656E6975, 0x6E65476E,
> +        HYPERCALL_INSTRUCTION_VMMCALL
> +    },
> +};
> +
> +static HYPERCALL_INSTRUCTION    HypercallInstruction
> +    =3D HYPERCALL_INSTRUCTION_UNKNOWN;
> +
> +static FORCEINLINE VOID
> +__CpuId(
> +    IN  ULONG   Leaf,
> +    OUT PULONG  EAX OPTIONAL,
> +    OUT PULONG  EBX OPTIONAL,
> +    OUT PULONG  ECX OPTIONAL,
> +    OUT PULONG  EDX OPTIONAL
> +    )
> +{
> +    int         Value[4] =3D {0};
> +
> +    __cpuid(Value, Leaf);
> +
> +    if (EAX)
> +        *EAX =3D (ULONG)Value[0];
> +
> +    if (EBX)
> +        *EBX =3D (ULONG)Value[1];
> +
> +    if (ECX)
> +        *ECX =3D (ULONG)Value[2];
> +
> +    if (EDX)
> +        *EDX =3D (ULONG)Value[3];
> +}
> +
> +NTSTATUS
> +HypercallInitialize(
> +    VOID
> +    )
> +{
> +    ULONG                   XenBaseLeaf =3D 0x40000000;
> +    ULONG                   EAX =3D 'DEAD';
> +    ULONG                   EBX =3D 'DEAD';
> +    ULONG                   ECX =3D 'DEAD';
> +    ULONG                   EDX =3D 'DEAD';
> +    HYPERCALL_INSTRUCTION   Instruction =3D HYPERCALL_INSTRUCTION_UNKNO=
WN;
> +    ULONG                   Index;
> +
> +    for (;;) {
> +        CHAR    Signature[13] =3D {0};
> +
> +        __CpuId(XenBaseLeaf, &EAX, &EBX, &ECX, &EDX);
> +        *((PULONG)(Signature + 0)) =3D EBX;
> +        *((PULONG)(Signature + 4)) =3D ECX;
> +        *((PULONG)(Signature + 8)) =3D EDX;
> +
> +        if (strcmp(Signature, "XenVMMXenVMM") =3D=3D 0 &&
> +            EAX >=3D XenBaseLeaf + 2)
> +            break;
> +
> +        XenBaseLeaf +=3D 0x100;
> +
> +        if (XenBaseLeaf > 0x40000100) {
> +            LogVerbose("XEN: BASE CPUID LEAF NOT FOUND\n");
> +            return STATUS_NOT_SUPPORTED;
> +        }
> +    }
> +
> +    LogVerbose("XEN: BASE CPUID LEAF @ %08x\n",
> +               XenBaseLeaf);
> +
> +    __CpuId(0, &EAX, &EBX, &ECX, &EDX);
> +    for (Index =3D 0; Index < ARRAYSIZE(HypercallVendorData); Index++) =
{
> +        const CPU_VENDOR_DATA   *CurrentData =3D &HypercallVendorData[I=
ndex];
> +
> +        if (EBX =3D=3D CurrentData->EBX &&
> +            ECX =3D=3D CurrentData->ECX &&
> +            EDX =3D=3D CurrentData->EDX) {
> +            Instruction =3D CurrentData->Instruction;
> +            break;
> +        }
> +    }
> +
> +    if (Instruction =3D=3D HYPERCALL_INSTRUCTION_UNKNOWN) {
> +        LogVerbose("XEN: CANNOT DETECT HYPERCALL INSTRUCTION\n");
> +        return STATUS_NOT_SUPPORTED;
> +    }
> +
> +    HypercallInstruction =3D Instruction;
> +    return STATUS_SUCCESS;
> +}
> +
> +extern uintptr_t __stdcall hypercall2_vmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2);
> +extern uintptr_t __stdcall hypercall2_vmmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2);
> +extern uintptr_t __stdcall hypercall3_vmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2,
> +    uintptr_t   arg3);
> +extern uintptr_t __stdcall hypercall3_vmmcall(
> +    uint32_t    ord,
> +    uintptr_t   arg1,
> +    uintptr_t   arg2,
> +    uintptr_t   arg3);
>  =20
>   ULONG_PTR
>   ___Hypercall2(
> @@ -50,10 +198,24 @@ ___Hypercall2(
>       ULONG_PTR   Argument2
>       )
>   {
> -    return asm___hypercall2(Ordinal, Argument1, Argument2);
> -}
> +    ULONG_PTR   Value;
>  =20
> -extern uintptr_t __stdcall asm___hypercall3(uint32_t ord, uintptr_t arg=
1, uintptr_t arg2, uintptr_t arg3);
> +    switch (HypercallInstruction) {
> +    case HYPERCALL_INSTRUCTION_VMCALL:
> +        Value =3D hypercall2_vmcall(Ordinal, Argument1, Argument2);
> +        break;
> +
> +    case HYPERCALL_INSTRUCTION_VMMCALL:
> +        Value =3D hypercall2_vmmcall(Ordinal, Argument1, Argument2);
> +        break;
> +
> +    default:
> +        Value =3D 0;
> +        BUG("NO HYPERCALL INSTRUCTION");
> +    }
> +
> +    return Value;
> +}
>  =20
>   ULONG_PTR
>   ___Hypercall3(
> @@ -63,5 +225,22 @@ ___Hypercall3(
>       ULONG_PTR   Argument3
>       )
>   {
> -    return asm___hypercall3(Ordinal, Argument1, Argument2, Argument3);
> +    ULONG_PTR   Value;
> +
> +    switch (HypercallInstruction) {
> +    case HYPERCALL_INSTRUCTION_VMCALL:
> +        Value =3D hypercall3_vmcall(Ordinal, Argument1, Argument2, Argu=
ment3);
> +        break;
> +
> +    case HYPERCALL_INSTRUCTION_VMMCALL:
> +        Value =3D hypercall3_vmmcall(Ordinal, Argument1, Argument2, Arg=
ument3);
> +        break;
> +
> +    default:
> +        Value =3D 0;
> +        BUG("NO HYPERCALL INSTRUCTION");
> +    }
> +
> +    return Value;
> +
>   }
> diff --git a/src/xencrsh/i386/hypercall=2Easm b/src/xencrsh/i386/hyperca=
ll=2Easm
> index 51094be=2E=2Ebe68db3 100644
> --- a/src/xencrsh/i386/hypercall=2Easm
> +++ b/src/xencrsh/i386/hypercall=2Easm
> @@ -1,45 +1,84 @@
> -                page    ,132
> -                title   Hypercall Gates
> +                        page    ,132
> +                        title   Hypercall Thunks
>  =20
> -                =2E686p
> -                =2Emodel  FLAT
> -                =2Ecode
> +                        =2E686p
> +                        =2Emodel  FLAT
> +                        =2Ecode
>  =20
> -                extrn   _Hypercall:dword
> +                        ; uintptr_t __stdcall hypercall2_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public _hypercall2_vmcall@12
> +_hypercall2_vmcall@12   proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        vmcall
> +                        pop     ebx
> +                        leave
> +                        ret     0Ch
> +_hypercall2_vmcall@12   endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall2(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2);
> -                public _asm___hypercall2@12
> -_asm___hypercall2@12 proc
> -                push    ebp
> -                mov     ebp, esp
> -                push    ebx
> -                mov     eax, [ebp + 08h]                ; ord
> -                mov     ebx, [ebp + 0ch]                ; arg1
> -                mov     ecx, [ebp + 10h]                ; arg2
> -                shl     eax, 5
> -                add     eax, dword ptr [_Hypercall]
> -                call    eax
> -                pop     ebx
> -                leave
> -                ret     0Ch
> -_asm___hypercall2@12 endp
> +                        ; uintptr_t __stdcall hypercall2_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2);
> +                        public _hypercall2_vmmcall@12
> +_hypercall2_vmmcall@12  proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        vmmcall
> +                        pop     ebx
> +                        leave
> +                        ret     0Ch
> +_hypercall2_vmmcall@12  endp
>  =20
> -                ; uintptr_t __stdcall asm___hypercall3(uint32_t ord, ui=
ntptr_t arg1, uintptr_t arg2, uintptr_t arg3);
> -                public _asm___hypercall3@16
> -_asm___hypercall3@16 proc
> -                push    ebp
> -                mov     ebp, esp
> -                push    ebx
> -                mov     eax, [ebp + 08h]                ; ord
> -                mov     ebx, [ebp + 0ch]                ; arg1
> -                mov     ecx, [ebp + 10h]                ; arg2
> -                mov     edx, [ebp + 14h]                ; arg3
> -                shl     eax, 5
> -                add     eax, dword ptr [_Hypercall]
> -                call    eax
> -                pop     ebx
> -                leave
> -                ret     10h
> -_asm___hypercall3@16 endp
> +                        ; uintptr_t __stdcall hypercall3_vmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public _hypercall3_vmcall@16
> +_hypercall3_vmcall@16   proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        mov     edx, [ebp + 14h]                ; arg3
> +                        vmcall
> +                        pop     ebx
> +                        leave
> +                        ret     10h
> +_hypercall3_vmcall@16   endp
>  =20
> -                end
> +                        ; uintptr_t __stdcall hypercall3_vmmcall(
> +                        ;     uint32_t    ord,
> +                        ;     uintptr_t   arg1,
> +                        ;     uintptr_t   arg2,
> +                        ;     uintptr_t   arg3);
> +                        public _hypercall3_vmmcall@16
> +_hypercall3_vmmcall@16  proc
> +                        push    ebp
> +                        mov     ebp, esp
> +                        push    ebx
> +                        mov     eax, [ebp + 08h]                ; ord
> +                        mov     ebx, [ebp + 0ch]                ; arg1
> +                        mov     ecx, [ebp + 10h]                ; arg2
> +                        mov     edx, [ebp + 14h]                ; arg3
> +                        vmmcall
> +                        pop     ebx
> +                        leave
> +                        ret     10h
> +_hypercall3_vmmcall@16  endp
> +
> +                        end



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.283a.931d6d131446643d.19dbf55cc9c.e91e8c3243f06be4=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 08:18:01 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 08:18:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295469.1572110 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHddo-0007fi-32; Tue, 28 Apr 2026 08:18:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295469.1572110; Tue, 28 Apr 2026 08:18:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHddn-0007fP-Um; Tue, 28 Apr 2026 08:17:59 +0000
Received: by outflank-mailman (input) for mailman id 1295469;
 Tue, 28 Apr 2026 08:17:58 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373@swg.vates.tech>)
 id 1wHddm-0007dy-2v
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 08:17:58 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHddj-00FfQn-UT
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 10:17:57 +0200
Received: from [10.42.69.5] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373@swg.vates.tech>)
 id 69f06d32-5cb7-0a2a0a5109dd-0a2a4505eb2e-24
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:17:57 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373@swg.vates.tech>)
 id 69f06d34-aaa8-0a2a45050019-b9ff1c22a9a7-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:17:57 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd32a92fb000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 08:17:55 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 3711486204;
 Tue, 28 Apr 2026 10:17:55 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=IdSuAmfGQ79a3yaWW73bMJvI2pPAenmAfk7IEOeFkQg=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:feedback-id;
 b=AjTyiUDd+bQySJeSxPDPnQ9CgPJuYLOZhm5+SuYP6/jzceYrmTtAFCvFQ5bTX3Pgm/auar/cN
 +vg/iU2QfGuoGNgnG+bEVjR5j7lWUf8x1TuWhOFeyh0CKO0/TYaw/TzZY3A9sj0Aw+bmrSPjc7Q
 lhOFEFntMUfnqu+2C4tKZzvhsGLn4dO/KiNa8lYo8O5saOLeJPlyCgVg/CFQMN6tjkz4ZsgIRa9
 4/sYAfAiiKgPak6eTQOFne6sYkAjBEyiL/qw1m6f5Y9aZ+1952cAj6/odFoeJjrTy/tmVA8vTUL
 2PisZGB54RQk5H0wT6y0gdqPi8amuL5pVz5PuNOi7XiA==
X-Zone-Loop: fc363e2afa8ccb2a331edc13b9f473eb0125ba7d30bb
x-campaign-type: default
x-transaction-id: 94856c66-a17e-4ad3-a0eb-172d760436fe
x-swg-uid: 01-c8700b42-707b-41cc-a721-49b51913a83f
X-Mailer: Sweego
Message-ID:
 <1777364276.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373@vates.tech>
x-swg-bid: 1777364276.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 1/2] Remove ASSERT on CacheGet object allocation failure
Date: Tue, 28 Apr 2026 10:17:48 +0200
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.f.7282e8dead87a98e.19dd32a908c.58ffafcbbb194ac4=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777364275346
X-purgate-ID: tlsNG-c201ff/1777364277-2B563443-F839A178/0/0
X-purgate-type: clean
X-purgate-size: 1094

---=Part.f.7282e8dead87a98e.19dd32a908c.58ffafcbbb194ac4=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

When the grant table is exhausted, CacheGetObjectFromSlab can fail and
return NULL=2E Failing with an assert here prevents the grant exhaustion
from being handled elsewhere=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xenbus/cache=2Ec | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/xenbus/cache=2Ec b/src/xenbus/cache=2Ec
index e61033d=2E=2Ee58e2f9 100644
--- a/src/xenbus/cache=2Ec
+++ b/src/xenbus/cache=2Ec
@@ -623,7 +623,6 @@ again:
         Slab =3D CONTAINING_RECORD(ListEntry, XENBUS_CACHE_SLAB, ListEntr=
y);
=20
         Object =3D CacheGetObjectFromSlab(Slab);
-        ASSERT(Object !=3D NULL);
=20
         //
         // If the slab is now fully occupied, ove the cursor on to the ne=
xt
--=20
2=2E53=2E0=2Ewindows=2E2



-- 
 | Vates 

XCP-ng & Xen Orchestra - Vates solutions

web: https://vate=
s=2Etech
---=Part.f.7282e8dead87a98e.19dd32a908c.58ffafcbbb194ac4=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 08:18:01 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 08:18:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295468.1572107 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHddo-0007fM-0x; Tue, 28 Apr 2026 08:18:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295468.1572107; Tue, 28 Apr 2026 08:18:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHddn-0007fE-TK; Tue, 28 Apr 2026 08:17:59 +0000
Received: by outflank-mailman (input) for mailman id 1295468;
 Tue, 28 Apr 2026 08:17:58 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373@swg.vates.tech>)
 id 1wHddm-0007dx-1u
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 08:17:58 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHddl-007x7R-Eo
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 10:17:57 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373@swg.vates.tech>)
 id 69f06d31-e002-0a2a0a5209dd-0a2a450ca3e2-14
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:17:57 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373@swg.vates.tech>)
 id 69f06d34-62f1-0a2a450c0019-b9ff1c22a015-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:17:57 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd32a93ff000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 08:17:56 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id B67D3862A7;
 Tue, 28 Apr 2026 10:17:55 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=XMlMnCxoWJE6zqOynDYTqO/x7S7d7VczTU8tXLeYSI8=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=IEPvceDHbinnREu/8G28OVmcKoTHIi0gLbgmf2Cir3gi0+GE5Qhi7yW0NXQ4RxXMm2ybz0Z1Y
 kyiXl5B4gIPx7ud8n3JfMa6STeezEluFfm91K/giiAtr6guXq2DovsB9Q7T9TaQdN12bAhWozgq
 qX3yobYftzWgbqZM3f1nzopsFFp4VQNeEfkdyQpg+rme65DZYRXYRMqHHwyty2NpwiYu2ZWAm8n
 hSygAmi1lqtIbQrh3H2iBOnOumqjkCb7s2ZpyQxxR8tZTYD6N5zjfXyOhVHCir+276tmhFlCBxV
 8m5hhgJrfuCCVVMmSwF0CzXmZ6YOCvMHGx9Q2PL33ANQ==
X-Zone-Loop: b5c3eedfb70c4f424ed4565d3ff34b78c53d0c2b3f06
x-campaign-type: default
x-transaction-id: ca0fc0f2-4e53-4c36-a0e5-9d3fdd4308fb
x-swg-uid: 01-979efe12-d622-4a1e-a732-ac6dbff62d9e
X-Mailer: Sweego
Message-ID:
 <1777364276.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373@vates.tech>
x-swg-bid: 1777364276.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 2/2] Fix the display of GnttabDebugCallback Address
Date: Tue, 28 Apr 2026 10:17:49 +0200
In-Reply-To: <20260428081751.199-1-ngoc-tu.dinh@vates.tech>
References: <20260428081751.199-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.10.f6a6e409530d55c8.19dd32a9291.59f411e9fe26019a=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777364275857
X-purgate-ID: tlsNG-d25034/1777364277-6C965CF5-F30C08FB/0/0
X-purgate-type: clean
X-purgate-size: 1142

---=Part.10.f6a6e409530d55c8.19dd32a9291.59f411e9fe26019a=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

PFN_NUMBER is an ULONG and needs to be upcasted first=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xenbus/gnttab=2Ec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xenbus/gnttab=2Ec b/src/xenbus/gnttab=2Ec
index ea95edf=2E=2E71f8ec1 100644
--- a/src/xenbus/gnttab=2Ec
+++ b/src/xenbus/gnttab=2Ec
@@ -816,7 +816,7 @@ GnttabDebugCallback(
         PXENBUS_GNTTAB_FRAME    Frame =3D &Context->Frame[Index];
         PHYSICAL_ADDRESS        Address;
=20
-        Address=2EQuadPart =3D MmGetMdlPfnArray(Frame->Mdl)[0] << PAGE_SH=
IFT;
+        Address=2EQuadPart =3D (LONGLONG)MmGetMdlPfnArray(Frame->Mdl)[0] =
<< PAGE_SHIFT;
=20
         XENBUS_DEBUG(Printf,
                     &Context->DebugInterface,
--=20
2=2E53=2E0=2Ewindows=2E2



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.10.f6a6e409530d55c8.19dd32a9291.59f411e9fe26019a=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 08:34:16 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 08:34:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295479.1572124 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHdtX-0002MR-Ay; Tue, 28 Apr 2026 08:34:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295479.1572124; Tue, 28 Apr 2026 08:34:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHdtX-0002MJ-7a; Tue, 28 Apr 2026 08:34:15 +0000
Received: by outflank-mailman (input) for mailman id 1295479;
 Tue, 28 Apr 2026 08:34:14 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3397a06000f373@swg.vates.tech>)
 id 1wHdtW-0002M6-KD
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 08:34:14 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHdtW-00BKKQ-0s
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 10:34:14 +0200
Received: from [10.42.69.11] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3397a06000f373@swg.vates.tech>)
 id 69f070fc-5cb7-0a2a0a5109dd-0a2a450b8588-36
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:34:13 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3397a06000f373@swg.vates.tech>)
 id 69f07105-212f-0a2a450b0019-b9ff1c229f11-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:34:13 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3397a06000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 08:34:12 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 26D2586321;
 Tue, 28 Apr 2026 10:34:12 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=T2pUf0qBZUCit+5c0FMeCteTfQc6kMZnr/gtE2q3MaM=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=CqYTxR+zsI6fg9EYM9FiCWfqcuJ6BnjfLyvAdQHx65OxZND9QNwy5rNFR/P5xIO78dqTkGOY8
 D2e4hEF7adn5+CjaMMt4g83l07ueqbppiEYw8XFtkQWIm2kR6VVd6RXD38xatns71HXDQ2PqV9o
 ADwcH5QfHflaWx1PRo0fqyCkZN8U3mnPUVXxuY+1JMjpSbm7BlbEBhj0tNGdfozn3gNDU+smSmr
 E5FPu9QCVXm8GPy8UoO1NMwx0CYEqL4Kh3SKJkYadeIMXqGnUihvCb38ykIYw7g+/ouJvD71AUk
 NBXoeklYhJu6/HmNneo0pSwIDGxh289D8lvKtNdIDEpw==
X-Zone-Loop: de2f281b548b8a692e5d6789dd6e9c6ae5859c5e3a34
x-campaign-type: default
x-transaction-id: 0579c05d-c30d-4b8d-9995-d759200b7c8d
x-swg-uid: 01-ee25ad38-027d-4511-9bce-a5b45d2eccd3
X-Mailer: Sweego
Message-ID:
 <1777365252.8631fc262581453bbf619ec5b2062170.19dd3397a06000f373@vates.tech>
x-swg-bid: 1777365252.8631fc262581453bbf619ec5b2062170.19dd3397a06000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 2/2] Use memcpy/byteswap to translate CDB words
Date: Tue, 28 Apr 2026 10:33:42 +0200
In-Reply-To: <20260428083343.1011-1-ngoc-tu.dinh@vates.tech>
References: <20260428083343.1011-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.1d.70384f99d5ef6592.19dd3397882.597642e958010183=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777365252226
X-purgate-ID: tlsNG-42698a/1777365253-0556BF3B-BE3DDF14/0/0
X-purgate-type: clean
X-purgate-size: 1812

---=Part.1d.70384f99d5ef6592.19dd3397882.597642e958010183=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

MSVC cannot optimize manual byte concatenation=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 include/xencdb=2Eh | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/include/xencdb=2Eh b/include/xencdb=2Eh
index 594e9fe=2E=2Eae19f09 100644
--- a/include/xencdb=2Eh
+++ b/include/xencdb=2Eh
@@ -33,24 +33,31 @@
 #ifndef XENCDB_H
 #define XENCDB_H
=20
+#include <intrin=2Eh>
+
 #define XENCDB_SCSIOP_INVALID 0xFF
=20
 FORCEINLINE USHORT Cdb_get_big_endian_word(const UCHAR src[2])
 {
-    return src[1] | ((USHORT)src[0] << 8);
+    USHORT      Result;
+
+    memcpy(&Result, src, 2);
+    return _byteswap_ushort(Result);
 }
 FORCEINLINE ULONG Cdb_get_big_endian_dword(const UCHAR src[4])
 {
-    return src[3] | ((ULONG)src[2] << 8) | ((ULONG)src[1] << 16) |
-            ((ULONG)src[0] << 24);
+    ULONG       Result;
+
+    memcpy(&Result, src, 4);
+    return _byteswap_ulong(Result);
 }
=20
 FORCEINLINE ULONG64 Cdb_get_big_endian_qword(const UCHAR src[8])
 {
-    return src[7] | ((ULONG64)src[6] << 8) | ((ULONG64)src[5] << 16) |
-        ((ULONG64)src[4] << 24) | ((ULONG64)src[3] << 32) |
-        ((ULONG64)src[2] << 40) | ((ULONG64)src[1] << 48) |
-        ((ULONG64)src[0] << 56);
+    ULONG64     Result;
+
+    memcpy(&Result, src, 8);
+    return _byteswap_uint64(Result);
 }
=20
 FORCEINLINE UCHAR Cdb_CheckLen6(UCHAR op)
--=20
2=2E53=2E0=2Ewindows=2E2



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.1d.70384f99d5ef6592.19dd3397882.597642e958010183=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 08:34:16 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 08:34:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295480.1572127 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHdtY-0002Nb-Bl; Tue, 28 Apr 2026 08:34:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295480.1572127; Tue, 28 Apr 2026 08:34:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHdtY-0002NU-91; Tue, 28 Apr 2026 08:34:16 +0000
Received: by outflank-mailman (input) for mailman id 1295480;
 Tue, 28 Apr 2026 08:34:15 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd339790c000f373@swg.vates.tech>)
 id 1wHdtX-0002MC-46
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 08:34:15 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHdtW-000oeY-DE
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 10:34:14 +0200
Received: from [10.42.69.4] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd339790c000f373@swg.vates.tech>)
 id 69f070fb-2eae-0a2a0a5409dd-0a2a4504bb6e-34
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:34:14 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd339790c000f373@swg.vates.tech>)
 id 69f07105-1dec-0a2a45040019-b9ff1c22876b-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 10:34:13 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd339790c000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 08:34:12 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id CFA86862C8;
 Tue, 28 Apr 2026 10:34:11 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=PFYDMU1OVviTy/a07dBnZuYcgGfKlzHaUA9Ep08kOnM=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:feedback-id;
 b=p9KKbuAc406EJ80GGiYMmhU8VwqCi9Mo+NCK6IJBal91zo1CII97BfdkYi8kwGNZpqSpaTsvh
 VODCvstyHYVtv/QGGbeki5NnkUf8TkHK3tbaaszabrGYgrnK7VCJZwKwoTnnOYwmhUPVvsXEAMo
 qbxH/4PBsYKKHPp6u7Sr1yHG/88N0uU9vHwb8woY40ak9L2tYJ/YFoXVe5dEPVjwnUDJUL+lTja
 7qn8oTx0sSkLu6Py05Jf1DQ18NaWmIDY5ffhwe5bJGw2oNFvsPhcCoX/FEhem4y+GtSBbV0UAGZ
 58YBuUV/+fcC5SQ0yqYwU0aq0qf9Apcik0RdgBIvhoGQ==
X-Zone-Loop: f1c80746eb7568d1af8895900983bf2b6c0dd918cc66
x-campaign-type: default
x-transaction-id: e881a440-9b6a-4f63-be63-be223d160831
x-swg-uid: 01-a82bae92-5bf1-4da1-ad6d-9939674e4af8
X-Mailer: Sweego
Message-ID:
 <1777365252.8631fc262581453bbf619ec5b2062170.19dd339790c000f373@vates.tech>
x-swg-bid: 1777365252.8631fc262581453bbf619ec5b2062170.19dd339790c000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 1/2] Correct reporting of unmap granularity
Date: Tue, 28 Apr 2026 10:33:41 +0200
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.1c.8336e17a421c0bff.19dd3397754.d5c4cf5f30fb9c0=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777365251924
X-purgate-ID: tlsNG-ebf023/1777365253-2B5683FF-0E60B63E/0/0
X-purgate-type: clean
X-purgate-size: 1943

---=Part.1c.8336e17a421c0bff.19dd3397754.d5c4cf5f30fb9c0=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

blkif=2Eh specifies discard-alignment and discard-granularity as being in
byte unit=2E These values must be converted to LBA unit in the
corresponding inquiry outputs=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xenvbd/target=2Ec | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/xenvbd/target=2Ec b/src/xenvbd/target=2Ec
index e4a9c03=2E=2E102e8b8 100644
--- a/src/xenvbd/target=2Ec
+++ b/src/xenvbd/target=2Ec
@@ -842,6 +842,7 @@ TargetInquiryB0(
     )
 {
     PXENVBD_FEATURES        Features =3D FrontendGetFeatures(Target->Fron=
tend);
+    PXENVBD_DISKINFO        DiskInfo =3D FrontendGetDiskInfo(Target->Fron=
tend);
     PVPD_BLOCK_LIMITS_PAGE  Data =3D Srb->DataBuffer;
     ULONG                   Length =3D Srb->DataTransferLength;
=20
@@ -867,8 +868,10 @@ TargetInquiryB0(
      * default=2E
      */
     *(PULONG)Data->MaximumUnmapBlockDescriptorCount =3D _byteswap_ulong(8=
);
-    *(PULONG)Data->OptimalUnmapGranularity =3D _byteswap_ulong(Features->=
DiscardGranularity);
-    *(PULONG)Data->UnmapGranularityAlignment =3D _byteswap_ulong(Features=
->DiscardAlignment);
+    *(PULONG)Data->OptimalUnmapGranularity =3D
+        _byteswap_ulong(Features->DiscardGranularity / DiskInfo->SectorSi=
ze);
+    *(PULONG)Data->UnmapGranularityAlignment =3D
+        _byteswap_ulong(Features->DiscardAlignment / DiskInfo->SectorSize=
);
     // alignment is only valid if a granularity has been set
     Data->UGAValid =3D (Features->DiscardGranularity !=3D 0) ? 1 : 0;
=20
--=20
2=2E53=2E0=2Ewindows=2E2



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.1c.8336e17a421c0bff.19dd3397754.d5c4cf5f30fb9c0=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:02:51 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:02:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295484.1572131 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeLC-0006Td-9t; Tue, 28 Apr 2026 09:02:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295484.1572131; Tue, 28 Apr 2026 09:02:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeLC-0006TV-7A; Tue, 28 Apr 2026 09:02:50 +0000
Received: by outflank-mailman (input) for mailman id 1295484;
 Tue, 28 Apr 2026 09:02:49 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@swg.vates.tech>)
 id 1wHeLB-0006TP-4g
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:02:49 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeLA-00BR2N-31
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:02:48 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@swg.vates.tech>)
 id 69f077b8-e002-0a2a0a5209dd-0a2a4502d768-0
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:02:48 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@swg.vates.tech>)
 id 69f077b7-af86-0a2a45020019-b9ff1c22a8a9-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:02:48 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3539ada000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:02:44 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 81B278621B;
 Tue, 28 Apr 2026 11:02:43 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=KSy6QOlMgFHCyz4yMwPQ2GYsVpG+jHWbnXm5XVxr8Ko=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:feedback-id;
 b=NToP5RMAgTXAdxvHiyEDtSsjCRbzOa3pQ5daz5mjH9BGurvQSF/06uOh/lGPHScX0dOXw1Rjr
 B8JGnHKhuXhHAGEdljMGXJQ69DLnfh0w4flYvoh568qOj/pUEXqg6iAMTKj8AmmLFlEeQz59iJo
 ar93s8CIlGLBJYLOrCi5KUC5l40uennyb2AnRPfzR/aLNotCXUyuJLr7WtnzEzgFkXPUx0z5CcO
 pKQ3S8/7NowqNKsUmw+bY7SRxKhnBgV9j9oCceZi/HPlF8YUqAlcL3QEPnZgU15YLj+otrcokEd
 9zQ1uwrbnImgjjtOOewPLAmzB6eZDng12WvsZyihDVFg==
X-Zone-Loop: 2765492a486f1733967a24c183d5bfaba0941c5e6c27
x-campaign-type: default
x-transaction-id: 65a9f2be-0f51-497b-8df4-ff8632cdc7f2
x-swg-uid: 01-ec937c15-0a25-487c-a184-7203fe247115
X-Mailer: Sweego
Message-ID:
 <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
x-swg-bid: 1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 0/6] Align blkif protocol values to 512B sectors
Date: Tue, 28 Apr 2026 11:02:31 +0200
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.2d.bef2002554706b48.19dd353959a.56e4136fea6510e9=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777366963610
X-purgate-ID: tlsNG-720697/1777366968-B316D161-9B287060/0/0
X-purgate-type: clean
X-purgate-size: 1682

---=Part.2d.bef2002554706b48.19dd353959a.56e4136fea6510e9=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Xen revision 221f2748e8da deprecated feature-large-sector-size and
clarified that all protocol-level sector sizes are based on 512-byte
units=2E This is the behavior observed on Linux blkback, and deviating
from this will lead to corrupting the virtual disk=2E

Tested on Linux blkback with a loop device using 4K blocksize=2E The guest
used a purely emulated disk "xvdz", as QEMU doesn't support more than
512B logical sector size in emulated devices=2E Note that Qdisk is still
broken wrt=2E 221f2748e8da=2E

Tu Dinh (6):
  Update to latest blkif=2Eh
  Stop reporting feature-large-sector-size
  Align blkif protocol values to 512B sectors
  Centralize VBD extent checking
  xencrsh: Stop reporting feature-large-sector-size
  xencrsh: Align blkif protocol values to 512B sectors

 include/xen/io/blkif=2Eh | 103 ++++++++++++++++++++++++++++-------------
 src/xencrsh/frontend=2Ec |  30 ++++++------
 src/xencrsh/frontend=2Eh |  10 +++-
 src/xencrsh/pdo=2Ec      | 103 +++++++++++++++++++++++++++--------------
 src/xenvbd/frontend=2Ec  |  90 +++++++++++++++++++++--------------
 src/xenvbd/frontend=2Eh  |  36 +++++++++++++-
 src/xenvbd/ring=2Ec      |  60 ++++++++++++------------
 src/xenvbd/target=2Ec    |  37 ++++++++-------
 8 files changed, 302 insertions(+), 167 deletions(-)

--
2=2E54=2E0=2Ewindows=2E1


-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.2d.bef2002554706b48.19dd353959a.56e4136fea6510e9=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:03:45 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:03:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295485.1572137 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM5-0006Xt-Ev; Tue, 28 Apr 2026 09:03:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295485.1572137; Tue, 28 Apr 2026 09:03:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM5-0006Xi-AO; Tue, 28 Apr 2026 09:03:45 +0000
Received: by outflank-mailman (input) for mailman id 1295485;
 Tue, 28 Apr 2026 09:03:44 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547688000f373@swg.vates.tech>)
 id 1wHeM4-0006XU-MZ
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:03:44 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeM4-00FKgm-3E
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:03:44 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547688000f373@swg.vates.tech>)
 id 69f077e9-5cb7-0a2a0a5109dd-0a2a4508c94c-46
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:44 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547688000f373@swg.vates.tech>)
 id 69f077ef-63b5-0a2a45080019-b9ff1c22af15-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:43 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3547688000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:03:41 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id B248886235;
 Tue, 28 Apr 2026 11:03:40 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=y27qZkpR4/6nfBj5rqIa7s/OTz1oTeFHTbfk049Hhpo=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=GycRUQuU2jmC4kYdLjSs29kHs4SobzXfB1yKmQkuNjeloYiq8K9HRQV6cwcV1LreROeGazBwG
 gQh7igr9ing/G+ibjfQCWmc1owScp6uh/Ge0gn/NJXDBTx2GCI6eu4L/T9v7twKRdl5bgPfglF0
 lJPN3Mi71C8qooqgwh1gWYBf/N05jkMZy20odn/6J11sSXz/Tp3JqE4GUPrjVhTX/cRHYYX8q2J
 C9nk1roC0iS3Ay+ePK8qFu+qYQhPUF6qsooHsfYaGedc9HFvnJo2yab3/XRxOdz0cTVc3eajEDe
 JMFW12kPpuMmkiVtmAQphsbk3RkRBxeyIwqG3DMjYFXg==
X-Zone-Loop: 7edfb51b49b174a997fe7a8a98989d602f05782de373
x-campaign-type: default
x-transaction-id: e6b816e4-87a5-45d3-9f88-d8ab0b1df1df
x-swg-uid: 01-4c9b732b-efe2-4277-a152-f211467e87cf
X-Mailer: Sweego
Message-ID:
 <1777367021.8631fc262581453bbf619ec5b2062170.19dd3547688000f373@vates.tech>
x-swg-bid: 1777367021.8631fc262581453bbf619ec5b2062170.19dd3547688000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 2/6] Stop reporting feature-large-sector-size
Date: Tue, 28 Apr 2026 11:03:31 +0200
In-Reply-To: <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
References: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
 <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.2f.9cb009549288cc0b.19dd3547504.429a8aab1cc68261=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777367020805
X-purgate-ID: tlsNG-c1860d/1777367024-3B370DB1-E579849A/0/0
X-purgate-type: clean
X-purgate-size: 1520

---=Part.2f.9cb009549288cc0b.19dd3547504.429a8aab1cc68261=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

This feature is deprecated and incompatible with blkif=2Eh revision
221f2748e8da=2E It must be removed before moving towards using 512B
sectors in our blkif protocol implementation=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xenvbd/frontend=2Ec | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/xenvbd/frontend=2Ec b/src/xenvbd/frontend=2Ec
index ef60f9c=2E=2E45a5f49 100644
--- a/src/xenvbd/frontend=2Ec
+++ b/src/xenvbd/frontend=2Ec
@@ -1203,16 +1203,6 @@ FrontendConnect(
         if (!NT_SUCCESS(Status))
             goto abort;
=20
-        Status =3D XENBUS_STORE(Printf,
-                              &Frontend->StoreInterface,
-                              Transaction,
-                              Frontend->FrontendPath,
-                              "feature-large-sector-size",
-                              "%u",
-                              1);
-        if (!NT_SUCCESS(Status))
-            goto abort;
-
         Status =3D XENBUS_STORE(TransactionEnd,
                               &Frontend->StoreInterface,
                               Transaction,
--=20
2=2E54=2E0=2Ewindows=2E1



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.2f.9cb009549288cc0b.19dd3547504.429a8aab1cc68261=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:03:45 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:03:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295486.1572142 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM5-0006YK-Jt; Tue, 28 Apr 2026 09:03:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295486.1572142; Tue, 28 Apr 2026 09:03:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM5-0006Xz-Bx; Tue, 28 Apr 2026 09:03:45 +0000
Received: by outflank-mailman (input) for mailman id 1295486;
 Tue, 28 Apr 2026 09:03:44 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd354757d000f373@swg.vates.tech>)
 id 1wHeM4-0006XV-Na
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:03:44 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeM4-00446K-2L
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:03:44 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd354757d000f373@swg.vates.tech>)
 id 69f077eb-e002-0a2a0a5209dd-0a2a45099b9c-42
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:43 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd354757d000f373@swg.vates.tech>)
 id 69f077ef-2497-0a2a45090019-b9ff1c22a143-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:43 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd354757d000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:03:40 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 2C0C786205;
 Tue, 28 Apr 2026 11:03:40 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=F1+FFDfE3cWaEz86waQEk7eYy7AajM4QkhPT6uWvliU=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=pvO59LgiKCnn4uWZ9ezuvv3aKFqCqI/+UI07kMki/1TtxRMS4QSTUKcAlWWzyLRkP6pBrWMIf
 ItXgx+mv1ItL/HTZQPEWcEPi2CkJ49IuQydtGQlb/IZcgGnQVnbnO7rC8l2wvqwnO3LoKcVpsQl
 JIskdKVwLRh/yngRdmjQLc+3mSZ7qpkxbpMTVMLK+4se7fdrejF3H6vtOSykk6jCw4FXC/rXdgW
 3FaWTgmU+Wub5ynU1VYXmwFOzkjn/9I5xIzqfOkmyWG5lZWzb4OtZ9lP5S/bnPzBqIMlIMjZBia
 PgR86oEVJ6zjpmIpX0yohfNjldgHrcjm9klildupW7xw==
X-Zone-Loop: d879d7eafae51adf763827f1e1ea46d94fe22266243e
x-campaign-type: default
x-transaction-id: 060bc1fd-ceba-4090-ab52-58f7d2483365
x-swg-uid: 01-c4731a31-5fc2-43c8-9a01-1030c2c0329c
X-Mailer: Sweego
Message-ID:
 <1777367020.8631fc262581453bbf619ec5b2062170.19dd354757d000f373@vates.tech>
x-swg-bid: 1777367020.8631fc262581453bbf619ec5b2062170.19dd354757d000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 1/6] Update to latest blkif.h
Date: Tue, 28 Apr 2026 11:03:30 +0200
In-Reply-To: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
References: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.2e.5572b683bae16472.19dd35472e8.c322694cc0f9896b=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777367020265
X-purgate-ID: tlsNG-bad1c0/1777367023-404A9A53-EB68835A/0/0
X-purgate-type: clean
X-purgate-size: 11624

---=Part.2e.5572b683bae16472.19dd35472e8.c322694cc0f9896b=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

>From Xen revision 457052167b4dbcda59e06300039302479cc1debf=2E

It brings a change to the semantics of sector sizes and related units=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 include/xen/io/blkif=2Eh | 103 ++++++++++++++++++++++++++++-------------
 1 file changed, 70 insertions(+), 33 deletions(-)

diff --git a/include/xen/io/blkif=2Eh b/include/xen/io/blkif=2Eh
index e6db196=2E=2E8407453 100644
--- a/include/xen/io/blkif=2Eh
+++ b/include/xen/io/blkif=2Eh
@@ -1,26 +1,9 @@
+/* SPDX-License-Identifier: MIT */
 /************************************************************************=
******
  * blkif=2Eh
  *
  * Unified block-device I/O interface for Xen guest OSes=2E
  *
- * Permission is hereby granted, free of charge, to any person obtaining =
a copy
- * of this software and associated documentation files (the "Software"), =
to
- * deal in the Software without restriction, including without limitation=
 the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, a=
nd/or
- * sell copies of the Software, and to permit persons to whom the Softwar=
e is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be include=
d in
- * all copies or substantial portions of the Software=2E
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRES=
S OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILIT=
Y,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT=2E IN NO EVENT SH=
ALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISIN=
G
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE=2E
- *
  * Copyright (c) 2003-2004, Keir Fraser
  * Copyright (c) 2012, Spectra Logic Corporation
  */
@@ -59,7 +42,7 @@
  * All data in the XenStore is stored as strings=2E  Nodes specifying num=
eric
  * values are encoded in decimal=2E  Integer value ranges listed below ar=
e
  * expressed as fixed sized integer types capable of storing the conversi=
on
- * of a properly formated node string, without loss of information=2E
+ * of a properly formatted node string, without loss of information=2E
  *
  * Any specified default value is in effect if the corresponding XenBus n=
ode
  * is not present in the XenStore=2E
@@ -118,7 +101,7 @@
  *
  *      The underlying storage is not affected by the direct IO memory
  *      lifetime bug=2E  See:
- *        http://lists=2Exen=2Eorg/archives/html/xen-devel/2012-12/msg011=
54=2Ehtml
+ *        https://lists=2Exen=2Eorg/archives/html/xen-devel/2012-12/msg01=
154=2Ehtml
  *
  *      Therefore this option gives the backend permission to use
  *      O_DIRECT, notwithstanding that bug=2E
@@ -254,18 +237,30 @@
  * sector-size
  *      Values:         <uint32_t>
  *
- *      The logical sector size, in bytes, of the backend device=2E
+ *      The logical block size, in bytes, of the underlying storage=2E Th=
is must
+ *      be a power of two with a minimum value of 512=2E  The sector size=
 should
+ *      only be used for request segment length and alignment=2E
+ *
+ *      When exposing a device that uses a logical sector size of 4096, t=
he
+ *      only difference xenstore wise will be that 'sector-size' (and pos=
sibly
+ *      'physical-sector-size' if supported by the backend) will be 4096,=
 but
+ *      the 'sectors' node will still be calculated using 512 byte units=
=2E  The
+ *      sector base units in the ring requests fields will all be 512 byt=
e
+ *      based despite the logical sector size exposed in 'sector-size'=2E
  *
  * physical-sector-size
  *      Values:         <uint32_t>
+ *      Default Value:  <"sector-size">
  *
- *      The physical sector size, in bytes, of the backend device=2E
+ *      The physical block size, in bytes, of the backend storage=2E This
+ *      must be an integer multiple of "sector-size"=2E
  *
  * sectors
  *      Values:         <uint64_t>
  *
- *      The size of the backend device, expressed in units of its logical
- *      sector size ("sector-size")=2E
+ *      The size of the backend device, expressed in units of 512b=2E  Th=
e
+ *      product of "sectors" * 512 must also be an integer multiple of
+ *      "physical-sector-size", if that node is present=2E
  *
  ************************************************************************=
*****
  *                            Frontend XenBus Nodes
@@ -321,6 +316,8 @@
  *      The size of the frontend allocated request ring buffer in units o=
f
  *      machine pages=2E  The value must be a power of 2=2E
  *
+ *--------------------------------- Features ----------------------------=
-----
+ *
  * feature-persistent
  *      Values:         0/1 (boolean)
  *      Default Value:  0
@@ -331,7 +328,7 @@
  *      access (even when it should be read-only)=2E If the frontend hits=
 the
  *      maximum number of allowed persistently mapped grants, it can fall=
back
  *      to non persistent mode=2E This will cause a performance degradati=
on,
- *      since the the backend driver will still try to map those grants
+ *      since the backend driver will still try to map those grants
  *      persistently=2E Since the persistent grants protocol is compatibl=
e with
  *      the previous protocol, a frontend driver can choose to work in
  *      persistent mode even when the backend doesn't support it=2E
@@ -342,6 +339,26 @@
  *      decides to limit the maximum number of persistently mapped grants
  *      to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST=
=2E
  *
+ * feature-large-sector-size
+ *      Values:         0/1 (boolean)
+ *      Default Value:  0
+ *      Notes:          DEPRECATED, 12
+ *
+ *      A value of "1" indicates that the frontend will correctly supply =
and
+ *      interpret all sector-based quantities in terms of the "sector-siz=
e"
+ *      value supplied in the backend info, whatever that may be set to=
=2E
+ *      If this node is not present or its value is "0" then it is assume=
d
+ *      that the frontend requires that the logical block size is 512 as =
it
+ *      is hardcoded (which is the case in some frontend implementations)=
=2E
+ *
+ * trusted
+ *      Values:         0/1 (boolean)
+ *      Default value:  1
+ *
+ *      A value of "0" indicates that the frontend should not trust the
+ *      backend, and should deploy whatever measures available to protect=
 from
+ *      a malicious backend on the other end=2E
+ *
  *------------------------- Virtual Device Properties -------------------=
------
  *
  * device-type
@@ -399,6 +416,11 @@
  *(10) The discard-secure property may be present and will be set to 1 if=
 the
  *     backing device supports secure discard=2E
  *(11) Only used by Linux and NetBSD=2E
+ *(12) Possibly only ever implemented by the QEMU Qdisk backend and the W=
indows
+ *     PV block frontend=2E  Other backends and frontends supported 'sect=
or-size'
+ *     values greater than 512 before such feature was added=2E  Frontend=
s should
+ *     not expose this node, neither should backends make any decisions b=
ased
+ *     on it being exposed by the frontend=2E
  */
=20
 /*
@@ -549,7 +571,7 @@
  */
 #define BLKIF_OP_RESERVED_1        4
 /*
- * Indicate to the backend device that a region of storage is no LONG_PTR=
er in
+ * Indicate to the backend device that a region of storage is no longer i=
n
  * use, and may be discarded at any time without impact to the client=2E =
 If
  * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the
  * discarded region on the device must be rendered unrecoverable before t=
he
@@ -577,7 +599,7 @@
  * present, the frontend might use blkif_request_indirect structs in orde=
r to
  * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11)=2E T=
he
  * maximum number of indirect segments is fixed by the backend, but the
- * frontend can issue requests with any number of indirect segments as LO=
NG_PTR as
+ * frontend can issue requests with any number of indirect segments as lo=
ng as
  * it's less than the number provided by the backend=2E The indirect_gref=
s field
  * in blkif_request_indirect should be filled by the frontend with the
  * grant references of the pages that are holding the indirect segments=
=2E
@@ -607,12 +629,14 @@
 #define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
=20
 /*
- * NB=2E first_sect and last_sect in blkif_request_segment, as well as
- * sector_number in blkif_request, are always expressed in 512-byte units=
=2E
- * However they must be properly aligned to the real sector size of the
- * physical disk, which is reported in the "physical-sector-size" node in
- * the backend xenbus info=2E Also the xenbus "sectors" node is expressed=
 in
- * 512-byte units=2E
+ * NB=2E 'first_sect' and 'last_sect' in blkif_request_segment are all in=
 units
+ * of 512 bytes, despite the 'sector-size' xenstore node possibly having =
a
+ * value greater than 512=2E
+ *
+ * The value in 'first_sect' and 'last_sect' fields must be setup so that=
 the
+ * resulting segment offset and size is aligned to the logical sector siz=
e
+ * reported by the 'sector-size' xenstore node, see 'Backend Device Prope=
rties'
+ * section=2E
  */
 struct blkif_request_segment {
     grant_ref_t gref;        /* reference to I/O buffer frame        */
@@ -623,6 +647,10 @@ struct blkif_request_segment {
=20
 /*
  * Starting ring element for any I/O request=2E
+ *
+ * The 'sector_number' field is in units of 512b, despite the value of th=
e
+ * 'sector-size' xenstore node=2E  Note however that the offset in
+ * 'sector_number' must be aligned to 'sector-size'=2E
  */
 struct blkif_request {
     uint8_t        operation;    /* BLKIF_OP_???                         =
*/
@@ -637,6 +665,10 @@ typedef struct blkif_request blkif_request_t;
 /*
  * Cast to this structure when blkif_request=2Eoperation =3D=3D BLKIF_OP_=
DISCARD
  * sizeof(struct blkif_request_discard) <=3D sizeof(struct blkif_request)
+ *
+ * The 'sector_number' field is in units of 512b, despite the value of th=
e
+ * 'sector-size' xenstore node=2E  Note however that the offset in
+ * 'sector_number' must be aligned to 'discard-granularity'=2E
  */
 struct blkif_request_discard {
     uint8_t        operation;    /* BLKIF_OP_DISCARD                     =
*/
@@ -649,6 +681,11 @@ struct blkif_request_discard {
 };
 typedef struct blkif_request_discard blkif_request_discard_t;
=20
+/*
+ * The 'sector_number' field is in units of 512b, despite the value of th=
e
+ * 'sector-size' xenstore node=2E  Note however that the offset in
+ * 'sector_number' must be aligned to 'sector-size'=2E
+ */
 struct blkif_request_indirect {
     uint8_t        operation;    /* BLKIF_OP_INDIRECT                    =
*/
     uint8_t        indirect_op;  /* BLKIF_OP_{READ/WRITE}                =
*/
--=20
2=2E54=2E0=2Ewindows=2E1



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.2e.5572b683bae16472.19dd35472e8.c322694cc0f9896b=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:03:46 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:03:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295487.1572143 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM6-0006b2-I6; Tue, 28 Apr 2026 09:03:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295487.1572143; Tue, 28 Apr 2026 09:03:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM6-0006av-Ex; Tue, 28 Apr 2026 09:03:46 +0000
Received: by outflank-mailman (input) for mailman id 1295487;
 Tue, 28 Apr 2026 09:03:45 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547784000f373@swg.vates.tech>)
 id 1wHeM5-0006Xf-3S
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:03:45 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeM4-00FKjm-GO
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:03:44 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547784000f373@swg.vates.tech>)
 id 69f077f0-5cb7-0a2a0a5109dd-0a2a4508a4d6-0
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:44 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547784000f373@swg.vates.tech>)
 id 69f077ef-63b5-0a2a45080019-b9ff1c22af15-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:44 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3547784000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:03:41 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id EC41E8624B;
 Tue, 28 Apr 2026 11:03:40 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=ifFzluhKVYxVcpC/P/c8Pkc/JCoOBUW034ILK6Axw/E=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=jM+yVErtPzPaVfyrHTU6h2XqdSBALzfsXV6gBotWFrcz17emoFfT4IEhLAhDJYqtjj50g7orY
 nzl7Nx/0s42xUrIT3dbOTeDQObATM9AHFRMMHLyuet3qRIf6X2wWoE/L/Sxp1/XVaAHLeESRW2J
 0B9gDBRqhDIIcn8pPQKq6Q4yhM+DOoZOUYhk4oLg3tzTT37yYB/xAMIUCM9jmVT2fiKtUEJ+wQJ
 yOBXbjwN6PC6++0082n1VypXr/9Da4DvHdoInaAOSq29zWnG2d7KInALp6qpC6mstdZ76YZFs1Y
 hLs77OcO8WreT5gWkpZOkmSj8JDWve/wPSO11rLOd9ng==
X-Zone-Loop: 933971b5cecb96be51b927d71d59692524ff51ba35ae
x-campaign-type: default
x-transaction-id: 48e75d69-ba5f-47dd-8262-ad3bd86e1ca7
x-swg-uid: 01-09762a5a-c1cc-4c0f-b0ba-af44f93516aa
X-Mailer: Sweego
Message-ID:
 <1777367021.8631fc262581453bbf619ec5b2062170.19dd3547784000f373@vates.tech>
x-swg-bid: 1777367021.8631fc262581453bbf619ec5b2062170.19dd3547784000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 3/6] Align blkif protocol values to 512B sectors
Date: Tue, 28 Apr 2026 11:03:32 +0200
In-Reply-To: <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
References: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
 <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.30.7304d5f1cdddfc3d.19dd35475f6.65125494cfbb0a43=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777367021046
X-purgate-ID: tlsNG-c1860d/1777367024-C357FDB1-0B2D269D/0/0
X-purgate-type: clean
X-purgate-size: 18345

---=Part.30.7304d5f1cdddfc3d.19dd35475f6.65125494cfbb0a43=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

With the deprecation of feature-large-sector-size, blkif=2Eh now specifies
that all sector amounts in the protocol are in 512B units=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xenvbd/frontend=2Ec | 80 +++++++++++++++++++++++++++++--------------
 src/xenvbd/frontend=2Eh | 10 +++++-
 src/xenvbd/ring=2Ec     | 56 ++++++++++++++----------------
 src/xenvbd/target=2Ec   | 13 +++----
 4 files changed, 97 insertions(+), 62 deletions(-)

diff --git a/src/xenvbd/frontend=2Ec b/src/xenvbd/frontend=2Ec
index 45a5f49=2E=2Ed8e3287 100644
--- a/src/xenvbd/frontend=2Ec
+++ b/src/xenvbd/frontend=2Ec
@@ -761,7 +761,7 @@ __Size(
     __in  PXENVBD_DISKINFO  Info
     )
 {
-    ULONG64                 MBytes =3D (Info->SectorSize * Info->SectorCo=
unt) >> 20; // / (1024 * 1024);
+    ULONG64                 MBytes =3D Info->BlkifSectorCount >> (20 - BL=
KIF_SECTOR_SHIFT);
=20
     if (MBytes < 10240)
         return (ULONG)MBytes;
@@ -773,7 +773,7 @@ __Units(
     __in  PXENVBD_DISKINFO  Info
     )
 {
-    ULONG64                 MBytes =3D (Info->SectorSize * Info->SectorCo=
unt) >> 20; // / (1024 * 1024);
+    ULONG64                 MBytes =3D Info->BlkifSectorCount >> (20 - BL=
KIF_SECTOR_SHIFT);
=20
     if (MBytes < 10240)
         return "MB";
@@ -856,46 +856,73 @@ FrontendReadDiskInfo(
     )
 {
     BOOLEAN                 Changed;
+    PXENVBD_DISKINFO        DiskInfo =3D &Frontend->DiskInfo;
=20
     Changed =3D FrontendReadDiskValue32(Frontend,
                                       "info",
-                                      &Frontend->DiskInfo=2EDiskInfo);
+                                      &DiskInfo->DiskInfo);
     Changed |=3D FrontendReadDiskValue32(Frontend,
                                        "sector-size",
-                                       &Frontend->DiskInfo=2ESectorSize);
+                                       &DiskInfo->SectorSize);
     Changed |=3D FrontendReadDiskValue32(Frontend,
                                        "physical-sector-size",
-                                       &Frontend->DiskInfo=2EPhysSectorSi=
ze);
+                                       &DiskInfo->PhysSectorSize);
     Changed |=3D FrontendReadValue64(Frontend,
                                    "sectors",
-                                   &Frontend->DiskInfo=2ESectorCount);
+                                   &DiskInfo->BlkifSectorCount);
=20
     if (!Changed)
         return;
=20
-    if (Frontend->DiskInfo=2EDiskInfo & VDISK_READONLY) {
-        Warning("Target[%d] : DiskInfo contains VDISK_READONLY flag!\n", =
Frontend->TargetId);
+    if (DiskInfo->DiskInfo & VDISK_READONLY) {
+        Warning("Target[%d] : DiskInfo contains VDISK_READONLY flag!\n",
+                Frontend->TargetId);
     }
-    if (Frontend->DiskInfo=2EDiskInfo & VDISK_CDROM) {
-        Warning("Target[%d] : DiskInfo contains VDISK_CDROM flag!\n", Fro=
ntend->TargetId);
+    if (DiskInfo->DiskInfo & VDISK_CDROM) {
+        Warning("Target[%d] : DiskInfo contains VDISK_CDROM flag!\n",
+                Frontend->TargetId);
     }
-    if (Frontend->DiskInfo=2ESectorSize =3D=3D 0) {
-        Error("Target[%d] : Invalid SectorSize!\n", Frontend->TargetId);
+    if (DiskInfo->SectorSize < BLKIF_SECTOR_SIZE ||
+        (DiskInfo->SectorSize & (DiskInfo->SectorSize - 1)) !=3D 0) {
+        Error("Target[%d] : Invalid SectorSize %lu, defaulting to %u!\n",
+              Frontend->TargetId,
+              DiskInfo->SectorSize,
+              BLKIF_SECTOR_SIZE);
+        DiskInfo->SectorSize =3D BLKIF_SECTOR_SIZE;
     }
-    if (Frontend->DiskInfo=2ESectorCount =3D=3D 0) {
-        Error("Target[%d] : Invalid SectorCount!\n", Frontend->TargetId);
+    // infallible due to check above
+    BitScanForward(&DiskInfo->SectorShift, DiskInfo->SectorSize);
+    DiskInfo->SectorShift -=3D BLKIF_SECTOR_SHIFT;
+    if (DiskInfo->PhysSectorSize < DiskInfo->SectorSize ||
+        DiskInfo->PhysSectorSize % DiskInfo->SectorSize !=3D 0) {
+        Error("Target[%d] : Invalid PhysSectorSize %lu, defaulting to %lu=
!\n",
+              Frontend->TargetId,
+              DiskInfo->PhysSectorSize,
+              DiskInfo->SectorSize);
+        DiskInfo->PhysSectorSize =3D DiskInfo->SectorSize;
     }
-    if (Frontend->DiskInfo=2EPhysSectorSize =3D=3D 0) {
-        Frontend->DiskInfo=2EPhysSectorSize =3D Frontend->DiskInfo=2ESect=
orSize;
+    if (DiskInfo->BlkifSectorCount =3D=3D 0 ||
+        DiskInfo->BlkifSectorCount % (DiskInfo->PhysSectorSize >>
+                                               DiskInfo->SectorShift) !=
=3D 0) {
+        Error("Target[%d] : Invalid BlkifSectorCount %llu!\n",
+              Frontend->TargetId,
+              DiskInfo->BlkifSectorCount);
     }
=20
     // dump actual values
-    Trace("Target[%d] : %lld sectors of %d bytes (%d)\n", Frontend->Targe=
tId,
-          Frontend->DiskInfo=2ESectorCount, Frontend->DiskInfo=2ESectorSi=
ze,
-          Frontend->DiskInfo=2EPhysSectorSize);
-    Trace("Target[%d] : %d %s (%08x)\n", Frontend->TargetId,
-          __Size(&Frontend->DiskInfo), __Units(&Frontend->DiskInfo),
-          Frontend->DiskInfo=2EDiskInfo);
+    Trace("Target[%d] : %llu %luB blocks, %luB logical sectors (2^%lu), "
+          "%luB physical sectors\n",
+          Frontend->TargetId,
+          DiskInfo->BlkifSectorCount,
+          BLKIF_SECTOR_SIZE,
+          DiskInfo->SectorSize,
+          DiskInfo->SectorShift,
+          DiskInfo->PhysSectorSize);
+    Trace("Target[%d] : %d %s (%08x)\n",
+          Frontend->TargetId,
+          __Size(&Frontend->DiskInfo),
+          __Units(&Frontend->DiskInfo),
+          DiskInfo->DiskInfo);
 }
=20
 static FORCEINLINE VOID
@@ -1590,9 +1617,12 @@ FrontendDebugCallback(
=20
     XENBUS_DEBUG(Printf,
                  &Frontend->DebugInterface,
-                 "DiskInfo: %llu @ %u (%u) %08x\n",
-                 Frontend->DiskInfo=2ESectorCount,
+                 "DiskInfo: %llu %luB blocks, %luB logical sectors (2^%lu=
), "
+                 "%luB physical sectors, info %08x\n",
+                 Frontend->DiskInfo=2EBlkifSectorCount,
+                 BLKIF_SECTOR_SIZE,
                  Frontend->DiskInfo=2ESectorSize,
+                 Frontend->DiskInfo=2ESectorShift,
                  Frontend->DiskInfo=2EPhysSectorSize,
                  Frontend->DiskInfo=2EDiskInfo);
 }
@@ -1814,7 +1844,7 @@ FrontendCreate(
     Frontend->TargetId =3D TargetId;
     Frontend->DeviceId =3D strtoul(DeviceId, NULL, 10);
     Frontend->State =3D XENVBD_INITIALIZED;
-    Frontend->DiskInfo=2ESectorSize =3D 512; // default sector size
+    Frontend->DiskInfo=2ESectorSize =3D BLKIF_SECTOR_SIZE; // default sec=
tor size
     Frontend->BackendDomain =3D DOMID_INVALID;
=20
     Frontend->MaxQueues =3D DriverGetMaxQueues();
diff --git a/src/xenvbd/frontend=2Eh b/src/xenvbd/frontend=2Eh
index dc7b55f=2E=2E3c304f0 100644
--- a/src/xenvbd/frontend=2Eh
+++ b/src/xenvbd/frontend=2Eh
@@ -35,6 +35,10 @@
=20
 #include <ntddk=2Eh>
=20
+// This is the fixed size, in bytes, of a sector used in the blkif protoc=
ol=2E
+#define BLKIF_SECTOR_SHIFT      9
+#define BLKIF_SECTOR_SIZE       (1U << BLKIF_SECTOR_SHIFT)
+
 typedef enum _XENVBD_STATE {
     XENVBD_STATE_INVALID,
     XENVBD_INITIALIZED, // -> { CLOSED }
@@ -65,8 +69,12 @@ typedef struct _XENVBD_FEATURES {
 } XENVBD_FEATURES, *PXENVBD_FEATURES;
=20
 typedef struct _XENVBD_DISKINFO {
-    ULONG64                     SectorCount;
+    // each "sector" here is of size BLKIF_SECTOR_SIZE
+    ULONG64                     BlkifSectorCount;
+    // logical sector size as used by Windows for addressing
     ULONG                       SectorSize;
+    // log2(sector size / BLKIF_SECTOR_SIZE)
+    ULONG                       SectorShift;
     ULONG                       PhysSectorSize;
     ULONG                       DiskInfo;
 } XENVBD_DISKINFO, *PXENVBD_DISKINFO;
diff --git a/src/xenvbd/ring=2Ec b/src/xenvbd/ring=2Ec
index 1e8f761=2E=2E2a4eb56 100644
--- a/src/xenvbd/ring=2Ec
+++ b/src/xenvbd/ring=2Ec
@@ -125,6 +125,8 @@ struct _XENVBD_RING {
 #define RING_POOL_TAG               'gnRX'
 #define XEN_IO_PROTO_ABI            "x86_64-abi"
=20
+#define SECTORS_PER_PAGE            ((ULONG)(PAGE_SIZE / BLKIF_SECTOR_SIZ=
E))
+
 static FORCEINLINE PVOID
 __RingAllocate(
     IN  ULONG                       Length
@@ -181,15 +183,6 @@ __StatName(
     }
 }
=20
-static FORCEINLINE ULONG
-__SectorsPerPage(
-    IN  ULONG   SectorSize
-    )
-{
-    ASSERT3U(SectorSize, !=3D , 0);
-    return PAGE_SIZE / SectorSize;
-}
-
 static FORCEINLINE VOID
 __Operation(
     IN  UCHAR       CdbOp,
@@ -213,7 +206,6 @@ __Operation(
=20
 static FORCEINLINE ULONG
 __UseIndirect(
-    IN  ULONG           SectorsPerPage,
     IN  ULONG           MaxIndirectSegs,
     IN  ULONG           SectorsLeft
     )
@@ -221,7 +213,7 @@ __UseIndirect(
     if (MaxIndirectSegs <=3D BLKIF_MAX_SEGMENTS_PER_REQUEST)
         return BLKIF_MAX_SEGMENTS_PER_REQUEST; // not supported
=20
-    if (SectorsLeft < BLKIF_MAX_SEGMENTS_PER_REQUEST * SectorsPerPage)
+    if (SectorsLeft < BLKIF_MAX_SEGMENTS_PER_REQUEST * SECTORS_PER_PAGE)
         return BLKIF_MAX_SEGMENTS_PER_REQUEST; // first into a single BLK=
IF_OP_{READ/WRITE}
=20
     return MaxIndirectSegs;
@@ -646,7 +638,6 @@ BlkifRingPrepareSegment(
     PXENVBD_ADAPTER         Adapter =3D TargetGetAdapter(Target);
=20
     const ULONG             SectorSize =3D FrontendGetDiskInfo(Ring->Fron=
tend)->SectorSize;
-    const ULONG             SectorsPerPage =3D __SectorsPerPage(SectorSiz=
e);
=20
     Pfn =3D AdapterGetNextSGEntry(Adapter,
                                 SrbExt,
@@ -658,11 +649,11 @@ BlkifRingPrepareSegment(
         InterlockedIncrement(&Ring->Stats[XENVBD_STAT_SEGMENTS_GRANTED]);
=20
         // get first sector, last sector and count
-        Segment->FirstSector =3D (UCHAR)((Offset + SectorSize - 1) / Sect=
orSize);
-        *SectorsNow =3D __min(SectorsLeft, SectorsPerPage - Segment->Firs=
tSector);
+        Segment->FirstSector =3D (UCHAR)((Offset + BLKIF_SECTOR_SIZE - 1)=
 / BLKIF_SECTOR_SIZE);
+        *SectorsNow =3D __min(SectorsLeft, SECTORS_PER_PAGE - Segment->Fi=
rstSector);
         Segment->LastSector =3D (UCHAR)(Segment->FirstSector + *SectorsNo=
w - 1);
=20
-        ASSERT3U((Length / SectorSize), =3D=3D , *SectorsNow);
+        ASSERT3U((Length / BLKIF_SECTOR_SIZE), =3D=3D , *SectorsNow);
     } else {
         PXENVBD_BOUNCE      Bounce;
         PMDL                Mdl;
@@ -672,7 +663,7 @@ BlkifRingPrepareSegment(
=20
         // get first sector, last sector and count
         Segment->FirstSector =3D 0;
-        *SectorsNow =3D __min(SectorsLeft, SectorsPerPage);
+        *SectorsNow =3D __min(SectorsLeft, SECTORS_PER_PAGE);
         Segment->LastSector =3D (UCHAR)(*SectorsNow - 1);
=20
         Bounce =3D AdapterGetBounce(Adapter);
@@ -693,7 +684,7 @@ BlkifRingPrepareSegment(
         Mdl->ByteOffset =3D Offset;
         Bounce->SourcePfn[0] =3D Pfn;
=20
-        if (Length < *SectorsNow * SectorSize) {
+        if (Length < *SectorsNow * BLKIF_SECTOR_SIZE) {
             Pfn =3D AdapterGetNextSGEntry(Adapter,
                                         SrbExt,
                                         Length,
@@ -705,9 +696,9 @@ BlkifRingPrepareSegment(
         }
 #pragma warning(pop)
=20
-        ASSERT((Mdl->ByteCount & (SectorSize - 1)) =3D=3D 0);
+        ASSERT((Mdl->ByteCount & (BLKIF_SECTOR_SIZE - 1)) =3D=3D 0);
         ASSERT3U(Mdl->ByteCount, <=3D , PAGE_SIZE);
-        ASSERT3U(*SectorsNow, =3D=3D , (Mdl->ByteCount / SectorSize));
+        ASSERT3U(*SectorsNow, =3D=3D , (Mdl->ByteCount / BLKIF_SECTOR_SIZ=
E));
=20
         Bounce->SourcePtr =3D MmMapLockedPagesSpecifyCache(Mdl,
                                                          KernelMode,
@@ -753,15 +744,13 @@ BlkifRingPrepareReadWrite(
     PXENVBD_RING            Ring =3D BlkifRing->Ring;
     PXENVBD_FRONTEND        Frontend =3D Ring->Frontend;
     PSCSI_REQUEST_BLOCK     Srb =3D SrbExt->Srb;
-    ULONG64                 SectorStart =3D Cdb_LogicalBlock(Srb);
-    ULONG                   SectorsLeft =3D Cdb_TransferBlock(Srb);
     UCHAR                   Operation;
     BOOLEAN                 ReadOnly;
     LIST_ENTRY              List;
-
-    const ULONG             SectorSize =3D FrontendGetDiskInfo(Frontend)-=
>SectorSize;
-    const ULONG             SectorsPerPage =3D __SectorsPerPage(SectorSiz=
e);
     const ULONG             MaxIndirect =3D FrontendGetFeatures(Frontend)=
->Indirect;
+    const ULONG             SectorShift =3D FrontendGetDiskInfo(Frontend)=
->SectorShift;
+    ULONG64                 SectorStart =3D Cdb_LogicalBlock(Srb) << Sect=
orShift;
+    ULONG                   SectorsLeft =3D Cdb_TransferBlock(Srb) << Sec=
torShift;
=20
     InitializeListHead(&List);
=20
@@ -784,9 +773,7 @@ BlkifRingPrepareReadWrite(
=20
         Request->SrbExt =3D SrbExt;
=20
-        MaxSegments =3D __UseIndirect(SectorsPerPage,
-                                    MaxIndirect,
-                                    SectorsLeft);
+        MaxSegments =3D __UseIndirect(MaxIndirect, SectorsLeft);
=20
         Request->Operation =3D Operation;
         Request->NrSegments =3D 0;
@@ -857,11 +844,14 @@ BlkifRingPrepareUnmap(
     IN  PXENVBD_SRBEXT      SrbExt
     )
 {
+    PXENVBD_RING            Ring =3D BlkifRing->Ring;
+    PXENVBD_FRONTEND        Frontend =3D Ring->Frontend;
     PSCSI_REQUEST_BLOCK     Srb =3D SrbExt->Srb;
     PUNMAP_LIST_HEADER      Unmap =3D Srb->DataBuffer;
     ULONG                   Count;
     ULONG                   Index;
     LIST_ENTRY              List;
+    const ULONG             SectorShift =3D FrontendGetDiskInfo(Frontend)=
->SectorShift;
=20
     InitializeListHead(&List);
=20
@@ -873,6 +863,8 @@ BlkifRingPrepareUnmap(
     for (Index =3D 0; Index < Count; ++Index) {
         PUNMAP_BLOCK_DESCRIPTOR Descr =3D &Unmap->Descriptors[Index];
         PXENVBD_REQUEST         Request;
+        ULONG64                 FirstSector;
+        ULONG                   NrSectors;
=20
         Request =3D BlkifRingGetRequest(BlkifRing);
         if (Request =3D=3D NULL)
@@ -880,10 +872,13 @@ BlkifRingPrepareUnmap(
         InsertTailList(&List, &Request->ListEntry);
         SrbExt->RequestCount++;
=20
+        FirstSector =3D _byteswap_uint64(*(PULONG64)Descr->StartingLba) <=
< SectorShift;
+        NrSectors =3D _byteswap_ulong(*(PULONG)Descr->LbaCount) << Sector=
Shift;
+
         Request->SrbExt =3D SrbExt;
         Request->Operation =3D BLKIF_OP_DISCARD;
-        Request->FirstSector =3D _byteswap_uint64(*(PULONG64)Descr->Start=
ingLba);
-        Request->NrSectors =3D _byteswap_ulong(*(PULONG)Descr->LbaCount);
+        Request->FirstSector =3D FirstSector;
+        Request->NrSectors =3D NrSectors;
         Request->Flags =3D 0;
     }
=20
@@ -909,6 +904,7 @@ BlkifRingPrepareSyncCache(
     PXENVBD_REQUEST         Request;
     UCHAR                   Operation;
     LIST_ENTRY              List;
+    const ULONG             SectorShift =3D FrontendGetDiskInfo(Frontend)=
->SectorShift;
=20
     InitializeListHead(&List);
     Srb->SrbStatus =3D SRB_STATUS_PENDING;
@@ -928,7 +924,7 @@ BlkifRingPrepareSyncCache(
=20
     Request->SrbExt =3D SrbExt;
     Request->Operation =3D Operation;
-    Request->FirstSector =3D Cdb_LogicalBlock(Srb);
+    Request->FirstSector =3D Cdb_LogicalBlock(Srb) << SectorShift;
=20
     BlkifRingQueueRequests(BlkifRing, &List);
     return STATUS_SUCCESS;
diff --git a/src/xenvbd/target=2Ec b/src/xenvbd/target=2Ec
index 102e8b8=2E=2E128ae63 100644
--- a/src/xenvbd/target=2Ec
+++ b/src/xenvbd/target=2Ec
@@ -218,6 +218,7 @@ TargetReadWrite(
     PXENVBD_SRBEXT          SrbExt =3D Srb->SrbExtension;
     PXENVBD_FRONTEND        Frontend =3D Target->Frontend;
     PXENVBD_RING            Ring =3D FrontendGetRing(Frontend);
+    PXENVBD_DISKINFO        DiskInfo =3D FrontendGetDiskInfo(Target->Fron=
tend);
     ULONG64                 SectorCount;
     ULONG64                 SectorStart;
     ULONG                   NumSectors;
@@ -227,14 +228,14 @@ TargetReadWrite(
         goto fail1;
=20
     // disallow writes to read-only disks
-    if (FrontendGetDiskInfo(Frontend)->DiskInfo & VDISK_READONLY &&
+    if (DiskInfo->DiskInfo & VDISK_READONLY &&
         Cdb_OperationEx(Srb) =3D=3D SCSIOP_WRITE)
         goto fail2;
=20
     // check Sectors requested is on the disk
-    SectorCount =3D FrontendGetDiskInfo(Frontend)->SectorCount;
-    SectorStart =3D Cdb_LogicalBlock(Srb);
-    NumSectors =3D Cdb_TransferBlock(Srb);
+    SectorCount =3D DiskInfo->BlkifSectorCount;
+    SectorStart =3D Cdb_LogicalBlock(Srb) << DiskInfo->SectorShift;
+    NumSectors =3D Cdb_TransferBlock(Srb) << DiskInfo->SectorShift;
=20
     if (SectorStart >=3D SectorCount)
         goto fail3;
@@ -560,7 +561,7 @@ TargetReadCapacity(
     if (Cdb_PMI(Srb) =3D=3D 0 && Cdb_LogicalBlock(Srb) !=3D 0)
         goto fail3;
=20
-    SectorCount =3D DiskInfo->SectorCount;
+    SectorCount =3D DiskInfo->BlkifSectorCount >> DiskInfo->SectorShift;
     SectorSize =3D DiskInfo->SectorSize;
=20
     if (SectorCount =3D=3D (ULONG)SectorCount)
@@ -611,7 +612,7 @@ TargetReadCapacity16(
     if (Cdb_PMI(Srb) =3D=3D 0 && Cdb_LogicalBlock(Srb) !=3D 0)
         goto fail3;
=20
-    SectorCount =3D DiskInfo->SectorCount;
+    SectorCount =3D DiskInfo->BlkifSectorCount >> DiskInfo->SectorShift;
     SectorSize =3D DiskInfo->SectorSize;
     PhysSectorSize =3D DiskInfo->PhysSectorSize;
=20
--=20
2=2E54=2E0=2Ewindows=2E1



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.30.7304d5f1cdddfc3d.19dd35475f6.65125494cfbb0a43=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:03:46 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:03:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295488.1572150 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM6-0006bP-OT; Tue, 28 Apr 2026 09:03:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295488.1572150; Tue, 28 Apr 2026 09:03:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM6-0006b6-GT; Tue, 28 Apr 2026 09:03:46 +0000
Received: by outflank-mailman (input) for mailman id 1295488;
 Tue, 28 Apr 2026 09:03:45 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547850000f373@swg.vates.tech>)
 id 1wHeM5-0006Yd-N8
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:03:45 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeM5-00446K-3C
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:03:45 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547850000f373@swg.vates.tech>)
 id 69f077f1-e002-0a2a0a5209dd-0a2a4509df18-0
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:45 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547850000f373@swg.vates.tech>)
 id 69f077ef-2497-0a2a45090019-b9ff1c22a143-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:44 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3547850000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:03:41 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 3728786263;
 Tue, 28 Apr 2026 11:03:41 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=fXMB9Z1ytw8m9Vr74wZsjKFWKRFVGAex4ehyO8xUXO8=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=YcK7bbIPG7PVzEOZku8plrefZNKlh7XVrQ5TczGxRjQGb9BHncB+eMBsXoBzeZNvuP+XeLllE
 Ds1ly1+wcwRL/Y/U8r+Mr59KfQifx/USx6wp916rae8LGAR/LZ1qSoiCgu74FPay/bVejj89efA
 6dSiuvubo0VUSBBftkLUDWisRKiT8y6zlosUu1f/qoWUtWtMXeMFlPKN8ZkAL0HCPB8M/Bx2dnc
 Gsv71FFxPPOMCR5Hpai89yXH3Xi0dn0on57YTEh32cDGEkEAUYpnwWbXJZkAITTjDPBGwXF+UB6
 duA+hJUbSAZLdkRAnjCRoEHAJx1MHBBiZHk+RPtIjDrA==
X-Zone-Loop: 3cef411bf5a5a299354adb7e7c1bbad5c254338fa4dd
x-campaign-type: default
x-transaction-id: fc3bd7f6-acf2-4402-b854-1bce9623e46c
x-swg-uid: 01-152ca249-8d9b-417d-b9b1-d7bd451df665
X-Mailer: Sweego
Message-ID:
 <1777367021.8631fc262581453bbf619ec5b2062170.19dd3547850000f373@vates.tech>
x-swg-bid: 1777367021.8631fc262581453bbf619ec5b2062170.19dd3547850000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 4/6] Centralize VBD extent checking
Date: Tue, 28 Apr 2026 11:03:33 +0200
In-Reply-To: <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
References: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
 <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.31.5f42af79e2b01ed1.19dd35476ef.e851d1a9eabeaf97=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777367021295
X-purgate-ID: tlsNG-bad1c0/1777367024-410B3A53-9CCEB19C/0/0
X-purgate-type: clean
X-purgate-size: 7600

---=Part.31.5f42af79e2b01ed1.19dd35476ef.e851d1a9eabeaf97=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Introduce a DiskInfoIsValidExtent function that checks if a LBA range
is within the virtual disk's sector count=2E

Replace the inlined checks in target=2Ec and ring=2Ec with this function=
=2E

Add an extent check in TargetSyncCache=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xenvbd/frontend=2Eh | 26 ++++++++++++++++++++++++++
 src/xenvbd/ring=2Ec     | 18 +++++++++++-------
 src/xenvbd/target=2Ec   | 32 +++++++++++++++++---------------
 3 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/src/xenvbd/frontend=2Eh b/src/xenvbd/frontend=2Eh
index 3c304f0=2E=2E6c7665d 100644
--- a/src/xenvbd/frontend=2Eh
+++ b/src/xenvbd/frontend=2Eh
@@ -34,6 +34,7 @@
 #define _XENVBD_FRONTEND_H
=20
 #include <ntddk=2Eh>
+#include <limits=2Eh>
=20
 // This is the fixed size, in bytes, of a sector used in the blkif protoc=
ol=2E
 #define BLKIF_SECTOR_SHIFT      9
@@ -175,4 +176,29 @@ FRONTEND_GET_PROPERTY(DiskInfo, PXENVBD_DISKINFO)
=20
 #undef FRONTEND_GET_PROPERTY
=20
+static inline BOOLEAN
+DiskInfoIsValidExtent(
+    _In_ PXENVBD_DISKINFO   DiskInfo,
+    _In_ ULONG64            StartLBA,
+    _In_ ULONG64            CountLBA
+    )
+{
+    ULONG64                 BlkifSectorStart;
+    ULONG64                 BlkifSectorEnd;
+
+    if (StartLBA > (ULLONG_MAX >> DiskInfo->SectorShift) ||
+        CountLBA > (ULLONG_MAX >> DiskInfo->SectorShift))
+        return FALSE;
+
+    BlkifSectorStart =3D StartLBA << DiskInfo->SectorShift;
+    BlkifSectorEnd =3D BlkifSectorStart + (CountLBA << DiskInfo->SectorSh=
ift);
+    if (BlkifSectorEnd < BlkifSectorStart)
+        return FALSE;
+
+    if (BlkifSectorEnd > DiskInfo->BlkifSectorCount)
+        return FALSE;
+
+    return TRUE;
+}
+
 #endif // _XENVBD_FRONTEND_H
diff --git a/src/xenvbd/ring=2Ec b/src/xenvbd/ring=2Ec
index 2a4eb56=2E=2E10ca6ee 100644
--- a/src/xenvbd/ring=2Ec
+++ b/src/xenvbd/ring=2Ec
@@ -846,12 +846,12 @@ BlkifRingPrepareUnmap(
 {
     PXENVBD_RING            Ring =3D BlkifRing->Ring;
     PXENVBD_FRONTEND        Frontend =3D Ring->Frontend;
+    PXENVBD_DISKINFO        DiskInfo =3D FrontendGetDiskInfo(Frontend);
     PSCSI_REQUEST_BLOCK     Srb =3D SrbExt->Srb;
     PUNMAP_LIST_HEADER      Unmap =3D Srb->DataBuffer;
     ULONG                   Count;
     ULONG                   Index;
     LIST_ENTRY              List;
-    const ULONG             SectorShift =3D FrontendGetDiskInfo(Frontend)=
->SectorShift;
=20
     InitializeListHead(&List);
=20
@@ -863,8 +863,8 @@ BlkifRingPrepareUnmap(
     for (Index =3D 0; Index < Count; ++Index) {
         PUNMAP_BLOCK_DESCRIPTOR Descr =3D &Unmap->Descriptors[Index];
         PXENVBD_REQUEST         Request;
-        ULONG64                 FirstSector;
-        ULONG                   NrSectors;
+        ULONG64                 StartLBA;
+        ULONG                   CountLBA;
=20
         Request =3D BlkifRingGetRequest(BlkifRing);
         if (Request =3D=3D NULL)
@@ -872,19 +872,23 @@ BlkifRingPrepareUnmap(
         InsertTailList(&List, &Request->ListEntry);
         SrbExt->RequestCount++;
=20
-        FirstSector =3D _byteswap_uint64(*(PULONG64)Descr->StartingLba) <=
< SectorShift;
-        NrSectors =3D _byteswap_ulong(*(PULONG)Descr->LbaCount) << Sector=
Shift;
+        StartLBA =3D _byteswap_uint64(*(PULONG64)Descr->StartingLba);
+        CountLBA =3D _byteswap_ulong(*(PULONG)Descr->LbaCount);
+
+        if (!DiskInfoIsValidExtent(DiskInfo, StartLBA, CountLBA))
+            goto fail2;
=20
         Request->SrbExt =3D SrbExt;
         Request->Operation =3D BLKIF_OP_DISCARD;
-        Request->FirstSector =3D FirstSector;
-        Request->NrSectors =3D NrSectors;
+        Request->FirstSector =3D StartLBA << DiskInfo->SectorShift;
+        Request->NrSectors =3D CountLBA << DiskInfo->SectorShift;
         Request->Flags =3D 0;
     }
=20
     BlkifRingQueueRequests(BlkifRing, &List);
     return STATUS_SUCCESS;
=20
+fail2:
 fail1:
     BlkifRingUnprepareRequest(BlkifRing, &List);
     SrbExt->RequestCount =3D 0;
diff --git a/src/xenvbd/target=2Ec b/src/xenvbd/target=2Ec
index 128ae63=2E=2Ece688f5 100644
--- a/src/xenvbd/target=2Ec
+++ b/src/xenvbd/target=2Ec
@@ -218,10 +218,7 @@ TargetReadWrite(
     PXENVBD_SRBEXT          SrbExt =3D Srb->SrbExtension;
     PXENVBD_FRONTEND        Frontend =3D Target->Frontend;
     PXENVBD_RING            Ring =3D FrontendGetRing(Frontend);
-    PXENVBD_DISKINFO        DiskInfo =3D FrontendGetDiskInfo(Target->Fron=
tend);
-    ULONG64                 SectorCount;
-    ULONG64                 SectorStart;
-    ULONG                   NumSectors;
+    PXENVBD_DISKINFO        DiskInfo =3D FrontendGetDiskInfo(Frontend);
=20
     Srb->SrbStatus =3D SRB_STATUS_ERROR;
     if (!FrontendGetCaps(Frontend)->Connected)
@@ -232,21 +229,15 @@ TargetReadWrite(
         Cdb_OperationEx(Srb) =3D=3D SCSIOP_WRITE)
         goto fail2;
=20
-    // check Sectors requested is on the disk
-    SectorCount =3D DiskInfo->BlkifSectorCount;
-    SectorStart =3D Cdb_LogicalBlock(Srb) << DiskInfo->SectorShift;
-    NumSectors =3D Cdb_TransferBlock(Srb) << DiskInfo->SectorShift;
-
-    if (SectorStart >=3D SectorCount)
+    Srb->SrbStatus =3D SRB_STATUS_INVALID_REQUEST;
+    if (!DiskInfoIsValidExtent(DiskInfo,
+                               Cdb_LogicalBlock(Srb),
+                               Cdb_TransferBlock(Srb)))
         goto fail3;
-    if ((SectorStart + NumSectors) > SectorCount)
-        goto fail4;
=20
     Srb->SrbStatus =3D SRB_STATUS_PENDING;
     return RingQueueRequest(Ring, SrbExt);
=20
-fail4:
-     Error("fail4\n");
 fail3:
     Error("fail3\n");
 fail2:
@@ -265,14 +256,21 @@ TargetSyncCache(
     PXENVBD_SRBEXT          SrbExt =3D Srb->SrbExtension;
     PXENVBD_FRONTEND        Frontend =3D Target->Frontend;
     PXENVBD_RING            Ring =3D FrontendGetRing(Frontend);
+    PXENVBD_DISKINFO        DiskInfo =3D FrontendGetDiskInfo(Frontend);
=20
     Srb->SrbStatus =3D SRB_STATUS_ERROR;
     if (!FrontendGetCaps(Frontend)->Connected)
         goto fail1;
=20
-    if (FrontendGetDiskInfo(Frontend)->DiskInfo & VDISK_READONLY)
+    if (DiskInfo->DiskInfo & VDISK_READONLY)
         goto fail2;
=20
+    Srb->SrbStatus =3D SRB_STATUS_INVALID_REQUEST;
+    if (!DiskInfoIsValidExtent(DiskInfo,
+                               Cdb_LogicalBlock(Srb),
+                               Cdb_TransferBlock(Srb)))
+        goto fail3;
+
     // If neither FLUSH or BARRIER is supported, just succceed the SRB
     if (!(FrontendGetFeatures(Frontend)->FlushCache ||
           FrontendGetFeatures(Frontend)->Barrier))
@@ -285,6 +283,8 @@ succeed:
     Srb->SrbStatus =3D SRB_STATUS_SUCCESS;
     return FALSE; // not-queued
=20
+fail3:
+    Error("fail3\n");
 fail2:
     Error("fail2\n");
 fail1:
@@ -309,6 +309,8 @@ TargetUnmap(
     if (FrontendGetDiskInfo(Frontend)->DiskInfo & VDISK_READONLY)
         goto fail2;
=20
+    // Extents are checked in BlkifRingPrepareUnmap=2E
+
     if (!FrontendGetFeatures(Frontend)->Discard)
         goto succeed;
=20
--=20
2=2E54=2E0=2Ewindows=2E1



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.31.5f42af79e2b01ed1.19dd35476ef.e851d1a9eabeaf97=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:03:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:03:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295489.1572155 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM8-0006fS-Qu; Tue, 28 Apr 2026 09:03:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295489.1572155; Tue, 28 Apr 2026 09:03:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM8-0006fJ-Is; Tue, 28 Apr 2026 09:03:48 +0000
Received: by outflank-mailman (input) for mailman id 1295489;
 Tue, 28 Apr 2026 09:03:47 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547940000f373@swg.vates.tech>)
 id 1wHeM7-0006dz-3a
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:03:47 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeM4-00Fr8K-Ui
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:03:46 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547940000f373@swg.vates.tech>)
 id 69f077f1-2eae-0a2a0a5409dd-0a2a4509df1a-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:46 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547940000f373@swg.vates.tech>)
 id 69f077ef-2497-0a2a45090019-b9ff1c22a143-5
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:46 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3547940000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:03:41 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 6F41486291;
 Tue, 28 Apr 2026 11:03:41 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=wUdF6PP9ST5ZCB5UhmxzxqyQrX/v7I3lhjS8iNrMWks=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=ivABF9uqxWIlz+JW9HW8l83Um1J18ZDrYy8VMdqY5AlYyqcGC+tuaWZ0+JtqHWVkKjxpFaxRd
 AVV8wZbc0KOatCocDkIVZvpQ/IgB4oQ73trzFtIPIF1ObN4f/bmTv5yG7gpmdXBDPfQ/C3avbiH
 7xpwJ+nKIP7+Pgt9TrJAe470b3IPIWPJF+0atVTnY1shyxoh/vUvtC9GS0kTl3Z+ruqnPa18y9k
 X/6U8o2wjony6yM/HI/v3D4H+ztSeL7YbaIKJC3pf3olp+QV6hVhO+N48fIcGTn7OAvcM0Hnc2g
 aBN/OuX49EFLpfYZJQl927n6wMG5L5uhtsYF5VQ7MFHQ==
X-Zone-Loop: 5aacd333fa8a5c4f3ec3719e9bb95de2434a63d8ac4e
x-campaign-type: default
x-transaction-id: 5810b58c-0ce7-4219-bf4e-d7b53bf432e0
x-swg-uid: 01-e3241f33-70e3-4c12-805a-18f3db9d642e
X-Mailer: Sweego
Message-ID:
 <1777367021.8631fc262581453bbf619ec5b2062170.19dd3547940000f373@vates.tech>
x-swg-bid: 1777367021.8631fc262581453bbf619ec5b2062170.19dd3547940000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 5/6] xencrsh: Stop reporting feature-large-sector-size
Date: Tue, 28 Apr 2026 11:03:34 +0200
In-Reply-To: <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
References: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
 <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.32.e5dfafc371535d19.19dd35477d5.5d97763458990d72=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777367021526
X-purgate-ID: tlsNG-bad1c0/1777367026-92573A53-A64F8345/0/0
X-purgate-type: clean
X-purgate-size: 1276

---=Part.32.e5dfafc371535d19.19dd35477d5.5d97763458990d72=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

This feature is deprecated and incompatible with blkif=2Eh revision
221f2748e8da=2E It must be removed before moving towards using 512B
sectors=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xencrsh/frontend=2Ec | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/src/xencrsh/frontend=2Ec b/src/xencrsh/frontend=2Ec
index 0b9e46b=2E=2E32ba1df 100644
--- a/src/xencrsh/frontend=2Ec
+++ b/src/xencrsh/frontend=2Ec
@@ -670,11 +670,6 @@ __WriteRing(
         if (!NT_SUCCESS(Status))
             goto abort;
=20
-        Status =3D StoreWrite(Transaction, Frontend->FrontendPath,
-                        "feature-large-sector-size", "1");
-        if (!NT_SUCCESS(Status))
-            goto abort;
-
         Status =3D StoreWrite(Transaction, Frontend->FrontendPath,
                         "multi-queue-num-queues", "1");
         if (!NT_SUCCESS(Status))
--=20
2=2E54=2E0=2Ewindows=2E1



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.32.e5dfafc371535d19.19dd35477d5.5d97763458990d72=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:03:48 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:03:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295490.1572157 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM8-0006fm-Rc; Tue, 28 Apr 2026 09:03:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295490.1572157; Tue, 28 Apr 2026 09:03:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHeM8-0006fW-KJ; Tue, 28 Apr 2026 09:03:48 +0000
Received: by outflank-mailman (input) for mailman id 1295490;
 Tue, 28 Apr 2026 09:03:47 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547a3f000f373@swg.vates.tech>)
 id 1wHeM7-0006e2-94
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:03:47 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHeM5-00Fr8K-44
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:03:46 +0200
Received: from [10.42.69.9] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547a3f000f373@swg.vates.tech>)
 id 69f077f1-2eae-0a2a0a5409dd-0a2a4509df1a-6
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:46 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd3547a3f000f373@swg.vates.tech>)
 id 69f077ef-2497-0a2a45090019-b9ff1c22a143-6
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:03:46 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd3547a3f000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:03:42 +0000
Received: from localhost.localdomain (155.223.66.37.rev.sfr.net
 [37.66.223.155]) (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id AA00D862B6;
 Tue, 28 Apr 2026 11:03:41 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=+AvUidCgw37VZNy652VzrjBBixuYHkB59nQ5C0rJBl8=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=gcVQt1X0KiCCymkSrsWZl0njRFD6u8sVSpL9tZD66ppjJSBgD0VmG4uSdb/gfCNJpkFv7qHTO
 raKOLAU9F8d7jRF3pU3zN//k0QIw93RUPkPEcCZnutMQm1yK+EBDxhzzvwqOB0yyq6fyY3Xtnj5
 4+7Eo4qnNT5CtqUh+xXYCDtE/rh1oTghu/2c35rKC1vQa/mn1PF3LOk+1pipivdWMBYnD9G3QSh
 /9sDUcgqCbQqO9fi9lvGQdD5aP6dCVHUkHFTD29fusMh8u7CT1bxVqtngGuVLQ/GgA7I23KPy12
 u6FF9qBQOqfjMCqbrqwy05917lEtw4JqATUO9xJDTlRg==
X-Zone-Loop: 1e8c63b530a1477be03b3182a8584087698210ea65be
x-campaign-type: default
x-transaction-id: 9ef5e0da-540e-4a36-999a-9c0979d47ad6
x-swg-uid: 01-bad76093-7802-4aaa-bb99-f1546e419bd0
X-Mailer: Sweego
Message-ID:
 <1777367022.8631fc262581453bbf619ec5b2062170.19dd3547a3f000f373@vates.tech>
x-swg-bid: 1777367022.8631fc262581453bbf619ec5b2062170.19dd3547a3f000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh <ngoc-tu.dinh@vates.tech>,
	Owen Smith <owen.smith@citrix.com>
Subject: [PATCH 6/6] xencrsh: Align blkif protocol values to 512B sectors
Date: Tue, 28 Apr 2026 11:03:35 +0200
In-Reply-To: <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
References: <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
 <20260428090337.463-1-ngoc-tu.dinh@vates.tech>
MIME-Version: 1.0
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.33.877be38f5a96aa0f.19dd35478cd.e80b897797271c3e=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777367021773
X-purgate-ID: tlsNG-bad1c0/1777367026-91969A53-8367DE50/0/0
X-purgate-type: clean
X-purgate-size: 13245

---=Part.33.877be38f5a96aa0f.19dd35478cd.e80b897797271c3e=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

With the deprecation of feature-large-sector-size, blkif=2Eh now specifies
that all sector amounts in the protocol are in 512B units=2E

Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
---
 src/xencrsh/frontend=2Ec |  25 ++++++----
 src/xencrsh/frontend=2Eh |  10 +++-
 src/xencrsh/pdo=2Ec      | 103 +++++++++++++++++++++++++++--------------
 3 files changed, 92 insertions(+), 46 deletions(-)

diff --git a/src/xencrsh/frontend=2Ec b/src/xencrsh/frontend=2Ec
index 32ba1df=2E=2E0cb4dd6 100644
--- a/src/xencrsh/frontend=2Ec
+++ b/src/xencrsh/frontend=2Ec
@@ -523,22 +523,29 @@ __ReadDiskInfo(
     Status =3D StoreRead(NULL, Frontend->BackendPath,=20
                         "sectors", &Buffer);
     if (NT_SUCCESS(Status)) {
-        Frontend->SectorCount =3D _strtoui64(Buffer, NULL, 10);
+        Frontend->BlkifSectorCount =3D _strtoui64(Buffer, NULL, 10);
         AustereFree(Buffer);
         Updated =3D TRUE;
     }
=20
-    if (Frontend->SectorCount =3D=3D 0) {
-        LogError("Invalid SectorCount!\n");
+    if (Frontend->BlkifSectorCount =3D=3D 0) {
+        LogError("Invalid BlkifSectorCount!\n");
     }
-    if (Frontend->SectorSize =3D=3D 0) {
+    if (Frontend->SectorSize < BLKIF_SECTOR_SIZE ||
+        (Frontend->SectorSize & (Frontend->SectorSize - 1)) !=3D 0) {
         LogError("Invalid SectorSize!\n");
+        Frontend->SectorSize =3D BLKIF_SECTOR_SIZE;
     }
+    BitScanForward(&Frontend->SectorShift, Frontend->SectorSize);
+    Frontend->SectorShift -=3D BLKIF_SECTOR_SHIFT;
     if (Updated) {
-        LogVerbose("DiskInfo: %08x, %lld sectors of %d bytes (%lld KB or =
%lld MB)\n",=20
-                    Frontend->DiskInfo, Frontend->SectorCount, Frontend->=
SectorSize,=20
-                    (Frontend->SectorSize * Frontend->SectorCount) / 1024=
,
-                    (Frontend->SectorSize * Frontend->SectorCount) / (102=
4 * 1024));
+        LogVerbose("DiskInfo: %llu %luB blocks, %luB logical sectors (2^%=
lu), "
+                   "info %08x\n",
+                   Frontend->BlkifSectorCount,
+                   BLKIF_SECTOR_SIZE,
+                   Frontend->SectorSize,
+                   Frontend->SectorShift,
+                   Frontend->DiskInfo);
     }
     if (Frontend->DiskInfo & VDISK_READONLY) {
         LogWarning("DiskInfo contains VDISK_READONLY flag!\n");
@@ -919,7 +926,7 @@ FrontendCreate(
     Frontend->TargetId =3D TargetId;
     Frontend->DeviceId =3D strtoul(DeviceId, NULL, 10);
     Frontend->State =3D XENVBD_INITIALIZED;
-    Frontend->SectorSize =3D 512; // default value
+    Frontend->SectorSize =3D BLKIF_SECTOR_SIZE; // default value
=20
     Frontend->FrontendPath =3D DriverFormat("device/vbd/%s", DeviceId);
     if (Frontend->FrontendPath =3D=3D NULL)
diff --git a/src/xencrsh/frontend=2Eh b/src/xencrsh/frontend=2Eh
index 2e2c305=2E=2E5b0030a 100644
--- a/src/xencrsh/frontend=2Eh
+++ b/src/xencrsh/frontend=2Eh
@@ -39,6 +39,10 @@
 #include "pdo=2Eh"
 #include "ring=2Eh"
=20
+// This is the fixed size, in bytes, of a sector used in the blkif protoc=
ol=2E
+#define BLKIF_SECTOR_SHIFT      9
+#define BLKIF_SECTOR_SIZE       (1U << BLKIF_SECTOR_SHIFT)
+
 typedef enum _XENVBD_STATE {
     XENVBD_STATE_INVALID,
     XENVBD_INITIALIZED,
@@ -69,8 +73,12 @@ typedef struct _XENVBD_FRONTEND {
     BOOLEAN                     DumpFile;
=20
     // Disk Info
+    // each "sector" here is of size BLKIF_SECTOR_SIZE
+    ULONG64                     BlkifSectorCount;
+    // logical sector size as used by Windows for addressing
     ULONG                       SectorSize;
-    ULONG64                     SectorCount;
+    // log2(sector size / BLKIF_SECTOR_SIZE)
+    ULONG                       SectorShift;
     ULONG                       DiskInfo;
=20
     // Inquiry
diff --git a/src/xencrsh/pdo=2Ec b/src/xencrsh/pdo=2Ec
index 76c4d59=2E=2E0335205 100644
--- a/src/xencrsh/pdo=2Ec
+++ b/src/xencrsh/pdo=2Ec
@@ -32,6 +32,8 @@
=20
 #include "pdo=2Eh"
=20
+#include <limits=2Eh>
+
 #include "driver=2Eh"
 #include "fdo=2Eh"
 #include "frontend=2Eh"
@@ -53,6 +55,8 @@
 #include "assert=2Eh"
 #include "util=2Eh"
=20
+#define SECTORS_PER_PAGE            ((ULONG)(PAGE_SIZE / BLKIF_SECTOR_SIZ=
E))
+
 typedef struct _XENVBD_SG_INDEX {
     ULONG       Index;
     ULONG       Offset;
@@ -305,13 +309,6 @@ static FORCEINLINE ULONG __SectorSize(
     ASSERT3U(Pdo->Frontend=2ESectorSize, !=3D, 0);
     return Pdo->Frontend=2ESectorSize;
 }
-static FORCEINLINE ULONG __SectorsPerPage(
-    IN  ULONG                   SectorSize
-    )
-{
-    ASSERT3U(SectorSize, !=3D, 0);
-    return PAGE_SIZE / SectorSize;
-}
 static FORCEINLINE VOID
 __Operation(
     IN  UCHAR                   CdbOp,
@@ -402,12 +399,12 @@ PrepareReadWrite(
     PSTOR_SCATTER_GATHER_LIST   SGList;
     XENVBD_SG_INDEX             SGIndex;
=20
-    PXENVBD_SRBEXT  SrbExt =3D GetSrbExt(Srb);
+    PXENVBD_FRONTEND            Frontend =3D &Pdo->Frontend;
+    PXENVBD_SRBEXT              SrbExt =3D GetSrbExt(Srb);
=20
-    const ULONG64   StartSector     =3D Cdb_LogicalBlock(Srb);
-    const ULONG     NumSectors      =3D Cdb_TransferBlock(Srb);
+    const ULONG64   StartSector     =3D Cdb_LogicalBlock(Srb) << Frontend=
->SectorShift;
+    const ULONG     NumSectors      =3D Cdb_TransferBlock(Srb) << Fronten=
d->SectorShift;
     const ULONG     SectorSize      =3D __SectorSize(Pdo);
-    const ULONG     SectorsPerPage  =3D __SectorsPerPage(SectorSize);
     __Operation(Cdb_OperationEx(Srb), &Operation, &ReadOnly);
=20
     SGList =3D StorPortGetScatterGatherList(Pdo->Fdo, Srb);
@@ -439,13 +436,15 @@ PrepareReadWrite(
                 ULONG Type;
=20
                 // get first sector, last sector and count
-                FirstSector =3D (__Offset(PhysAddr) + SectorSize - 1) / S=
ectorSize;
-                SectorsNow  =3D __Min(NumSectors - SectorsDone, SectorsPe=
rPage - FirstSector);
+                FirstSector =3D (__Offset(PhysAddr) + BLKIF_SECTOR_SIZE -=
 1) /
+                    BLKIF_SECTOR_SIZE;
+                SectorsNow  =3D __Min(NumSectors - SectorsDone,
+                                    SECTORS_PER_PAGE - FirstSector);
                 LastSector  =3D FirstSector + SectorsNow - 1;
=20
-                ASSERT3U((PhysLen / SectorSize), =3D=3D, SectorsNow);
-                ASSERT3U((PhysLen & (SectorSize - 1)), =3D=3D, 0);
-              =20
+                ASSERT3U((PhysLen / BLKIF_SECTOR_SIZE), =3D=3D, SectorsNo=
w);
+                ASSERT3U((PhysLen & (BLKIF_SECTOR_SIZE - 1)), =3D=3D, 0);
+
                 // simples - grab Pfn of PhysAddr
                 Pfn         =3D __Pfn(PhysAddr);
=20
@@ -471,7 +470,7 @@ PrepareReadWrite(
=20
                 // get first sector, last sector and count
                 FirstSector =3D 0;
-                SectorsNow  =3D __Min(NumSectors - SectorsDone, SectorsPe=
rPage);
+                SectorsNow  =3D __Min(NumSectors - SectorsDone, SECTORS_P=
ER_PAGE);
                 LastSector  =3D SectorsNow - 1;
=20
                 // map PhysAddr to 1 or 2 pages and lock for VirtAddr
@@ -489,19 +488,19 @@ PrepareReadWrite(
                 Request->Segments[Index2]=2EPfn[0] =3D __Pfn(PhysAddr);
 #pragma warning(pop)
=20
-                if (PhysLen < SectorsNow * SectorSize) {
+                if (PhysLen < SectorsNow * BLKIF_SECTOR_SIZE) {
                     __GetPhysAddr(SGList, &SGIndex, &PhysAddr, &PhysLen);
                     Mdl->Size       +=3D sizeof(PFN_NUMBER);
                     Mdl->ByteCount  =3D Mdl->ByteCount + PhysLen;
                     Request->Segments[Index2]=2EPfn[1] =3D __Pfn(PhysAddr=
);
                 }
=20
-                ASSERT((Mdl->ByteCount & (SectorSize - 1)) =3D=3D 0);
+                ASSERT((Mdl->ByteCount & (BLKIF_SECTOR_SIZE - 1)) =3D=3D =
0);
                 ASSERT3U(Mdl->ByteCount, <=3D, PAGE_SIZE);
-                ASSERT3U(SectorsNow, =3D=3D, (Mdl->ByteCount / SectorSize=
));
-               =20
+                ASSERT3U(SectorsNow, =3D=3D, (Mdl->ByteCount / BLKIF_SECT=
OR_SIZE));
+
                 Length =3D __Min(Mdl->ByteCount, PAGE_SIZE);
-                Buffer =3D MmMapLockedPagesSpecifyCache(Mdl, KernelMode,=
=20
+                Buffer =3D MmMapLockedPagesSpecifyCache(Mdl, KernelMode,
                                         MmCached, NULL, FALSE, HighPagePr=
iority);
                 if (!Buffer) {
                     Pdo->NeedsWake =3D TRUE;
@@ -585,7 +584,7 @@ PrepareSyncCache(
=20
     Request->Operation      =3D Operation;
     Request->NrSegments     =3D 0;
-    Request->FirstSector    =3D Cdb_LogicalBlock(Srb);
+    Request->FirstSector    =3D Cdb_LogicalBlock(Srb) << Pdo->Frontend=2E=
SectorShift;
     Request->NrSectors      =3D 0;
=20
     __UpdateStats(Pdo, Operation);
@@ -743,13 +742,27 @@ PdoCompleteSubmittedRequest(
=20
 static FORCEINLINE BOOLEAN
 __ValidateSectors(
-    IN  ULONG64                 SectorCount,
-    IN  ULONG64                 Start,
-    IN  ULONG                   Length
+    _In_ PXENVBD_FRONTEND   Frontend,
+    _In_ ULONG64            StartLBA,
+    _In_ ULONG64            CountLBA
     )
 {
-    // Deal with overflow
-    return (Start < SectorCount) && ((Start + Length) < SectorCount);
+    ULONG64                 BlkifSectorStart;
+    ULONG64                 BlkifSectorEnd;
+
+    if (StartLBA > (ULLONG_MAX >> Frontend->SectorShift) ||
+        CountLBA > (ULLONG_MAX >> Frontend->SectorShift))
+        return FALSE;
+
+    BlkifSectorStart =3D StartLBA << Frontend->SectorShift;
+    BlkifSectorEnd =3D BlkifSectorStart + (CountLBA << Frontend->SectorSh=
ift);
+    if (BlkifSectorEnd < BlkifSectorStart)
+        return FALSE;
+
+    if (BlkifSectorEnd > Frontend->BlkifSectorCount)
+        return FALSE;
+
+    return TRUE;
 }
 static BOOLEAN
 PdoReadWrite(
@@ -765,8 +778,13 @@ PdoReadWrite(
         return TRUE;
     }
     // check valid sectors
-    if (!__ValidateSectors(Pdo->Frontend=2ESectorCount, Cdb_LogicalBlock(=
Srb), Cdb_TransferBlock(Srb))) {
-        LogTrace("Target[%d] : Invalid Sectors (%lld, %lld, %d)\n", Pdo->=
Frontend=2ETargetId, Pdo->Frontend=2ESectorCount, Cdb_LogicalBlock(Srb), Cd=
b_TransferBlock(Srb));
+    if (!__ValidateSectors(&Pdo->Frontend,
+                           Cdb_LogicalBlock(Srb),
+                           Cdb_TransferBlock(Srb))) {
+        LogTrace("Target[%lu] : Invalid Sectors (%llu, %lu)\n",
+                 Pdo->Frontend=2ETargetId,
+                 Cdb_LogicalBlock(Srb),
+                 Cdb_TransferBlock(Srb));
         Srb->ScsiStatus =3D 0x40; // SCSI_ABORT
         return TRUE; // Complete now
     }
@@ -791,7 +809,18 @@ PdoSyncCache(
         Srb->ScsiStatus =3D 0x40; // SCSI_ABORT;
         return TRUE;
     }
-=20
+    // check valid sectors
+    if (!__ValidateSectors(&Pdo->Frontend,
+                           Cdb_LogicalBlock(Srb),
+                           Cdb_TransferBlock(Srb))) {
+        LogTrace("Target[%lu] : Invalid Sectors (%llu, %lu)\n",
+                 Pdo->Frontend=2ETargetId,
+                 Cdb_LogicalBlock(Srb),
+                 Cdb_TransferBlock(Srb));
+        Srb->ScsiStatus =3D 0x40; // SCSI_ABORT
+        return TRUE; // Complete now
+    }
+
     PrepareSyncCache(Pdo, Srb);
     PdoSubmitPrepared(Pdo);
     return FALSE;
@@ -964,13 +993,14 @@ PdoReadCapacity(
     IN  PSCSI_REQUEST_BLOCK     Srb
     )
 {
+    PXENVBD_FRONTEND        Frontend =3D &Pdo->Frontend;
     PREAD_CAPACITY_DATA     Capacity =3D Srb->DataBuffer;
     ULONG64                 SectorCount;
     ULONG                   SectorSize;
     ULONG                   LastBlock;
-   =20
-    SectorCount =3D Pdo->Frontend=2ESectorCount;
-    SectorSize =3D Pdo->Frontend=2ESectorSize;
+
+    SectorCount =3D Frontend->BlkifSectorCount >> Frontend->SectorShift;
+    SectorSize =3D Frontend->SectorSize;
=20
     if (SectorCount =3D=3D (ULONG)SectorCount)
         LastBlock =3D (ULONG)SectorCount - 1;
@@ -990,12 +1020,13 @@ PdoReadCapacity16(
     IN  PSCSI_REQUEST_BLOCK     Srb
     )
 {
+    PXENVBD_FRONTEND        Frontend =3D &Pdo->Frontend;
     PREAD_CAPACITY_DATA_EX  Capacity =3D Srb->DataBuffer;
     ULONG64                 SectorCount;
     ULONG                   SectorSize;
=20
-    SectorCount =3D Pdo->Frontend=2ESectorCount;
-    SectorSize =3D Pdo->Frontend=2ESectorSize;
+    SectorCount =3D Frontend->BlkifSectorCount >> Frontend->SectorShift;
+    SectorSize =3D Frontend->SectorSize;
=20
     if (Capacity) {
         Capacity->LogicalBlockAddress=2EQuadPart =3D _byteswap_uint64(Sec=
torCount - 1);
--=20
2=2E54=2E0=2Ewindows=2E1



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.33.877be38f5a96aa0f.19dd35478cd.e80b897797271c3e=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:24:36 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:24:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295503.1572170 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHegF-0001WC-DR; Tue, 28 Apr 2026 09:24:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295503.1572170; Tue, 28 Apr 2026 09:24:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHegF-0001W5-AT; Tue, 28 Apr 2026 09:24:35 +0000
Received: by outflank-mailman (input) for mailman id 1295503;
 Tue, 28 Apr 2026 09:24:33 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd367843d000f373@swg.vates.tech>)
 id 1wHegD-0001Vz-Ka
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:24:33 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHegB-00Fvnl-Bz
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:24:32 +0200
Received: from [10.42.69.6] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd367843d000f373@swg.vates.tech>)
 id 69f07cc1-2eae-0a2a0a5409dd-0a2a4506c56e-28
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:24:32 +0200
Received: from [185.255.28.34] (helo=prod-mta-13.swg-srv.net)
 by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from
 <prod-mta-13.8631fc262581453bbf619ec5b2062170.19dd367843d000f373@swg.vates.tech>)
 id 69f07cd0-7371-0a2a45060019-b9ff1c22a43b-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:24:32 +0200
Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr)
 (Authenticated sender:
 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e)
 by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id
 19dd367843d000f373.002 for <win-pv-devel@lists.xenproject.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Tue, 28 Apr 2026 09:24:29 +0000
Received: from [192.168.1.61] (155.223.66.37.rev.sfr.net [37.66.223.155])
 (Authenticated sender: ngoc-tu.dinh@vates.tech)
 by mail2.vates.fr (Postfix) with ESMTPSA id 47FED86200;
 Tue, 28 Apr 2026 11:24:29 +0200 (CEST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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:In-Reply-To:References:Feedback-ID"
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech;
 q=dns/txt; s=selector1; bh=cEnJQ8i0LGsofLp38a+1XS7/sqYlPoXTw6OsfFb19JI=;
 h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id;
 b=IS1V2Y41jRgoGP4tnwVHtPYc/ZsU79smaGh8jxtmZ5XjxVv/fGTv2Bsnm7PooFAaz8bIbxUX2
 AIk2cK0NYXAFrc0aN/0AfizfV/Q5Tq5cZSbZq+362SsboX2TarArImx++HgA6rgEAFsiNCQTqoh
 V3EGfUeaAn0UuLtcNqG16Mhy/Dk3r/a0XRqImAOR7Y9U8XbJMFsgElVE3QUawN7covf6VRxrisT
 62GfWb9BcppbC7e0iqSDLxydDKxHOrLfXuJqcond4h1i9rsgcQ5mR1uoXb9v2BNTtG6Qnts9YW/
 DkSzEo/B+f3NzWEJLLO2EmX3DrwUOgRE90zC28H4oCmw==
X-Zone-Loop: 378e67f23d22b6cbbb10db8f74357253e345fa649c0e
x-campaign-type: default
x-transaction-id: f8da0a00-957e-45c0-af9e-d5c2b195beb5
x-swg-uid: 01-df3a08a9-0996-424d-8dd9-1d2f32525563
X-Mailer: Sweego
Message-ID:
 <1777368269.8631fc262581453bbf619ec5b2062170.19dd367843d000f373@vates.tech>
x-swg-bid: 1777368269.8631fc262581453bbf619ec5b2062170.19dd367843d000f373
Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego
x-campaign-id: default
x-client-id: 8631fc262581453bbf619ec5b2062170
X-Originating-IP: [37.26.189.201]
Date: Tue, 28 Apr 2026 11:24:28 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PATCH] Delete xenbus_monitor.dll
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@citrix.com>
References: <20260414114344.149-1-ngoc-tu.dinh@vates.tech>
Content-Language: en-US
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
In-Reply-To: <20260414114344.149-1-ngoc-tu.dinh@vates.tech>
X-BM-Disclaimer: Yes
Content-Type: multipart/alternative; boundary="-=Part.3d.1f7018768dfda455.19dd3678234.4da63d2f94238d2f=-"
X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2
X-Bm-Transport-Timestamp: 1777368269365
X-purgate-ID: tlsNG-16d1c6/1777368272-CEB75D75-79716425/0/0
X-purgate-type: clean
X-purgate-size: 8168

---=Part.3d.1f7018768dfda455.19dd3678234.4da63d2f94238d2f=-
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,

Just a quick reminder for this patch=2E

Thanks,

On 14/04/2026 13:44, Tu Dinh wrote:
> Now that trace logging is used, the DLL is not needed any more=2E Remove
> it from the build and package=2E
>=20
> Signed-off-by: Tu Dinh <ngoc-tu=2Edinh@vates=2Etech>
> ---
>   src/monitor/messages=2Emc                      | 55 ------------------=
--
>   src/monitor/monitor=2Ec                        |  2 -
>   src/monitor/xenbus_monitor=2Erc                |  1 -
>   vs2019/xenbus_monitor/xenbus_monitor=2Evcxproj | 17 ------
>   vs2022/xenbus_monitor/xenbus_monitor=2Evcxproj | 12 -----
>   5 files changed, 87 deletions(-)
>   delete mode 100644 src/monitor/messages=2Emc
>=20
> diff --git a/src/monitor/messages=2Emc b/src/monitor/messages=2Emc
> deleted file mode 100644
> index eb1d382=2E=2E0000000
> --- a/src/monitor/messages=2Emc
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -; // Copyright (c) Xen Project=2E
> -; // Copyright (c) Cloud Software Group, Inc=2E
> -; // All rights reserved=2E
> -; //
> -; // Redistribution and use in source and binary forms,
> -; // with or without modification, are permitted provided
> -; // that the following conditions are met:
> -; //
> -; // *   Redistributions of source code must retain the above
> -; //     copyright notice, this list of conditions and the
> -; //     following disclaimer=2E
> -; // *   Redistributions in binary form must reproduce the above
> -; //     copyright notice, this list of conditions and the
> -; //     following disclaimer in the documentation and/or other
> -; //     materials provided with the distribution=2E
> -; //
> -; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> -; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
> -; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> -; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> -; // DISCLAIMED=2E IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> -; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> -; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> -; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> -; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> -; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> -; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> -; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> -; // SUCH DAMAGE=2E
> -
> -MessageIdTypedef=3DDWORD
> -
> -SeverityNames=3D(
> -	Success=3D0x0:STATUS_SEVERITY_SUCCESS
> -	Informational=3D0x1:STATUS_SEVERITY_INFORMATIONAL
> -	Warning=3D0x2:STATUS_SEVERITY_WARNING
> -	Error=3D0x3:STATUS_SEVERITY_ERROR
> -	)
> -
> -
> -FacilityNames=3D(
> -	System=3D0x0:FACILITY_SYSTEM
> -	Runtime=3D0x2:FACILITY_RUNTIME
> -	Stubs=3D0x3:FACILITY_STUBS
> -	Io=3D0x4:FACILITY_IO_ERROR_CODE
> -	)
> -
> -MessageId=3D0x1
> -Severity=3DInformational
> -Facility=3DSystem
> -SymbolicName=3DMONITOR_LOG
> -Language=3DEnglish
> -%1
> -=2E
> diff --git a/src/monitor/monitor=2Ec b/src/monitor/monitor=2Ec
> index 9bfb1f6=2E=2E904badd 100644
> --- a/src/monitor/monitor=2Ec
> +++ b/src/monitor/monitor=2Ec
> @@ -47,8 +47,6 @@
>  =20
>   #include <version=2Eh>
>  =20
> -#include "messages=2Eh"
> -
>   #define stringify_literal(_text) #_text
>   #define stringify(_text) stringify_literal(_text)
>   #define __MODULE__ stringify(PROJECT)
> diff --git a/src/monitor/xenbus_monitor=2Erc b/src/monitor/xenbus_monito=
r=2Erc
> index dc2fc19=2E=2Ee771dad 100644
> --- a/src/monitor/xenbus_monitor=2Erc
> +++ b/src/monitor/xenbus_monitor=2Erc
> @@ -54,4 +54,3 @@
>   #define VER_FILESUBTYPE		    VFT2_UNKNOWN
>  =20
>   #include "common=2Ever"
> -#include "messages=2Erc"
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor=2Evcxproj b/vs2019/xen=
bus_monitor/xenbus_monitor=2Evcxproj
> index c9eef03=2E=2E9b20fce 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor=2Evcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor=2Evcxproj
> @@ -18,9 +18,6 @@
>       <EnableInf2cat>false</EnableInf2cat>
>       <SpectreMitigation>Spectre</SpectreMitigation>
>     </PropertyGroup>
> -  <PropertyGroup>
> -    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
> -  </PropertyGroup>
>     <ItemDefinitionGroup>
>       <ClCompile>
>         <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalO=
ptions>
> @@ -55,32 +52,18 @@
>       <ClCompile>
>         <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</Pr=
eprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName)=2Edll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName)=2Eres</Inputs>
> -      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs=
)</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemDefinitionGroup Condition=3D"'$(Platform)'=3D=3D'x64'">
>       <ClCompile>
>         <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</=
PreprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName)=2Edll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName)=2Eres</Inputs>
> -      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs=
)</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemGroup>
>       <FilesToPackage Include=3D"$(TargetPath)" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName)=2Epdb" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName)=2Emap" />
> -    <FilesToPackage Include=3D"$(OutDir)$(TargetName)=2Edll" />
>       <FilesToPackage Include=3D"@(Inf->'%(CopyOutput)')" Condition=3D"'=
@(Inf)'!=3D''" />
>     </ItemGroup>
> -  <ItemGroup>
> -    <MessageCompile Include=3D"=2E=2E\=2E=2E\src\monitor\messages=2Emc"=
 />
> -  </ItemGroup>
>     <ItemGroup>
>       <ClCompile Include=3D"=2E=2E\=2E=2E\src\monitor\monitor=2Ec" />
>     </ItemGroup>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor=2Evcxproj b/vs2022/xen=
bus_monitor/xenbus_monitor=2Evcxproj
> index 1d686df=2E=2E7d30855 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor=2Evcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor=2Evcxproj
> @@ -18,9 +18,6 @@
>       <EnableInf2cat>false</EnableInf2cat>
>       <SpectreMitigation>Spectre</SpectreMitigation>
>     </PropertyGroup>
> -  <PropertyGroup>
> -    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
> -  </PropertyGroup>
>     <ItemDefinitionGroup>
>       <ClCompile>
>         <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalO=
ptions>
> @@ -55,22 +52,13 @@
>       <ClCompile>
>         <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</=
PreprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName)=2Edll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName)=2Eres</Inputs>
> -      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs=
)</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemGroup>
>       <FilesToPackage Include=3D"$(TargetPath)" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName)=2Epdb" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName)=2Emap" />
> -    <FilesToPackage Include=3D"$(OutDir)$(TargetName)=2Edll" />
>       <FilesToPackage Include=3D"@(Inf->'%(CopyOutput)')" Condition=3D"'=
@(Inf)'!=3D''" />
>     </ItemGroup>
> -  <ItemGroup>
> -    <MessageCompile Include=3D"=2E=2E\=2E=2E\src\monitor\messages=2Emc"=
 />
> -  </ItemGroup>
>     <ItemGroup>
>       <ClCompile Include=3D"=2E=2E\=2E=2E\src\monitor\monitor=2Ec" />
>     </ItemGroup>



-- 
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates =
solutions

web: https://vates=2Etech
---=Part.3d.1f7018768dfda455.19dd3678234.4da63d2f94238d2f=---


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 09:54:11 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 09:54:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1295529.1572190 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHf8r-0006dz-WD; Tue, 28 Apr 2026 09:54:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1295529.1572190; Tue, 28 Apr 2026 09:54:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHf8r-0006ds-TZ; Tue, 28 Apr 2026 09:54:09 +0000
Received: by outflank-mailman (input) for mailman id 1295529;
 Tue, 28 Apr 2026 09:54:08 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wHf8q-0006dm-J6
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 09:54:08 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHf8p-008JLD-Kf
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 11:54:07 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f083be-2eae-0a2a0a5409dd-0a2a450c867c-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:54:07 +0200
Received: from [40.107.200.10]
 (helo=CH5PR02CU005.outbound.protection.outlook.com)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f083bd-62f1-0a2a450c0019-286bc80a0798-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 11:54:07 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by MN2PR03MB5165.namprd03.prod.outlook.com (2603:10b6:208:1e4::21)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 28 Apr
 2026 09:54:03 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9846.025; Tue, 28 Apr 2026
 09:54:03 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=s5VZtNL2+pSf/CPSvhnFvwDqfUcyypuvk3MKyuifXRSVEZZiyuAmlaFCYb/bD4nfUNOkf7kWm5zr8BTFFQzIx2CyXl1TCAFjTZvbi0XJ7Mt/IDXsTdVwnKGz6ueU/oqhkyp4+0aySChXdF+yJltmuvtSGBSxj/dJMWuLh1lxzcq+UdG31xK/ueL1SbMFftN2a93Ew2+JySCYh0WDphUWih+UbkaRVzPIfX/cbYOvL761l1/2x1r5ZalZGoTLoArG2DD7y48shM6/37qfpHBsuJNnUjZIpGCp9tms3N2n87f/s/UeexCF/76nk3zwwYVQIlRn3OXrkfax+ir66z1Hag==
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=/X6bCRLQsj+vP9Y/A5gGWgTt3xdHoJ7VVv4c3a9Zdik=;
 b=IYItXSowbezaJwCe14q0ItCjo+MeQtSMn7DJ65eWSvMk/ZbkdoHdx4FwNkbckmgi2CJEhycItnoHIDMPzOuEx9OkLg8ETJwi4RgFiocnADdxEV6eJPc3VW49pmRWd8zj1oa6WcaeIQGZdI6csgIo92wZLuGem79XXIiGH3Ax+4YO2qFAIm4n+CNVTT0dAs+L3ErPaUmjK3JhOExwp3F54RG3OklIymWnrAqfSVbpuS+bigZ1ImxR6vIbnPDpYVRYO22MEaKaNGSmAQg+OMuKU/M8Q0HQImTYtVC+LyGc0F5toi2V6f25iNAotPY+WfIYBn0ts8DnSNVcd9z8UDX4rA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=/X6bCRLQsj+vP9Y/A5gGWgTt3xdHoJ7VVv4c3a9Zdik=;
 b=VUZh7IKi33M+nBHwcI67bRI042621WZOXq/zlkX7l4vueVY2/ZfAxnN0XtiopLtxKe/T3fl/ECVNH6/Wqgpon1dxuGWSYFKfBcIrTcgBE+oHCAbsHtkKPeAU00VsVCvzS63vdRH5uv6Vre+27Coh4sryRs8oDWVmgsALv3RWyU0=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH] Delete xenbus_monitor.dll
Thread-Topic: [PATCH] Delete xenbus_monitor.dll
Thread-Index: AQHczAP7NI3Pmnq7sk+uN4uX9Cz4Q7X0SZcAgAAHyZk=
Date: Tue, 28 Apr 2026 09:54:03 +0000
Message-ID:
 <SA6PR03MB7760E97EE716D477D4629634FE372@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260414114344.149-1-ngoc-tu.dinh@vates.tech>
 <1777368269.8631fc262581453bbf619ec5b2062170.19dd367843d000f373@vates.tech>
In-Reply-To:
 <1777368269.8631fc262581453bbf619ec5b2062170.19dd367843d000f373@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|MN2PR03MB5165:EE_
x-ms-office365-filtering-correlation-id: 9323bc64-8c9a-4b7c-e9be-08dea50c1493
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|366016|1800799024|376014|56012099003|18002099003|22082099003|38070700021;
x-microsoft-antispam-message-info:
 UnpuUu0qS6reqXS6Y2ixMheNLDsgMtSXVW0WJ+W1FKHhwN6uGABhFc8y2TFo+av7ELBn00iNqa5CrkoB6DSSPMU5M3e8umesjna45w5bd6p8CB8VZMd9vnuMs3qG+J9RZYev+CWiuktExrHYpyyPrrj23WvbzmhZFJyT2nxw6wKlhWmxFPiLmFojOZabzRgmD4WHyHbAZFiOGAZ0FFBvYhBqHw6Wh6eWFCqTSIVqXtgXUA5CtgYJpTEG71y98smerSazsORjGRmFWO6Pyw5jJewxVWTcDdWLzfrp7raU+fEq0jzoZMxYmlcIrFgevsyGRY3B0BHhbY/LKPG08EBnEAPnQqWHRuYbE47BBkAbuv6oHlMwJAeBI1Jsh1nY7qn8wCJ0KfcR+zt4+QSTG1T4fmfujQI2FPTablN/9yINcCHGxaa8o2ISs6Sy2zWng/K5j6HIdPjm4lVX3sZvBOq1lEhCInngcVnAXMQ5iQY6B54YmexUaBx463dk8w19RB0XtFItXP/fRZPhYNvzNq+JqrpF7qh8iU9flrMT0QOEPsXsQrRHmMu5AtT+k2zxQNuQXaQ0GVIGG6qYXXEbKpnEXuXlcelAyLzbcaTZc/u42LvIb2HKIosKxqhiQPUPqMWMdOM8MAB1zWy/Cc6Nko1Q6ZWiku2MXIjLdGLGOXJ1a8//XT+10TqVm+kzjB2EFVzcDdeb6uQJZzMzbV/F1WYpCM29xTfQdWWmKhlf6yCABkk=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(56012099003)(18002099003)(22082099003)(38070700021);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?0So4WyhVaOqkCF8DAaW35mTmn7xNDueHaWUoxXPunauPQNCvSM+UZHAjaPB9?=
 =?us-ascii?Q?PEGOvQf9AOveEkQCBHYdr/Wd1mdUT+4yeBB3R4MyhRWfV/sZAkOPfg3hFDs4?=
 =?us-ascii?Q?pHakJwSqvmmsRsI4gkp7frmDhF59LInQtJ/L2lmq7uGCKQr+S6zbzxqKHAFC?=
 =?us-ascii?Q?jiIxTbT1+JQBXdFqEONcdi7EEJtQyuZvzk+c8jcooYpb8AFJi5YeSkwHYA2K?=
 =?us-ascii?Q?rsGV5S1RxQamRtvEfrUKMCHwYd9nu0ywZG14tDfP5TPbBFj6jg1Yu23a1xbV?=
 =?us-ascii?Q?yk+J2UJKZnHRLQcKLrIEgm81lQcdxGBU5z2AWmugWTM0F7rXom0DRFiNFOq2?=
 =?us-ascii?Q?EJHjYxQxqm8WIZl02CAF+Eexj2drGVPird2nzWNEiqtGsUgO0orXdBituATk?=
 =?us-ascii?Q?FlHBX1IiuggCBlWBJEwRBKmgMnWHyNYYIGgR6uuzc7i/9xsGmdcmV0xpw+D6?=
 =?us-ascii?Q?rhW+4p/9erK3mjcur+9MExBHAKWQPpL929f3FRoXVPtCIeFju0tTiGbM4HOW?=
 =?us-ascii?Q?y3xQnYZhookE1CMRtlCb8l0HtBUIdg4tAQ9trx7DwEydxdU3fxwtjYrZWs+J?=
 =?us-ascii?Q?Yt/r5aMYeUbvaGPZ8VGRhlNXCJUtcw8qtoAom/4GOqZFBG+1+9ZBCUHetP+B?=
 =?us-ascii?Q?ogIIOezvB1j9Nx8UhDU6HmPTZ72++d+UFYGEM7J2xYQ4emHJrcs4/gkDyf5x?=
 =?us-ascii?Q?qcPsgmV1Ck4/nzZqZE0Ba6urnA3URg8l0ewHAKseEL/4sGUS/jcEqldFPMvA?=
 =?us-ascii?Q?0SnSpUsJtP49hQXcuMS1rmkk8yZfLX2h97PdwNy+smQ69qIYLXL/jNIvVdmr?=
 =?us-ascii?Q?3rxBnsFIE8YX6MhksoH+RgaMQ+BcD1FrIRIeVIBXWM6qvDPjByq7vbfRAFer?=
 =?us-ascii?Q?/PcLFkmbBj1vHuVlx7LaSkLflypp3N5OOL2VVipKXUwHauaPUU2XK22JMHwD?=
 =?us-ascii?Q?i+9ZrCg8cggAME4pHTEsNnYpaLfu+m3e+VxCJyaGXLxKgIx7Krf3D/JrLxQN?=
 =?us-ascii?Q?zDKjKUtsNXi5eRqCEQbFVCRgwTvqznRPLDa0rJz+rYlhfPcrkozeaoZ+gNYe?=
 =?us-ascii?Q?aWPLY88uJTJCoPyq0M8EdB03LzxKVMOcHXL+P4es6PzohRhDDLVSvKseKL44?=
 =?us-ascii?Q?xRqyZf7P+/Vzfx8oPfgP9XauEnnLOb2GyZdO3vkg4qJhnw89J2wi0Z4fjd2z?=
 =?us-ascii?Q?UOsRNh34exIR24oOW+rdngvSV0HvQa8hT4QCyGgUJ7AVuBU0ZZBdndcRSPNk?=
 =?us-ascii?Q?5W8QCbYfUbc5wY6cDVaIMtFzw2PCmlonLJEBAD4Ia9xYE/3r9E0CgmeKQa+p?=
 =?us-ascii?Q?xk0Futqkue96T5OSP7e5arnS/SLJOcg88rzpQ0Ba2r0GM82Gp524OVOlgX3X?=
 =?us-ascii?Q?TzQhJn5Ipy9/6UX5cYbt8GwrM1S/CfYFYRn8kOqwCBQIuAd/1cXNY/Tjsxl7?=
 =?us-ascii?Q?tDnwrHslyLOj4OU4ZqAsgKy2Qm2iNmIG/TPrWuNp1BjqLVxiJX9u0LT5eBG1?=
 =?us-ascii?Q?4KQ5W7o1sv/Jzy/XSOrNxjKyX2RfnLt6Se+4aORK+gXWoXZ8DAy9ewdzzv8q?=
 =?us-ascii?Q?waUAHcgbHMer1YeFJjTa/W2ohGRGG+mdGtqKKOOW4MTzEf/CmQQg2QBvRSnG?=
 =?us-ascii?Q?JvAWN2pa9Bt4GWCN7JGEZ3CzbvVesDU64NBhrz+KZqdMlgwj5yKszn1HBm8a?=
 =?us-ascii?Q?spo8cqAcBUbtoCcIamaq3kTcoV/7TD4thbEjuAGaGukE7YwTTgmQu3EKrq/1?=
 =?us-ascii?Q?8bmfcrVsWA=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 9323bc64-8c9a-4b7c-e9be-08dea50c1493
X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2026 09:54:03.6487
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 8Fk4JDxjhM8T3uWmGXWgVEWRZH0MvDb8bqjdifHVmH3euQ451NL4FKPZIAsYm2VX2VS9JYw/saY+9tRkdDOYfQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR03MB5165
X-purgate-ID: tlsNG-d25034/1777370047-6F370CF5-4FCA1267/0/0
X-purgate-type: clean
X-purgate-size: 8309

<SpectreMitigation>Spectre</SpectreMitigation> is not present in the curren=
t project files,
which makes the patch not apply.
I have modified the patch to remove these lines from the diff's context, an=
d will apply
the patch

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


________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 28 April 2026 10:24 AM
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith
Subject: Re: [PATCH] Delete xenbus_monitor.dll

Hi,

Just a quick reminder for this patch.

Thanks,

On 14/04/2026 13:44, Tu Dinh wrote:
> Now that trace logging is used, the DLL is not needed any more. Remove
> it from the build and package.
>
> Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
> ---
>   src/monitor/messages.mc                      | 55 --------------------
>   src/monitor/monitor.c                        |  2 -
>   src/monitor/xenbus_monitor.rc                |  1 -
>   vs2019/xenbus_monitor/xenbus_monitor.vcxproj | 17 ------
>   vs2022/xenbus_monitor/xenbus_monitor.vcxproj | 12 -----
>   5 files changed, 87 deletions(-)
>   delete mode 100644 src/monitor/messages.mc
>
> diff --git a/src/monitor/messages.mc b/src/monitor/messages.mc
> deleted file mode 100644
> index eb1d382..0000000
> --- a/src/monitor/messages.mc
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -; // Copyright (c) Xen Project.
> -; // Copyright (c) Cloud Software Group, Inc.
> -; // All rights reserved.
> -; //
> -; // Redistribution and use in source and binary forms,
> -; // with or without modification, are permitted provided
> -; // that the following conditions are met:
> -; //
> -; // *   Redistributions of source code must retain the above
> -; //     copyright notice, this list of conditions and the
> -; //     following disclaimer.
> -; // *   Redistributions in binary form must reproduce the above
> -; //     copyright notice, this list of conditions and the
> -; //     following disclaimer in the documentation and/or other
> -; //     materials provided with the distribution.
> -; //
> -; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
> -; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
> -; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> -; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> -; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
> -; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> -; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
> -; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> -; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> -; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> -; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
> -; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> -; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> -; // SUCH DAMAGE.
> -
> -MessageIdTypedef=3DDWORD
> -
> -SeverityNames=3D(
> -     Success=3D0x0:STATUS_SEVERITY_SUCCESS
> -     Informational=3D0x1:STATUS_SEVERITY_INFORMATIONAL
> -     Warning=3D0x2:STATUS_SEVERITY_WARNING
> -     Error=3D0x3:STATUS_SEVERITY_ERROR
> -     )
> -
> -
> -FacilityNames=3D(
> -     System=3D0x0:FACILITY_SYSTEM
> -     Runtime=3D0x2:FACILITY_RUNTIME
> -     Stubs=3D0x3:FACILITY_STUBS
> -     Io=3D0x4:FACILITY_IO_ERROR_CODE
> -     )
> -
> -MessageId=3D0x1
> -Severity=3DInformational
> -Facility=3DSystem
> -SymbolicName=3DMONITOR_LOG
> -Language=3DEnglish
> -%1
> -.
> diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
> index 9bfb1f6..904badd 100644
> --- a/src/monitor/monitor.c
> +++ b/src/monitor/monitor.c
> @@ -47,8 +47,6 @@
>
>   #include <version.h>
>
> -#include "messages.h"
> -
>   #define stringify_literal(_text) #_text
>   #define stringify(_text) stringify_literal(_text)
>   #define __MODULE__ stringify(PROJECT)
> diff --git a/src/monitor/xenbus_monitor.rc b/src/monitor/xenbus_monitor.r=
c
> index dc2fc19..e771dad 100644
> --- a/src/monitor/xenbus_monitor.rc
> +++ b/src/monitor/xenbus_monitor.rc
> @@ -54,4 +54,3 @@
>   #define VER_FILESUBTYPE                 VFT2_UNKNOWN
>
>   #include "common.ver"
> -#include "messages.rc"
> diff --git a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj b/vs2019/xenbus=
_monitor/xenbus_monitor.vcxproj
> index c9eef03..9b20fce 100644
> --- a/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2019/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -18,9 +18,6 @@
>       <EnableInf2cat>false</EnableInf2cat>
>       <SpectreMitigation>Spectre</SpectreMitigation>
>     </PropertyGroup>
> -  <PropertyGroup>
> -    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
> -  </PropertyGroup>
>     <ItemDefinitionGroup>
>       <ClCompile>
>         <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalOp=
tions>
> @@ -55,32 +52,18 @@
>       <ClCompile>
>         <PreprocessorDefinitions>__i386__;%(PreprocessorDefinitions)</Pre=
processorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName).res</Inputs>
> -      <Command>link -machine:x86 -dll -noentry -out:%(Outputs) %(Inputs)=
</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemDefinitionGroup Condition=3D"'$(Platform)'=3D=3D'x64'">
>       <ClCompile>
>         <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</P=
reprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName).res</Inputs>
> -      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)=
</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemGroup>
>       <FilesToPackage Include=3D"$(TargetPath)" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName).pdb" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName).map" />
> -    <FilesToPackage Include=3D"$(OutDir)$(TargetName).dll" />
>       <FilesToPackage Include=3D"@(Inf->'%(CopyOutput)')" Condition=3D"'@=
(Inf)'!=3D''" />
>     </ItemGroup>
> -  <ItemGroup>
> -    <MessageCompile Include=3D"..\..\src\monitor\messages.mc" />
> -  </ItemGroup>
>     <ItemGroup>
>       <ClCompile Include=3D"..\..\src\monitor\monitor.c" />
>     </ItemGroup>
> diff --git a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj b/vs2022/xenbus=
_monitor/xenbus_monitor.vcxproj
> index 1d686df..7d30855 100644
> --- a/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> +++ b/vs2022/xenbus_monitor/xenbus_monitor.vcxproj
> @@ -18,9 +18,6 @@
>       <EnableInf2cat>false</EnableInf2cat>
>       <SpectreMitigation>Spectre</SpectreMitigation>
>     </PropertyGroup>
> -  <PropertyGroup>
> -    <CustomBuildAfterTargets>Link</CustomBuildAfterTargets>
> -  </PropertyGroup>
>     <ItemDefinitionGroup>
>       <ClCompile>
>         <AdditionalOptions>/ZH:SHA_256 %(AdditionalOptions)</AdditionalOp=
tions>
> @@ -55,22 +52,13 @@
>       <ClCompile>
>         <PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</P=
reprocessorDefinitions>
>       </ClCompile>
> -    <CustomBuildStep>
> -      <Outputs>$(TargetDir)$(TargetName).dll</Outputs>
> -      <Inputs>$(IntDir)$(TargetName).res</Inputs>
> -      <Command>link -machine:x64 -dll -noentry -out:%(Outputs) %(Inputs)=
</Command>
> -    </CustomBuildStep>
>     </ItemDefinitionGroup>
>     <ItemGroup>
>       <FilesToPackage Include=3D"$(TargetPath)" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName).pdb" />
>       <FilesToPackage Include=3D"$(OutDir)$(TargetName).map" />
> -    <FilesToPackage Include=3D"$(OutDir)$(TargetName).dll" />
>       <FilesToPackage Include=3D"@(Inf->'%(CopyOutput)')" Condition=3D"'@=
(Inf)'!=3D''" />
>     </ItemGroup>
> -  <ItemGroup>
> -    <MessageCompile Include=3D"..\..\src\monitor\messages.mc" />
> -  </ItemGroup>
>     <ItemGroup>
>       <ClCompile Include=3D"..\..\src\monitor\monitor.c" />
>     </ItemGroup>



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 12:46:05 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 12:46:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1296147.1572536 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHhpD-0006Zx-Ry; Tue, 28 Apr 2026 12:46:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1296147.1572536; Tue, 28 Apr 2026 12:46:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHhpD-0006Zq-PC; Tue, 28 Apr 2026 12:46:03 +0000
Received: by outflank-mailman (input) for mailman id 1296147;
 Tue, 28 Apr 2026 12:46:02 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wHhpC-0006Zk-4r
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 12:46:02 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHhpB-004tEU-Gm
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 14:46:01 +0200
Received: from [10.42.69.12] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f0abf9-e002-0a2a0a5209dd-0a2a450cad60-46
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 14:46:01 +0200
Received: from [52.101.56.1]
 (helo=BN1PR04CU002.outbound.protection.outlook.com)
 by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f0ac07-62f1-0a2a450c0019-3465380150e0-3
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 14:46:00 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by LV4PR03MB8330.namprd03.prod.outlook.com (2603:10b6:408:2e0::18)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 28 Apr
 2026 12:45:58 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9846.025; Tue, 28 Apr 2026
 12:45:58 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=KkIpWJG9731Pf+wrOVt8AnILtSwE3hlqGdru4S+3g1lx4M+vPcRSrIb91mkR9xoFrhFfe6moZkUe/riBm7dkp6nI/0nLXsBcE3cS3UKEkq4a55oOCoTgQ35eJi7sH7ER1klYxjOV2BV9tmp3Q6zDrTI6UOqnwepvAhEXUvUjVQzDS2i382Y7pfjJMWlQrTOuyvog76zCzwGbouUsLCM6UabBn0dd8m2mC+SOReVCFscNyvxX+BnNS9OvSoB5TtqEFn/9c1jjYQ5teHnC2DIGnkU83wwdpFlG26Mnr20EovG3D2webeU9HJF91zjVacrd2tPEtO47X/H3ZB8YKl+Kew==
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=turBy+HEo71OwAYiZ3pN6I8vYaCOmebbkNTvSTnRMwU=;
 b=Mxl5dRbdoAkV4UZsxZT0owr48I2wLB9WKoU4IozWHnFUeZHeGs/Ai2WyYKyWN4JpfTNP9KfT4Jb67HOi5unEYOndRqbXRtuhN3yVUirJNUqItq0+5QWf1+EtZTECr6MwkLtrnQbl29ePuxJ6fuMjHIZEWv6oaYHAEfxSnB1XsUJ2Ak34r8aGUZnSiBYvzms3vw04zJEAWC0WlGXlTqpxKmUOHz5a1vYETvRvq9ZhpVNElMoji8iCMfbVmBN04ovs24QRnmHx/vQEyOHDsO4fs+d5TgHDzphKuUH1TfGXqirWn2jaFppn74nU1Ap81xDZ+AtGaTGLXGbG5AIbxCg/Ag==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=turBy+HEo71OwAYiZ3pN6I8vYaCOmebbkNTvSTnRMwU=;
 b=Hg3ggevOOA7QalUU47JUuU51+w1LwdkqFFiKC2F4MYHgyzVdpuauUlw8wi85zYHbxtATfxH/QxoO2env3z1clDXmAvu0jKhjktj8p31jorRRGnlIUodWDUCbe7rZ2PA3/0F3snyuLStiKPpleLDFf5UhWo2L8vm/0MkGYkvoA0w=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/2] Remove ASSERT on CacheGet object allocation failure
Thread-Topic: [PATCH 1/2] Remove ASSERT on CacheGet object allocation failure
Thread-Index: AQHc1ueIRqVwa6XF+EmdwmZHnLQLGLX0a0xH
Date: Tue, 28 Apr 2026 12:45:57 +0000
Message-ID:
 <SA6PR03MB77607A3C9D09D9B7379E7B81FE372@SA6PR03MB7760.namprd03.prod.outlook.com>
References:
 <1777364276.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373@vates.tech>
In-Reply-To:
 <1777364276.8631fc262581453bbf619ec5b2062170.19dd32a92fb000f373@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|LV4PR03MB8330:EE_
x-ms-office365-filtering-correlation-id: da3c4076-7bab-4286-04ff-08dea524186d
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|366016|1800799024|38070700021|22082099003|18002099003|56012099003;
x-microsoft-antispam-message-info:
 kKmtvTQeW58d4P+XKd9bCc9B02ENfaNnHUXesBWDDM0enO9a5FEYXvE6Fedccbo+AjoyNolIrORwHSgqSRHabYNF9S4cGD6MKAlEQfdhEwjfhCvdCPkxPeXVD9Eo/C8S7yCWFGi1uN6bn2h91k2KvM90uc+2EtGhRSCSJv2/uGN4+ncqECc2qxeKToUnW9aapXfIBvGMm2PuEhdzu3f5U+Rt7g0qjWxgtUtwFAFQhdiP/AbphszKOc/T2zi1LzbC+OazFiGL2wqsOfVLgK+jQcUT29jlUR3joTktuDKpCJdfrIHQ2zEP9mKyX6sKK7w9kCUhUMDuVp0uT0heSOpNMhv5kl6uRjkjSmz/CTIATpCYaIQ0t7uOXMxFq7752khj/bRPGDeuhdfqWwwLkrrQHP1QZlADrdKbGXxsx6KQxehpdGj/KqDVoy85OLNnbXUkGOaVDAgF/XrVuAdkhNYX8hQJX29RlbGFiI5FZLUUPuzQH4ZqwBku7b9unkD+91brc4vcJPT3HBaHsy3upZM3S0lPWTM01H98Ah+SaoW05wt01/SFPUcOIpIorLeQRV9dtV5VsDSo8nrTE/gZadmehKwypPSHNQ5Lpzpyfq+/uvLi3PyorLOBn3jo2fCFmSeSjS9o+MmANQ5x7kDNQ4g0kfTZrCgRMtYsOnLQ+Ua217/MQ25trAjeZiTJWXq7saZLYj/PpMzJcTVhoF0AFGRjNOb4ECPYmt2Xy/LnYbBsUxM=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?eNmFANGAUFz20F97u7x1DtVaAQytn9i7NttryR0LdHh79d1by4rT2vvVB0iC?=
 =?us-ascii?Q?RyeL10iIH2ITAFV7JSnjzYuSmyfyln9paiXtcyROBZ4PSpQZSNy3Qaka4Ggd?=
 =?us-ascii?Q?tu47ZVyEFADQxtjwfQ8YRKCHd46EsQtm2OQyZwC3uNmeCrdwrop3Gdib5LfB?=
 =?us-ascii?Q?cZcIG9HfRxD6REG13biMzWkEbQMkIqkJ54VuQdH+xhdT4eBN8gXO4sVxqjCF?=
 =?us-ascii?Q?Ec7JWVzdNYuNlPlq/dq+rO7gminn9ZUh4lG0niHkboME5BrUijDf9vCfYoGW?=
 =?us-ascii?Q?syG+SbKdqnhadsbuaK3Q2+v1aAm05LISth/IZgmdD7bCyezNPebo2pOjaFgN?=
 =?us-ascii?Q?dDFcO166/fb8zsUj9/ZE/7xf6vDFwPfDBmPtysXGi86B+MNSyesnCZLdeySd?=
 =?us-ascii?Q?9aTx9IASwhf4qlIRDInnkFYGn/aOCnXt4sB6PnXCFB/DFFU1g4eEQetNc1Qk?=
 =?us-ascii?Q?/mFR5Qvu5KcdKNwlvZAYt4EYEntLvRkkVQLe9VYlIWQXVm/WHqs2NeHGMSzQ?=
 =?us-ascii?Q?BjyydQF2a44auZvPTTnc0W9t0zp+MWNpbGopygCe/+VP7vnJORuIr5XTp23e?=
 =?us-ascii?Q?Ez5dSpYJCD6GzrvtRmD8bJbAraTjSJbQTmyojnBkfHfBX5bM66QV2HGIsjML?=
 =?us-ascii?Q?X58DBSteIGiudBxKjoShZRhYnbh1J32FjdtpZv+MbJoyIRtzQZMNAl1V/ciL?=
 =?us-ascii?Q?kM8BVqmuDtAtEgllMJ6kzuUJmsaJaFmVxI4UDf4YZ1U74a889ape1khY/3AB?=
 =?us-ascii?Q?OXpRaCRDogH7rECr6g3rPe615Z+JdxyGeF38upQ97CU186lKPE6y5H6qgflx?=
 =?us-ascii?Q?cufBckoPUtcgddeOcs7sGqXR0Rxsh0xxSYrLDdCBAIGp1rHKgcYCA/tvzgaz?=
 =?us-ascii?Q?faxYgzwZ38E2zO8kwTUY6STaM8jiG0kXZ8pDdtuP43x6RoCMi8dAxMraE4e8?=
 =?us-ascii?Q?mWJbIP8enYSavOmGyeoVW+Bhwo7CdMKsH2BU79ml7m2Ss9xLvm5RAjDzYk97?=
 =?us-ascii?Q?tWNek6SyMqfZaAvh2om4itMzvkpNxxaJVeRiz0dWK4uqFzuWSW286a3H6o6I?=
 =?us-ascii?Q?EEnZ5X7h0ggHte0LsHEDLcz4OUyDVRMsxArdTdpyH0qkUSjjmSDf91IPwUyS?=
 =?us-ascii?Q?omQ660T0KoJuOcNqvxwxF30BBeVKFTKrsXCeRKwcV/uuED0SvOZdkFKcmMaT?=
 =?us-ascii?Q?+Gy5zlm1briA8k6ANfQFMgBg7aMdtThRRvjeB54e5l682efUAJcZB3ZDW5IO?=
 =?us-ascii?Q?nULUa8O13lu1tjdrKtCMJr+DABa8kBaMep9aCXtTbEIE1oyVs+KWGFczInGq?=
 =?us-ascii?Q?O1b+q7eBGlj0XUNAWtmD1RC/qtk/WshpLPYzUnuyKq2h1AupfTmODib1YuOe?=
 =?us-ascii?Q?hM1mHFUbKpAbp1ljK+5didrMiGRG+31IIG1nkKa87DVZXRU/eXRHve1qW8MX?=
 =?us-ascii?Q?kmkwulpYsp3CBKJlCEfESAuIHw2uABf4BMx+JjIrJRBcFZIOoSPVXUZPziox?=
 =?us-ascii?Q?RV8XaHyfOqsK7T+H47w0mI/ognc/1FKJx1hL/Fk1a0zZdP+hW0GdeGq61VSR?=
 =?us-ascii?Q?F1/SJdlkuV/luOPNKVkeRRs2feDlTFdX1x2S9xksBpXvWxUnqVhdjDzsubFq?=
 =?us-ascii?Q?P9TYk5Z2qMF5flUm8+i7zZDrHwFKssdzN+SzN5M4jNfNTToiGutPhqXC6Eds?=
 =?us-ascii?Q?fs+KNlFTWBxjzyh0GRfPyfMVDPAMpJqRCSprZkcnT6T1zX+W+CScmbqqxo32?=
 =?us-ascii?Q?KNKclE5MTg=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: da3c4076-7bab-4286-04ff-08dea524186d
X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2026 12:45:57.9992
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: MHJCkUU5cqHB/ULYn4SIDka4RlBBMfAmvJsAqbBvXIGE6Mjb+4jKe010HqFiE/ChIk58ysoYOxNriN7KenBhPg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV4PR03MB8330
X-purgate-ID: tlsNG-d25034/1777380361-F5A00CF5-B4D9E1AF/0/0
X-purgate-type: clean
X-purgate-size: 1141

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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 28 April 2026 9:17 AM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH 1/2] Remove ASSERT on CacheGet object allocation failure

When the grant table is exhausted, CacheGetObjectFromSlab can fail and
return NULL. Failing with an assert here prevents the grant exhaustion
from being handled elsewhere.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/cache.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index e61033d..e58e2f9 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -623,7 +623,6 @@ again:
         Slab =3D CONTAINING_RECORD(ListEntry, XENBUS_CACHE_SLAB, ListEntry=
);

         Object =3D CacheGetObjectFromSlab(Slab);
-        ASSERT(Object !=3D NULL);

         //
         // If the slab is now fully occupied, ove the cursor on to the nex=
t
--
2.53.0.windows.2



--
 | Vates

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech


From win-pv-devel-bounces@lists.xenproject.org Tue Apr 28 12:46:09 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 28 Apr 2026 12:46:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1296148.1572540 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHhpJ-0006bl-TU; Tue, 28 Apr 2026 12:46:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1296148.1572540; Tue, 28 Apr 2026 12:46:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wHhpJ-0006be-Qt; Tue, 28 Apr 2026 12:46:09 +0000
Received: by outflank-mailman (input) for mailman id 1296148;
 Tue, 28 Apr 2026 12:46:08 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wHhpI-0006bO-0q
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 12:46:08 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wHhpH-0005LS-CQ
 for win-pv-devel@lists.xenproject.org; Tue, 28 Apr 2026 14:46:07 +0200
Received: from [10.42.69.8] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f0ac0e-5cb7-0a2a0a5109dd-0a2a45089a34-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 14:46:07 +0200
Received: from [40.107.201.33]
 (helo=CH4PR04CU002.outbound.protection.outlook.com)
 by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f0ac0d-63b5-0a2a45080019-286bc9219e7a-4
 for <win-pv-devel@lists.xenproject.org>; Tue, 28 Apr 2026 14:46:06 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by LV4PR03MB8330.namprd03.prod.outlook.com (2603:10b6:408:2e0::18)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 28 Apr
 2026 12:46:04 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9846.025; Tue, 28 Apr 2026
 12:46:04 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=gJxKuu2Aw3Om6HhwEGaIN6TdwG/RFKuCnwCePSneB2SP7Vl41dLsH8qtrV7cCgNIiXEhFz8kY08Oh6geOVKgxXkywEoQIxGdKomsht9USG4bR5XI1hIfXdVzQMkn2rEcAZZWS5mWZWz94U+E9Pgsu53XRBw0+Su9ZCSPQ/AUBaSGl1e13703xaAaFFJSbOn1IA2k5hDtQJpBEaRutvBSiJNfkfiCYQxBMIKIMF54A25TYlHafkNEyuiV8MaJKtmzAMDUgqLJ1+x39qFLwnIUXVE70aB86Ee2ZjpVIbn85y+Fjr1FKjbqeZymUjaVK2pO2aEgjeussSgj/nquwv2ExA==
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=+d/kDsvUKdBV6YJsltCsUdhMY2dR1RywxHL+OObr/Yo=;
 b=Ot1zrUzYgsqw8P2RWDmxIHD7XMhd9G+2R52WuBDvrv0JaRZytFIzLZ+ZLpjogqEgAQKJNagrBduhcv3wSbJ+waUbpo6vCiTa6usFSkwYcgfMsurAIBraockvGztqmjZ19rlhouuxhu3S4xs6CZlwE+DRbuwzMEXIB3YMPSIt2UV/chNcOKNFFb6feZh79dIVOKjqeMlPJFSPcsMBO6GMavmgPurb02lE19Zi/QJr4KgdmsIuT+xU855hRNTzzJMcd35IWAKPtEC4ylxV7DUxIiiCMsv0/vQq5hwNo6Pi1eJKrQpOKEY0C/QHneAvxZkNljNjsLuYdLvopOT/GYax0w==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=+d/kDsvUKdBV6YJsltCsUdhMY2dR1RywxHL+OObr/Yo=;
 b=q36Vc0yPpb9mTFNHL/IGi8dAX/lxLMN65XWL1NYMJTIjlGOeiL7RgmJff4g2BHwaRg9yasNOYcwkJ36i2S983GRP/SAr/UV9wmY4mok1vnWgbnZgidQaW3Xyb2ZuXj4Ozj8nnTbMdS1HckJT2etv6ETF3Hc++P2tWMGbnqLnzK0=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 2/2] Fix the display of GnttabDebugCallback Address
Thread-Topic: [PATCH 2/2] Fix the display of GnttabDebugCallback Address
Thread-Index: AQHc1ueI3XcyNnEkFkOMQnioWaYprbX0bCCL
Date: Tue, 28 Apr 2026 12:46:04 +0000
Message-ID:
 <SA6PR03MB776030295D3B4DF809768916FE372@SA6PR03MB7760.namprd03.prod.outlook.com>
References: <20260428081751.199-1-ngoc-tu.dinh@vates.tech>
 <1777364276.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373@vates.tech>
In-Reply-To:
 <1777364276.8631fc262581453bbf619ec5b2062170.19dd32a93ff000f373@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|LV4PR03MB8330:EE_
x-ms-office365-filtering-correlation-id: 52a4846e-2b40-4318-52ec-08dea5241c2f
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|366016|1800799024|38070700021|22082099003|18002099003|56012099003;
x-microsoft-antispam-message-info:
 1lBY5YKdmcL0rESO6jJ9jbglTzM+0wa45DC61LGkPFUd3QGJryEwcT6X6teX+yo8HjXmhl1NMTQ+2GBjh6wh0pTVCKi5c3r8WqV25ejGrh6lIhI0lax3Qg8nUTKcQh1/FtrWLAbaGVa0tdLo9GRK7MQ0Rvke/n5QdSu8Ig/xDYNPuupt/KOH9X9/EY3U8AefHMzcPRSi0IXLuXOuKKryeIHi7T8ybsIohbGT6vKvSGroASUxt0bhocSnn17IGQxJ1o9Ne3we0k4lQHsp/795d9uK07WtCvn0xvBgOWt3VgHLqrcZ+pfRSfxba+lV9t3TStZ5DLGx24oCxB/+pWQgrw6rXXW6PUDd7zU79LIx+Nhi+C46HiOkebMVlayJUf37HC9BigacAxB40+9beD08YeXry4sJ1Xd+V5fI7xzQ1APr4byslthbnRfuj2K/zyQ5DLq5MVKkJfzvqemJMNrgax2x+0C8WvAOHNYedu5S0thhA2WniRK6OEjU9CLT0V5cEu1U3v6oXPVRAFo8DQfNMh7kPnZN2pZNKCCZryQrq3VJjZzxtz4mmE0xGg9c9lA99JT93ZNbZ/oW2+ewms3w+STeAgB3KEbe6iVCUzcw1mGONN5aF4H4806h/N530xx4DMab6pZEdfcKom5mkBCL5HFoRRWLmMsra/g/QdntzihbHcEncvJeKDSyzaqYXgAOB06T76izlLeNKnQym3tANL5JBF0SC5jEjHu/D+IGxqM=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?D9jT53eDen6AGmOdoSgV5qd9ryW97yGFWIZ3L5gGq+0d3oQnAjusaAftwqbo?=
 =?us-ascii?Q?wEgtV5zuJOYVrTsaQ43QiMK/4/o2XRHHQEiDJWcHU3UpKIC0Y6WR9BRlo2Xz?=
 =?us-ascii?Q?dZ+NhT3rFPuvEFaOzvVLjir9jYKrEKgySjrxdaz7X0eFrmyeMEvPC5Yl0b6y?=
 =?us-ascii?Q?JO0gJHqBlKzy35mPcYz7D/V52UCpNnRsbJhcYii/pTas59TZcXKpFpWGwxX3?=
 =?us-ascii?Q?NKyl1BZSGH3jRQNWnoVJP3Cq1ofmhRIYYhhmEplPTOmxJCA2wrFiK/nekdtc?=
 =?us-ascii?Q?O7IBTNX1G9+kv30xa5FT3ATFFHEEAoFE/yYjCgmStDBF74mAtDOaDSsgv4FW?=
 =?us-ascii?Q?IFR15DqHElz2ropbbTEj7VJmVBDdOmwA4kxF2To0caSSRk5KkrACLSEDxAE+?=
 =?us-ascii?Q?AjzQ8OyvPjLHlicnRjXP0k9QvjQMfy0pT3xh1x7mLW68mVh8e8lZpVfXSyr0?=
 =?us-ascii?Q?deKR41qYJn2ZNHcWsaeIoqSdKn2jlv1FQWja6rVp94fBX9r1A5q9P4er1KnU?=
 =?us-ascii?Q?I+5nh5GELG7vmQHYE15dXkpsMd17fRqp1O4lXTdpaInNQVq0FuJ6rk9oO8ob?=
 =?us-ascii?Q?dI9m4mjfjJQNG6Piy9OFo6zi9M0sjeiHMTW2k+er5K9its63PzE1ZUWzQhyZ?=
 =?us-ascii?Q?76LpGS/v/yNK1P3ZPxaXRC9/PW29vI+PypcyNvuqfsqTnD5Ruus15CpHNdmr?=
 =?us-ascii?Q?TB7bLIVbWqMJFmKT5fKlYySiKMzbJp6nrLphLJGkjkBTYJkJapc4ZUmPHNNB?=
 =?us-ascii?Q?JPjV2MUTAZvwpn0FYCcClu+zMvWZvJgN2w/RhOYK4f+6+YdrcI2Qwh9TVMNW?=
 =?us-ascii?Q?GK1qh2Knta67spn4jiivHSm/SNt6wyJMG1OY3LCEGE+iL/U3TZvlLwdBavtL?=
 =?us-ascii?Q?i4MeOUcAJ2RcoN3z0i+fvkY3N5k0tZOShBF7wJm5efn+mEy5MvwSBIu4GxKD?=
 =?us-ascii?Q?oY4cKUTgYwF+OCWZ3U/XVEcYwlxwfBu6m5W4Jlk5HZuBMft2s4yfAkkjYSLs?=
 =?us-ascii?Q?9QcVRAERTiw7cSaqgC/6qtMbeKC2Dio77+cxL144iV5z8/clrw45OUFSSl8h?=
 =?us-ascii?Q?yl8TsQaU4HeaQtCjEin7MKDxN28Ck1tdr/Tm+i61J62RsiW8C/yPZqiV1/Ia?=
 =?us-ascii?Q?BmfBPCBqJ4kKeLluGqKNazbohGu0+NrNF0R1sXVv7zbnud1pqYy9E7nGDWmN?=
 =?us-ascii?Q?oyLbsEani5UFFOWf8DXQY56owMgcWOb/aAYNjhV0xwFQwL8uhHOJndgATrOP?=
 =?us-ascii?Q?6DNeSIapQU/TmLSNZ1jkbZxZiAgFei2YG6AjEETgdUpsdim1yk3SyslcWONy?=
 =?us-ascii?Q?vAjA5BvoA7+ZW2IeYJBfyi8weti59D/4bbtZIE8dB4ZGr1WM8WitDuy+DZsk?=
 =?us-ascii?Q?XdDOqoNVs01YrzB9ijpAfzZgcpU+xMLjw5W6CcqvbSWq/495pFXOazNsSNv3?=
 =?us-ascii?Q?5XqUD70Yyz5f0sdygxDxXzI4d4eafIBVTGFIwQkZJLrfCEHU9jwAnyFQrUMu?=
 =?us-ascii?Q?9sEwqDbGvijzJ9u8zbwVWIcPDm8bLBhD6K/ySka/0gH1e4cx4dBU2q3UaREd?=
 =?us-ascii?Q?QZPT0nJc/Rv8z++61LH1cgIHYqPBrsVMq0fzDHTXGzU0bXHugyr1262c7x0x?=
 =?us-ascii?Q?pyb1k/Mu30rWFwfFfJxv8OXoTaf7xfteKVL6s3lrvKquirLtJdm+vgE5ttN6?=
 =?us-ascii?Q?4KwINFAUADCz9Rl/deAMFlR2GsUU82Wu3ry8HZF6sty0AaMrQTcjUbD3+Ah2?=
 =?us-ascii?Q?Yd6QvR5JOQ=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 52a4846e-2b40-4318-52ec-08dea5241c2f
X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2026 12:46:04.3225
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: FUjiuHo0nbGNH/2LaDJV1yj6PRAGFGqMHoMRGzmulvZIaqapQ9PgD3DsNCxnTnwmckxAaF02CZwk1SsfUoWimQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV4PR03MB8330
X-purgate-ID: tlsNG-c1860d/1777380367-C2776DB1-B5683013/0/0
X-purgate-type: clean
X-purgate-size: 1183


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

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 28 April 2026 9:17 AM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH 2/2] Fix the display of GnttabDebugCallback Address

PFN_NUMBER is an ULONG and needs to be upcasted first.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@vates.tech>
---
 src/xenbus/gnttab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index ea95edf..71f8ec1 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -816,7 +816,7 @@ GnttabDebugCallback(
         PXENBUS_GNTTAB_FRAME    Frame =3D &Context->Frame[Index];
         PHYSICAL_ADDRESS        Address;

-        Address.QuadPart =3D MmGetMdlPfnArray(Frame->Mdl)[0] << PAGE_SHIFT=
;
+        Address.QuadPart =3D (LONGLONG)MmGetMdlPfnArray(Frame->Mdl)[0] << =
PAGE_SHIFT;

         XENBUS_DEBUG(Printf,
                     &Context->DebugInterface,
--
2.53.0.windows.2



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech


From win-pv-devel-bounces@lists.xenproject.org Wed Apr 29 11:15:50 2026
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 29 Apr 2026 11:15:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.1297219.1573326 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wI2tR-0006Gp-5n; Wed, 29 Apr 2026 11:15:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 1297219.1573326; Wed, 29 Apr 2026 11:15:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1wI2tR-0006Gh-2j; Wed, 29 Apr 2026 11:15:49 +0000
Received: by outflank-mailman (input) for mailman id 1297219;
 Wed, 29 Apr 2026 11:15:47 +0000
Received: from mx.expurgate.net ([195.190.135.10])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <owen.smith@citrix.com>) id 1wI2tP-0006Gb-4P
 for win-pv-devel@lists.xenproject.org; Wed, 29 Apr 2026 11:15:47 +0000
Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp
 id 1wI2tO-00CJtX-ED
 for win-pv-devel@lists.xenproject.org; Wed, 29 Apr 2026 13:15:46 +0200
Received: from [10.42.69.2] (helo=localhost)
 by localhost with ESMTP (eXpurgate MTA 0.9.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f1e85c-2eae-0a2a0a5409dd-0a2a4502e014-20
 for <win-pv-devel@lists.xenproject.org>; Wed, 29 Apr 2026 13:15:46 +0200
Received: from [40.107.209.32]
 (helo=PH8PR06CU001.outbound.protection.outlook.com)
 by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1)
 (envelope-from <owen.smith@citrix.com>)
 id 69f1e860-af86-0a2a45020019-286bd120639b-3
 for <win-pv-devel@lists.xenproject.org>; Wed, 29 Apr 2026 13:15:46 +0200
Received: from SA6PR03MB7760.namprd03.prod.outlook.com (2603:10b6:806:43c::5)
 by SA6PR03MB7926.namprd03.prod.outlook.com (2603:10b6:806:432::21)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.20; Wed, 29 Apr
 2026 11:15:42 +0000
Received: from SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38]) by SA6PR03MB7760.namprd03.prod.outlook.com
 ([fe80::4d5b:a91f:46a3:4b38%7]) with mapi id 15.20.9870.016; Wed, 29 Apr 2026
 11:15:42 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
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"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
 b=Jyi2kZVz6pqRKzx3I60H88gvP0nA0Ei7q0iWuP7UiEOM+UMgIzf0HIPUWQULe81947iBFCOOajhXgkq0b7BsH0BxgEvW53MV2qqCOdqKKxgMOuPUfmpI1EBM3Ph0tRH4M8/DzPmAdAqkFWIhwT+R2hB3GGmQTimmDYTBTqhT7pPUlgYiWnEhOgSPQ5+1QxPcRa/4sI5SFg4xuFHZU+LZdj302fIIq0d4hfv6NFdq214OT8Tn3Ayo5da0YVqc7CzJUaxaIUBSyyBrIhlh+DGhWwws8i0qD/ErUSL3E7KoHll0OkHIGbtXRBEQQCvAvP8Bn8jkmT+kwSirao/WTbx6sg==
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=gxFn+yjPIDU6hiaHvJptH//pBqfSOHqeJ4RbaqttJFA=;
 b=OAU0gItqQA1zmLnB+gx4UQpRCVebqe9fuIcBjGPg0MhWpBNHbZmpioNLtY6C0468GtbcpiZ3QAy8rmwRH0EQIqU1w8PbPzItdRZ/9yIdgqBidkrp7SSUcLlIGyRbTC0eK9eIudu2TOCyVyRMNRPy4KPZFIOLsY2qsLqhLuO65Mm6b16uyQCIWsbCIcWfFtanKX2oecFAKclE/Vq8d0XmRA9cEDFfms+my+BJTcG3j/uDtAAIPpintXE3m4ET5KigKp7VIzzbvdCb3y2LeuFUuEgWKKMbqX2q82CESJ5mzjk5z9BF+YcqCEVW0ACg1KlxfexROldAGLiRsk2TPl1ReA==
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
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com;
 s=selector1;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=gxFn+yjPIDU6hiaHvJptH//pBqfSOHqeJ4RbaqttJFA=;
 b=hX6uOYYAK820NtjDeFBBs/Alh36u45ctCFbt7jVkXSRSf43E/ot3B58DFjHDgRfY3OhVns2BqlAZuVfqSSzF75inJj8TVFcdfj/3pJytn23ZZbiB+fHm9WhyyoEgj1uXBCeOrsJBZoUWlGqkzZ41ZjBqc7eBtxD2RQ7pthdwfvs=
From: Owen Smith <owen.smith@citrix.com>
To: Tu Dinh <ngoc-tu.dinh@vates.tech>, "win-pv-devel@lists.xenproject.org"
	<win-pv-devel@lists.xenproject.org>
Subject: Re: [PATCH 0/6] Align blkif protocol values to 512B sectors
Thread-Topic: [PATCH 0/6] Align blkif protocol values to 512B sectors
Thread-Index: AQHc1u3LxAxR8B3e8E+TWGCXs7r9Q7X14P7r
Date: Wed, 29 Apr 2026 11:15:42 +0000
Message-ID:
 <SA6PR03MB7760AE76F7EEC2F29DC76A7EFE342@SA6PR03MB7760.namprd03.prod.outlook.com>
References:
 <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
In-Reply-To:
 <1777366965.8631fc262581453bbf619ec5b2062170.19dd3539ada000f373@vates.tech>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
msip_labels:
authentication-results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=citrix.com;
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SA6PR03MB7760:EE_|SA6PR03MB7926:EE_
x-ms-office365-filtering-correlation-id: 7054c533-f96c-40bd-1574-08dea5e0a6fa
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam:
 BCL:0;ARA:13230040|376014|366016|1800799024|38070700021|56012099003|18002099003|22082099003;
x-microsoft-antispam-message-info:
 rSlRefY2QK+HoZxVrgKC7nEPFG0Ic7fLolr5Ahnrqg9Ke5H+YWSVIoEXCpSRcY/XB1zK9DILhJyPTpBDHrmyLFISvbMSz5zbuj+Zy5Hlpizj5t0wc1Dv9qJJNC4mMvvVuOFd53cdiRZOFbvcFnr8jDX5poTK9KV1l7tSSQnEtNeF2qmkIIaEZg6a/fv4/f/ZTrguwTEa4JSPI2WlA8FByCsaPuLIeQWImBTAcUqalja6JlRpi03OTb8aT3UNEEfbyKZqDfWe6KgyecYcZNXNi5Sz7KAYSeBfvMlBiCbyIgsEAJ/O6Dp3+2AO4gpHeeFiwFLUim+DmbjHV9UMS1OXXeruYem3/+Ln7M5ctiIaKdJDtDaLV2xXQDxyLO0my4Uladhqo7srOey8VolLk896rQ3RYeS9wxFsDoo378SiuEI5Yiqw8Mi6eyKUuTe2ExaTUGA1jgKnh7bEPvVJqABjCSry5VxjWeBmzaAXwF4CR5cTrz+z7FEUehetxL8DK+P5+8Ny5Bzff5NK4fv0muP4ZGB+x/X+6fBLtQCMT8LJCxJWrpfK38ewkKLqvJZR46oIhBlH/FK1XjwFEd/y23X++XHcsJ5a6F/+7d+xqxpIfRxadKYc9+ReCfSZk357p8in2n1TvrOEPmeG9ouUfrG68SAx/swN/YfftTFf3mDJ+Kj0VviuIRYH7X/zf3UhTeUVGQx/ZktrAn6HJKP8temr4+rwyTyzbyJF1KNmJpzB4FA=
x-forefront-antispam-report:
 CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA6PR03MB7760.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(38070700021)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0:
 =?us-ascii?Q?bcNkvn6lCYDAiheZWG8JgDRTZH8wVIDvD9fXZjbk5EXJ4NpfEtgK6JpfkgSE?=
 =?us-ascii?Q?7CM5OMaRnzLxsBXevP+e4/hd6xZGzQo6G5k+UTx706wFWFXjzReBV6lMkkg3?=
 =?us-ascii?Q?gxhCvU38PXo+MI/ha0OWkNrtwnQ3nUS/vqFiKLKdYGMxzQB9sPH1Fc4B5TBP?=
 =?us-ascii?Q?vEmcjEhH3n5FZK2OPmsInGZJqTxJirDeFDqLI+8Pnq4reUtu4Yd2f/cQb4NN?=
 =?us-ascii?Q?w9QudroaG0PxwbrU3bAXzPBesMFo1EXn++hJAh2lW5vdWIsSIlkZbn6+16mk?=
 =?us-ascii?Q?ft2CIm8BAXZ0LQY2E+G6IJkK9+PG8W9/FbgiTphTm85cwIwD3RdC5R7gSRsX?=
 =?us-ascii?Q?AC8Zr7lKxSFS9vfUK2I1s77Xo8JKYjFy/XufED1fn7CztuITEdsOXnlgEqBi?=
 =?us-ascii?Q?w8dHjBDIU+yu1qrT18OtBhIAqXF2ZswNsHrPdbgDnHuy9BiXzDq6jgGzGKSY?=
 =?us-ascii?Q?kz8QcFrWTe7AY4fjzoQ5fZQbRXqFynvRDD+hiUFe4+jx7lgMwe12ouUR++R6?=
 =?us-ascii?Q?l6F5FzpVsKv7jc5O8ZBoyRpojyTInUde5Y/Nqk0YshhjKCQkhdBYirROw6pp?=
 =?us-ascii?Q?SrBBhxWa40e3clqZcCBRnhYUCUbxKvw5xZGJxku5eQdFWB33FjRboKjFX6ID?=
 =?us-ascii?Q?QPSv0epRYG7ib7v6uWopUG9GX2ZrLKJd/76ZeValct0GQySpSLMyMLwDH7r3?=
 =?us-ascii?Q?6tiRDnpubo9alA8Md7z/iSq3bXNdsQePhHo81Qwp1yEuKL3XoLerEhnZmpPx?=
 =?us-ascii?Q?wg9wxy+gnOmezAHsGORi+rGzBLi5VL0KcX21zumi90H7I53bbKLCejD9mzii?=
 =?us-ascii?Q?PppQ1h0/dMrBVdJwqHxnTL/NhnZl/oxwsBqel9jaD7P4sGcE/hFeFuS2UN12?=
 =?us-ascii?Q?m+hDsqiIRXefvjyoEn+y73KKBB1VPvUD1YxgN6/mbtbogIa3o2EHAnttV4OW?=
 =?us-ascii?Q?shrB/ZgqygGNvbtu/PyPeydaxA7ZWyU5sLS2WWdKcfZUEsYAQAUR6obIB9O2?=
 =?us-ascii?Q?sQIrTbILVufOpUaj5ZcCIX7O1oc805cFCp+4EiO+p7Aj2PiBi6HIphhPr/zh?=
 =?us-ascii?Q?ebuMkfvSKmPM2u3VC7Xx/WyFNS4pTVgigaBu0TbmdzhRf41a+zTT2UOCpnDE?=
 =?us-ascii?Q?HHXeCYUJzKIfYd7hvN6tNNGvofnMmlZTe2aNBx9ySvQmnkzR2gYBqpvznIA1?=
 =?us-ascii?Q?Wt18MLX+CfJFhupiHp6xLRefrZ0UjtTSEVZWiSE8iVq3NLuIbHMpKDjsO5P1?=
 =?us-ascii?Q?n73XJCaUsPcM/kCxyAo9l6Mk8UBoYhP4cVJ3xMsMGe+zA9zuhOfrNaSSOGO4?=
 =?us-ascii?Q?m001FOv90zKb48MhA6mqs9ySeM6DC606HZJqRq/Ru/lKy620KX9JztvtQ/EW?=
 =?us-ascii?Q?xk5W66e/3ILbTvTQ0ARuXzZsJYLSrW4iBI7KUnPn4X9ddZp8q7kAGEOZnYal?=
 =?us-ascii?Q?GErXTOpOV5Pkh+wIHbuuq9bD7LvXIIy98kMjlPiXBv4ATv7WdWnn9p9srFCa?=
 =?us-ascii?Q?y5F9kMUB3v+qR5No+fHWUDsjglhx3m6QhD06tuMRZPNKQLewzMV/d0AZGvkF?=
 =?us-ascii?Q?ygsRRyWryzB3CEUqf2oCqDam9a/3vufhQ7Cd9d+8B6w925lzS+UrWgRw3ynn?=
 =?us-ascii?Q?NS6xxzS1TIuaomFke+ICnF9LPdW5LmDOsIVdQ6FKMsTOzHsjC2n6+6bAyhe/?=
 =?us-ascii?Q?v8VjPFYtCWM42FVkZ6CvjFE4yRjECgwpexBWmruLPNAzSuHQGCLoemxukrCF?=
 =?us-ascii?Q?rmFAhO4IaA=3D=3D?=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: citrix.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SA6PR03MB7760.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 7054c533-f96c-40bd-1574-08dea5e0a6fa
X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Apr 2026 11:15:42.5655
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: vG9HJZx+tkOKEBWbfmTB0x2UX1CRmPIZ81HDwJwM9iuqry6WfehVa6O7wZZsS+s8kGu4Am1J9gBYnUk2ZsJGmQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA6PR03MB7926
X-purgate-ID: tlsNG-720697/1777461346-82374161-38BDF778/0/0
X-purgate-type: clean
X-purgate-size: 1804

This series looks like a good update, and passes basic testing.

Entire series
Reviewed-by: Owen Smith <owen.smith@citrix.com>

________________________________________
From: Tu Dinh <ngoc-tu.dinh@vates.tech>
Sent: 28 April 2026 10:02 AM
To: win-pv-devel@lists.xenproject.org
Cc: Tu Dinh; Owen Smith
Subject: [PATCH 0/6] Align blkif protocol values to 512B sectors

Xen revision 221f2748e8da deprecated feature-large-sector-size and
clarified that all protocol-level sector sizes are based on 512-byte
units. This is the behavior observed on Linux blkback, and deviating
from this will lead to corrupting the virtual disk.

Tested on Linux blkback with a loop device using 4K blocksize. The guest
used a purely emulated disk "xvdz", as QEMU doesn't support more than
512B logical sector size in emulated devices. Note that Qdisk is still
broken wrt. 221f2748e8da.

Tu Dinh (6):
  Update to latest blkif.h
  Stop reporting feature-large-sector-size
  Align blkif protocol values to 512B sectors
  Centralize VBD extent checking
  xencrsh: Stop reporting feature-large-sector-size
  xencrsh: Align blkif protocol values to 512B sectors

 include/xen/io/blkif.h | 103 ++++++++++++++++++++++++++++-------------
 src/xencrsh/frontend.c |  30 ++++++------
 src/xencrsh/frontend.h |  10 +++-
 src/xencrsh/pdo.c      | 103 +++++++++++++++++++++++++++--------------
 src/xenvbd/frontend.c  |  90 +++++++++++++++++++++--------------
 src/xenvbd/frontend.h  |  36 +++++++++++++-
 src/xenvbd/ring.c      |  60 ++++++++++++------------
 src/xenvbd/target.c    |  37 ++++++++-------
 8 files changed, 302 insertions(+), 167 deletions(-)

--
2.54.0.windows.1


--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech


