From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:12 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79646.145061 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzD-0000Y8-Ux; Mon, 01 Feb 2021 09:59:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79646.145061; Mon, 01 Feb 2021 09:59:11 +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 1l6VzD-0000Y0-RM; Mon, 01 Feb 2021 09:59:11 +0000
Received: by outflank-mailman (input) for mailman id 79646;
 Mon, 01 Feb 2021 09:59:10 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzC-0000XP-IJ
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:10 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzC-0007Hc-Ae; Mon, 01 Feb 2021 09:59:10 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzB-00087B-Vi; Mon, 01 Feb 2021 09:59:10 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=P3ckuhnB2A7cu49v59N9hp8ts0y3TvCsCtCQjrfg+Ic=; b=p7s0BZG6NpJ7R3BL3OuuLVKD+
	ka1UyMF3OjJ77FZlB+/Ljrewcf+ZnPxySm2xbqf8Sic3fRyMhmPAIZZEG+f1yCh+wyDa1fr/gZmKA
	KD2WoPzOZjTfPPukZDwyTBoy0/Wpjac96BFGWdyk8x5x5U2/v0yjTp7SV9KB6aHocZfzc=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 1/8] Remove bogus ASSERTion
Date: Mon,  1 Feb 2021 09:58:59 +0000
Message-Id: <20210201095906.10295-2-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

The ASSERT(Index > 0) in DriverQueryId() in XENFILT appears to have started
to fail in Windows 10 2004. It is bogus as it will fail if an underlying
driver passes back an empty buffer from either BusQueryHardwareIDs or
BusQueryCompatibleIDs, yet DriverQueryId() will cope perfectly will in these
circimstances, passing back en empty string to its caller. This patch simply
removes the ASSERT().

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenfilt/driver.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 8f14ec890017..5496a17670d7 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -579,7 +579,6 @@ DriverQueryId(
 
             Index += Length + 1;
         }
-        ASSERT(Index > 0);
 
         Size = (Index + 1) * sizeof (CHAR);
 
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:12 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79645.145057 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzC-0000Xb-So; Mon, 01 Feb 2021 09:59:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79645.145057; Mon, 01 Feb 2021 09:59: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 1l6VzC-0000XU-Py; Mon, 01 Feb 2021 09:59:10 +0000
Received: by outflank-mailman (input) for mailman id 79645;
 Mon, 01 Feb 2021 09:59:09 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzB-0000XK-SD
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:09 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzB-0007HY-K2; Mon, 01 Feb 2021 09:59:09 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzB-00087B-AO; Mon, 01 Feb 2021 09:59: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=ZnXIO9gS471xxYzGMKxgynCfvVeVqI6+xJ3uTqJDT4o=; b=ngHjzohvapDFUzG3E/n+Fhik8x
	0LSx7PKmiJmC6hnenjeBPBT55bTpdZbz8L6IbpbGu0gexOSYEfdxVfvA5kSqzptPNXUUQq3lgWq5J
	Zx4Flu3usLpWp7C7IIta+fuCi2bZ/5fqUQYdPx1OR4zT8EvAtT+qM53aWF7stbeSef2A=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 0/8] More refinement around vcpu_info registration
Date: Mon,  1 Feb 2021 09:58:58 +0000
Message-Id: <20210201095906.10295-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

Patches #1 and #2 are independent fixes for a ASSERTion failures found
during development of the series.

Paul Durrant (8):
  Remove bogus ASSERTion
  Fix ASSERTion failure in FdoDisconnectInterrupt()
  Introduce XENBUS_SHARED_INFO_PROCESSOR to hold per-CPU state
  Allocate SYSTEM_PROCESSOR array up-front
  Create interface to retrieve XEN driver 'Parameters' key
  Make vcpu_info registration conditional on number of vCPUs
  Retire PDO versions 08000009 thru 0800000B
  Add XENBUS_SHARED_INFO method to check whether event upcalls are
    supported

 include/evtchn_interface.h      |  19 +--
 include/gnttab_interface.h      |  17 +--
 include/revision.h              |   6 +-
 include/shared_info_interface.h |  30 +++-
 include/store_interface.h       |  22 +--
 include/xen.h                   |   6 -
 src/xen/driver.c                |  36 ++++-
 src/xen/driver.h                |   5 +
 src/xen/system.c                | 162 ++++++++++-----------
 src/xenbus/evtchn.c             |  50 +++----
 src/xenbus/evtchn_fifo.c        |   5 +-
 src/xenbus/fdo.c                |   2 +
 src/xenbus/gnttab.c             |  28 ----
 src/xenbus/shared_info.c        | 241 ++++++++++++++++++++++++--------
 src/xenbus/store.c              |  33 -----
 src/xenfilt/driver.c            |   1 -
 16 files changed, 359 insertions(+), 304 deletions(-)

-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:12 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79647.145066 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzE-0000YU-2Z; Mon, 01 Feb 2021 09:59:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79647.145066; Mon, 01 Feb 2021 09:59: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 1l6VzD-0000YE-T0; Mon, 01 Feb 2021 09:59:11 +0000
Received: by outflank-mailman (input) for mailman id 79647;
 Mon, 01 Feb 2021 09:59:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzD-0000Xq-3m
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzC-0007Hg-St; Mon, 01 Feb 2021 09:59:10 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzC-00087B-Kg; Mon, 01 Feb 2021 09:59:10 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=jYEPW/sS5inJJwLRA36txdwKyj8oSFpmeJRHmJM39Mg=; b=5ZpyzytOHmGlP1BYKUCI7Qtsx
	QpKT7hnAP12cvIt1Zg1tsf9QYGQRe7D+dxMOiBPMmtX8q6f6Kos/GSjiHp/LFZxpQYXCz9f0r/B+Y
	dlPnraCdmYOwU/McSCF8je5A9PYe+IihAmkG19ip6w9sIYwP1Y41RTiUAnZkzAbrCaFmo=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 2/8] Fix ASSERTion failure in FdoDisconnectInterrupt()
Date: Mon,  1 Feb 2021 09:59:00 +0000
Message-Id: <20210201095906.10295-3-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

Currently the ASSERT(IsZeroMemory(...)) will fail because nothing zeroes
the interrupt count added in commit 162545540cb9 ("Make sure the interrupt
handler for each vCPU is run..."). This patch sets it to zero just after
calling IoDisconnectInterruptEx() (which unhooks FdoInterruptCallback(), where
the count is incremented).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenbus/fdo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 21de8678c959..5bbb70a9bf06 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -2348,6 +2348,8 @@ FdoDisconnectInterrupt(
 
     IoDisconnectInterruptEx(&Disconnect);
 
+    Interrupt->Count = 0;
+
     Interrupt->Line = 0;
     Interrupt->InterruptObject = NULL;
     Interrupt->InterruptMode = 0;
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:13 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79648.145069 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzF-0000ZF-1M; Mon, 01 Feb 2021 09:59:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79648.145069; Mon, 01 Feb 2021 09:59: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 1l6VzE-0000Z8-UV; Mon, 01 Feb 2021 09:59:12 +0000
Received: by outflank-mailman (input) for mailman id 79648;
 Mon, 01 Feb 2021 09:59:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzD-0000Xv-Mo
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzD-0007Hk-Ic; Mon, 01 Feb 2021 09:59:11 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzD-00087B-9u; Mon, 01 Feb 2021 09:59:11 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=dbw3EzIqLFs1MwAkgELi1SEcEBoKIqbJCHL0U2FbX60=; b=0uKPom6hjtNlJABgzU0DNxR/s
	ahU0IBFqlrLMebJ2V11OpW0JOYDv1wWFRcZ8hvhvrP0pmD6SH4uOLqtUSYEae5ASrrWqZf1qIoWJ7
	OGjIXmgO6uWUSBKQmXKC2qDkEtG1zEEaKNI1FF3lwXPXuto1CEfraEet/Rcya7okYDPr0=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 3/8] Introduce XENBUS_SHARED_INFO_PROCESSOR to hold per-CPU state
Date: Mon,  1 Feb 2021 09:59:01 +0000
Message-Id: <20210201095906.10295-4-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

This allows the vcpu_info pointer and vcpu_id to be retrieved once for each
vCPU during SharedInfoAcquire(). It also provides a convenient place to
save the event port that terminated the previous poll (which, for fairness, is
where the next poll starts from).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenbus/shared_info.c | 190 +++++++++++++++++++++++++++------------
 1 file changed, 132 insertions(+), 58 deletions(-)

diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index 9c9f0b4cf3e3..20f07a82d801 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -42,17 +42,24 @@
 #define XENBUS_SHARED_INFO_EVTCHN_PER_SELECTOR     (sizeof (ULONG_PTR) * 8)
 #define XENBUS_SHARED_INFO_EVTCHN_SELECTOR_COUNT   (RTL_FIELD_SIZE(shared_info_t, evtchn_pending) / sizeof (ULONG_PTR))
 
+typedef struct _XENBUS_SHARED_INFO_PROCESSOR {
+    unsigned int    vcpu_id;
+    vcpu_info_t     *Vcpu;
+    ULONG           Port;
+} XENBUS_SHARED_INFO_PROCESSOR, *PXENBUS_SHARED_INFO_PROCESSOR;
+
 struct _XENBUS_SHARED_INFO_CONTEXT {
-    PXENBUS_FDO                 Fdo;
-    KSPIN_LOCK                  Lock;
-    LONG                        References;
-    PHYSICAL_ADDRESS            Address;
-    shared_info_t               *Shared;
-    ULONG                       Port[HVM_MAX_VCPUS];
-    XENBUS_SUSPEND_INTERFACE    SuspendInterface;
-    PXENBUS_SUSPEND_CALLBACK    SuspendCallbackEarly;
-    XENBUS_DEBUG_INTERFACE      DebugInterface;
-    PXENBUS_DEBUG_CALLBACK      DebugCallback;
+    PXENBUS_FDO                     Fdo;
+    KSPIN_LOCK                      Lock;
+    LONG                            References;
+    PHYSICAL_ADDRESS                Address;
+    shared_info_t                   *Shared;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor;
+    ULONG                           ProcessorCount;
+    XENBUS_SUSPEND_INTERFACE        SuspendInterface;
+    PXENBUS_SUSPEND_CALLBACK        SuspendCallbackEarly;
+    XENBUS_DEBUG_INTERFACE          DebugInterface;
+    PXENBUS_DEBUG_CALLBACK          DebugCallback;
 };
 
 #define XENBUS_SHARED_INFO_TAG 'OFNI'
@@ -155,20 +162,22 @@ SharedInfoEvtchnMaskAll(
 
 static BOOLEAN
 SharedInfoUpcallPending(
-    IN  PINTERFACE  Interface,
-    IN  ULONG       Index
+    IN  PINTERFACE                  Interface,
+    IN  ULONG                       Index
     )
 {
-    vcpu_info_t     *Vcpu;
-    UCHAR           Pending;
-    NTSTATUS        status;
+    PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor = &Context->Processor[Index];
+    vcpu_info_t                     *Vcpu;
+    UCHAR                           Pending;
 
-    UNREFERENCED_PARAMETER(Interface);
+    ASSERT3U(Index, <, Context->ProcessorCount);
 
-    status = SystemProcessorVcpuInfo(Index, &Vcpu);
-    if (!NT_SUCCESS(status))
+    if (Processor->Vcpu == NULL)
         return FALSE;
 
+    Vcpu = Processor->Vcpu;
+
     KeMemoryBarrier();
 
     Pending = _InterlockedExchange8((CHAR *)&Vcpu->evtchn_upcall_pending, 0);
@@ -185,37 +194,36 @@ SharedInfoEvtchnPoll(
     )
 {
     PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor = &Context->Processor[Index];
     shared_info_t                   *Shared = Context->Shared;
     unsigned int                    vcpu_id;
     vcpu_info_t                     *Vcpu;
     ULONG                           Port;
     ULONG_PTR                       SelectorMask;
     BOOLEAN                         DoneSomething;
-    NTSTATUS                        status;
 
     DoneSomething = FALSE;
 
-    status = SystemProcessorVcpuId(Index, &vcpu_id);
-    if (!NT_SUCCESS(status))
-        goto done;
+    ASSERT3U(Index, <, Context->ProcessorCount);
 
-    status = SystemProcessorVcpuInfo(Index, &Vcpu);
-    if (!NT_SUCCESS(status))
+    if (Processor->Vcpu == NULL)
         goto done;
 
+    vcpu_id = Processor->vcpu_id;
+    Vcpu = Processor->Vcpu;
+
     KeMemoryBarrier();
 
     SelectorMask = (ULONG_PTR)InterlockedExchangePointer((PVOID *)&Vcpu->evtchn_pending_sel, (PVOID)0);
 
     KeMemoryBarrier();
 
-    Port = Context->Port[vcpu_id];
+    Port = Processor->Port;
 
     while (SelectorMask != 0) {
         ULONG   SelectorBit;
         ULONG   PortBit;
 
-
         SelectorBit = Port / XENBUS_SHARED_INFO_EVTCHN_PER_SELECTOR;
         PortBit = Port % XENBUS_SHARED_INFO_EVTCHN_PER_SELECTOR;
 
@@ -246,7 +254,7 @@ SharedInfoEvtchnPoll(
             Port = 0;
     }
 
-    Context->Port[vcpu_id] = Port;
+    Processor->Port = Port;
 
 done:
     return DoneSomething;
@@ -316,36 +324,35 @@ SharedInfoEvtchnUnmask(
 
 static VOID
 SharedInfoGetTime(
-    IN  PINTERFACE              Interface,
-    OUT PLARGE_INTEGER          Time,
-    OUT PBOOLEAN                Local
+    IN  PINTERFACE                  Interface,
+    OUT PLARGE_INTEGER              Time,
+    OUT PBOOLEAN                    Local
     )
 {
 #define NS_PER_S 1000000000ull
 
-    PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
-    shared_info_t               *Shared;
-    vcpu_info_t                 *Vcpu;
-    ULONG                       WcVersion;
-    ULONG                       TimeVersion;
-    ULONGLONG                   Seconds;
-    ULONGLONG                   NanoSeconds;
-    ULONGLONG                   Timestamp;
-    ULONGLONG                   Tsc;
-    ULONGLONG                   SystemTime;
-    ULONG                       TscSystemMul;
-    CHAR                        TscShift;
-    TIME_FIELDS                 TimeFields;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor = &Context->Processor[0];
+    shared_info_t                   *Shared;
+    vcpu_info_t                     *Vcpu;
+    ULONG                           WcVersion;
+    ULONG                           TimeVersion;
+    ULONGLONG                       Seconds;
+    ULONGLONG                       NanoSeconds;
+    ULONGLONG                       Timestamp;
+    ULONGLONG                       Tsc;
+    ULONGLONG                       SystemTime;
+    ULONG                           TscSystemMul;
+    CHAR                            TscShift;
+    TIME_FIELDS                     TimeFields;
+    KIRQL                           Irql;
 
     // Make sure we don't suspend
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
 
     Shared = Context->Shared;
-
-    status = SystemProcessorVcpuInfo(0, &Vcpu);
-    ASSERT(NT_SUCCESS(status));
+    Vcpu = Processor->Vcpu;
+    ASSERT(Vcpu != NULL);
 
     // Loop until we can read a consistent set of values from the same update
     do {
@@ -554,13 +561,16 @@ SharedInfoDebugCallback(
 
 static NTSTATUS
 SharedInfoAcquire(
-    IN  PINTERFACE              Interface
+    IN  PINTERFACE                  Interface
     )
 {
-    PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
-    PXENBUS_FDO                 Fdo = Context->Fdo;
-    KIRQL                       Irql;
-    NTSTATUS                    status;
+    PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_FDO                     Fdo = Context->Fdo;
+    KIRQL                           Irql;
+    shared_info_t                   *Shared;
+    LONG                            Index;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor;
+    NTSTATUS                        status;
 
     KeAcquireSpinLock(&Context->Lock, &Irql);
 
@@ -602,6 +612,27 @@ SharedInfoAcquire(
     if (!NT_SUCCESS(status))
         goto fail5;
 
+    Context->ProcessorCount = KeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS);
+    Context->Processor = __SharedInfoAllocate(sizeof (XENBUS_SHARED_INFO_PROCESSOR) * Context->ProcessorCount);
+
+    status = STATUS_NO_MEMORY;
+    if (Context->Processor == NULL)
+        goto fail6;
+
+    Shared = Context->Shared;
+
+    for (Index = 0; Index < (LONG)Context->ProcessorCount; Index++) {
+        Processor = &Context->Processor[Index];
+
+        status = SystemProcessorVcpuId(Index, &Processor->vcpu_id);
+        if (!NT_SUCCESS(status))
+            goto fail7;
+
+        status = SystemProcessorVcpuInfo(Index, &Processor->Vcpu);
+        if (!NT_SUCCESS(status) && status != STATUS_NOT_SUPPORTED)
+            goto fail8;
+    }
+
     Trace("<====\n");
 
 done:
@@ -609,6 +640,35 @@ done:
 
     return STATUS_SUCCESS;
 
+fail8:
+    Error("fail8\n");
+
+    Processor->vcpu_id = 0;
+
+fail7:
+    Error("fail7\n");
+
+    while (--Index >= 0) {
+        Processor = &Context->Processor[Index];
+
+        Processor->Vcpu = NULL;
+        Processor->vcpu_id = 0;
+    }
+
+    ASSERT(IsZeroMemory(Context->Processor, sizeof (XENBUS_SHARED_INFO_PROCESSOR) * Context->ProcessorCount));
+    __SharedInfoFree(Context->Processor);
+    Context->Processor = NULL;
+
+fail6:
+    Error("fail6\n");
+
+    Context->ProcessorCount = 0;
+
+    XENBUS_DEBUG(Deregister,
+                 &Context->DebugInterface,
+                 Context->DebugCallback);
+    Context->DebugCallback = NULL;
+
 fail5:
     Error("fail5\n");
 
@@ -648,12 +708,14 @@ fail1:
 
 static VOID
 SharedInfoRelease (
-    IN  PINTERFACE              Interface
+    IN  PINTERFACE                  Interface
     )
 {
-    PXENBUS_SHARED_INFO_CONTEXT Context = Interface->Context;
-    PXENBUS_FDO                 Fdo = Context->Fdo;
-    KIRQL                       Irql;
+    PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_FDO                     Fdo = Context->Fdo;
+    KIRQL                           Irql;
+    LONG                            Index;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor;
 
     KeAcquireSpinLock(&Context->Lock, &Irql);
 
@@ -662,7 +724,19 @@ SharedInfoRelease (
 
     Trace("====>\n");
 
-    RtlZeroMemory(Context->Port, sizeof (ULONG) * HVM_MAX_VCPUS);
+    Index = (LONG)Context->ProcessorCount;
+    while (--Index >= 0) {
+        Processor = &Context->Processor[Index];
+
+        Processor->Port = 0;
+        Processor->Vcpu = NULL;
+        Processor->vcpu_id = 0;
+    }
+
+    ASSERT(IsZeroMemory(Context->Processor, sizeof (XENBUS_SHARED_INFO_PROCESSOR) * Context->ProcessorCount));
+    __SharedInfoFree(Context->Processor);
+    Context->Processor = NULL;
+    Context->ProcessorCount = 0;
 
     XENBUS_DEBUG(Deregister,
                  &Context->DebugInterface,
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:14 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79649.145072 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzG-0000aB-3z; Mon, 01 Feb 2021 09:59:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79649.145072; Mon, 01 Feb 2021 09:59:14 +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 1l6VzF-0000a1-Vy; Mon, 01 Feb 2021 09:59:13 +0000
Received: by outflank-mailman (input) for mailman id 79649;
 Mon, 01 Feb 2021 09:59:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzE-0000Z3-AZ
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzE-0007Ho-7u; Mon, 01 Feb 2021 09:59:12 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzD-00087B-V3; Mon, 01 Feb 2021 09:59: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=HGVj4SUb3xMNpn/O6yzE5cQErJdWC8p9qhqPCcLmryk=; b=Hv5h3WXjYWh0F+EWXqHu78Nsk
	gkC9Q3CWHNFH3FgMkyziuGPZJEnfiveSlz+ai9H6jRA8IRgnCLjYtB/mw6PhomstLfFt95LiYJbml
	jlDDaVXv43E0j0ihE+PjLpGwLcX4dZyjuLv2bTyxnbMYvHaeOS1Bx55wv7TINKNJdiWd4=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 4/8] Allocate SYSTEM_PROCESSOR array up-front
Date: Mon,  1 Feb 2021 09:59:02 +0000
Message-Id: <20210201095906.10295-5-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

Most code uses KeQueryMaximumProcessorCountEx() to determine the number of
CPUs in the system, so remove the one and only caller of
SystemProcessorCount(), remove it from the XEN_API and allocate the array
up-front (also using KeQueryMaximumProcessorCountEx()) rather than growing
it in response to each processor callback.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/xen.h            |   6 ---
 src/xen/system.c         | 110 ++++++++++++++-------------------------
 src/xenbus/evtchn_fifo.c |   5 +-
 3 files changed, 42 insertions(+), 79 deletions(-)

diff --git a/include/xen.h b/include/xen.h
index fd3bb3ebb4b8..e1ed1178f0d2 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -448,12 +448,6 @@ LogRemoveDisposition(
 
 // SYSTEM
 
-XEN_API
-ULONG
-SystemProcessorCount(
-    VOID
-    );
-
 XEN_API
 NTSTATUS
 SystemProcessorVcpuId(
diff --git a/src/xen/system.c b/src/xen/system.c
index 14de3a2de015..5323b3e11b35 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -627,18 +627,6 @@ SystemProcessorTeardown(
     RtlZeroMemory(Processor->Manufacturer, sizeof (Processor->Manufacturer));
 }
 
-static FORCEINLINE ULONG
-__SystemProcessorCount(
-    VOID
-    )
-{
-    PSYSTEM_CONTEXT     Context = &SystemContext;
-
-    KeMemoryBarrier();
-
-    return Context->ProcessorCount;
-}
-
 XEN_API
 NTSTATUS
 SystemProcessorVcpuId(
@@ -651,7 +639,7 @@ SystemProcessorVcpuId(
     NTSTATUS            status;
 
     status = STATUS_UNSUCCESSFUL;
-    if (Cpu >= __SystemProcessorCount())
+    if (Cpu >= Context->ProcessorCount)
         goto fail1;
 
     *vcpu_id = Processor->ProcessorID;
@@ -673,7 +661,7 @@ SystemProcessorVcpuInfo(
     NTSTATUS            status;
 
     status = STATUS_UNSUCCESSFUL;
-    if (Cpu >= __SystemProcessorCount())
+    if (Cpu >= Context->ProcessorCount)
         goto fail1;
 
     ASSERT(*Processor->Registered);
@@ -702,7 +690,7 @@ SystemProcessorRegisterVcpuInfo(
     NTSTATUS            status;
 
     status = STATUS_UNSUCCESSFUL;
-    if (Cpu >= __SystemProcessorCount())
+    if (Cpu >= Context->ProcessorCount)
         goto fail1;
 
     ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
@@ -840,6 +828,7 @@ SystemProcessorChangeCallback(
     NTSTATUS                                    status;
 
     UNREFERENCED_PARAMETER(Argument);
+    UNREFERENCED_PARAMETER(Status);
 
     Cpu = Change->NtNumber;
 
@@ -852,36 +841,9 @@ SystemProcessorChangeCallback(
           ProcessorChangeName(Change->State));
 
     switch (Change->State) {
-    case KeProcessorAddStartNotify: {
-        PSYSTEM_PROCESSOR   Processor;
-        ULONG               ProcessorCount;
-
-        if (Cpu < Context->ProcessorCount)
-            break;
-
-        ProcessorCount = Cpu + 1;
-        Processor = __SystemAllocate(sizeof (SYSTEM_PROCESSOR) *
-                                     ProcessorCount);
-
-        if (Processor == NULL) {
-            *Status = STATUS_NO_MEMORY;
-            break;
-        }
-
-        if (Context->ProcessorCount != 0) {
-            RtlCopyMemory(Processor,
-                          Context->Processor,
-                          sizeof (SYSTEM_PROCESSOR) *
-                          Context->ProcessorCount);
-            __SystemFree(Context->Processor);
-        }
-
-        Context->Processor = Processor;
-        KeMemoryBarrier();
-
-        Context->ProcessorCount = ProcessorCount;
+    case KeProcessorAddStartNotify:
         break;
-    }
+
     case KeProcessorAddCompleteNotify: {
         PSYSTEM_PROCESSOR   Processor;
 
@@ -1007,7 +969,7 @@ SystemDeregisterProcessorChangeCallback(
     KeDeregisterProcessorChangeCallback(Context->ProcessorChangeHandle);
     Context->ProcessorChangeHandle = NULL;
 
-    for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++) {
+    for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) {
         PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
         SystemProcessorDeregisterVcpuInfo(Cpu);
@@ -1020,10 +982,6 @@ SystemDeregisterProcessorChangeCallback(
         ASSERT(IsZeroMemory(Processor, sizeof (SYSTEM_PROCESSOR)));
     }
 
-    __SystemFree(Context->Processor);
-    Context->Processor = NULL;
-    Context->ProcessorCount = 0;
-
     SystemFreeVcpuInfo();
 }
 
@@ -1233,7 +1191,7 @@ SystemCheckProcessors(
     ULONG           Cpu;
     NTSTATUS        status;
 
-    for (Cpu = 0; Cpu < __SystemProcessorCount(); Cpu++)
+    for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++)
     {
         PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
@@ -1271,59 +1229,69 @@ SystemInitialize(
     if (References != 1)
         goto fail1;
 
+    Context->ProcessorCount = KeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS);
+    Context->Processor = __SystemAllocate(sizeof (SYSTEM_PROCESSOR) * Context->ProcessorCount);
+
+    status = STATUS_NO_MEMORY;
+    if (Context->Processor == NULL)
+        goto fail2;
+
     status = SystemGetStartOptions();
     if (!NT_SUCCESS(status))
-        goto fail2;
+        goto fail3;
 
     status = SystemGetVersionInformation();
     if (!NT_SUCCESS(status))
-        goto fail3;
+        goto fail4;
 
     status = SystemGetMemoryInformation();
     if (!NT_SUCCESS(status))
-        goto fail4;
+        goto fail5;
 
     status = SystemGetAcpiInformation();
     if (!NT_SUCCESS(status))
-        goto fail5;
+        goto fail6;
 
     status = SystemRegisterProcessorChangeCallback();
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail7;
 
     status = SystemRegisterPowerStateCallback();
     if (!NT_SUCCESS(status))
-        goto fail7;
+        goto fail8;
 
     status = SystemGetTimeInformation();
     if (!NT_SUCCESS(status))
-        goto fail8;
+        goto fail9;
 
     status = SystemCheckProcessors();
     if (!NT_SUCCESS(status))
-        goto fail9;
+        goto fail10;
 
     return STATUS_SUCCESS;
 
+fail10:
+    Error("fail10\n");
+
 fail9:
     Error("fail9\n");
 
+    SystemDeregisterPowerStateCallback();
+
 fail8:
     Error("fail8\n");
 
-    SystemDeregisterPowerStateCallback();
+    SystemDeregisterProcessorChangeCallback();
 
 fail7:
     Error("fail7\n");
 
-    SystemDeregisterProcessorChangeCallback();
+    __SystemFree(Context->Madt);
+    Context->Madt = NULL;
 
 fail6:
     Error("fail6\n");
 
-    __SystemFree(Context->Madt);
-    Context->Madt = NULL;
-
 fail5:
     Error("fail5\n");
 
@@ -1333,9 +1301,13 @@ fail4:
 fail3:
     Error("fail3\n");
 
+    __SystemFree(Context->Processor);
+
 fail2:
     Error("fail2\n");
 
+    Context->ProcessorCount = 0;
+
 fail1:
     Error("fail1 (%08x)\n", status);
 
@@ -1344,15 +1316,6 @@ fail1:
     return status;
 }
 
-XEN_API
-ULONG
-SystemProcessorCount(
-    VOID
-    )
-{
-    return __SystemProcessorCount();
-}
-
 XEN_API
 PHYSICAL_ADDRESS
 SystemMaximumPhysicalAddress(
@@ -1447,6 +1410,9 @@ SystemTeardown(
 
     Context->MaximumPhysicalAddress.QuadPart = 0;
 
+    __SystemFree(Context->Processor);
+    Context->ProcessorCount = 0;
+
     (VOID) InterlockedDecrement(&Context->References);
 
     ASSERT(IsZeroMemory(Context, sizeof (SYSTEM_CONTEXT)));
diff --git a/src/xenbus/evtchn_fifo.c b/src/xenbus/evtchn_fifo.c
index 475f99de10d7..3b3f4938ed73 100644
--- a/src/xenbus/evtchn_fifo.c
+++ b/src/xenbus/evtchn_fifo.c
@@ -487,6 +487,7 @@ EvtchnFifoAcquire(
 {
     PXENBUS_EVTCHN_FIFO_CONTEXT     Context = (PVOID)_Context;
     KIRQL                           Irql;
+    LONG                            ProcessorCount;
     LONG                            Index;
     PMDL                            Mdl;
     NTSTATUS                        status;
@@ -498,8 +499,10 @@ EvtchnFifoAcquire(
 
     Trace("====>\n");
 
+    ProcessorCount = KeQueryMaximumProcessorCountEx(ALL_PROCESSOR_GROUPS);
+
     Index = 0;
-    while (Index < (LONG)SystemProcessorCount()) {
+    while (Index < ProcessorCount) {
         unsigned int        vcpu_id;
         PFN_NUMBER          Pfn;
         PHYSICAL_ADDRESS    Address;
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:14 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79650.145077 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzG-0000aS-7S; Mon, 01 Feb 2021 09:59:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79650.145077; Mon, 01 Feb 2021 09:59:14 +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 1l6VzG-0000aE-1C; Mon, 01 Feb 2021 09:59:14 +0000
Received: by outflank-mailman (input) for mailman id 79650;
 Mon, 01 Feb 2021 09:59:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzE-0000ZN-Vw
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzE-0007Hs-Rw; Mon, 01 Feb 2021 09:59:12 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzE-00087B-K7; Mon, 01 Feb 2021 09:59: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=I7nApe6Sk4S40Jy9+gAskTjgNAue3vksvvlh/XEfWss=; b=15Mp0OeBWqkBbOOqyJ/XtytDE
	b1ozIXayAL1t4LF8c3OgNW5KoUiYV8x9AdDzsKZ0KNLI7e280YrzarHYb4CDsgTfI0omTbeqSFUrr
	J022SHLrTWHDfx1+V0myjbbQtlnFPO//UOkZb9GZFZEMS7y8uPX1s+KbV4TN3GjdRdLyc=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 5/8] Create interface to retrieve XEN driver 'Parameters' key
Date: Mon,  1 Feb 2021 09:59:03 +0000
Message-Id: <20210201095906.10295-6-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

Subsequent patches will need to query a parameter. This patch simply adds the
interface.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xen/driver.c | 36 ++++++++++++++++++++++++++++++++++--
 src/xen/driver.h |  5 +++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/xen/driver.c b/src/xen/driver.c
index 4670539b488a..3f126eefa8f2 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -60,6 +60,7 @@
 typedef struct _XEN_DRIVER {
     PLOG_DISPOSITION    XenDisposition;
     PLOG_DISPOSITION    QemuDisposition;
+    HANDLE              ParametersKey;
     HANDLE              UnplugKey;
     HANDLE              MemoryKey;
 } XEN_DRIVER, *PXEN_DRIVER;
@@ -94,6 +95,30 @@ __DriverSafeMode(
     return (*InitSafeBootMode > 0) ? TRUE : FALSE;
 }
 
+static FORCEINLINE VOID
+__DriverSetParametersKey(
+    IN  HANDLE  Key
+    )
+{
+    Driver.ParametersKey = Key;
+}
+
+static FORCEINLINE HANDLE
+__DriverGetParametersKey(
+    VOID
+    )
+{
+    return Driver.ParametersKey;
+}
+
+HANDLE
+DriverGetParametersKey(
+    VOID
+    )
+{
+    return __DriverGetParametersKey();
+}
+
 static FORCEINLINE VOID
 __DriverSetUnplugKey(
     IN  HANDLE  Key
@@ -504,6 +529,8 @@ DllInitialize(
     if (!NT_SUCCESS(status))
         goto fail4;
 
+    __DriverSetParametersKey(ParametersKey);
+
     status = LogReadLogLevel(ParametersKey,
                              "XenLogLevel",
                              &LogLevel);
@@ -584,8 +611,6 @@ DllInitialize(
     if (!NT_SUCCESS(status))
         goto fail12;
 
-    RegistryCloseKey(ParametersKey);
-
     RegistryCloseKey(ServiceKey);
 
     Trace("<====\n");
@@ -641,6 +666,7 @@ fail5:
     Driver.XenDisposition = NULL;
 
     RegistryCloseKey(ParametersKey);
+    __DriverSetParametersKey(NULL);
 
 fail4:
     Error("fail4\n");
@@ -672,6 +698,7 @@ DllUnload(
 {
     HANDLE  MemoryKey;
     HANDLE  UnplugKey;
+    HANDLE  ParametersKey;
 
     Trace("====>\n");
 
@@ -699,6 +726,11 @@ DllUnload(
     RegistryCloseKey(UnplugKey);
     __DriverSetUnplugKey(NULL);
 
+    ParametersKey = __DriverGetParametersKey();
+
+    RegistryCloseKey(ParametersKey);
+    __DriverSetParametersKey(NULL);
+
     RegistryTeardown();
 
     Info("XEN %d.%d.%d (%d) (%02d.%02d.%04d)\n",
diff --git a/src/xen/driver.h b/src/xen/driver.h
index 8c39735147c6..11b421b10f76 100644
--- a/src/xen/driver.h
+++ b/src/xen/driver.h
@@ -32,6 +32,11 @@
 #ifndef _XEN_DRIVER_H
 #define _XEN_DRIVER_H
 
+extern HANDLE
+DriverGetParametersKey(
+    VOID
+    );
+
 extern HANDLE
 DriverGetUnplugKey(
     VOID
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:15 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79651.145082 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzH-0000c2-7s; Mon, 01 Feb 2021 09:59:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79651.145082; Mon, 01 Feb 2021 09:59: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 1l6VzH-0000bs-3Z; Mon, 01 Feb 2021 09:59:15 +0000
Received: by outflank-mailman (input) for mailman id 79651;
 Mon, 01 Feb 2021 09:59:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzF-0000Zu-OB
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzF-0007Hw-Gz; Mon, 01 Feb 2021 09:59:13 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzF-00087B-99; Mon, 01 Feb 2021 09:59:13 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=iWn1KXu07EZyOIMFI4P67BkUQQa+YLbUvHU7ZZdrVwo=; b=Rs1P6aiLY6YdevKrq/8XUtmaz
	8btIsb4U2hdMy4Kln239/qaC1s6tvZO65gVC88jExMCl7NFCtEZxNu3FPdDRoe4mePUbukYZJNfEh
	5hvL8U2vnVryrSHfCJTU4STLGYMSTRoraXYsVICT/GKDGWr4M5AtcnBxQsqIobSlkmkGw=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 6/8] Make vcpu_info registration conditional on number of vCPUs
Date: Mon,  1 Feb 2021 09:59:04 +0000
Message-Id: <20210201095906.10295-7-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

It is unnecessary to explicitly register vcpu_info structures for VMs with
XEN_LEGACY_MAX_VCPUS (32) vCPUs or fewer as the array embedded in the
shared_info structure can be used instead, saving a small amount of memory and
speeding up boot slightly. NOTE: events may only be delivered to a vCPU with a
vcpu_info structure that is available to Xen.

This patch adds a registry override in the form of a registry parameter of
the XEN driver, 'RegisterVcpuInfo'. If this parameter is present and set
to zero then vcpu_info structures are not registered (regardless of vCPU
count), meaning that event channel binding may fail for some vCPUs in the
system (i.e. those with vcpu_id >= 32). If the parameter is present and set
to a non-zero value then vcpu_info structures are always registered (as is
the case without this patch). However, if the parameter is missing (which is
the default case) then vcpu_info structures will be registered only if the
vCPU count exceeds 32.

NOTE: The logic checking XEN_LEGACY_MAX_VCPUS in EvtchnIsProcessorEnabled()
      doesn't really belong there. The code in shared_info.c knows whether
      a vcpu_info is available but querying this will require a new version
      of XENBUS_SHARED_INFO. This will be addressed in a subsequent patch.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xen/system.c         | 54 ++++++++++++++++++++++++++++++++--------
 src/xenbus/evtchn.c      | 31 ++++++++++++++++++++---
 src/xenbus/shared_info.c | 11 ++++++--
 3 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/src/xen/system.c b/src/xen/system.c
index 5323b3e11b35..f664635119fe 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -75,6 +75,7 @@ typedef struct _SYSTEM_CONTEXT {
     PHYSICAL_ADDRESS    MaximumPhysicalAddress;
     BOOLEAN             RealTimeIsUniversal;
     SYSTEM_WATCHDOG     Watchdog;
+    BOOLEAN             RegisterVcpuInfo;
     PMDL                Mdl;
 } SYSTEM_CONTEXT, *PSYSTEM_CONTEXT;
 
@@ -664,11 +665,16 @@ SystemProcessorVcpuInfo(
     if (Cpu >= Context->ProcessorCount)
         goto fail1;
 
+    status = STATUS_NOT_SUPPORTED;
+    if (Processor->Registered == NULL)
+        goto fail2;
+
     ASSERT(*Processor->Registered);
     *Vcpu = Processor->Vcpu;
 
     return STATUS_SUCCESS;
 
+fail2:
 fail1:
     return status;
 }
@@ -689,6 +695,8 @@ SystemProcessorRegisterVcpuInfo(
     PUCHAR              MdlMappedSystemVa;
     NTSTATUS            status;
 
+    ASSERT(Context->RegisterVcpuInfo);
+
     status = STATUS_UNSUCCESSFUL;
     if (Cpu >= Context->ProcessorCount)
         goto fail1;
@@ -756,6 +764,8 @@ SystemProcessorDeregisterVcpuInfo(
     PSYSTEM_CONTEXT     Context = &SystemContext;
     PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
+    ASSERT(Context->RegisterVcpuInfo);
+
     Processor->Vcpu = NULL;
     Processor->Registered = NULL;
 }
@@ -795,9 +805,11 @@ SystemProcessorDpc(
 
     SystemProcessorInitialize(Cpu);
 
-    status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE);
-    if (!NT_SUCCESS(status))
-        goto fail1;
+    if (Context->RegisterVcpuInfo) {
+        status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE);
+        if (!NT_SUCCESS(status))
+            goto fail1;
+    }
 
     Info("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
 
@@ -843,7 +855,6 @@ SystemProcessorChangeCallback(
     switch (Change->State) {
     case KeProcessorAddStartNotify:
         break;
-
     case KeProcessorAddCompleteNotify: {
         PSYSTEM_PROCESSOR   Processor;
 
@@ -893,6 +904,8 @@ SystemAllocateVcpuInfo(
     ULONG           Size;
     NTSTATUS        status;
 
+    ASSERT(Context->RegisterVcpuInfo);
+
     Size = sizeof (vcpu_info_t) * HVM_MAX_VCPUS;
     Size += sizeof (BOOLEAN) * HVM_MAX_VCPUS;
     Size = P2ROUNDUP(Size, PAGE_SIZE);
@@ -918,6 +931,8 @@ SystemFreeVcpuInfo(
 {
     PSYSTEM_CONTEXT Context = &SystemContext;
 
+    ASSERT(Context->RegisterVcpuInfo);
+
     DriverPutNamedPages(Context->Mdl);
     Context->Mdl = NULL;
 }
@@ -931,9 +946,11 @@ SystemRegisterProcessorChangeCallback(
     PVOID           Handle;
     NTSTATUS        status;
 
-    status = SystemAllocateVcpuInfo();
-    if (!NT_SUCCESS(status))
-        goto fail1;
+    if (Context->RegisterVcpuInfo) {
+        status = SystemAllocateVcpuInfo();
+        if (!NT_SUCCESS(status))
+            goto fail1;
+    }
 
     Handle = KeRegisterProcessorChangeCallback(SystemProcessorChangeCallback,
                                                NULL,
@@ -950,7 +967,8 @@ SystemRegisterProcessorChangeCallback(
 fail2:
     Error("fail2\n");
 
-    SystemFreeVcpuInfo();
+    if (Context->RegisterVcpuInfo)
+        SystemFreeVcpuInfo();
 
 fail1:
     Error("fail1 (%08x)\n", status);
@@ -972,7 +990,9 @@ SystemDeregisterProcessorChangeCallback(
     for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) {
         PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
-        SystemProcessorDeregisterVcpuInfo(Cpu);
+        if (Context->RegisterVcpuInfo)
+            SystemProcessorDeregisterVcpuInfo(Cpu);
+
         SystemProcessorTeardown(Cpu);
 
         RtlZeroMemory(&Processor->Dpc, sizeof (KDPC));
@@ -982,7 +1002,8 @@ SystemDeregisterProcessorChangeCallback(
         ASSERT(IsZeroMemory(Processor, sizeof (SYSTEM_PROCESSOR)));
     }
 
-    SystemFreeVcpuInfo();
+    if (Context->RegisterVcpuInfo)
+        SystemFreeVcpuInfo();
 }
 
 static NTSTATUS
@@ -1221,6 +1242,8 @@ SystemInitialize(
 {
     PSYSTEM_CONTEXT Context = &SystemContext;
     LONG            References;
+    HANDLE          ParametersKey;
+    ULONG           RegisterVcpuInfo;
     NTSTATUS        status;
 
     References = InterlockedIncrement(&Context->References);
@@ -1236,6 +1259,17 @@ SystemInitialize(
     if (Context->Processor == NULL)
         goto fail2;
 
+    ParametersKey = DriverGetParametersKey();
+
+    status = RegistryQueryDwordValue(ParametersKey,
+                                     "RegisterVcpuInfo",
+                                     &RegisterVcpuInfo);
+    if (NT_SUCCESS(status))
+        Context->RegisterVcpuInfo = (RegisterVcpuInfo != 0) ? TRUE : FALSE;
+    else
+        Context->RegisterVcpuInfo = (Context->ProcessorCount > XEN_LEGACY_MAX_VCPUS) ?
+                                    TRUE : FALSE;
+
     status = SystemGetStartOptions();
     if (!NT_SUCCESS(status))
         goto fail3;
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index d0702686aeea..97664524e737 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1506,6 +1506,33 @@ EvtchnDebugCallback(
     }
 }
 
+static BOOLEAN
+EvtchnIsProcessorEnabled(
+    IN  PXENBUS_EVTCHN_CONTEXT      Context,
+    IN  ULONG                       Cpu
+    )
+{
+    vcpu_info_t                     *Vcpu;
+    NTSTATUS                        status;
+
+    status = SystemProcessorVcpuInfo(Cpu, &Vcpu);
+    if (!NT_SUCCESS(status)) {
+        unsigned int    vcpu_id;
+
+        ASSERT(status == STATUS_NOT_SUPPORTED);
+
+        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
+        ASSERT(NT_SUCCESS(status));
+
+        if (vcpu_id >= XEN_LEGACY_MAX_VCPUS)
+            return FALSE;
+    }
+
+    return XENBUS_EVTCHN_ABI(IsProcessorEnabled,
+                             &Context->EvtchnAbi,
+                             Cpu);
+}
+
 static NTSTATUS
 EvtchnAcquire(
     IN  PINTERFACE          Interface
@@ -1578,9 +1605,7 @@ EvtchnAcquire(
     for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) {
         PXENBUS_EVTCHN_PROCESSOR    Processor;
 
-        if (!XENBUS_EVTCHN_ABI(IsProcessorEnabled,
-                               &Context->EvtchnAbi,
-                               Cpu))
+        if (!EvtchnIsProcessorEnabled(Context, Cpu))
             continue;
 
         status = KeGetProcessorNumberFromIndex(Cpu, &ProcNumber);
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index 20f07a82d801..984ee6ff0417 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -629,8 +629,15 @@ SharedInfoAcquire(
             goto fail7;
 
         status = SystemProcessorVcpuInfo(Index, &Processor->Vcpu);
-        if (!NT_SUCCESS(status) && status != STATUS_NOT_SUPPORTED)
-            goto fail8;
+        if (!NT_SUCCESS(status)) {
+            if (status != STATUS_NOT_SUPPORTED)
+                goto fail8;
+
+            if (Processor->vcpu_id >= ARRAYSIZE(Shared->vcpu_info))
+                continue;
+
+            Processor->Vcpu = &Shared->vcpu_info[Processor->vcpu_id];
+        }
     }
 
     Trace("<====\n");
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:16 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79652.145084 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzI-0000cy-8e; Mon, 01 Feb 2021 09:59:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79652.145084; Mon, 01 Feb 2021 09:59: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 1l6VzI-0000cq-4z; Mon, 01 Feb 2021 09:59:16 +0000
Received: by outflank-mailman (input) for mailman id 79652;
 Mon, 01 Feb 2021 09:59:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzG-0000aw-7N
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzG-0007I3-6D; Mon, 01 Feb 2021 09:59:14 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzF-00087B-UV; Mon, 01 Feb 2021 09:59: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=3gWqZFS5q1LtyW0JhWXPqv7h8RkZcb1tLr5AIkgEnNk=; b=YxUok/kXKxQsVXk+7g8Dku7D6
	2orTc06HkihxHqG9i//lzYscnAL0MLzW31zmHbgERh7lQqSFdgM5RvOexiKvJKwNbh6NHABAjOg50
	S88SMK2N17hFT/f0YGrzsUfvTSXMdo2ni/52KOZoEsseDU6kKDblxvhk4AOEkGXZYLEiY=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 7/8] Retire PDO versions 08000009 thru 0800000B
Date: Mon,  1 Feb 2021 09:59:05 +0000
Message-Id: <20210201095906.10295-8-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

These are the last of the v8 PDO versions. The v9 drivers have been available
for a long time now so these versions can be retired. This allows support for
XENBUS_EVTCHN v4, XENBUS_STORE v1 and XENBUS_GNTTAB v1 interfaces to be
removed.

NOTE: Without this patch then adding new interface versions is essentially
      blocked, as a single extra PDO revision will trigger an assertion in
      PdoQueryId() in XENBUS because the length of the buffer for
      'BusQueryCompatibleIDs' will exceed REGSTR_VAL_MAX_HCID_LEN (1024).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/evtchn_interface.h | 19 +------------------
 include/gnttab_interface.h | 17 +----------------
 include/revision.h         |  3 ---
 include/store_interface.h  | 22 +---------------------
 src/xenbus/evtchn.c        | 30 ------------------------------
 src/xenbus/gnttab.c        | 28 ----------------------------
 src/xenbus/store.c         | 33 ---------------------------------
 7 files changed, 3 insertions(+), 149 deletions(-)

diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index fffde05bf1da..05c342e50db8 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -251,23 +251,6 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
-    \ingroup interfaces
-*/
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
-    INTERFACE               Interface;
-    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
-    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
-    XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND      EvtchnBind;
-    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
-    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
-    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
-    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
-    XENBUS_EVTCHN_CLOSE     EvtchnClose;
-};
-
 /*! \struct _XENBUS_EVTCHN_INTERFACE_V5
     \brief EVTCHN interface version 5
     \ingroup interfaces
@@ -371,7 +354,7 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
 #define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index c34dbd03bfc4..e3ee888bd979 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -233,21 +233,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
-    INTERFACE                           Interface;
-    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
-    XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
-    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
-    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
-    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
-    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
-};
-
 /*! \struct _XENBUS_GNTTAB_INTERFACE_V2
     \brief GNTTAB interface version 2
     \ingroup interfaces
@@ -311,7 +296,7 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
 #define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
diff --git a/include/revision.h b/include/revision.h
index 3a6b398e93a3..fe4661b42082 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -47,9 +47,6 @@
 
 //                    REVISION   S  SI   E   D  ST   R   C   G   U  CO  EM
 #define DEFINE_REVISION_TABLE                                                \
-    DEFINE_REVISION(0x08000009,  1,  2,  4,  1,  1,  1,  1,  1,  1,  0,  1), \
-    DEFINE_REVISION(0x0800000A,  1,  2,  5,  1,  1,  1,  1,  1,  1,  0,  1), \
-    DEFINE_REVISION(0x0800000B,  1,  2,  5,  1,  2,  1,  1,  2,  1,  0,  1), \
     DEFINE_REVISION(0x09000000,  1,  2,  5,  1,  2,  1,  1,  2,  1,  0,  1), \
     DEFINE_REVISION(0x09000001,  1,  2,  6,  1,  2,  1,  1,  2,  1,  1,  1), \
     DEFINE_REVISION(0x09000002,  1,  2,  7,  1,  2,  1,  1,  2,  1,  1,  1), \
diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index 97664524e737..cb0e8e54fb29 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1811,19 +1811,6 @@ done:
     KeReleaseSpinLock(&Context->Lock, Irql);
 }
 
-static struct _XENBUS_EVTCHN_INTERFACE_V4 EvtchnInterfaceVersion4 = {
-    { sizeof (struct _XENBUS_EVTCHN_INTERFACE_V4), 4, NULL, NULL, NULL },
-    EvtchnAcquire,
-    EvtchnRelease,
-    EvtchnOpen,
-    EvtchnBind,
-    EvtchnUnmaskVersion4,
-    EvtchnSendVersion1,
-    EvtchnTrigger,
-    EvtchnGetPort,
-    EvtchnClose
-};
-
 static struct _XENBUS_EVTCHN_INTERFACE_V5 EvtchnInterfaceVersion5 = {
     { sizeof (struct _XENBUS_EVTCHN_INTERFACE_V5), 5, NULL, NULL, NULL },
     EvtchnAcquire,
@@ -2014,23 +2001,6 @@ EvtchnGetInterface(
     ASSERT(Context != NULL);
 
     switch (Version) {
-    case 4: {
-        struct _XENBUS_EVTCHN_INTERFACE_V4  *EvtchnInterface;
-
-        EvtchnInterface = (struct _XENBUS_EVTCHN_INTERFACE_V4 *)Interface;
-
-        status = STATUS_BUFFER_OVERFLOW;
-        if (Size < sizeof (struct _XENBUS_EVTCHN_INTERFACE_V4))
-            break;
-
-        *EvtchnInterface = EvtchnInterfaceVersion4;
-
-        ASSERT3U(Interface->Version, ==, Version);
-        Interface->Context = Context;
-
-        status = STATUS_SUCCESS;
-        break;
-    }
     case 5: {
         struct _XENBUS_EVTCHN_INTERFACE_V5  *EvtchnInterface;
 
diff --git a/src/xenbus/gnttab.c b/src/xenbus/gnttab.c
index 3fe52aacf7ab..33373c2e127c 100644
--- a/src/xenbus/gnttab.c
+++ b/src/xenbus/gnttab.c
@@ -979,17 +979,6 @@ done:
     KeReleaseSpinLock(&Context->Lock, Irql);
 }
 
-static struct _XENBUS_GNTTAB_INTERFACE_V1   GnttabInterfaceVersion1 = {
-    { sizeof (struct _XENBUS_GNTTAB_INTERFACE_V1), 1, NULL, NULL, NULL },
-    GnttabAcquire,
-    GnttabRelease,
-    GnttabCreateCacheVersion1,
-    GnttabPermitForeignAccess,
-    GnttabRevokeForeignAccess,
-    GnttabGetReference,
-    GnttabDestroyCache
-};
-                     
 static struct _XENBUS_GNTTAB_INTERFACE_V2   GnttabInterfaceVersion2 = {
     { sizeof (struct _XENBUS_GNTTAB_INTERFACE_V2), 2, NULL, NULL, NULL },
     GnttabAcquire,
@@ -1110,23 +1099,6 @@ GnttabGetInterface(
     ASSERT(Context != NULL);
 
     switch (Version) {
-    case 1: {
-        struct _XENBUS_GNTTAB_INTERFACE_V1  *GnttabInterface;
-
-        GnttabInterface = (struct _XENBUS_GNTTAB_INTERFACE_V1 *)Interface;
-
-        status = STATUS_BUFFER_OVERFLOW;
-        if (Size < sizeof (struct _XENBUS_GNTTAB_INTERFACE_V1))
-            break;
-
-        *GnttabInterface = GnttabInterfaceVersion1;
-
-        ASSERT3U(Interface->Version, ==, Version);
-        Interface->Context = Context;
-
-        status = STATUS_SUCCESS;
-        break;
-    }
     case 2: {
         struct _XENBUS_GNTTAB_INTERFACE_V2  *GnttabInterface;
 
diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 570b8b5191d9..2f9f36524963 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -2639,22 +2639,6 @@ done:
     KeReleaseSpinLock(&Context->Lock, Irql);
 }
 
-static struct _XENBUS_STORE_INTERFACE_V1 StoreInterfaceVersion1 = {
-    { sizeof (struct _XENBUS_STORE_INTERFACE_V1), 1, NULL, NULL, NULL },
-    StoreAcquire,
-    StoreRelease,
-    StoreFree,
-    StoreRead,
-    StorePrintf,
-    StoreRemove,
-    StoreDirectory,
-    StoreTransactionStart,
-    StoreTransactionEnd,
-    StoreWatchAdd,
-    StoreWatchRemove,
-    StorePoll
-};
-                     
 static struct _XENBUS_STORE_INTERFACE_V2 StoreInterfaceVersion2 = {
     { sizeof (struct _XENBUS_STORE_INTERFACE_V2), 2, NULL, NULL, NULL },
     StoreAcquire,
@@ -2800,23 +2784,6 @@ StoreGetInterface(
     ASSERT(Context != NULL);
 
     switch (Version) {
-    case 1: {
-        struct _XENBUS_STORE_INTERFACE_V1  *StoreInterface;
-
-        StoreInterface = (struct _XENBUS_STORE_INTERFACE_V1 *)Interface;
-
-        status = STATUS_BUFFER_OVERFLOW;
-        if (Size < sizeof (struct _XENBUS_STORE_INTERFACE_V1))
-            break;
-
-        *StoreInterface = StoreInterfaceVersion1;
-
-        ASSERT3U(Interface->Version, ==, Version);
-        Interface->Context = Context;
-
-        status = STATUS_SUCCESS;
-        break;
-    }
     case 2: {
         struct _XENBUS_STORE_INTERFACE_V2  *StoreInterface;
 
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 01 09:59:16 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 01 Feb 2021 09:59:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.79653.145090 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l6VzI-0000dJ-Dx; Mon, 01 Feb 2021 09:59:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 79653.145090; Mon, 01 Feb 2021 09:59: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 1l6VzI-0000d2-6W; Mon, 01 Feb 2021 09:59:16 +0000
Received: by outflank-mailman (input) for mailman id 79653;
 Mon, 01 Feb 2021 09:59:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1l6VzG-0000bj-V8
 for win-pv-devel@lists.xenproject.org; Mon, 01 Feb 2021 09:59:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzG-0007I8-RD; Mon, 01 Feb 2021 09:59:14 +0000
Received: from host86-190-149-163.range86-190.btcentralplus.com
 ([86.190.149.163] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1l6VzG-00087B-JQ; Mon, 01 Feb 2021 09:59: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From;
	 bh=7HrqtStgBhtnzIXra4Kg0MZkHufKiNqc3RjAX2idHis=; b=JeYpjIuHv6R+hDPTaWcZwurmt
	y6gOjaOAUsOhl0tM2p8Tg60Ys5bwlb12Edjk3EFsSAUIkZKP2nnRMV0rDdM1lxGUbh88fFOAauQKy
	wztRThzZK8aWUqQS2UZgIKwIpNN3uT4FGskff7P2qqIGgTnVZ8Nore5vcIlSKRV53a3PI=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus 8/8] Add XENBUS_SHARED_INFO method to check whether event upcalls are supported
Date: Mon,  1 Feb 2021 09:59:06 +0000
Message-Id: <20210201095906.10295-9-paul@xen.org>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20210201095906.10295-1-paul@xen.org>
References: <20210201095906.10295-1-paul@xen.org>

From: Paul Durrant <pdurrant@amazon.com>

Upcalls can only be supported on a vCPU that has a vcpu_info structure
available to Xen; that is one with a vcpu_id < XEN_LEGACY_MAX_VCPUS (32) or
one that has explicitly registered a vcpu_info. This is determined during
SharedInfoAcquire() but the information needs to be avalable to the code in
evtchn.c. Hence this patch adds a new 'UpcallSupported' method to
XENBUS_SHARED_INFO (consequently bumping the interface version to 3).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/revision.h              |  3 ++-
 include/shared_info_interface.h | 30 ++++++++++++++++++++--
 src/xenbus/evtchn.c             | 19 +++-----------
 src/xenbus/shared_info.c        | 44 +++++++++++++++++++++++++++++++++
 4 files changed, 78 insertions(+), 18 deletions(-)

diff --git a/include/revision.h b/include/revision.h
index fe4661b42082..d507e60373a4 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -55,6 +55,7 @@
     DEFINE_REVISION(0x09000005,  1,  2,  8,  1,  2,  1,  2,  4,  1,  1,  1), \
     DEFINE_REVISION(0x09000006,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  1), \
     DEFINE_REVISION(0x09000007,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  2), \
-    DEFINE_REVISION(0x09000008,  1,  3,  9,  1,  2,  1,  2,  4,  1,  1,  2)
+    DEFINE_REVISION(0x09000008,  1,  3,  9,  1,  2,  1,  2,  4,  1,  1,  2), \
+    DEFINE_REVISION(0x09000008,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2)
 
 #endif  // _REVISION_H
diff --git a/include/shared_info_interface.h b/include/shared_info_interface.h
index f99bcb634cdd..27910b020a8e 100644
--- a/include/shared_info_interface.h
+++ b/include/shared_info_interface.h
@@ -60,6 +60,15 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+/*! \typedef XENBUS_SHARED_INFO_UPCALL_SUPPORTED
+    \brief Private method for EVTCHN inerface
+*/
+typedef BOOLEAN
+(*XENBUS_SHARED_INFO_UPCALL_SUPPORTED)(
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Index
+    );
+
 /*! \typedef XENBUS_SHARED_INFO_UPCALL_PENDING
     \brief Private method for EVTCHN inerface
 */
@@ -168,7 +177,24 @@ struct _XENBUS_SHARED_INFO_INTERFACE_V3 {
     XENBUS_SHARED_INFO_GET_TIME         SharedInfoGetTime;
 };
 
-typedef struct _XENBUS_SHARED_INFO_INTERFACE_V3 XENBUS_SHARED_INFO_INTERFACE, *PXENBUS_SHARED_INFO_INTERFACE;
+/*! \struct _XENBUS_SHARED_INFO_INTERFACE_V4
+    \brief SHARED_INFO interface version 4
+    \ingroup interfaces
+*/
+struct _XENBUS_SHARED_INFO_INTERFACE_V4 {
+    INTERFACE                           Interface;
+    XENBUS_SHARED_INFO_ACQUIRE          SharedInfoAcquire;
+    XENBUS_SHARED_INFO_RELEASE          SharedInfoRelease;
+    XENBUS_SHARED_INFO_UPCALL_SUPPORTED SharedInfoUpcallSupported;
+    XENBUS_SHARED_INFO_UPCALL_PENDING   SharedInfoUpcallPending;
+    XENBUS_SHARED_INFO_EVTCHN_POLL      SharedInfoEvtchnPoll;
+    XENBUS_SHARED_INFO_EVTCHN_ACK       SharedInfoEvtchnAck;
+    XENBUS_SHARED_INFO_EVTCHN_MASK      SharedInfoEvtchnMask;
+    XENBUS_SHARED_INFO_EVTCHN_UNMASK    SharedInfoEvtchnUnmask;
+    XENBUS_SHARED_INFO_GET_TIME         SharedInfoGetTime;
+};
+
+typedef struct _XENBUS_SHARED_INFO_INTERFACE_V4 XENBUS_SHARED_INFO_INTERFACE, *PXENBUS_SHARED_INFO_INTERFACE;
 
 /*! \def XENBUS_SHARED_INFO
     \brief Macro at assist in method invocation
@@ -179,6 +205,6 @@ typedef struct _XENBUS_SHARED_INFO_INTERFACE_V3 XENBUS_SHARED_INFO_INTERFACE, *P
 #endif  // _WINDLL
 
 #define XENBUS_SHARED_INFO_INTERFACE_VERSION_MIN    2
-#define XENBUS_SHARED_INFO_INTERFACE_VERSION_MAX    3
+#define XENBUS_SHARED_INFO_INTERFACE_VERSION_MAX    4
 
 #endif  // _XENBUS_SHARED_INFO_H
diff --git a/src/xenbus/evtchn.c b/src/xenbus/evtchn.c
index cb0e8e54fb29..8942cdf30f81 100644
--- a/src/xenbus/evtchn.c
+++ b/src/xenbus/evtchn.c
@@ -1512,21 +1512,10 @@ EvtchnIsProcessorEnabled(
     IN  ULONG                       Cpu
     )
 {
-    vcpu_info_t                     *Vcpu;
-    NTSTATUS                        status;
-
-    status = SystemProcessorVcpuInfo(Cpu, &Vcpu);
-    if (!NT_SUCCESS(status)) {
-        unsigned int    vcpu_id;
-
-        ASSERT(status == STATUS_NOT_SUPPORTED);
-
-        status = SystemProcessorVcpuId(Cpu, &vcpu_id);
-        ASSERT(NT_SUCCESS(status));
-
-        if (vcpu_id >= XEN_LEGACY_MAX_VCPUS)
-            return FALSE;
-    }
+    if (!XENBUS_SHARED_INFO(UpcallSupported,
+                            &Context->SharedInfoInterface,
+                            Cpu))
+        return FALSE;
 
     return XENBUS_EVTCHN_ABI(IsProcessorEnabled,
                              &Context->EvtchnAbi,
diff --git a/src/xenbus/shared_info.c b/src/xenbus/shared_info.c
index 984ee6ff0417..9f119791a03a 100644
--- a/src/xenbus/shared_info.c
+++ b/src/xenbus/shared_info.c
@@ -160,6 +160,20 @@ SharedInfoEvtchnMaskAll(
     }
 }
 
+static BOOLEAN
+SharedInfoUpcallSupported(
+    IN  PINTERFACE                  Interface,
+    IN  ULONG                       Index
+    )
+{
+    PXENBUS_SHARED_INFO_CONTEXT     Context = Interface->Context;
+    PXENBUS_SHARED_INFO_PROCESSOR   Processor = &Context->Processor[Index];
+
+    ASSERT3U(Index, <, Context->ProcessorCount);
+
+    return (Processor->Vcpu != NULL) ? TRUE : FALSE;
+}
+
 static BOOLEAN
 SharedInfoUpcallPending(
     IN  PINTERFACE                  Interface,
@@ -795,6 +809,19 @@ static struct _XENBUS_SHARED_INFO_INTERFACE_V3 SharedInfoInterfaceVersion3 = {
     SharedInfoGetTime
 };
                      
+static struct _XENBUS_SHARED_INFO_INTERFACE_V4 SharedInfoInterfaceVersion4 = {
+    { sizeof (struct _XENBUS_SHARED_INFO_INTERFACE_V4), 4, NULL, NULL, NULL },
+    SharedInfoAcquire,
+    SharedInfoRelease,
+    SharedInfoUpcallSupported,
+    SharedInfoUpcallPending,
+    SharedInfoEvtchnPoll,
+    SharedInfoEvtchnAck,
+    SharedInfoEvtchnMask,
+    SharedInfoEvtchnUnmask,
+    SharedInfoGetTime
+};
+
 NTSTATUS
 SharedInfoInitialize(
     IN  PXENBUS_FDO                 Fdo,
@@ -886,6 +913,23 @@ SharedInfoGetInterface(
         status = STATUS_SUCCESS;
         break;
     }
+    case 4: {
+        struct _XENBUS_SHARED_INFO_INTERFACE_V4 *SharedInfoInterface;
+
+        SharedInfoInterface = (struct _XENBUS_SHARED_INFO_INTERFACE_V4 *)Interface;
+
+        status = STATUS_BUFFER_OVERFLOW;
+        if (Size < sizeof (struct _XENBUS_SHARED_INFO_INTERFACE_V4))
+            break;
+
+        *SharedInfoInterface = SharedInfoInterfaceVersion4;
+
+        ASSERT3U(Interface->Version, ==, Version);
+        Interface->Context = Context;
+
+        status = STATUS_SUCCESS;
+        break;
+    }
     default:
         status = STATUS_NOT_SUPPORTED;
         break;
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 08 16:09:33 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 08 Feb 2021 16:09:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.82946.153470 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1l996Q-0002mw-Uh; Mon, 08 Feb 2021 16:09:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 82946.153470; Mon, 08 Feb 2021 16:09: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 1l996Q-0002mp-Rv; Mon, 08 Feb 2021 16:09:30 +0000
Received: by outflank-mailman (input) for mailman id 82946;
 Mon, 08 Feb 2021 16:09:30 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1l996Q-0002mk-2T
 for win-pv-devel@lists.xenproject.org; Mon, 08 Feb 2021 16:09: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>
Date: Mon, 8 Feb 2021 16:09:31 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <3252490.3.1612800571988.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #215 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2_16546720.1612800571676"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


------=_Part_2_16546720.1612800571676
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #215.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/215/console to view the results.
------=_Part_2_16546720.1612800571676--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 15 12:03:18 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 15 Feb 2021 12:03:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.85210.159770 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lBcay-0001tD-Mh; Mon, 15 Feb 2021 12:03:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 85210.159770; Mon, 15 Feb 2021 12:03: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 1lBcay-0001t6-Jq; Mon, 15 Feb 2021 12:03:16 +0000
Received: by outflank-mailman (input) for mailman id 85210;
 Mon, 15 Feb 2021 12:03:15 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=TjUh=HR=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lBcax-0001t0-Cb
 for win-pv-devel@lists.xenproject.org; Mon, 15 Feb 2021 12:03:15 +0000
Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 67497497-7651-41de-ba4a-7f120a97413c;
 Mon, 15 Feb 2021 12:03:14 +0000 (UTC)
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>
X-Inumbo-ID: 67497497-7651-41de-ba4a-7f120a97413c
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1613390594;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=c3XTgnb5o4p05HmyAFsgTN4lDNGbKcw6NuoScdNjEQE=;
  b=aIIAtIGheuOrLWzij9jcCa5nwiCDP3loZym+dpImdmjYuEYif4nCj751
   2iBhVwsjSeE/SPX1y07YlkoxJWl8pBj+adBL7w+KLsRT/MtI9oeu29VII
   JzdWbAoxKWZV6AzHNpXRDtdYMrihSXdi3N2ZFcay3mUCw9Btn10uHif8w
   s=;
Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: IxdKX48OzfeSGkeDuyD/fYRMSFX/OlmpgJ2Glx1rHhcW5eNmcjnSJvLMm/ANm1e52JMUHfflE2
 gbPgkl/BEErlhfIS1N9TuiK5d/+6iDgDtCfTUzE9FLts8tgQzn7ClP82bvYHirwYw2TrQz2wCH
 66j5C8NDuQzIf9IPpbBFrsNoXfLpg77UhH57ym4yLzeMduHxD25cv0lCK8Sl/iOoYWt2XFG5f9
 h7CO1xmY8IP6MRUjWms9iGJF6Ql/3FkN8OWYxKICd7Aq2W+llSGtF5Q5hOcuuxCKVb8b/ZOtyo
 IgM=
X-SBRS: 5.1
X-MesageID: 37189956
X-Ironport-Server: esa5.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,180,1610427600"; 
   d="scan'208";a="37189956"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Fix Activev Device Present logging
Date: Mon, 15 Feb 2021 12:02:48 +0000
Message-ID: <20210215120248.2575482-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

Log active device presence from DriverIsActiveDevicePresent, rather than
the caller when DriverIsActiveDevicePresent reported its present. This
move fixes the non-functional conditional in the logging.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xenfilt/driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 5496a17..e9e6673 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -324,6 +324,8 @@ DriverIsActivePresent(
 done:
     XENFILT_EMULATED(Release, &Driver.EmulatedInterface);
 
+    Info("ACTIVE DEVICE %sPRESENT\n", (!Present) ? "NOT " : "");
+
     return Present;
 
 fail1:
@@ -362,8 +364,6 @@ DriverSetFilterState(
             break;
 
         if (DriverIsActivePresent()) {
-            Info("ACTIVE DEVICE %sPRESENT\n", (!Present) ? "NOT " : "");
-
             if (!__DriverSafeMode())
                 UnplugDevices();
         }
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 15 12:36:11 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 15 Feb 2021 12:36:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.85225.159793 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lBd6o-0004cC-Ah; Mon, 15 Feb 2021 12:36:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 85225.159793; Mon, 15 Feb 2021 12:36: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 1lBd6o-0004c3-7O; Mon, 15 Feb 2021 12:36:10 +0000
Received: by outflank-mailman (input) for mailman id 85225;
 Mon, 15 Feb 2021 12:36:08 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=83rJ=HR=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lBd6m-0004by-Ns
 for win-pv-devel@lists.xenproject.org; Mon, 15 Feb 2021 12:36:08 +0000
Received: from mail-wr1-x433.google.com (unknown [2a00:1450:4864:20::433])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 660f8aa1-4783-457b-acde-4246582e4b4d;
 Mon, 15 Feb 2021 12:36:07 +0000 (UTC)
Received: by mail-wr1-x433.google.com with SMTP id n8so8646840wrm.10
 for <win-pv-devel@lists.xenproject.org>; Mon, 15 Feb 2021 04:36:07 -0800 (PST)
Received: from CBGR90WXYV0 (host86-180-176-157.range86-180.btcentralplus.com.
 [86.180.176.157])
 by smtp.gmail.com with ESMTPSA id f17sm2663228wru.31.2021.02.15.04.36.06
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 15 Feb 2021 04:36:06 -0800 (PST)
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>
X-Inumbo-ID: 660f8aa1-4783-457b-acde-4246582e4b4d
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:to:references:in-reply-to:subject:date:message-id
         :mime-version:content-transfer-encoding:content-language
         :thread-index;
        bh=kxFegfCamw3NxLD9n8OF+lHsMS2RndtQPJgG+4ufJlg=;
        b=UCjA2K5V7uQOMDzsgKTs1HCLW3AJ4cfRGSI/mnCrKkQmpmVuD5mszB7eTy/tm2seXs
         Jl7rMg1GFu8NuAzPGBGtrUV4H2JvBnKr86j+gtzrfbvereYN4Mo9so3PtQlUK21Vj6nh
         28l743brBT8UbEUAGhIYZZEKqM1f7Vh6qUqmZXxSA+wTFiUKcUvVznj5thycnkad+ai9
         zZhYLW58IC1N3XZIpG5i8wtmlJ3xJuxVfW3m5ngJhidfYR4qlY4r+cr8u1NeKsvRgQfH
         CR2d2cBrxTo3E4PcA5usxrjME6mgGDW/MVi6Gj3Okr0HKfXznny/Hlm8wq1fJgDWyOzX
         pj2A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:to:references:in-reply-to:subject
         :date:message-id:mime-version:content-transfer-encoding
         :content-language:thread-index;
        bh=kxFegfCamw3NxLD9n8OF+lHsMS2RndtQPJgG+4ufJlg=;
        b=rlIPHPMt1z08k1e92gsrTI7WnI9Fz1ioe6EpAaatWpGr70jOt/CAq9pgEJKB24jCha
         0F3ye/FuatmRq2G2YQkzZKCv5l+PXBObc9WnCtovgTX0eSF4Vv2s6Y5DJgcseUWbT/zy
         5jGpg4pUx5FyzyCqdwRRJrHX8PiUYymO49zDq92bVgJJ4uW7oawXBGKLHFL11nNYms/n
         rCqppYhGhEtJ8kLZ287TmvZfminaYVB2biHt9zlPcIR+QL18GNQWK/icLLe+YS1DDorH
         pMOOHpjiyEYR6sDG2F7tq9HGJC2oB0SHDtfzEvo1/ue0agBYCVmDut+hJw6HgIwxNf0Q
         wU8A==
X-Gm-Message-State: AOAM533vETSEaSMbgFzI9LpAnTdYRJUcaL9DB9Yd12P/bk2p2gkzL2NI
	AEzLPm4ghH6HGpZJjAkc5cc=
X-Google-Smtp-Source: ABdhPJydWqxHBUy5ns7blhvRYUJVS8YGyX5gy07uhBckLxtF2U4D5ccJnJnk5lhL5AF70IYj4hm8Xg==
X-Received: by 2002:a5d:6602:: with SMTP id n2mr18132008wru.150.1613392567061;
        Mon, 15 Feb 2021 04:36:07 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: "Paul Durrant" <paul@xen.org>
Reply-To: <paul@xen.org>
To: "'Owen Smith'" <owen.smith@citrix.com>,
	<win-pv-devel@lists.xenproject.org>
References: <20210215120248.2575482-1-owen.smith@citrix.com>
In-Reply-To: <20210215120248.2575482-1-owen.smith@citrix.com>
Subject: RE: [PATCH] Fix Activev Device Present logging
Date: Mon, 15 Feb 2021 12:36:05 -0000
Message-ID: <005601d70397$2177e6d0$6467b470$@xen.org>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 16.0
Content-Language: en-gb
Thread-Index: AQK2sJDa6DrCM0T8oq8BROitqkXefaiZzNCg

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> On Behalf Of Owen Smith
> Sent: 15 February 2021 12:03
> To: win-pv-devel@lists.xenproject.org
> Cc: Owen Smith <owen.smith@citrix.com>
> Subject: [PATCH] Fix Activev Device Present logging
> 
> Log active device presence from DriverIsActiveDevicePresent, rather than
> the caller when DriverIsActiveDevicePresent reported its present. This
> move fixes the non-functional conditional in the logging.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Typo in the subject line, but I'll fix that on commit...

Acked-by: Paul Durrant <paul@xen.org>

> ---
>  src/xenfilt/driver.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
> index 5496a17..e9e6673 100644
> --- a/src/xenfilt/driver.c
> +++ b/src/xenfilt/driver.c
> @@ -324,6 +324,8 @@ DriverIsActivePresent(
>  done:
>      XENFILT_EMULATED(Release, &Driver.EmulatedInterface);
> 
> +    Info("ACTIVE DEVICE %sPRESENT\n", (!Present) ? "NOT " : "");
> +
>      return Present;
> 
>  fail1:
> @@ -362,8 +364,6 @@ DriverSetFilterState(
>              break;
> 
>          if (DriverIsActivePresent()) {
> -            Info("ACTIVE DEVICE %sPRESENT\n", (!Present) ? "NOT " : "");
> -
>              if (!__DriverSafeMode())
>                  UnplugDevices();
>          }
> --
> 2.28.0.windows.1
> 




From win-pv-devel-bounces@lists.xenproject.org Wed Feb 17 17:37:09 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 17 Feb 2021 17:37:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.86382.162174 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lCQl8-0000gV-RT; Wed, 17 Feb 2021 17:37:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 86382.162174; Wed, 17 Feb 2021 17:37:06 +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 1lCQl8-0000gN-OE; Wed, 17 Feb 2021 17:37:06 +0000
Received: by outflank-mailman (input) for mailman id 86382;
 Wed, 17 Feb 2021 17:37:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lCQl7-0000gI-AL
 for win-pv-devel@lists.xenproject.org; Wed, 17 Feb 2021 17:37:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lCQl6-0008MP-VL; Wed, 17 Feb 2021 17:37:04 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lCQl6-00088u-Ll; Wed, 17 Feb 2021 17:37: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=0YoxlQD7/m/fxbzy5rYcuZs2N/qdQcz1+TF33GvZ/0o=; b=MtrKqn30j1nUQvelyy5PAGzmHz
	1br+0FfUmhqAApUKOv14qPeTciA00aQksvBGhrdB49y+rB+O4yISrG4dY7EO4uQRgdSUc0cKVW7YL
	slZLNWYwp7f9UnPfyCke3eRLgd/kttJOEX7HKjLIdGlgM6OYA5it+6kE+YTXYUfjhhlE=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus] Avoid ASSERTion failure on migrate/resume
Date: Wed, 17 Feb 2021 17:37:01 +0000
Message-Id: <20210217173701.672-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

After commit ed57f5f6367f ("Make vcpu_info registration conditional on number
of vCPUs") it is no longer certain that SystemProcessorRegisterVcpuInfo()
will be called during boot and indeed it was modified to ASSERT that the
'RegisterVcpuInfo' flag in SYSTEM_CONTEXT is TRUE. Unfortunately this means
that the (now erroneously) unconditional call to
SystemProcessorRegisterVcpuInfo() in SuspendEarly() may fail the ASSERTion.

This patch fixes the problem by allowing SystemProcessorRegisterVcpuInfo() to
be called unconditionally and simply having it exit early if the
'RegisterVcpuInfo' flag is not set. SystemProcessorDeregisterVcpuInfo() is
also similarly modified for consistency.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xen/system.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/xen/system.c b/src/xen/system.c
index f664635119fe..ffa41a749282 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -695,7 +695,8 @@ SystemProcessorRegisterVcpuInfo(
     PUCHAR              MdlMappedSystemVa;
     NTSTATUS            status;
 
-    ASSERT(Context->RegisterVcpuInfo);
+    if (!Context->RegisterVcpuInfo)
+        goto done;
 
     status = STATUS_UNSUCCESSFUL;
     if (Cpu >= Context->ProcessorCount)
@@ -742,6 +743,7 @@ SystemProcessorRegisterVcpuInfo(
               Address.HighPart,
               Address.LowPart);
 
+done:
     return STATUS_SUCCESS;
 
 fail2:
@@ -764,7 +766,8 @@ SystemProcessorDeregisterVcpuInfo(
     PSYSTEM_CONTEXT     Context = &SystemContext;
     PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
-    ASSERT(Context->RegisterVcpuInfo);
+    if (!Context->RegisterVcpuInfo)
+        return;
 
     Processor->Vcpu = NULL;
     Processor->Registered = NULL;
@@ -805,11 +808,9 @@ SystemProcessorDpc(
 
     SystemProcessorInitialize(Cpu);
 
-    if (Context->RegisterVcpuInfo) {
-        status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE);
-        if (!NT_SUCCESS(status))
-            goto fail1;
-    }
+    status = SystemProcessorRegisterVcpuInfo(Cpu, FALSE);
+    if (!NT_SUCCESS(status))
+        goto fail1;
 
     Info("<==== (%u:%u)\n", ProcNumber.Group, ProcNumber.Number);
 
@@ -990,9 +991,7 @@ SystemDeregisterProcessorChangeCallback(
     for (Cpu = 0; Cpu < Context->ProcessorCount; Cpu++) {
         PSYSTEM_PROCESSOR   Processor = &Context->Processor[Cpu];
 
-        if (Context->RegisterVcpuInfo)
-            SystemProcessorDeregisterVcpuInfo(Cpu);
-
+        SystemProcessorDeregisterVcpuInfo(Cpu);
         SystemProcessorTeardown(Cpu);
 
         RtlZeroMemory(&Processor->Dpc, sizeof (KDPC));
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 17 18:15:23 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 17 Feb 2021 18:15:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.86405.162227 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lCRMA-0004lK-M4; Wed, 17 Feb 2021 18:15:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 86405.162227; Wed, 17 Feb 2021 18:15:22 +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 1lCRMA-0004lD-J1; Wed, 17 Feb 2021 18:15:22 +0000
Received: by outflank-mailman (input) for mailman id 86405;
 Wed, 17 Feb 2021 18:15:21 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lCRM8-0004l7-TH
 for win-pv-devel@lists.xenproject.org; Wed, 17 Feb 2021 18:15: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>
Date: Wed, 17 Feb 2021 18:15:05 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <10340573.1.1613585707888.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #216 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_Part_0_2868790.1613585705731"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


------=_Part_0_2868790.1613585705731
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #216.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/216/console to view the results.
------=_Part_0_2868790.1613585705731--


From win-pv-devel-bounces@lists.xenproject.org Wed Feb 17 18:37:50 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 17 Feb 2021 18:37:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.86415.162243 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lCRhs-0006kr-Hr; Wed, 17 Feb 2021 18:37:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 86415.162243; Wed, 17 Feb 2021 18:37: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 1lCRhs-0006kk-Er; Wed, 17 Feb 2021 18:37:48 +0000
Received: by outflank-mailman (input) for mailman id 86415;
 Wed, 17 Feb 2021 18:37:47 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lCRhr-0006kf-BC
 for win-pv-devel@lists.xenproject.org; Wed, 17 Feb 2021 18:37:47 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lCRhr-0000zS-3R; Wed, 17 Feb 2021 18:37:47 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lCRhq-0004u4-PY; Wed, 17 Feb 2021 18:37: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=TV8HfqECrBFpMggQE609dGRuVbxLOf/PZUp0K8MraIY=; b=zQW5+R54SiRJ9t2smV6GUP2LOf
	s2LnbAaAwbQoPC2liqOEKYgSYyx5L1pDhbgUXc5l9deldUCRGQWSxKciQCbI9jyDzLZhv0zXVwDfo
	bpb5gXzHnnq0xDHKv775bNUKC2vi191HvnsshAMiQLHM8Mb4aAhmcvkOccQVMm/Sw/3c=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus] Make sure StoreSubmitRequest() cannot fail...
Date: Wed, 17 Feb 2021 18:37:44 +0000
Message-Id: <20210217183744.967-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... after a request completes successfully in xenstored.

Currently a failure is possible if a request completes successfully but
StoreCopyResponse() fails to allocate memory. This has a particularly nasty
side effect in StoreTransactionStart() where is can return a failure status
to its caller but a new transaction was, in fact, initialized in xenstored.
This then leads to a transaction 'leak'.

This patch makes sure that memory is allocated up-front in
StoreSubmitRequest() so it cannot fail after communicating with xenstored.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 src/xenbus/store.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 2f9f36524963..ce4c755f1d58 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -739,21 +739,15 @@ StoreResetResponse(
     Segment->Length = sizeof (struct xsd_sockmsg);
 }
 
-static PXENBUS_STORE_RESPONSE
+static VOID
 StoreCopyResponse(
-    IN  PXENBUS_STORE_CONTEXT   Context
+    IN  PXENBUS_STORE_CONTEXT   Context,
+    OUT PXENBUS_STORE_RESPONSE  Response
     )
 {
-    PXENBUS_STORE_RESPONSE      Response;
     PXENBUS_STORE_SEGMENT       Segment;
-    NTSTATUS                    status;
-
-    Response = __StoreAllocate(sizeof (XENBUS_STORE_RESPONSE));
-
-    status = STATUS_NO_MEMORY;
-    if (Response == NULL)
-        goto fail1;
 
+    ASSERT(Response != NULL);
     *Response = Context->Response;
 
     Segment = &Response->Segment[XENBUS_STORE_RESPONSE_HEADER_SEGMENT];
@@ -767,13 +761,6 @@ StoreCopyResponse(
     } else {
         ASSERT3P(Segment->Data, ==, NULL);
     }
-
-    return Response;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return NULL;
 }
 
 static VOID
@@ -817,7 +804,7 @@ StoreProcessResponse(
 
     RemoveEntryList(&Request->ListEntry);
 
-    Request->Response = StoreCopyResponse(Context);
+    StoreCopyResponse(Context, Request->Response);
     StoreResetResponse(Context);
 
     Request->State = XENBUS_STORE_REQUEST_COMPLETED;
@@ -921,9 +908,16 @@ StoreSubmitRequest(
     ULONG                       Count;
     XENBUS_STORE_REQUEST_STATE  State;
     LARGE_INTEGER               Timeout;
+    NTSTATUS                    status;
 
     ASSERT3U(Request->State, ==, XENBUS_STORE_REQUEST_PREPARED);
 
+    Request->Response = __StoreAllocate(sizeof (XENBUS_STORE_RESPONSE));
+
+    status = STATUS_NO_MEMORY;
+    if (Request->Response == NULL)
+        goto fail1;
+
     // Make sure we don't suspend
     ASSERT3U(KeGetCurrentIrql(), <=, DISPATCH_LEVEL);
     KeRaiseIrql(DISPATCH_LEVEL, &Irql);
@@ -942,8 +936,6 @@ StoreSubmitRequest(
     Timeout.QuadPart = TIME_RELATIVE(TIME_S(XENBUS_STORE_POLL_PERIOD));
 
     while (State != XENBUS_STORE_REQUEST_COMPLETED) {
-        NTSTATUS    status;
-
         status = XENBUS_EVTCHN(Wait,
                                &Context->EvtchnInterface,
                                Context->Channel,
@@ -970,6 +962,11 @@ StoreSubmitRequest(
     KeLowerIrql(Irql);
 
     return Response;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return NULL;
 }
 
 static NTSTATUS
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Fri Feb 19 14:23:22 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 19 Feb 2021 14:23:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.86894.163429 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lD6gi-00027p-PO; Fri, 19 Feb 2021 14:23:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 86894.163429; Fri, 19 Feb 2021 14:23: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 1lD6gi-00027h-MO; Fri, 19 Feb 2021 14:23:20 +0000
Received: by outflank-mailman (input) for mailman id 86894;
 Fri, 19 Feb 2021 14:23:19 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=DLMK=HV=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lD6gg-00027Z-Uz
 for win-pv-devel@lists.xenproject.org; Fri, 19 Feb 2021 14:23:19 +0000
Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0ab788c7-b5dc-4b0d-9d9d-873ac70ddae1;
 Fri, 19 Feb 2021 14:23:17 +0000 (UTC)
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>
X-Inumbo-ID: 0ab788c7-b5dc-4b0d-9d9d-873ac70ddae1
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1613744597;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=/n3YGozJ92ZTxddYli9IVzWF4+n28/cnia5/aRHJkM0=;
  b=eByh2750CWeS06byklgFY+B/XjtC73SdyR0sAWsB5QBL+37AUSBTAJpU
   L4WSaeCu7QbcBlQ4htB1BPSf4ei9WTFkZu7HxmF7qWSBwQtP/xUVFbloA
   ET07J9EweMA6iq1xuCw3dCsmhGFZwCRqtlDTSWZ6MNK4EnaN2dk4y54Bj
   8=;
Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: c4yv24gnlc9ierLJzCoL6UdJwB/f6kC0nYYBqAzDWUoB5NvKXeP1nYiJr8JB2dy/uKx0u5EUBM
 aYY+jvEQfk7opuJW9aUThx29sqZdcg+1XXfd5tpZylxXMeYH7FVVBbmfswKuTYYDK66WDv9Vfv
 AmLzDyfEKimQUlctaeYILPSbH2WsVGnV3vPIiWdV4zXbN+h7kZZMKXUbQD76BZy7UgoAIx3oVq
 torwP13C4jTTi2k93a7GvPL6Ww5e2TCK7Tw3xFC9F6+AV7SQM3+WC8wxO6bO6fw1/WPKlYSaBj
 df4=
X-SBRS: 5.1
X-MesageID: 37608256
X-Ironport-Server: esa3.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,189,1610427600"; 
   d="scan'208";a="37608256"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [RFC-PATCH] Add CodeQL support
Date: Fri, 19 Feb 2021 14:22:49 +0000
Message-ID: <20210219142249.492764-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

CodeQL results will be required for future WHQL certifications.
https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/static-tools-and-codeql

Add option to use CodeQL to generate the appropriate log. CodeQL uses
MSBuild to generate sarif files which are expected to be uploaded when
submitting WHQL results. sarif files will also highlight any violations
of the static analysis rules that will need fixing.

Note: The CodeQL doesnt seem to support passing quoted strings as MSBuild
parameters, so add default values for Configuration and Platform.

Assumptions:
- CodeQL binaries are installed and accessible on the path
- Windows Driver Development Supplemental Tools are installed and are
  ehtier in the parent directory of the project, or accessible with the
  environment variable CODEQL_QUERY_SUITE

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1            | 62 ++++++++++++++++++++++++++++++++++++++++++++
 vs2015/configs.props |  4 +++
 vs2017/configs.props |  4 +++
 vs2019/configs.props |  4 +++
 4 files changed, 74 insertions(+)

diff --git a/build.ps1 b/build.ps1
index 2ea6428..b6b5515 100644
--- a/build.ps1
+++ b/build.ps1
@@ -6,6 +6,7 @@ param(
 	[Parameter(Mandatory = $true)]
 	[string]$Type,
 	[string]$Arch,
+	[switch]$CodeQL,
 	[switch]$Sdv
 )
 
@@ -51,6 +52,63 @@ Function SdvBuild {
 	& ".\msbuild.ps1" @params
 }
 
+Function CodeQLBuild {
+	$DriverList = @("xen", "xenbus", "xenfilt")
+
+	$visualstudioversion = $Env:VisualStudioVersion
+	$solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; "16.0" = "vs2019"; }
+
+	if ([string]::IsNullOrEmpty($Env:CODEQL_QUERY_SUITE)) {
+		$searchpath = Resolve-Path ".."
+	} else {
+		$searchpath = $Env:CODEQL_QUERY_SUITE
+	}
+
+	if (Test-Path "database") {
+		Remove-Item -Recurse -Force "database"
+	}
+	New-Item -ItemType Directory "database"
+
+	$DriverList | ForEach {
+		$projpath = Resolve-Path (Join-Path $solutiondir[$visualstudioversion] $_)
+		$proj = Join-Path $projpath ($_ + ".vcxproj")
+		$output = Join-Path "xenbus" ($_ + ".sarif")
+		$database = "database\" + $_
+
+		$c = "codeql"
+		$c += " database"
+		$c += " create"
+		$c += " -l=cpp"
+		$c += " -s=src"
+		$c += " -c"
+		$c += ' "msbuild.exe /t:Build /p:Platform=x64 ' + $proj + '" '
+		$c += $database
+
+		Invoke-Expression $c
+		if ($LASTEXITCODE -ne 0) {
+			Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
+			Exit $LASTEXITCODE
+		}
+
+		$c = "codeql"
+		$c += " database"
+		$c += " analyze "
+		$c += $database
+		$c += " windows_driver_recommended.qls"
+		$c += " --format=sarifv2.1.0"
+		$c += " --output="
+		$c += $output
+		$c += " --search-path="
+		$c += $searchpath
+
+		Invoke-Expression $c
+		if ($LASTEXITCODE -ne 0) {
+			Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
+			Exit $LASTEXITCODE
+		}
+	}
+}
+
 if ($Type -ne "free" -and $Type -ne "checked") {
 	Write-Host "Invalid Type"
 	Exit -1
@@ -99,6 +157,10 @@ if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x64") {
 	Build "x64" $Type
 }
 
+if ($CodeQL) {
+	CodeQLBuild
+}
+
 if ($Sdv) {
 	SdvBuild
 }
diff --git a/vs2015/configs.props b/vs2015/configs.props
index cdbb3c8..4be9288 100644
--- a/vs2015/configs.props
+++ b/vs2015/configs.props
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+	<PropertyGroup>
+		<Configuration Condition=" '$(Configuration)' == '' ">Windows 10 Release</Configuration>
+		<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
+	</PropertyGroup>
 	<ItemGroup Label="ProjectConfigurations">
 		<ProjectConfiguration Include="Windows 10 Debug|Win32">
 			<Configuration>Windows 10 Debug</Configuration>
diff --git a/vs2017/configs.props b/vs2017/configs.props
index cdbb3c8..4be9288 100644
--- a/vs2017/configs.props
+++ b/vs2017/configs.props
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+	<PropertyGroup>
+		<Configuration Condition=" '$(Configuration)' == '' ">Windows 10 Release</Configuration>
+		<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
+	</PropertyGroup>
 	<ItemGroup Label="ProjectConfigurations">
 		<ProjectConfiguration Include="Windows 10 Debug|Win32">
 			<Configuration>Windows 10 Debug</Configuration>
diff --git a/vs2019/configs.props b/vs2019/configs.props
index cdbb3c8..4be9288 100644
--- a/vs2019/configs.props
+++ b/vs2019/configs.props
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+	<PropertyGroup>
+		<Configuration Condition=" '$(Configuration)' == '' ">Windows 10 Release</Configuration>
+		<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
+	</PropertyGroup>
 	<ItemGroup Label="ProjectConfigurations">
 		<ProjectConfiguration Include="Windows 10 Debug|Win32">
 			<Configuration>Windows 10 Debug</Configuration>
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:02:09 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:02:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87816.165013 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE82Y-0006bp-Ql; Mon, 22 Feb 2021 10:02:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87816.165013; Mon, 22 Feb 2021 10:02:06 +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 1lE82Y-0006bh-Ne; Mon, 22 Feb 2021 10:02:06 +0000
Received: by outflank-mailman (input) for mailman id 87816;
 Mon, 22 Feb 2021 10:02:06 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE82Y-0006bc-36
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:02:06 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE82X-0005WL-QV; Mon, 22 Feb 2021 10:02:05 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE82X-0008Lk-Fe; Mon, 22 Feb 2021 10:02: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=+NyNRu2cgucQP3m15J5WIa85lRxWa8P70ls5h0bOd9E=; b=Rj/FQGFpdkP0RNFHiEV7P9Rlf5
	zm1trop1J5kDC59BuLSQlE82yRPxLzR6VM8w2GJ4RmbaThezD1+rqvVtzOPyu146Z6VxPxKJYjtt4
	Fpk0Jaatu5ORDZIrmlfsJCw7MuDPgvD//4ZglneNRlOhrPRf5fTFlXfPCtguS068vTNs=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenbus] Fix PDO revision
Date: Mon, 22 Feb 2021 10:02:02 +0000
Message-Id: <20210222100202.409-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

Commit 58760cc3dd94 ("Add XENBUS_SHARED_INFO method to check whether event
upcalls are supported") added a new version of the XENBUS_SHARED_INFO
interface but there was a typo in the line added into revisions.h and hence
the XENBUS PDO revision was left as 0x09000008 rather then being increased to
0x09000009. This patch rectifies the situation.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/revision.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/revision.h b/include/revision.h
index d507e60373a4..3e3779fb8784 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -56,6 +56,6 @@
     DEFINE_REVISION(0x09000006,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  1), \
     DEFINE_REVISION(0x09000007,  1,  3,  8,  1,  2,  1,  2,  4,  1,  1,  2), \
     DEFINE_REVISION(0x09000008,  1,  3,  9,  1,  2,  1,  2,  4,  1,  1,  2), \
-    DEFINE_REVISION(0x09000008,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2)
+    DEFINE_REVISION(0x09000009,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2)
 
 #endif  // _REVISION_H
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:12:24 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:12:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87830.165044 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8CW-0007kJ-5X; Mon, 22 Feb 2021 10:12:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87830.165044; Mon, 22 Feb 2021 10:12:24 +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 1lE8CW-0007kC-1y; Mon, 22 Feb 2021 10:12:24 +0000
Received: by outflank-mailman (input) for mailman id 87830;
 Mon, 22 Feb 2021 10:12:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE8CU-0007k7-Cu
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:12:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8CU-0005gN-7C; Mon, 22 Feb 2021 10:12:22 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8CT-0000vq-TI; Mon, 22 Feb 2021 10:12:22 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=halhgH3QInPXLzB5qdopl/YT8GmtAvPGuj/36t8wYWY=; b=IIVC83bOm+R5+03i0nP0NE2QRn
	GZ7e6e7gJRlVG4jBM71st6rCIrXjKjMSRkVwb45gbDZLr8nk+mvXvaRozzLPdezaXiEYl+6SLtXOz
	9GdOyr+31avYV4wUZq0w/HIxnS3DgNO2XFUbN/PBBzNG7MN68/C8WY52WW58WwBXzjkA=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenvkbd] Bring XENBUS interface versions up to date...
Date: Mon, 22 Feb 2021 10:12:19 +0000
Message-Id: <20210222101219.601-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and update binding accordingly.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/cache_interface.h  |  34 ++++++++++-
 include/evtchn_interface.h | 108 ++++++++++++++++++++++------------
 include/gnttab_interface.h | 116 +++++++++++++++++++++++++++++++++++--
 include/store_interface.h  |  22 +------
 include/unplug_interface.h |   2 +-
 src/xenvkbd.inf            |   6 +-
 src/xenvkbd/ring.c         |   7 ++-
 7 files changed, 224 insertions(+), 71 deletions(-)

diff --git a/include/cache_interface.h b/include/cache_interface.h
index dae3ac6d556c..ce50f4e46376 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -123,6 +123,20 @@ typedef VOID
     IN  PVOID   Argument
     );
 
+typedef NTSTATUS
+(*XENBUS_CACHE_CREATE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Size,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_CTOR           Ctor,
+    IN  XENBUS_CACHE_DTOR           Dtor,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_CACHE               *Cache
+    );
+
 /*! \typedef XENBUS_CACHE_CREATE
     \brief Create a cache of objects of the given \a Size
 
@@ -130,6 +144,7 @@ typedef VOID
     \param Name A name for the cache which will be used in debug output
     \param Size The size of each object in bytes
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param Ctor A callback which is invoked when a new object created
     \param Dtor A callback which is invoked when an object is destroyed
     \param AcquireLock A callback invoked to acquire a spinlock
@@ -146,6 +161,7 @@ typedef NTSTATUS
     IN  const CHAR                  *Name,
     IN  ULONG                       Size,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_CTOR           Ctor,
     IN  XENBUS_CACHE_DTOR           Dtor,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
@@ -208,6 +224,20 @@ DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE,
     \ingroup interfaces
 */
 struct _XENBUS_CACHE_INTERFACE_V1 {
+    INTERFACE               Interface;
+    XENBUS_CACHE_ACQUIRE    CacheAcquire;
+    XENBUS_CACHE_RELEASE    CacheRelease;
+    XENBUS_CACHE_CREATE_V1  CacheCreateVersion1;
+    XENBUS_CACHE_GET        CacheGet;
+    XENBUS_CACHE_PUT        CachePut;
+    XENBUS_CACHE_DESTROY    CacheDestroy;
+};
+
+/*! \struct _XENBUS_CACHE_INTERFACE_V2
+    \brief CACHE interface version 1
+    \ingroup interfaces
+*/
+struct _XENBUS_CACHE_INTERFACE_V2 {
     INTERFACE               Interface;
     XENBUS_CACHE_ACQUIRE    CacheAcquire;
     XENBUS_CACHE_RELEASE    CacheRelease;
@@ -217,7 +247,7 @@ struct _XENBUS_CACHE_INTERFACE_V1 {
     XENBUS_CACHE_DESTROY    CacheDestroy;
 };
 
-typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
+typedef struct _XENBUS_CACHE_INTERFACE_V2 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
 
 /*! \def XENBUS_CACHE
     \brief Macro at assist in method invocation
@@ -228,6 +258,6 @@ typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE
 #endif  // _WINDLL
 
 #define XENBUS_CACHE_INTERFACE_VERSION_MIN  1
-#define XENBUS_CACHE_INTERFACE_VERSION_MAX  1
+#define XENBUS_CACHE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_CACHE_INTERFACE_H
diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index a9952d656141..05c342e50db8 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -100,6 +100,8 @@ typedef VOID
 
     \b VIRQ:
     \param Index The index number of the VIRQ
+    \param Group The group number of the CPU that should handle the VIRQ
+    \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
 */  
@@ -112,13 +114,6 @@ typedef PXENBUS_EVTCHN_CHANNEL
     ...
     );
 
-typedef NTSTATUS
-(*XENBUS_EVTCHN_BIND_V2)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Cpu
-    );
-
 /*! \typedef XENBUS_EVTCHN_BIND
     \brief Bind an event channel to a specific CPU
 
@@ -135,8 +130,8 @@ typedef NTSTATUS
     IN  UCHAR                   Number
     );
 
-typedef BOOLEAN
-(*XENBUS_EVTCHN_UNMASK_V1)(
+typedef VOID
+(*XENBUS_EVTCHN_UNMASK_V4)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
     IN  BOOLEAN                 InCallback
@@ -148,17 +143,28 @@ typedef BOOLEAN
     \param Interface The interface header
     \param Channel The channel handle
     \param InCallback Set to TRUE if this method is invoked in context of the channel callback
+    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return TRUE if the unmask did not complete and there is still an event pending.
 */
-typedef VOID
+typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InCallback
+    IN  BOOLEAN                 InCallback,
+    IN  BOOLEAN                 Force
+    );
+
+typedef VOID
+(*XENBUS_EVTCHN_SEND_V1)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel
     );
 
 /*! \typedef XENBUS_EVTCHN_SEND
     \brief Send an event to the remote end of the channel
 
+    It is assumed that the domain cannot suspend during this call so
+    IRQL must be >= DISPATCH_LEVEL.
+
     \param Interface The interface header
     \param Channel The channel handle
 */  
@@ -180,17 +186,39 @@ typedef VOID
     IN  PXENBUS_EVTCHN_CHANNEL  Channel
     );
 
+/*! \typedef XENBUS_EVTCHN_GET_COUNT
+    \brief Get the number of events received by the channel since it was opened
+
+    \param Interface The interface header
+    \param Channel The channel handle
+    \return The number of events
+*/
+typedef ULONG
+(*XENBUS_EVTCHN_GET_COUNT)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    );
+
+typedef NTSTATUS
+(*XENBUS_EVTCHN_WAIT_V5)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
+    IN  PLARGE_INTEGER          Timeout OPTIONAL
+    );
+
 /*! \typedef XENBUS_EVTCHN_WAIT
-    \brief Wait for an event to the local end of the channel
+    \brief Wait for events to the local end of the channel
 
     \param Interface The interface header
     \param Channel The channel handle
+    \param Count The event count to wait for
     \param Timeout An optional timeout value (similar to KeWaitForSingleObject(), but non-zero values are allowed at DISPATCH_LEVEL).
 */
 typedef NTSTATUS
 (*XENBUS_EVTCHN_WAIT)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
+    IN  ULONG                   Count,
     IN  PLARGE_INTEGER          Timeout OPTIONAL
     );
 
@@ -223,61 +251,66 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V1
-    \brief EVTCHN interface version 1
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V5
+    \brief EVTCHN interface version 5
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V1 {
+struct _XENBUS_EVTCHN_INTERFACE_V5 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_UNMASK_V1 EvtchnUnmaskVersion1;
-    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
+    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_WAIT_V5   EvtchnWaitVersion5;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V2
-    \brief EVTCHN interface version 2
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V6
+    \brief EVTCHN interface version 6
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V2 {
+struct _XENBUS_EVTCHN_INTERFACE_V6 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
-    XENBUS_EVTCHN_UNMASK_V1 EvtchnUnmaskVersion1;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_WAIT_V5   EvtchnWaitVersion5;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V3
-    \brief EVTCHN interface version 3
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V7
+    \brief EVTCHN interface version 7
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V3 {
+struct _XENBUS_EVTCHN_INTERFACE_V7 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
-    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V8
+    \brief EVTCHN interface version 8
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
+struct _XENBUS_EVTCHN_INTERFACE_V8 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -286,15 +319,17 @@ struct _XENBUS_EVTCHN_INTERFACE_V4 {
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V5
-    \brief EVTCHN interface version 5
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V9
+    \brief EVTCHN interface version 9
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V5 {
+struct _XENBUS_EVTCHN_INTERFACE_V9 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -303,12 +338,13 @@ struct _XENBUS_EVTCHN_INTERFACE_V5 {
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
     XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V5 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
+typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -318,8 +354,8 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V5 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 1
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
 
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index d29440a5e607..e3ee888bd979 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -72,12 +72,24 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+typedef NTSTATUS
+(*XENBUS_GNTTAB_CREATE_CACHE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    );
+
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
     \brief Create a cache of grant table entries
 
     \param Interface The interface header
     \param Name A name for the cache which will be used in debug output
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param AcquireLock A callback invoked to acquire a spinlock
     \param ReleaseLock A callback invoked to release the spinlock
     \param Argument An optional context argument passed to the callbacks
@@ -88,6 +100,7 @@ typedef NTSTATUS
     IN  PINTERFACE                  Interface,
     IN  const CHAR                  *Name,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
     IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
     IN  PVOID                       Argument OPTIONAL,
@@ -148,6 +161,26 @@ typedef ULONG
     IN  PXENBUS_GNTTAB_ENTRY        Entry
     );
 
+/*! \typedef XENBUS_GNTTAB_QUERY_REFERENCE
+    \brief Get the reference number of the entry
+
+    \param Interface The interface header
+    \param Reference The reference number
+    \param Pfn An optional pointer to receive the value of the reference frame number
+    \param ReadOnly An optional pointer to receive the boolean value of the read-only flag
+*/
+typedef NTSTATUS
+(*XENBUS_GNTTAB_QUERY_REFERENCE)(
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Reference,
+    OUT PPFN_NUMBER Pfn OPTIONAL,
+    OUT PBOOLEAN    ReadOnly OPTIONAL
+    );
+
+#define XENBUS_GNTTAB_CONSOLE_REFERENCE 0
+#define XENBUS_GNTTAB_STORE_REFERENCE   1
+
+
 /*! \typedef XENBUS_GNTTAB_DESTROY_CACHE
     \brief Destroy a cache of grant table entries
 
@@ -163,15 +196,83 @@ typedef VOID
     IN  PXENBUS_GNTTAB_CACHE    Cache
     );
 
+/*! \typedef XENBUS_GNTTAB_MAP_FOREIGN_PAGES
+    \brief Map foreign memory pages into the system address space
+
+    \param Interface The interface header
+    \param Domain The domid of the foreign domain that granted the pages
+    \param NumberPages Number of pages to map
+    \param References Array of grant reference numbers shared by the foreign domain
+    \param ReadOnly If TRUE, pages are mapped with read-only access
+    \param Address The physical address that the foreign pages are mapped under
+*/
+
+typedef NTSTATUS
+(*XENBUS_GNTTAB_MAP_FOREIGN_PAGES)(
+    IN  PINTERFACE              Interface,
+    IN  USHORT                  Domain,
+    IN  ULONG                   NumberPages,
+    IN  PULONG                  References,
+    IN  BOOLEAN                 ReadOnly,
+    OUT PHYSICAL_ADDRESS        *Address
+    );
+
+/*! \typedef XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES
+    \brief Unmap foreign memory pages from the system address space
+
+    \param Interface The interface header
+    \param Address The physical address that the foreign pages are mapped under
+*/
+typedef NTSTATUS
+(*XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES)(
+    IN  PINTERFACE              Interface,
+    IN  PHYSICAL_ADDRESS        Address
+    );
+
 // {763679C5-E5C2-4A6D-8B88-6BB02EC42D8E}
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
+    \brief GNTTAB interface version 2
+    \ingroup interfaces
+*/
+struct _XENBUS_GNTTAB_INTERFACE_V2 {
+    INTERFACE                           Interface;
+    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
+    XENBUS_GNTTAB_RELEASE               GnttabRelease;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
+    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
+    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
+    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
+};
+
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
+    \brief GNTTAB interface version 3
+    \ingroup interfaces
+*/
+struct _XENBUS_GNTTAB_INTERFACE_V3 {
+    INTERFACE                           Interface;
+    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
+    XENBUS_GNTTAB_RELEASE               GnttabRelease;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
+    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
+    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
+    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
+    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
+};
+
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V4
+    \brief GNTTAB interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
+struct _XENBUS_GNTTAB_INTERFACE_V4 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
@@ -179,10 +280,13 @@ struct _XENBUS_GNTTAB_INTERFACE_V1 {
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V1 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
+typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
 
 /*! \def XENBUS_GNTTAB
     \brief Macro at assist in method invocation
@@ -192,8 +296,8 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V1 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 1
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
 
diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index 6f459754cd41..83b3dc98d8be 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -85,7 +85,7 @@ typedef VOID
     );
 
 // {73db6517-3d06-4937-989f-199b7501e229}
-DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
 0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
 
 /*! \struct _XENBUS_UNPLUG_INTERFACE_V1
diff --git a/src/xenvkbd.inf b/src/xenvkbd.inf
index c571c15ce29c..3d67ef09d108 100644
--- a/src/xenvkbd.inf
+++ b/src/xenvkbd.inf
@@ -59,9 +59,9 @@ xenvkbd_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dl
 ; DisplayName		Section		DeviceID
 ; -----------		-------		--------
 
-%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VKBD&REV_09000000
-%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VKBD&REV_09000000
-%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VKBD&REV_09000000
+%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VKBD&REV_09000009
+%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VKBD&REV_09000009
+%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VKBD&REV_09000009
 
 [XenVkbd_Inst] 
 CopyFiles=XenVkbd_Copyfiles
diff --git a/src/xenvkbd/ring.c b/src/xenvkbd/ring.c
index 114427f87712..acb0a5c607d6 100644
--- a/src/xenvkbd/ring.c
+++ b/src/xenvkbd/ring.c
@@ -424,7 +424,8 @@ RingDpc(
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
                   Ring->Channel,
-                  FALSE);
+                  FALSE,
+                  TRUE);
 
 done:
     RingReleaseLock(Ring);
@@ -604,6 +605,7 @@ RingConnect(
                            &Ring->GnttabInterface,
                            "VKBD_Ring_Gnttab",
                            0,
+                           0,
                            RingAcquireLock,
                            RingReleaseLock,
                            Ring,
@@ -660,7 +662,8 @@ RingConnect(
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
                   Ring->Channel,
-                  FALSE);
+                  FALSE,
+                  TRUE);
 
     status = XENBUS_DEBUG(Register,
                           &Ring->DebugInterface,
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:18:04 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:18:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87836.165048 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8Hz-0007qi-KN; Mon, 22 Feb 2021 10:18:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87836.165048; Mon, 22 Feb 2021 10:18: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 1lE8Hz-0007qb-H3; Mon, 22 Feb 2021 10:18:03 +0000
Received: by outflank-mailman (input) for mailman id 87836;
 Mon, 22 Feb 2021 10:18:02 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Mec3=HY=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lE8Hy-0007qW-76
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:18:02 +0000
Received: from mail-wm1-x32e.google.com (unknown [2a00:1450:4864:20::32e])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 0399e264-ee0a-4b0c-b80d-98d08e4b74e4;
 Mon, 22 Feb 2021 10:18:01 +0000 (UTC)
Received: by mail-wm1-x32e.google.com with SMTP id a207so13807257wmd.1
 for <win-pv-devel@lists.xenproject.org>; Mon, 22 Feb 2021 02:18:01 -0800 (PST)
Received: from ?IPv6:2a00:23c5:5785:9a01:a18d:4222:f9c4:4fa0?
 ([2a00:23c5:5785:9a01:a18d:4222:f9c4:4fa0])
 by smtp.gmail.com with ESMTPSA id e17sm4799805wro.36.2021.02.22.02.18.00
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 22 Feb 2021 02:18:00 -0800 (PST)
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>
X-Inumbo-ID: 0399e264-ee0a-4b0c-b80d-98d08e4b74e4
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=D2YNGI3lHTypeKQeTZ5rbhGWsKtwmYsAww4qRD//YI4=;
        b=F9Gg52CttELWal7t1Gnm0mYDx5NRNsZcNAc0NUjw5MyEZSh639aAK6buKj96bXXqjZ
         dn2q9AYJgWNyQv2903nSBy5EhfJv5wwqT0gPvJDvWlIUHoCUJMiLWiMvwXo/AzWjBdn/
         OeGTPCvA5bd12DsQrd/cea1mVfr34Oh3TMvGM1/CYCdmOXa5yCBkemYTbzkWNCY7RMv8
         cysPJ0im8iomjWoCVbIjF3BaRzZUWNtD7e9ZIIZcCwDJw7D7cVK2HSoiULVRy7tJqj9B
         bX6PODeWRlIlRZuD1YwAwFC7xpdbXuXd8b2ezu4UB+hPPjbJ1Tax3iBfH86ITWqj3E64
         YsrQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=D2YNGI3lHTypeKQeTZ5rbhGWsKtwmYsAww4qRD//YI4=;
        b=rjeoAy86vYZwZi5YlGQJdSP7eBggnYMTHXvvA4Kx3uF1ucdyZqUR2IxUC158yBHUJM
         32vf+NsvbPNKo1JcACIQnUyiRBPND9OT8kB3BgNxdaHOZQwhJWwcss83i+266ksXNV98
         h5lxiV2VtNPoCiXcsWr0dmeOXkcC7l9yipz+9/moy4ilsaVDtsfu37CF/1wIF7C6Y1CX
         o4AVQUbE6kytvrCg2yK6FKCbvv5SiZ+3P3yCNnUNxwOda7GIQUSAKWJ0sgnN1ku85tAz
         xGMrpHrlxe8XvJboxQvus/BX0iEBVKoC0gdx1YQyZLiLu6aHctqMOGKNFZXtuD08Bdew
         79Tg==
X-Gm-Message-State: AOAM5339YxUsyHVFkzI6ed41+j++zZCjtwBg6cOeBz0LkJd/2NBmZa4M
	+ZoB599SInPkzd1tTOAtUc0fgxLnzWI=
X-Google-Smtp-Source: ABdhPJzIhKxQCT/6AmGXCD4r4ojvIB5S1Ev9xFI31vMAsyJ6d+O39+KTNivdlZ4yHEJRTsOxYlckSQ==
X-Received: by 2002:a7b:cb45:: with SMTP id v5mr19267912wmj.58.1613989080661;
        Mon, 22 Feb 2021 02:18:00 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [PATCH xenvkbd] Bring XENBUS interface versions up to date...
To: win-pv-devel@lists.xenproject.org
References: <20210222101219.601-1-paul@xen.org>
Message-ID: <a95e4225-d9cd-9c41-1ddc-87f1dc23c040@xen.org>
Date: Mon, 22 Feb 2021 10:17:59 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.7.1
MIME-Version: 1.0
In-Reply-To: <20210222101219.601-1-paul@xen.org>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 22/02/2021 10:12, Paul Durrant wrote:
> From: Paul Durrant <pdurrant@amazon.com>
> 
> ... and update binding accordingly.
> 

I should have also retired PDO revisions which are now defunct. Will 
send a v2.

   Paul

> Signed-off-by: Paul Durrant <pdurrant@amazon.com>


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:21:50 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:21:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87851.165065 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8Le-0000PJ-B0; Mon, 22 Feb 2021 10:21:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87851.165065; Mon, 22 Feb 2021 10:21: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 1lE8Le-0000PB-7V; Mon, 22 Feb 2021 10:21:50 +0000
Received: by outflank-mailman (input) for mailman id 87851;
 Mon, 22 Feb 2021 10:21:49 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE8Lc-0000P6-VH
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:21:48 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8Lc-0005q4-Mt; Mon, 22 Feb 2021 10:21:48 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8Lc-0001Ub-E8; Mon, 22 Feb 2021 10:21: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=VGaeSnIag6nJJvXkBVApTheuZUQAvWqhlG0EfX5Ik4Q=; b=w9qeqnmu74qAt+eD2iMWTZITgf
	DNxLr4rKl0XQv5o29MgmHv/12dLq2horv4sY31fynpsMn0UDnetX19AtC6q4HAuR6gE1Zh9tZeWIG
	MiD3huMgfIxZ7VRGMxBwJUlnTICpRG/+aUHpPBDHdgFUjGUg6bYcCMKPWIA3g+Dq4Bt4=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH v2] Bring XENBUS interface versions up to date...
Date: Mon, 22 Feb 2021 10:21:46 +0000
Message-Id: <20210222102146.783-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and update binding accordingly. Also remove PDO revisions 0x09000000 and
0x09000001 as they rely on versions of the XENBUS_STORE interface that are
no longer supported.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/cache_interface.h  |  34 ++++++++++-
 include/evtchn_interface.h | 108 ++++++++++++++++++++++------------
 include/gnttab_interface.h | 116 +++++++++++++++++++++++++++++++++++--
 include/revision.h         |   2 -
 include/store_interface.h  |  22 +------
 include/unplug_interface.h |   2 +-
 src/xenvkbd.inf            |   6 +-
 src/xenvkbd/ring.c         |   7 ++-
 8 files changed, 224 insertions(+), 73 deletions(-)

diff --git a/include/cache_interface.h b/include/cache_interface.h
index dae3ac6d556c..ce50f4e46376 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -123,6 +123,20 @@ typedef VOID
     IN  PVOID   Argument
     );
 
+typedef NTSTATUS
+(*XENBUS_CACHE_CREATE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Size,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_CTOR           Ctor,
+    IN  XENBUS_CACHE_DTOR           Dtor,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_CACHE               *Cache
+    );
+
 /*! \typedef XENBUS_CACHE_CREATE
     \brief Create a cache of objects of the given \a Size
 
@@ -130,6 +144,7 @@ typedef VOID
     \param Name A name for the cache which will be used in debug output
     \param Size The size of each object in bytes
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param Ctor A callback which is invoked when a new object created
     \param Dtor A callback which is invoked when an object is destroyed
     \param AcquireLock A callback invoked to acquire a spinlock
@@ -146,6 +161,7 @@ typedef NTSTATUS
     IN  const CHAR                  *Name,
     IN  ULONG                       Size,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_CTOR           Ctor,
     IN  XENBUS_CACHE_DTOR           Dtor,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
@@ -208,6 +224,20 @@ DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE,
     \ingroup interfaces
 */
 struct _XENBUS_CACHE_INTERFACE_V1 {
+    INTERFACE               Interface;
+    XENBUS_CACHE_ACQUIRE    CacheAcquire;
+    XENBUS_CACHE_RELEASE    CacheRelease;
+    XENBUS_CACHE_CREATE_V1  CacheCreateVersion1;
+    XENBUS_CACHE_GET        CacheGet;
+    XENBUS_CACHE_PUT        CachePut;
+    XENBUS_CACHE_DESTROY    CacheDestroy;
+};
+
+/*! \struct _XENBUS_CACHE_INTERFACE_V2
+    \brief CACHE interface version 1
+    \ingroup interfaces
+*/
+struct _XENBUS_CACHE_INTERFACE_V2 {
     INTERFACE               Interface;
     XENBUS_CACHE_ACQUIRE    CacheAcquire;
     XENBUS_CACHE_RELEASE    CacheRelease;
@@ -217,7 +247,7 @@ struct _XENBUS_CACHE_INTERFACE_V1 {
     XENBUS_CACHE_DESTROY    CacheDestroy;
 };
 
-typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
+typedef struct _XENBUS_CACHE_INTERFACE_V2 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
 
 /*! \def XENBUS_CACHE
     \brief Macro at assist in method invocation
@@ -228,6 +258,6 @@ typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE
 #endif  // _WINDLL
 
 #define XENBUS_CACHE_INTERFACE_VERSION_MIN  1
-#define XENBUS_CACHE_INTERFACE_VERSION_MAX  1
+#define XENBUS_CACHE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_CACHE_INTERFACE_H
diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index a9952d656141..05c342e50db8 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -100,6 +100,8 @@ typedef VOID
 
     \b VIRQ:
     \param Index The index number of the VIRQ
+    \param Group The group number of the CPU that should handle the VIRQ
+    \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
 */  
@@ -112,13 +114,6 @@ typedef PXENBUS_EVTCHN_CHANNEL
     ...
     );
 
-typedef NTSTATUS
-(*XENBUS_EVTCHN_BIND_V2)(
-    IN  PINTERFACE              Interface,
-    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  ULONG                   Cpu
-    );
-
 /*! \typedef XENBUS_EVTCHN_BIND
     \brief Bind an event channel to a specific CPU
 
@@ -135,8 +130,8 @@ typedef NTSTATUS
     IN  UCHAR                   Number
     );
 
-typedef BOOLEAN
-(*XENBUS_EVTCHN_UNMASK_V1)(
+typedef VOID
+(*XENBUS_EVTCHN_UNMASK_V4)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
     IN  BOOLEAN                 InCallback
@@ -148,17 +143,28 @@ typedef BOOLEAN
     \param Interface The interface header
     \param Channel The channel handle
     \param InCallback Set to TRUE if this method is invoked in context of the channel callback
+    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return TRUE if the unmask did not complete and there is still an event pending.
 */
-typedef VOID
+typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
-    IN  BOOLEAN                 InCallback
+    IN  BOOLEAN                 InCallback,
+    IN  BOOLEAN                 Force
+    );
+
+typedef VOID
+(*XENBUS_EVTCHN_SEND_V1)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel
     );
 
 /*! \typedef XENBUS_EVTCHN_SEND
     \brief Send an event to the remote end of the channel
 
+    It is assumed that the domain cannot suspend during this call so
+    IRQL must be >= DISPATCH_LEVEL.
+
     \param Interface The interface header
     \param Channel The channel handle
 */  
@@ -180,17 +186,39 @@ typedef VOID
     IN  PXENBUS_EVTCHN_CHANNEL  Channel
     );
 
+/*! \typedef XENBUS_EVTCHN_GET_COUNT
+    \brief Get the number of events received by the channel since it was opened
+
+    \param Interface The interface header
+    \param Channel The channel handle
+    \return The number of events
+*/
+typedef ULONG
+(*XENBUS_EVTCHN_GET_COUNT)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel
+    );
+
+typedef NTSTATUS
+(*XENBUS_EVTCHN_WAIT_V5)(
+    IN  PINTERFACE              Interface,
+    IN  PXENBUS_EVTCHN_CHANNEL  Channel,
+    IN  PLARGE_INTEGER          Timeout OPTIONAL
+    );
+
 /*! \typedef XENBUS_EVTCHN_WAIT
-    \brief Wait for an event to the local end of the channel
+    \brief Wait for events to the local end of the channel
 
     \param Interface The interface header
     \param Channel The channel handle
+    \param Count The event count to wait for
     \param Timeout An optional timeout value (similar to KeWaitForSingleObject(), but non-zero values are allowed at DISPATCH_LEVEL).
 */
 typedef NTSTATUS
 (*XENBUS_EVTCHN_WAIT)(
     IN  PINTERFACE              Interface,
     IN  PXENBUS_EVTCHN_CHANNEL  Channel,
+    IN  ULONG                   Count,
     IN  PLARGE_INTEGER          Timeout OPTIONAL
     );
 
@@ -223,61 +251,66 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V1
-    \brief EVTCHN interface version 1
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V5
+    \brief EVTCHN interface version 5
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V1 {
+struct _XENBUS_EVTCHN_INTERFACE_V5 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_UNMASK_V1 EvtchnUnmaskVersion1;
-    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
+    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_WAIT_V5   EvtchnWaitVersion5;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V2
-    \brief EVTCHN interface version 2
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V6
+    \brief EVTCHN interface version 6
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V2 {
+struct _XENBUS_EVTCHN_INTERFACE_V6 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
-    XENBUS_EVTCHN_UNMASK_V1 EvtchnUnmaskVersion1;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_WAIT_V5   EvtchnWaitVersion5;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V3
-    \brief EVTCHN interface version 3
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V7
+    \brief EVTCHN interface version 7
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V3 {
+struct _XENBUS_EVTCHN_INTERFACE_V7 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
     XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND_V2   EvtchnBindVersion2;
-    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V8
+    \brief EVTCHN interface version 8
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
+struct _XENBUS_EVTCHN_INTERFACE_V8 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -286,15 +319,17 @@ struct _XENBUS_EVTCHN_INTERFACE_V4 {
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V5
-    \brief EVTCHN interface version 5
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V9
+    \brief EVTCHN interface version 9
     \ingroup interfaces
 */
-struct _XENBUS_EVTCHN_INTERFACE_V5 {
+struct _XENBUS_EVTCHN_INTERFACE_V9 {
     INTERFACE               Interface;
     XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
     XENBUS_EVTCHN_RELEASE   EvtchnRelease;
@@ -303,12 +338,13 @@ struct _XENBUS_EVTCHN_INTERFACE_V5 {
     XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
     XENBUS_EVTCHN_SEND      EvtchnSend;
     XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
     XENBUS_EVTCHN_WAIT      EvtchnWait;
     XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V5 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
+typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -318,8 +354,8 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V5 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 1
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
 
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index d29440a5e607..e3ee888bd979 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -72,12 +72,24 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+typedef NTSTATUS
+(*XENBUS_GNTTAB_CREATE_CACHE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    );
+
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
     \brief Create a cache of grant table entries
 
     \param Interface The interface header
     \param Name A name for the cache which will be used in debug output
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param AcquireLock A callback invoked to acquire a spinlock
     \param ReleaseLock A callback invoked to release the spinlock
     \param Argument An optional context argument passed to the callbacks
@@ -88,6 +100,7 @@ typedef NTSTATUS
     IN  PINTERFACE                  Interface,
     IN  const CHAR                  *Name,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
     IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
     IN  PVOID                       Argument OPTIONAL,
@@ -148,6 +161,26 @@ typedef ULONG
     IN  PXENBUS_GNTTAB_ENTRY        Entry
     );
 
+/*! \typedef XENBUS_GNTTAB_QUERY_REFERENCE
+    \brief Get the reference number of the entry
+
+    \param Interface The interface header
+    \param Reference The reference number
+    \param Pfn An optional pointer to receive the value of the reference frame number
+    \param ReadOnly An optional pointer to receive the boolean value of the read-only flag
+*/
+typedef NTSTATUS
+(*XENBUS_GNTTAB_QUERY_REFERENCE)(
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Reference,
+    OUT PPFN_NUMBER Pfn OPTIONAL,
+    OUT PBOOLEAN    ReadOnly OPTIONAL
+    );
+
+#define XENBUS_GNTTAB_CONSOLE_REFERENCE 0
+#define XENBUS_GNTTAB_STORE_REFERENCE   1
+
+
 /*! \typedef XENBUS_GNTTAB_DESTROY_CACHE
     \brief Destroy a cache of grant table entries
 
@@ -163,15 +196,83 @@ typedef VOID
     IN  PXENBUS_GNTTAB_CACHE    Cache
     );
 
+/*! \typedef XENBUS_GNTTAB_MAP_FOREIGN_PAGES
+    \brief Map foreign memory pages into the system address space
+
+    \param Interface The interface header
+    \param Domain The domid of the foreign domain that granted the pages
+    \param NumberPages Number of pages to map
+    \param References Array of grant reference numbers shared by the foreign domain
+    \param ReadOnly If TRUE, pages are mapped with read-only access
+    \param Address The physical address that the foreign pages are mapped under
+*/
+
+typedef NTSTATUS
+(*XENBUS_GNTTAB_MAP_FOREIGN_PAGES)(
+    IN  PINTERFACE              Interface,
+    IN  USHORT                  Domain,
+    IN  ULONG                   NumberPages,
+    IN  PULONG                  References,
+    IN  BOOLEAN                 ReadOnly,
+    OUT PHYSICAL_ADDRESS        *Address
+    );
+
+/*! \typedef XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES
+    \brief Unmap foreign memory pages from the system address space
+
+    \param Interface The interface header
+    \param Address The physical address that the foreign pages are mapped under
+*/
+typedef NTSTATUS
+(*XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES)(
+    IN  PINTERFACE              Interface,
+    IN  PHYSICAL_ADDRESS        Address
+    );
+
 // {763679C5-E5C2-4A6D-8B88-6BB02EC42D8E}
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
+    \brief GNTTAB interface version 2
+    \ingroup interfaces
+*/
+struct _XENBUS_GNTTAB_INTERFACE_V2 {
+    INTERFACE                           Interface;
+    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
+    XENBUS_GNTTAB_RELEASE               GnttabRelease;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
+    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
+    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
+    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
+};
+
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
+    \brief GNTTAB interface version 3
+    \ingroup interfaces
+*/
+struct _XENBUS_GNTTAB_INTERFACE_V3 {
+    INTERFACE                           Interface;
+    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
+    XENBUS_GNTTAB_RELEASE               GnttabRelease;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
+    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
+    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
+    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
+    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
+};
+
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V4
+    \brief GNTTAB interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
+struct _XENBUS_GNTTAB_INTERFACE_V4 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
@@ -179,10 +280,13 @@ struct _XENBUS_GNTTAB_INTERFACE_V1 {
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V1 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
+typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
 
 /*! \def XENBUS_GNTTAB
     \brief Macro at assist in method invocation
@@ -192,8 +296,8 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V1 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 1
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
 
diff --git a/include/revision.h b/include/revision.h
index 8aed6df5c302..b7f798cefdcb 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -39,8 +39,6 @@
 
 //                    REVISION   H  ST SU
 #define DEFINE_REVISION_TABLE              \
-    DEFINE_REVISION(0x09000000,  1, 0, 0), \
-    DEFINE_REVISION(0x09000001,  1, 1, 1), \
     DEFINE_REVISION(0x09000002,  1, 2, 1)
 
 #endif  // _REVISION_H
diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index 6f459754cd41..83b3dc98d8be 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -85,7 +85,7 @@ typedef VOID
     );
 
 // {73db6517-3d06-4937-989f-199b7501e229}
-DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
 0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
 
 /*! \struct _XENBUS_UNPLUG_INTERFACE_V1
diff --git a/src/xenvkbd.inf b/src/xenvkbd.inf
index c571c15ce29c..3d67ef09d108 100644
--- a/src/xenvkbd.inf
+++ b/src/xenvkbd.inf
@@ -59,9 +59,9 @@ xenvkbd_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dl
 ; DisplayName		Section		DeviceID
 ; -----------		-------		--------
 
-%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VKBD&REV_09000000
-%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VKBD&REV_09000000
-%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VKBD&REV_09000000
+%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VKBD&REV_09000009
+%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VKBD&REV_09000009
+%XenVkbdName%		=XenVkbd_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VKBD&REV_09000009
 
 [XenVkbd_Inst] 
 CopyFiles=XenVkbd_Copyfiles
diff --git a/src/xenvkbd/ring.c b/src/xenvkbd/ring.c
index 114427f87712..acb0a5c607d6 100644
--- a/src/xenvkbd/ring.c
+++ b/src/xenvkbd/ring.c
@@ -424,7 +424,8 @@ RingDpc(
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
                   Ring->Channel,
-                  FALSE);
+                  FALSE,
+                  TRUE);
 
 done:
     RingReleaseLock(Ring);
@@ -604,6 +605,7 @@ RingConnect(
                            &Ring->GnttabInterface,
                            "VKBD_Ring_Gnttab",
                            0,
+                           0,
                            RingAcquireLock,
                            RingReleaseLock,
                            Ring,
@@ -660,7 +662,8 @@ RingConnect(
     XENBUS_EVTCHN(Unmask,
                   &Ring->EvtchnInterface,
                   Ring->Channel,
-                  FALSE);
+                  FALSE,
+                  TRUE);
 
     status = XENBUS_DEBUG(Register,
                           &Ring->DebugInterface,
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:33:40 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:33:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87887.165122 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8X5-0001tu-AU; Mon, 22 Feb 2021 10:33:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87887.165122; Mon, 22 Feb 2021 10:33:39 +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 1lE8X5-0001tm-7M; Mon, 22 Feb 2021 10:33:39 +0000
Received: by outflank-mailman (input) for mailman id 87887;
 Mon, 22 Feb 2021 10:33:37 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE8X3-0001tQ-Ra
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:33:37 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8X3-00062Z-Hz; Mon, 22 Feb 2021 10:33:37 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8X3-0002Wp-7K; Mon, 22 Feb 2021 10:33:37 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=vyNYgv/AAoGzDSmGBkgJTAXXZI+oq/G0RZ5MqdxbCtY=; b=pFPms25Wmul3ztSkDUPWDy+QKn
	SD/CfFyy7x4hZnrLGM5S+yIpr2q3uqooC9l/RHre/hXD5mh/YaFprChTizJHwuhraE7R6K/34MHtL
	FdUeW+hX3T9CGpoxFDR3Yz5lYzBUd6J6WtoJahBeEn9enjb72k9nUix9dbg1xmStIbM0=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenhid] Bring XENBUS_STORE interface header up to date
Date: Mon, 22 Feb 2021 10:33:34 +0000
Message-Id: <20210222103334.1005-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

Version 1 has been retired. No functional change (as version 2 was already
in used).

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/store_interface.h | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/include/store_interface.h b/include/store_interface.h
index f2b2147d5b3b..83fed17afffc 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE,
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:48:56 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:48:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87902.165138 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8lq-000317-RL; Mon, 22 Feb 2021 10:48:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87902.165138; Mon, 22 Feb 2021 10:48: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 1lE8lq-00030z-O1; Mon, 22 Feb 2021 10:48:54 +0000
Received: by outflank-mailman (input) for mailman id 87902;
 Mon, 22 Feb 2021 10:48:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE8lp-00030u-7Y
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:48:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8lo-0006HG-UG; Mon, 22 Feb 2021 10:48:52 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8lo-0003vY-Jb; Mon, 22 Feb 2021 10:48:52 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=UeQKdNu0KFdiM3W4b0qp4WvyD/DvkBB8zpwVvu1TRnk=; b=G/V9AKMxh48UF2+oQjO2Rr635M
	/o23RKqLlyro3ruVh4r1g+MJHkqjC6tKrhwnWYHT80RrmU7mEJDf/+WKvjZWs+EiZuSU6spLHuJ+k
	EHbJT2d+EHlMxG+JRVa6odGMS4/kiwYd8pz6+WprrkdhtNRz2b7f4seqDbVhZcRGNB1Q=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenvif] Bring XENBUS interface versions up to date...
Date: Mon, 22 Feb 2021 10:48:49 +0000
Message-Id: <20210222104849.1291-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and update binding accordlingly.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/evtchn_interface.h | 46 +++++++++++++++++++++-----------------
 include/gnttab_interface.h | 44 ++++++++++++++++++++++++------------
 include/store_interface.h  | 22 +-----------------
 include/unplug_interface.h |  2 +-
 src/xenvif.inf             |  6 ++---
 src/xenvif/controller.c    |  1 +
 src/xenvif/receiver.c      |  1 +
 src/xenvif/transmitter.c   |  1 +
 8 files changed, 63 insertions(+), 60 deletions(-)

diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index 068a69734fe9..05c342e50db8 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -100,6 +100,8 @@ typedef VOID
 
     \b VIRQ:
     \param Index The index number of the VIRQ
+    \param Group The group number of the CPU that should handle the VIRQ
+    \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
 */  
@@ -141,7 +143,7 @@ typedef VOID
     \param Interface The interface header
     \param Channel The channel handle
     \param InCallback Set to TRUE if this method is invoked in context of the channel callback
-    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return FALSE if the unmask did not complete.
+    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return TRUE if the unmask did not complete and there is still an event pending.
 */
 typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
@@ -249,23 +251,6 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
-    \ingroup interfaces
-*/
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
-    INTERFACE               Interface;
-    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
-    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
-    XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND      EvtchnBind;
-    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
-    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
-    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
-    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
-    XENBUS_EVTCHN_CLOSE     EvtchnClose;
-};
-
 /*! \struct _XENBUS_EVTCHN_INTERFACE_V5
     \brief EVTCHN interface version 5
     \ingroup interfaces
@@ -340,7 +325,26 @@ struct _XENBUS_EVTCHN_INTERFACE_V8 {
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V9
+    \brief EVTCHN interface version 9
+    \ingroup interfaces
+*/
+struct _XENBUS_EVTCHN_INTERFACE_V9 {
+    INTERFACE               Interface;
+    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
+    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
+    XENBUS_EVTCHN_OPEN      EvtchnOpen;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
+    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
+    XENBUS_EVTCHN_CLOSE     EvtchnClose;
+};
+
+typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -350,8 +354,8 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 8
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
 
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 61272ab41cb3..e3ee888bd979 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -72,12 +72,24 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+typedef NTSTATUS
+(*XENBUS_GNTTAB_CREATE_CACHE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    );
+
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
     \brief Create a cache of grant table entries
 
     \param Interface The interface header
     \param Name A name for the cache which will be used in debug output
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param AcquireLock A callback invoked to acquire a spinlock
     \param ReleaseLock A callback invoked to release the spinlock
     \param Argument An optional context argument passed to the callbacks
@@ -88,6 +100,7 @@ typedef NTSTATUS
     IN  PINTERFACE                  Interface,
     IN  const CHAR                  *Name,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
     IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
     IN  PVOID                       Argument OPTIONAL,
@@ -220,43 +233,46 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
+    \brief GNTTAB interface version 2
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
+struct _XENBUS_GNTTAB_INTERFACE_V2 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
-    \brief GNTTAB interface version 2
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
+    \brief GNTTAB interface version 3
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V2 {
+struct _XENBUS_GNTTAB_INTERFACE_V3 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
     XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
-    \brief GNTTAB interface version 3
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V4
+    \brief GNTTAB interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V3 {
+struct _XENBUS_GNTTAB_INTERFACE_V4 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
@@ -270,7 +286,7 @@ struct _XENBUS_GNTTAB_INTERFACE_V3 {
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
+typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
 
 /*! \def XENBUS_GNTTAB
     \brief Macro at assist in method invocation
@@ -280,8 +296,8 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 3
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
 
diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index 6f459754cd41..83b3dc98d8be 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -85,7 +85,7 @@ typedef VOID
     );
 
 // {73db6517-3d06-4937-989f-199b7501e229}
-DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE, 
+DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
 0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
 
 /*! \struct _XENBUS_UNPLUG_INTERFACE_V1
diff --git a/src/xenvif.inf b/src/xenvif.inf
index b091cfd36d04..5dfcd90a631d 100644
--- a/src/xenvif.inf
+++ b/src/xenvif.inf
@@ -59,9 +59,9 @@ xenvif_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll
 ; DisplayName		Section		DeviceID
 ; -----------		-------		--------
 
-%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_09000005
-%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_09000005
-%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_09000005
+%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VIF&REV_09000009
+%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VIF&REV_09000009
+%XenVifName%		=XenVif_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VIF&REV_09000009
 
 [XenVif_Inst] 
 CopyFiles=XenVif_Copyfiles
diff --git a/src/xenvif/controller.c b/src/xenvif/controller.c
index 35901a264388..3cd0a263aff7 100644
--- a/src/xenvif/controller.c
+++ b/src/xenvif/controller.c
@@ -456,6 +456,7 @@ ControllerConnect(
                            &Controller->GnttabInterface,
                            Name,
                            0,
+                           0,
                            ControllerAcquireLock,
                            ControllerReleaseLock,
                            Controller,
diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 7125743f7443..c70d9382358d 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -2581,6 +2581,7 @@ __ReceiverRingConnect(
                            &Receiver->GnttabInterface,
                            Name,
                            0,
+                           0,
                            ReceiverRingAcquireLock,
                            ReceiverRingReleaseLock,
                            Ring,
diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c
index 6a4db1f0d922..f6935a66e695 100644
--- a/src/xenvif/transmitter.c
+++ b/src/xenvif/transmitter.c
@@ -3692,6 +3692,7 @@ __TransmitterRingConnect(
                            &Transmitter->GnttabInterface,
                            Name,
                            0,
+                           0,
                            TransmitterRingAcquireLock,
                            TransmitterRingReleaseLock,
                            Ring,
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:49:51 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:49:51 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87908.165141 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8mk-00035t-VS; Mon, 22 Feb 2021 10:49:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87908.165141; Mon, 22 Feb 2021 10:49: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 1lE8mk-00035m-SM; Mon, 22 Feb 2021 10:49:50 +0000
Received: by outflank-mailman (input) for mailman id 87908;
 Mon, 22 Feb 2021 10:49:49 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE8mj-00035c-Ic
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:49:49 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8mj-0006ID-CH; Mon, 22 Feb 2021 10:49:49 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8mj-0003zP-2V; Mon, 22 Feb 2021 10:49: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=+sTHO5kIsfcYqJDkBf9DMFwdA8dGxoednX2DCmJyqSM=; b=jRxZv51ttMQHxrHJ5Vlt5TUkB2
	e7EzpT8Suj25wTBRhoaBJ7Yg7rvs+3aFhJdPxbeQL7dImDLKso2GlfMX5nGdVwwFWhvgZ2VyZ4Lg6
	mjfeSd61cPGIz2kqtYjXcmy8V1wYTzucPdYSslNlzh5/gJij7W2cSeQZNr0C3XO4ynIc=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xennet] Update XENBUS and XENVIF interface versions...
Date: Mon, 22 Feb 2021 10:49:42 +0000
Message-Id: <20210222104942.1350-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and update binding. No functional change.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/store_interface.h |  22 +--
 include/vif_interface.h   | 281 ++++++++++++--------------------------
 src/xennet.inf            |   6 +-
 3 files changed, 88 insertions(+), 221 deletions(-)

diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/include/vif_interface.h b/include/vif_interface.h
index 38872bc28c33..20de31433297 100644
--- a/include/vif_interface.h
+++ b/include/vif_interface.h
@@ -68,13 +68,6 @@ typedef enum _XENVIF_PACKET_HASH_TYPE {
     XENVIF_PACKET_HASH_TYPE_IPV6_TCP
 } XENVIF_PACKET_HASH_TYPE, *PXENVIF_PACKET_HASH_TYPE;
 
-struct _XENVIF_PACKET_HASH_V1 {
-    /*! Hash algorithm used to calculate value */
-    XENVIF_PACKET_HASH_ALGORITHM    Algorithm;
-    /*! Calculated value */
-    ULONG                           Value;
-};
-
 /*! \struct _XENVIF_PACKET_HASH_V2
     \brief Hash information
 */
@@ -99,19 +92,6 @@ struct  _XENVIF_PACKET_HEADER_V1 {
     ULONG   Length;
 };
 
-struct _XENVIF_PACKET_INFO_V1 {
-    ULONG                           Length;
-    USHORT                          TagControlInformation;
-    BOOLEAN                         IsAFragment;
-    struct _XENVIF_PACKET_HEADER_V1 EthernetHeader;
-    struct _XENVIF_PACKET_HEADER_V1 LLCSnapHeader;
-    struct _XENVIF_PACKET_HEADER_V1 IpHeader;
-    struct _XENVIF_PACKET_HEADER_V1 IpOptions;
-    struct _XENVIF_PACKET_HEADER_V1 TcpHeader;
-    struct _XENVIF_PACKET_HEADER_V1 TcpOptions;
-    struct _XENVIF_PACKET_HEADER_V1 UdpHeader;
-};
-
 /*! \struct _XENVIF_PACKET_INFO_V2
     \brief Packet information
 */
@@ -152,20 +132,20 @@ struct _XENVIF_PACKET_CHECKSUM_FLAGS_V1 {
             ULONG   IpChecksumSucceeded:1;
             /*! IPv4 header checksum validation failed */
             ULONG   IpChecksumFailed:1;
-            /*! IPv4 header checksum is present */
-            ULONG   IpChecksumPresent:1;
+            /*! IPv4 header checksum not validated */
+            ULONG   IpChecksumNotValidated:1;
             /*! TCP checksum validation succeeded */
             ULONG   TcpChecksumSucceeded:1;
             /*! TCP checksum validation failed */
             ULONG   TcpChecksumFailed:1;
-            /*! TCP checksum is present */
-            ULONG   TcpChecksumPresent:1;
+            /*! TCP checksum not validated */
+            ULONG   TcpChecksumNotValidated:1;
             /*! UDP checksum validation succeeded */
             ULONG   UdpChecksumSucceeded:1;
             /*! UDP checksum validation failed */
             ULONG   UdpChecksumFailed:1;
-            /*! UDP checksum is present */
-            ULONG   UdpChecksumPresent:1;
+            /*! UDP checksum not validated */
+            ULONG   UdpChecksumNotValidated:1;
             ULONG   Reserved:23;
         };
         /*! Raw representation */
@@ -175,24 +155,6 @@ struct _XENVIF_PACKET_CHECKSUM_FLAGS_V1 {
 
 typedef struct _XENVIF_PACKET_CHECKSUM_FLAGS_V1 XENVIF_PACKET_CHECKSUM_FLAGS, *PXENVIF_PACKET_CHECKSUM_FLAGS;
 
-#pragma warning(pop)
-
-struct _XENVIF_RECEIVER_PACKET_V1 {
-    LIST_ENTRY                              ListEntry;
-    struct _XENVIF_PACKET_INFO_V1           *Info;
-    ULONG                                   Offset;
-    ULONG                                   Length;
-    struct _XENVIF_PACKET_CHECKSUM_FLAGS_V1 Flags;
-    USHORT                                  MaximumSegmentSize;
-    PVOID                                   Cookie;
-    MDL                                     Mdl;
-    PFN_NUMBER                              __Pfn;
-};
-
-#pragma warning(push)
-#pragma warning(disable:4214)   // nonstandard extension used : bit field types other than int
-#pragma warning(disable:4201)   // nonstandard extension used : nameless struct/union
-
 /*! \struct _XENVIF_VIF_OFFLOAD_OPTIONS_V1
     \brief Offload options
 */
@@ -288,6 +250,10 @@ struct _XENVIF_TRANSMITTER_PACKET_V2 {
     \brief Interface statistics
 */
 typedef enum _XENVIF_VIF_STATISTIC {
+    /*
+     * Statistics required by XENNET
+     */
+
     /*! RFC 2863 ifOutDiscards */
     XENVIF_TRANSMITTER_PACKETS_DROPPED = 0,
     /*! Backend component of RFC 2863 ifOutErrors */
@@ -324,6 +290,77 @@ typedef enum _XENVIF_VIF_STATISTIC {
     XENVIF_RECEIVER_BROADCAST_PACKETS,
     /*! Total number of octets in ifInBroadcastPkts */
     XENVIF_RECEIVER_BROADCAST_OCTETS,
+
+    /*
+     * Miscellaneous statistics
+     */
+
+    /*! Total number of outbound VLAN tagged packets */
+    XENVIF_TRANSMITTER_TAGGED_PACKETS,
+    /*! Total number of outbound LLC/SNAP packets */
+    XENVIF_TRANSMITTER_LLC_SNAP_PACKETS,
+    /*! Total number of outbound IP version 4 packets */
+    XENVIF_TRANSMITTER_IPV4_PACKETS,
+    /*! Total number of outbound IP version 6 packets */
+    XENVIF_TRANSMITTER_IPV6_PACKETS,
+    /*! Total number of outbound TCP packets */
+    XENVIF_TRANSMITTER_TCP_PACKETS,
+    /*! Total number of outbound UDP packets */
+    XENVIF_TRANSMITTER_UDP_PACKETS,
+    /*! Total number of outbound GSO packets */
+    XENVIF_TRANSMITTER_GSO_PACKETS,
+    /*! Total number of outbound IP version 4 packets with good checksum */
+    XENVIF_TRANSMITTER_IPV4_CHECKSUM_SUCCEEDED,
+    /*! Total number of outbound IP version 4 packets with bad checksum */
+    XENVIF_TRANSMITTER_IPV4_CHECKSUM_FAILED,
+    /*! Total number of outbound IP version 4 packets without validated checksum */
+    XENVIF_TRANSMITTER_IPV4_CHECKSUM_NOT_VALIDATED,
+    /*! Total number of outbound TCP packets with good checksum */
+    XENVIF_TRANSMITTER_TCP_CHECKSUM_SUCCEEDED,
+    /*! Total number of outbound TCP packets with bad checksum */
+    XENVIF_TRANSMITTER_TCP_CHECKSUM_FAILED,
+    /*! Total number of outbound TCP packets without validated checksum */
+    XENVIF_TRANSMITTER_TCP_CHECKSUM_NOT_VALIDATED,
+    /*! Total number of outbound UDP packets with good checksum */
+    XENVIF_TRANSMITTER_UDP_CHECKSUM_SUCCEEDED,
+    /*! Total number of outbound UDP packets with bad checksum */
+    XENVIF_TRANSMITTER_UDP_CHECKSUM_FAILED,
+    /*! Total number of outbound UDP packets without validated checksum */
+    XENVIF_TRANSMITTER_UDP_CHECKSUM_NOT_VALIDATED,
+
+
+    /*! Total number of inbound VLAN tagged packets */
+    XENVIF_RECEIVER_TAGGED_PACKETS,
+    /*! Total number of inbound LLC/SNAP packets */
+    XENVIF_RECEIVER_LLC_SNAP_PACKETS,
+    /*! Total number of inbound IP version 4 packets */
+    XENVIF_RECEIVER_IPV4_PACKETS,
+    /*! Total number of inbound IP version 6 packets */
+    XENVIF_RECEIVER_IPV6_PACKETS,
+    /*! Total number of inbound TCP packets */
+    XENVIF_RECEIVER_TCP_PACKETS,
+    /*! Total number of inbound UDP packets */
+    XENVIF_RECEIVER_UDP_PACKETS,
+    /*! Total number of inbound GSO packets */
+    XENVIF_RECEIVER_GSO_PACKETS,
+    /*! Total number of inbound IP version 4 packets with good checksum */
+    XENVIF_RECEIVER_IPV4_CHECKSUM_SUCCEEDED,
+    /*! Total number of inbound IP version 4 packets with bad checksum */
+    XENVIF_RECEIVER_IPV4_CHECKSUM_FAILED,
+    /*! Total number of inbound IP version 4 packets without validated checksum */
+    XENVIF_RECEIVER_IPV4_CHECKSUM_NOT_VALIDATED,
+    /*! Total number of inbound TCP packets with good checksum */
+    XENVIF_RECEIVER_TCP_CHECKSUM_SUCCEEDED,
+    /*! Total number of inbound TCP packets with bad checksum */
+    XENVIF_RECEIVER_TCP_CHECKSUM_FAILED,
+    /*! Total number of inbound TCP packets without validated checksum */
+    XENVIF_RECEIVER_TCP_CHECKSUM_NOT_VALIDATED,
+    /*! Total number of inbound UDP packets with good checksum */
+    XENVIF_RECEIVER_UDP_CHECKSUM_SUCCEEDED,
+    /*! Total number of inbound UDP packets with bad checksum */
+    XENVIF_RECEIVER_UDP_CHECKSUM_FAILED,
+    /*! Total number of inbound UDP packets without validated checksum */
+    XENVIF_RECEIVER_UDP_CHECKSUM_NOT_VALIDATED,
     XENVIF_VIF_STATISTIC_COUNT
 } XENVIF_VIF_STATISTIC, *PXENVIF_VIF_STATISTIC;
 
@@ -483,12 +520,6 @@ typedef NTSTATUS
     IN  ULONG               Size
     );
 
-typedef VOID
-(*XENVIF_VIF_RECEIVER_RETURN_PACKETS_V1)(
-    IN  PINTERFACE  Interface,
-    IN  PLIST_ENTRY List
-    );
-
 /*! \typedef XENVIF_VIF_RECEIVER_RETURN_PACKET
     \brief Return packets queued for receive by \ref XENVIF_VIF_CALLBACK
     (Type = \ref XENVIF_RECEIVER_QUEUE_PACKET)
@@ -503,34 +534,7 @@ typedef VOID
     );
 
 typedef NTSTATUS
-(*XENVIF_VIF_TRANSMITTER_GET_PACKET_HEADERS_V2)(
-    IN  PINTERFACE                              Interface,
-    IN  struct _XENVIF_TRANSMITTER_PACKET_V2    *Packet,
-    OUT PVOID                                   Headers,
-    OUT PXENVIF_PACKET_INFO                     Info
-    );
-
-typedef NTSTATUS
-(*XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS_V2)(
-    IN  PINTERFACE  Interface,
-    IN  PLIST_ENTRY List
-    );
-
-typedef VOID
-(*XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V4)(
-    IN  PINTERFACE                  Interface,
-    IN  PMDL                        Mdl,
-    IN  ULONG                       Offset,
-    IN  ULONG                       Length,
-    IN  XENVIF_VIF_OFFLOAD_OPTIONS  OffloadOptions,
-    IN  USHORT                      MaximumSegmentSize,
-    IN  USHORT                      TagControlInformation,
-    IN  PXENVIF_PACKET_HASH         Hash,
-    IN  PVOID                       Cookie
-    );
-
-typedef NTSTATUS
-(*XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V5)(
+(*XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V6)(
     IN  PINTERFACE                  Interface,
     IN  PMDL                        Mdl,
     IN  ULONG                       Offset,
@@ -822,123 +826,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENVIF_VIF_INTERFACE, 
 0x76f279cd, 0xca11, 0x418b, 0x92, 0xe8, 0xc5, 0x7f, 0x77, 0xde, 0xe, 0x2e);
 
-/*! \struct _XENVIF_VIF_INTERFACE_V2
-    \brief VIF interface version 2
-    \ingroup interfaces
-*/
-struct _XENVIF_VIF_INTERFACE_V2 {
-    INTERFACE                                       Interface;
-    XENVIF_VIF_ACQUIRE                              Acquire;
-    XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
-    XENVIF_VIF_DISABLE                              Disable;
-    XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
-    XENVIF_VIF_RECEIVER_RETURN_PACKETS_V1           ReceiverReturnPacketsVersion1;
-    XENVIF_VIF_RECEIVER_SET_OFFLOAD_OPTIONS         ReceiverSetOffloadOptions;
-    XENVIF_VIF_RECEIVER_QUERY_RING_SIZE             ReceiverQueryRingSize;
-    XENVIF_VIF_TRANSMITTER_GET_PACKET_HEADERS_V2    TransmitterGetPacketHeadersVersion2;
-    XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS_V2         TransmitterQueuePacketsVersion2;
-    XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS    TransmitterQueryOffloadOptions;
-    XENVIF_VIF_TRANSMITTER_QUERY_LARGE_PACKET_SIZE  TransmitterQueryLargePacketSize;
-    XENVIF_VIF_TRANSMITTER_QUERY_RING_SIZE          TransmitterQueryRingSize;
-    XENVIF_VIF_MAC_QUERY_STATE                      MacQueryState;
-    XENVIF_VIF_MAC_QUERY_MAXIMUM_FRAME_SIZE         MacQueryMaximumFrameSize;
-    XENVIF_VIF_MAC_QUERY_PERMANENT_ADDRESS          MacQueryPermanentAddress;
-    XENVIF_VIF_MAC_QUERY_CURRENT_ADDRESS            MacQueryCurrentAddress;
-    XENVIF_VIF_MAC_QUERY_MULTICAST_ADDRESSES        MacQueryMulticastAddresses;
-    XENVIF_VIF_MAC_SET_MULTICAST_ADDRESSES          MacSetMulticastAddresses;
-    XENVIF_VIF_MAC_SET_FILTER_LEVEL                 MacSetFilterLevel;
-    XENVIF_VIF_MAC_QUERY_FILTER_LEVEL               MacQueryFilterLevel;
-};
-
-/*! \struct _XENVIF_VIF_INTERFACE_V3
-    \brief VIF interface version 3
-    \ingroup interfaces
-*/
-struct _XENVIF_VIF_INTERFACE_V3 {
-    INTERFACE                                       Interface;
-    XENVIF_VIF_ACQUIRE                              Acquire;
-    XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
-    XENVIF_VIF_DISABLE                              Disable;
-    XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
-    XENVIF_VIF_RECEIVER_RETURN_PACKETS_V1           ReceiverReturnPacketsVersion1;
-    XENVIF_VIF_RECEIVER_SET_OFFLOAD_OPTIONS         ReceiverSetOffloadOptions;
-    XENVIF_VIF_RECEIVER_SET_BACKFILL_SIZE           ReceiverSetBackfillSize;
-    XENVIF_VIF_RECEIVER_QUERY_RING_SIZE             ReceiverQueryRingSize;
-    XENVIF_VIF_TRANSMITTER_GET_PACKET_HEADERS_V2    TransmitterGetPacketHeadersVersion2;
-    XENVIF_VIF_TRANSMITTER_QUEUE_PACKETS_V2         TransmitterQueuePacketsVersion2;
-    XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS    TransmitterQueryOffloadOptions;
-    XENVIF_VIF_TRANSMITTER_QUERY_LARGE_PACKET_SIZE  TransmitterQueryLargePacketSize;
-    XENVIF_VIF_TRANSMITTER_QUERY_RING_SIZE          TransmitterQueryRingSize;
-    XENVIF_VIF_MAC_QUERY_STATE                      MacQueryState;
-    XENVIF_VIF_MAC_QUERY_MAXIMUM_FRAME_SIZE         MacQueryMaximumFrameSize;
-    XENVIF_VIF_MAC_QUERY_PERMANENT_ADDRESS          MacQueryPermanentAddress;
-    XENVIF_VIF_MAC_QUERY_CURRENT_ADDRESS            MacQueryCurrentAddress;
-    XENVIF_VIF_MAC_QUERY_MULTICAST_ADDRESSES        MacQueryMulticastAddresses;
-    XENVIF_VIF_MAC_SET_MULTICAST_ADDRESSES          MacSetMulticastAddresses;
-    XENVIF_VIF_MAC_SET_FILTER_LEVEL                 MacSetFilterLevel;
-    XENVIF_VIF_MAC_QUERY_FILTER_LEVEL               MacQueryFilterLevel;
-};
-
-/*! \struct _XENVIF_VIF_INTERFACE_V4
-    \brief VIF interface version 4
-    \ingroup interfaces
-*/
-struct _XENVIF_VIF_INTERFACE_V4 {
-    INTERFACE                                       Interface;
-    XENVIF_VIF_ACQUIRE                              Acquire;
-    XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
-    XENVIF_VIF_DISABLE                              Disable;
-    XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
-    XENVIF_VIF_RECEIVER_RETURN_PACKET               ReceiverReturnPacket;
-    XENVIF_VIF_RECEIVER_SET_OFFLOAD_OPTIONS         ReceiverSetOffloadOptions;
-    XENVIF_VIF_RECEIVER_SET_BACKFILL_SIZE           ReceiverSetBackfillSize;
-    XENVIF_VIF_RECEIVER_QUERY_RING_SIZE             ReceiverQueryRingSize;
-    XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V4          TransmitterQueuePacketVersion4;
-    XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS    TransmitterQueryOffloadOptions;
-    XENVIF_VIF_TRANSMITTER_QUERY_LARGE_PACKET_SIZE  TransmitterQueryLargePacketSize;
-    XENVIF_VIF_TRANSMITTER_QUERY_RING_SIZE          TransmitterQueryRingSize;
-    XENVIF_VIF_MAC_QUERY_STATE                      MacQueryState;
-    XENVIF_VIF_MAC_QUERY_MAXIMUM_FRAME_SIZE         MacQueryMaximumFrameSize;
-    XENVIF_VIF_MAC_QUERY_PERMANENT_ADDRESS          MacQueryPermanentAddress;
-    XENVIF_VIF_MAC_QUERY_CURRENT_ADDRESS            MacQueryCurrentAddress;
-    XENVIF_VIF_MAC_QUERY_MULTICAST_ADDRESSES        MacQueryMulticastAddresses;
-    XENVIF_VIF_MAC_SET_MULTICAST_ADDRESSES          MacSetMulticastAddresses;
-    XENVIF_VIF_MAC_SET_FILTER_LEVEL                 MacSetFilterLevel;
-    XENVIF_VIF_MAC_QUERY_FILTER_LEVEL               MacQueryFilterLevel;
-};
-
-/*! \struct _XENVIF_VIF_INTERFACE_V5
-    \brief VIF interface version 5
-    \ingroup interfaces
-*/
-struct _XENVIF_VIF_INTERFACE_V5 {
-    INTERFACE                                       Interface;
-    XENVIF_VIF_ACQUIRE                              Acquire;
-    XENVIF_VIF_RELEASE                              Release;
-    XENVIF_VIF_ENABLE                               Enable;
-    XENVIF_VIF_DISABLE                              Disable;
-    XENVIF_VIF_QUERY_STATISTIC                      QueryStatistic;
-    XENVIF_VIF_RECEIVER_RETURN_PACKET               ReceiverReturnPacket;
-    XENVIF_VIF_RECEIVER_SET_OFFLOAD_OPTIONS         ReceiverSetOffloadOptions;
-    XENVIF_VIF_RECEIVER_SET_BACKFILL_SIZE           ReceiverSetBackfillSize;
-    XENVIF_VIF_RECEIVER_QUERY_RING_SIZE             ReceiverQueryRingSize;
-    XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V5          TransmitterQueuePacket;
-    XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS    TransmitterQueryOffloadOptions;
-    XENVIF_VIF_TRANSMITTER_QUERY_LARGE_PACKET_SIZE  TransmitterQueryLargePacketSize;
-    XENVIF_VIF_TRANSMITTER_QUERY_RING_SIZE          TransmitterQueryRingSize;
-    XENVIF_VIF_MAC_QUERY_STATE                      MacQueryState;
-    XENVIF_VIF_MAC_QUERY_MAXIMUM_FRAME_SIZE         MacQueryMaximumFrameSize;
-    XENVIF_VIF_MAC_QUERY_PERMANENT_ADDRESS          MacQueryPermanentAddress;
-    XENVIF_VIF_MAC_QUERY_CURRENT_ADDRESS            MacQueryCurrentAddress;
-    XENVIF_VIF_MAC_QUERY_MULTICAST_ADDRESSES        MacQueryMulticastAddresses;
-    XENVIF_VIF_MAC_SET_MULTICAST_ADDRESSES          MacSetMulticastAddresses;
-    XENVIF_VIF_MAC_SET_FILTER_LEVEL                 MacSetFilterLevel;
-    XENVIF_VIF_MAC_QUERY_FILTER_LEVEL               MacQueryFilterLevel;
-};
-
 /*! \struct _XENVIF_VIF_INTERFACE_V6
     \brief VIF interface version 6
     \ingroup interfaces
@@ -959,7 +846,7 @@ struct _XENVIF_VIF_INTERFACE_V6 {
     XENVIF_VIF_RECEIVER_SET_HASH_ALGORITHM          ReceiverSetHashAlgorithm;
     XENVIF_VIF_RECEIVER_QUERY_HASH_CAPABILITIES     ReceiverQueryHashCapabilities;
     XENVIF_VIF_RECEIVER_UPDATE_HASH_PARAMETERS      ReceiverUpdateHashParameters;
-    XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V5          TransmitterQueuePacket;
+    XENVIF_VIF_TRANSMITTER_QUEUE_PACKET_V6          TransmitterQueuePacket;
     XENVIF_VIF_TRANSMITTER_QUERY_OFFLOAD_OPTIONS    TransmitterQueryOffloadOptions;
     XENVIF_VIF_TRANSMITTER_QUERY_LARGE_PACKET_SIZE  TransmitterQueryLargePacketSize;
     XENVIF_VIF_TRANSMITTER_QUERY_RING_SIZE          TransmitterQueryRingSize;
@@ -1051,7 +938,7 @@ typedef struct _XENVIF_VIF_INTERFACE_V8 XENVIF_VIF_INTERFACE, *PXENVIF_VIF_INTER
 
 #endif  // _WINDLL
 
-#define XENVIF_VIF_INTERFACE_VERSION_MIN    2
+#define XENVIF_VIF_INTERFACE_VERSION_MIN    6
 #define XENVIF_VIF_INTERFACE_VERSION_MAX    8
 
 #endif  // _XENVIF_INTERFACE_H
diff --git a/src/xennet.inf b/src/xennet.inf
index d39b712ddb6e..b36b1e36ebfb 100644
--- a/src/xennet.inf
+++ b/src/xennet.inf
@@ -61,9 +61,9 @@ xennet_coinst_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.dll
 ; DisplayName		Section		DeviceID
 ; -----------		-------		--------
 
-%XenNetName%		=XenNet_Inst,	XENVIF\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_NET&REV_09000000
-%XenNetName%		=XenNet_Inst,	XENVIF\VEN_@VENDOR_PREFIX@0001&DEV_NET&REV_09000000
-%XenNetName%		=XenNet_Inst,	XENVIF\VEN_@VENDOR_PREFIX@0002&DEV_NET&REV_09000000
+%XenNetName%		=XenNet_Inst,	XENVIF\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_NET&REV_09000001
+%XenNetName%		=XenNet_Inst,	XENVIF\VEN_@VENDOR_PREFIX@0001&DEV_NET&REV_09000001
+%XenNetName%		=XenNet_Inst,	XENVIF\VEN_@VENDOR_PREFIX@0002&DEV_NET&REV_09000001
 
 [XenNet_Inst] 
 Characteristics=0x84
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 10:57:01 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 10:57:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87923.165170 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE8tg-0004AK-Vr; Mon, 22 Feb 2021 10:57:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87923.165170; Mon, 22 Feb 2021 10:57: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 1lE8tg-0004AB-Sf; Mon, 22 Feb 2021 10:57:00 +0000
Received: by outflank-mailman (input) for mailman id 87923;
 Mon, 22 Feb 2021 10:57:00 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE8tg-0004A4-2l
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 10:57:00 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8tf-0006QD-ST; Mon, 22 Feb 2021 10:56:59 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE8tf-0004Yq-JN; Mon, 22 Feb 2021 10:56: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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=fMg0VqI6hkN8rupWU56bD3Jeh0c9C0xWjDNaZAX+bX4=; b=n80fItSo6IsBLmPWGf5CkPByVN
	a5hPahmmXrvFHt6JigY8KBM8GH4EpxN1j8kBhB7yyILh+oNsXQI3XvLypIf9tEiooQLHKIAxv5h4a
	3K6AKZIFwAvxOnSL95ttH3WcC64VSiVGmwXnLMqGUhGl2sBCGJB9ONiitRoc1KJbVkZ8=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xencons] Bring XENBUS interface versions up to date...
Date: Mon, 22 Feb 2021 10:56:57 +0000
Message-Id: <20210222105657.1537-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and update binding accordingly.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/cache_interface.h  | 34 ++++++++++++++++++++++++++--
 include/evtchn_interface.h | 46 +++++++++++++++++++++-----------------
 include/gnttab_interface.h | 44 ++++++++++++++++++++++++------------
 include/store_interface.h  | 22 +-----------------
 src/xencons.inf            |  6 ++---
 src/xencons/ring.c         |  1 +
 6 files changed, 92 insertions(+), 61 deletions(-)

diff --git a/include/cache_interface.h b/include/cache_interface.h
index ac50a82a804f..048e06b3f1c5 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -123,6 +123,20 @@ typedef VOID
     IN  PVOID   Argument
     );
 
+typedef NTSTATUS
+(*XENBUS_CACHE_CREATE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Size,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_CTOR           Ctor,
+    IN  XENBUS_CACHE_DTOR           Dtor,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_CACHE               *Cache
+    );
+
 /*! \typedef XENBUS_CACHE_CREATE
     \brief Create a cache of objects of the given \a Size
 
@@ -130,6 +144,7 @@ typedef VOID
     \param Name A name for the cache which will be used in debug output
     \param Size The size of each object in bytes
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param Ctor A callback which is invoked when a new object created
     \param Dtor A callback which is invoked when an object is destroyed
     \param AcquireLock A callback invoked to acquire a spinlock
@@ -146,6 +161,7 @@ typedef NTSTATUS
     IN  const CHAR                  *Name,
     IN  ULONG                       Size,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_CTOR           Ctor,
     IN  XENBUS_CACHE_DTOR           Dtor,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
@@ -208,6 +224,20 @@ DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE,
     \ingroup interfaces
 */
 struct _XENBUS_CACHE_INTERFACE_V1 {
+    INTERFACE               Interface;
+    XENBUS_CACHE_ACQUIRE    CacheAcquire;
+    XENBUS_CACHE_RELEASE    CacheRelease;
+    XENBUS_CACHE_CREATE_V1  CacheCreateVersion1;
+    XENBUS_CACHE_GET        CacheGet;
+    XENBUS_CACHE_PUT        CachePut;
+    XENBUS_CACHE_DESTROY    CacheDestroy;
+};
+
+/*! \struct _XENBUS_CACHE_INTERFACE_V2
+    \brief CACHE interface version 1
+    \ingroup interfaces
+*/
+struct _XENBUS_CACHE_INTERFACE_V2 {
     INTERFACE               Interface;
     XENBUS_CACHE_ACQUIRE    CacheAcquire;
     XENBUS_CACHE_RELEASE    CacheRelease;
@@ -217,7 +247,7 @@ struct _XENBUS_CACHE_INTERFACE_V1 {
     XENBUS_CACHE_DESTROY    CacheDestroy;
 };
 
-typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
+typedef struct _XENBUS_CACHE_INTERFACE_V2 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
 
 /*! \def XENBUS_CACHE
     \brief Macro at assist in method invocation
@@ -228,6 +258,6 @@ typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE
 #endif  // _WINDLL
 
 #define XENBUS_CACHE_INTERFACE_VERSION_MIN  1
-#define XENBUS_CACHE_INTERFACE_VERSION_MAX  1
+#define XENBUS_CACHE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_CACHE_INTERFACE_H
diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index 3f881bb86257..dbe874511866 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -100,6 +100,8 @@ typedef VOID
 
     \b VIRQ:
     \param Index The index number of the VIRQ
+    \param Group The group number of the CPU that should handle the VIRQ
+    \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
 */
@@ -141,7 +143,7 @@ typedef VOID
     \param Interface The interface header
     \param Channel The channel handle
     \param InCallback Set to TRUE if this method is invoked in context of the channel callback
-    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return FALSE if the unmask did not complete.
+    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return TRUE if the unmask did not complete and there is still an event pending.
 */
 typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
@@ -249,23 +251,6 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE,
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
-    \ingroup interfaces
-*/
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
-    INTERFACE               Interface;
-    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
-    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
-    XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND      EvtchnBind;
-    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
-    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
-    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
-    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
-    XENBUS_EVTCHN_CLOSE     EvtchnClose;
-};
-
 /*! \struct _XENBUS_EVTCHN_INTERFACE_V5
     \brief EVTCHN interface version 5
     \ingroup interfaces
@@ -340,7 +325,26 @@ struct _XENBUS_EVTCHN_INTERFACE_V8 {
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V9
+    \brief EVTCHN interface version 9
+    \ingroup interfaces
+*/
+struct _XENBUS_EVTCHN_INTERFACE_V9 {
+    INTERFACE               Interface;
+    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
+    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
+    XENBUS_EVTCHN_OPEN      EvtchnOpen;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
+    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
+    XENBUS_EVTCHN_CLOSE     EvtchnClose;
+};
+
+typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -350,7 +354,7 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 8
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index f4ad413b8095..865c4f302444 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -72,12 +72,24 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+typedef NTSTATUS
+(*XENBUS_GNTTAB_CREATE_CACHE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    );
+
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
     \brief Create a cache of grant table entries
 
     \param Interface The interface header
     \param Name A name for the cache which will be used in debug output
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param AcquireLock A callback invoked to acquire a spinlock
     \param ReleaseLock A callback invoked to release the spinlock
     \param Argument An optional context argument passed to the callbacks
@@ -88,6 +100,7 @@ typedef NTSTATUS
     IN  PINTERFACE                  Interface,
     IN  const CHAR                  *Name,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
     IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
     IN  PVOID                       Argument OPTIONAL,
@@ -220,43 +233,46 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE,
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
+    \brief GNTTAB interface version 2
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
+struct _XENBUS_GNTTAB_INTERFACE_V2 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
-    \brief GNTTAB interface version 2
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
+    \brief GNTTAB interface version 3
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V2 {
+struct _XENBUS_GNTTAB_INTERFACE_V3 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
     XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
-    \brief GNTTAB interface version 3
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V4
+    \brief GNTTAB interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V3 {
+struct _XENBUS_GNTTAB_INTERFACE_V4 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
@@ -270,7 +286,7 @@ struct _XENBUS_GNTTAB_INTERFACE_V3 {
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
+typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
 
 /*! \def XENBUS_GNTTAB
     \brief Macro at assist in method invocation
@@ -280,7 +296,7 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 3
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
diff --git a/include/store_interface.h b/include/store_interface.h
index f2b2147d5b3b..83fed17afffc 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE,
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/src/xencons.inf b/src/xencons.inf
index 606ef393e045..5eab17f53401 100644
--- a/src/xencons.inf
+++ b/src/xencons.inf
@@ -71,9 +71,9 @@ xencons_tty_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@_@BUILD_NUMBER@.exe,x
 ; DisplayName		Section		DeviceID
 ; -----------		-------		--------
 
-%XenConsName%		=XenCons_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_CONS&REV_09000000
-%XenConsName%		=XenCons_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_CONS&REV_09000000
-%XenConsName%		=XenCons_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_CONS&REV_09000000
+%XenConsName%		=XenCons_Inst,	XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_CONS&REV_09000009
+%XenConsName%		=XenCons_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_CONS&REV_09000009
+%XenConsName%		=XenCons_Inst,	XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_CONS&REV_09000009
 
 [XenCons_Inst]
 CopyFiles=XenCons_Copyfiles
diff --git a/src/xencons/ring.c b/src/xencons/ring.c
index e6e4f2c17c81..c4f01225c8bd 100644
--- a/src/xencons/ring.c
+++ b/src/xencons/ring.c
@@ -709,6 +709,7 @@ RingConnect(
                            &Ring->GnttabInterface,
                            Name,
                            0,
+                           0,
                            RingAcquireLock,
                            RingReleaseLock,
                            Ring,
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 11:03:42 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 11:03:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87943.165209 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE908-0005QA-7G; Mon, 22 Feb 2021 11:03:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87943.165209; Mon, 22 Feb 2021 11:03:40 +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 1lE908-0005Q3-4I; Mon, 22 Feb 2021 11:03:40 +0000
Received: by outflank-mailman (input) for mailman id 87943;
 Mon, 22 Feb 2021 11:03:38 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE906-0005Ph-LA
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 11:03:38 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE906-0006Ze-CW; Mon, 22 Feb 2021 11:03:38 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE906-00056w-2k; Mon, 22 Feb 2021 11:03:38 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=JgRJbepGovPdlDWXQj2tdmS02xoqT7PMqzxN2EIec28=; b=CrdVyao4l0NKLxgFwEtPe7Fv/5
	reovQGfKVyeVSeY88bVd4WLe/hG5uhIaGuWlIAaBuQPrE8GKBCxh1WunWAF7/uEIcRcy9Xwt8aGLd
	eFy4Hjf7Jn3YUmEgTpf5wuNbtSxnhJh8Yd7TjzRVDewcCfkXhiuk9U0l2nkO26DFlGx0=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xenvbd] Bring XENBUS interface versions up to date...
Date: Mon, 22 Feb 2021 11:03:35 +0000
Message-Id: <20210222110335.1741-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and amend binding accordingly.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/cache_interface.h  | 34 ++++++++++++++++++++++++++--
 include/evtchn_interface.h | 46 +++++++++++++++++++++-----------------
 include/gnttab_interface.h | 44 ++++++++++++++++++++++++------------
 include/store_interface.h  | 22 +-----------------
 src/xenvbd.inf             |  6 ++---
 src/xenvbd/adapter.c       |  1 +
 src/xenvbd/granter.c       |  1 +
 src/xenvbd/ring.c          |  3 +++
 8 files changed, 96 insertions(+), 61 deletions(-)

diff --git a/include/cache_interface.h b/include/cache_interface.h
index dae3ac6d556c..ce50f4e46376 100644
--- a/include/cache_interface.h
+++ b/include/cache_interface.h
@@ -123,6 +123,20 @@ typedef VOID
     IN  PVOID   Argument
     );
 
+typedef NTSTATUS
+(*XENBUS_CACHE_CREATE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Size,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_CTOR           Ctor,
+    IN  XENBUS_CACHE_DTOR           Dtor,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_CACHE               *Cache
+    );
+
 /*! \typedef XENBUS_CACHE_CREATE
     \brief Create a cache of objects of the given \a Size
 
@@ -130,6 +144,7 @@ typedef VOID
     \param Name A name for the cache which will be used in debug output
     \param Size The size of each object in bytes
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param Ctor A callback which is invoked when a new object created
     \param Dtor A callback which is invoked when an object is destroyed
     \param AcquireLock A callback invoked to acquire a spinlock
@@ -146,6 +161,7 @@ typedef NTSTATUS
     IN  const CHAR                  *Name,
     IN  ULONG                       Size,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_CTOR           Ctor,
     IN  XENBUS_CACHE_DTOR           Dtor,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
@@ -208,6 +224,20 @@ DEFINE_GUID(GUID_XENBUS_CACHE_INTERFACE,
     \ingroup interfaces
 */
 struct _XENBUS_CACHE_INTERFACE_V1 {
+    INTERFACE               Interface;
+    XENBUS_CACHE_ACQUIRE    CacheAcquire;
+    XENBUS_CACHE_RELEASE    CacheRelease;
+    XENBUS_CACHE_CREATE_V1  CacheCreateVersion1;
+    XENBUS_CACHE_GET        CacheGet;
+    XENBUS_CACHE_PUT        CachePut;
+    XENBUS_CACHE_DESTROY    CacheDestroy;
+};
+
+/*! \struct _XENBUS_CACHE_INTERFACE_V2
+    \brief CACHE interface version 1
+    \ingroup interfaces
+*/
+struct _XENBUS_CACHE_INTERFACE_V2 {
     INTERFACE               Interface;
     XENBUS_CACHE_ACQUIRE    CacheAcquire;
     XENBUS_CACHE_RELEASE    CacheRelease;
@@ -217,7 +247,7 @@ struct _XENBUS_CACHE_INTERFACE_V1 {
     XENBUS_CACHE_DESTROY    CacheDestroy;
 };
 
-typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
+typedef struct _XENBUS_CACHE_INTERFACE_V2 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE_INTERFACE;
 
 /*! \def XENBUS_CACHE
     \brief Macro at assist in method invocation
@@ -228,6 +258,6 @@ typedef struct _XENBUS_CACHE_INTERFACE_V1 XENBUS_CACHE_INTERFACE, *PXENBUS_CACHE
 #endif  // _WINDLL
 
 #define XENBUS_CACHE_INTERFACE_VERSION_MIN  1
-#define XENBUS_CACHE_INTERFACE_VERSION_MAX  1
+#define XENBUS_CACHE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_CACHE_INTERFACE_H
diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index 068a69734fe9..05c342e50db8 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -100,6 +100,8 @@ typedef VOID
 
     \b VIRQ:
     \param Index The index number of the VIRQ
+    \param Group The group number of the CPU that should handle the VIRQ
+    \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
 */  
@@ -141,7 +143,7 @@ typedef VOID
     \param Interface The interface header
     \param Channel The channel handle
     \param InCallback Set to TRUE if this method is invoked in context of the channel callback
-    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return FALSE if the unmask did not complete.
+    \param Force Set to TRUE if the unmask must succeed, otherwise set to FALSE and the function will return TRUE if the unmask did not complete and there is still an event pending.
 */
 typedef BOOLEAN
 (*XENBUS_EVTCHN_UNMASK)(
@@ -249,23 +251,6 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE, 
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
-    \ingroup interfaces
-*/
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
-    INTERFACE               Interface;
-    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
-    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
-    XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND      EvtchnBind;
-    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
-    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
-    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
-    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
-    XENBUS_EVTCHN_CLOSE     EvtchnClose;
-};
-
 /*! \struct _XENBUS_EVTCHN_INTERFACE_V5
     \brief EVTCHN interface version 5
     \ingroup interfaces
@@ -340,7 +325,26 @@ struct _XENBUS_EVTCHN_INTERFACE_V8 {
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V9
+    \brief EVTCHN interface version 9
+    \ingroup interfaces
+*/
+struct _XENBUS_EVTCHN_INTERFACE_V9 {
+    INTERFACE               Interface;
+    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
+    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
+    XENBUS_EVTCHN_OPEN      EvtchnOpen;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
+    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
+    XENBUS_EVTCHN_CLOSE     EvtchnClose;
+};
+
+typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -350,8 +354,8 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 8
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
 
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 61272ab41cb3..e3ee888bd979 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -72,12 +72,24 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+typedef NTSTATUS
+(*XENBUS_GNTTAB_CREATE_CACHE_V1)(
+    IN  PINTERFACE                  Interface,
+    IN  const CHAR                  *Name,
+    IN  ULONG                       Reservation,
+    IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
+    IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
+    IN  PVOID                       Argument OPTIONAL,
+    OUT PXENBUS_GNTTAB_CACHE        *Cache
+    );
+
 /*! \typedef XENBUS_GNTTAB_CREATE_CACHE
     \brief Create a cache of grant table entries
 
     \param Interface The interface header
     \param Name A name for the cache which will be used in debug output
     \param Reservation The target minimum population of the cache
+    \param Cap The maximum population of the cache
     \param AcquireLock A callback invoked to acquire a spinlock
     \param ReleaseLock A callback invoked to release the spinlock
     \param Argument An optional context argument passed to the callbacks
@@ -88,6 +100,7 @@ typedef NTSTATUS
     IN  PINTERFACE                  Interface,
     IN  const CHAR                  *Name,
     IN  ULONG                       Reservation,
+    IN  ULONG                       Cap,
     IN  XENBUS_CACHE_ACQUIRE_LOCK   AcquireLock,
     IN  XENBUS_CACHE_RELEASE_LOCK   ReleaseLock,
     IN  PVOID                       Argument OPTIONAL,
@@ -220,43 +233,46 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE, 
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
+    \brief GNTTAB interface version 2
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
+struct _XENBUS_GNTTAB_INTERFACE_V2 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
+    XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
+    XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V2
-    \brief GNTTAB interface version 2
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
+    \brief GNTTAB interface version 3
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V2 {
+struct _XENBUS_GNTTAB_INTERFACE_V3 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE          GnttabCreateCache;
+    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
     XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
     XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
     XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
+    XENBUS_GNTTAB_QUERY_REFERENCE       GnttabQueryReference;
     XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
     XENBUS_GNTTAB_MAP_FOREIGN_PAGES     GnttabMapForeignPages;
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V3
-    \brief GNTTAB interface version 3
+/*! \struct _XENBUS_GNTTAB_INTERFACE_V4
+    \brief GNTTAB interface version 4
     \ingroup interfaces
 */
-struct _XENBUS_GNTTAB_INTERFACE_V3 {
+struct _XENBUS_GNTTAB_INTERFACE_V4 {
     INTERFACE                           Interface;
     XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
     XENBUS_GNTTAB_RELEASE               GnttabRelease;
@@ -270,7 +286,7 @@ struct _XENBUS_GNTTAB_INTERFACE_V3 {
     XENBUS_GNTTAB_UNMAP_FOREIGN_PAGES   GnttabUnmapForeignPages;
 };
 
-typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
+typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNTTAB_INTERFACE;
 
 /*! \def XENBUS_GNTTAB
     \brief Macro at assist in method invocation
@@ -280,8 +296,8 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V3 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 3
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
 
diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/src/xenvbd.inf b/src/xenvbd.inf
index 0d575c3b0efc..7bec8c3e3e78 100644
--- a/src/xenvbd.inf
+++ b/src/xenvbd.inf
@@ -54,9 +54,9 @@ xenvbd_coinst.dll=0,,
 %Vendor%=Inst,NT@INF_ARCH@
 
 [Inst.NT@INF_ARCH@]
-%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VBD&REV_09000007
-%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VBD&REV_09000007
-%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VBD&REV_09000007
+%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_VBD&REV_09000009
+%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_VBD&REV_09000009
+%XenVbdName%=XenVbd_Inst,XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_VBD&REV_09000009
 
 [XenVbd_Inst] 
 CopyFiles=XenVbd_Copyfiles
diff --git a/src/xenvbd/adapter.c b/src/xenvbd/adapter.c
index 941587af3494..67dd14c6efc2 100644
--- a/src/xenvbd/adapter.c
+++ b/src/xenvbd/adapter.c
@@ -1382,6 +1382,7 @@ AdapterInitialize(
                           "vbd_bounce",
                           sizeof(XENVBD_BOUNCE),
                           32,
+                          0,
                           AdapterBounceCtor,
                           AdapterBounceDtor,
                           AdapterAcquireLock,
diff --git a/src/xenvbd/granter.c b/src/xenvbd/granter.c
index e09c116ac665..afb29bc3e81c 100644
--- a/src/xenvbd/granter.c
+++ b/src/xenvbd/granter.c
@@ -198,6 +198,7 @@ GranterConnect(
                            &Granter->GnttabInterface,
                            Name,
                            0,
+                           0,
                            GranterAcquireLock,
                            GranterReleaseLock,
                            Granter,
diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 07aa841274ad..bfe62a822c27 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1772,6 +1772,7 @@ BlkifRingCreate(
                           Name,
                           sizeof(XENVBD_REQUEST),
                           0,
+                          0,
                           BlkifRingRequestCtor,
                           BlkifRingRequestDtor,
                           BlkifRingAcquireLock,
@@ -1794,6 +1795,7 @@ BlkifRingCreate(
                           Name,
                           sizeof(XENVBD_SEGMENT),
                           0,
+                          0,
                           BlkifRingSegmentCtor,
                           BlkifRingSegmentDtor,
                           BlkifRingAcquireLock,
@@ -1816,6 +1818,7 @@ BlkifRingCreate(
                           Name,
                           sizeof(XENVBD_INDIRECT),
                           0,
+                          0,
                           BlkifRingIndirectCtor,
                           BlkifRingIndirectDtor,
                           BlkifRingAcquireLock,
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 11:07:44 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 11:07:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87950.165213 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE943-0005VE-I9; Mon, 22 Feb 2021 11:07:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87950.165213; Mon, 22 Feb 2021 11:07:43 +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 1lE943-0005V7-FG; Mon, 22 Feb 2021 11:07:43 +0000
Received: by outflank-mailman (input) for mailman id 87950;
 Mon, 22 Feb 2021 11:07:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>) id 1lE942-0005V2-2C
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 11:07:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE941-0006dq-2U; Mon, 22 Feb 2021 11:07:41 +0000
Received: from host86-180-176-157.range86-180.btcentralplus.com
 ([86.180.176.157] helo=CBG-R90WXYV0.home)
 by xenbits.xenproject.org with esmtpsa
 (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92)
 (envelope-from <paul@xen.org>)
 id 1lE940-0005Qa-PG; Mon, 22 Feb 2021 11:07:40 +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>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Message-Id:Date:Subject:Cc:To:From;
	bh=0J/02VGpONPJoE4aUH+cza3ViTq/Vchd+Is6FmyXBbo=; b=veA77x9w3u4iCaVottXwc/fkXY
	m222Imlbe79vgj7qHBhpXLp0SNFFXG1GQzcVx9xpREWHP6iETKM/a4B954sr1ac3mFdJNtC/fO0M8
	PQ6H6ovxvhA8GHeOfy6ZCwA1bma5CVVWCwSzByRR6JMsF0vZhgK5IdF8F93r9duovrvg=;
From: Paul Durrant <paul@xen.org>
To: win-pv-devel@lists.xenproject.org
Cc: Paul Durrant <pdurrant@amazon.com>
Subject: [PATCH xeniface] Bring XENBUS interface versions up to date...
Date: Mon, 22 Feb 2021 11:07:38 +0000
Message-Id: <20210222110738.1887-1-paul@xen.org>
X-Mailer: git-send-email 2.17.1

From: Paul Durrant <pdurrant@amazon.com>

... and amend binding accordingly.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
---
 include/evtchn_interface.h      | 44 ++++++++++++++++++---------------
 include/gnttab_interface.h      | 17 +------------
 include/shared_info_interface.h | 30 ++++++++++++++++++++--
 include/store_interface.h       | 22 +----------------
 src/xeniface.inf                |  6 ++---
 5 files changed, 57 insertions(+), 62 deletions(-)

diff --git a/include/evtchn_interface.h b/include/evtchn_interface.h
index 76a9256fa057..dbe874511866 100644
--- a/include/evtchn_interface.h
+++ b/include/evtchn_interface.h
@@ -100,6 +100,8 @@ typedef VOID
 
     \b VIRQ:
     \param Index The index number of the VIRQ
+    \param Group The group number of the CPU that should handle the VIRQ
+    \param Number The relative number of the CPU that should handle the VIRQ
 
     \return Event channel handle
 */
@@ -249,23 +251,6 @@ typedef VOID
 DEFINE_GUID(GUID_XENBUS_EVTCHN_INTERFACE,
 0xbe2440ac, 0x1098, 0x4150, 0xaf, 0x4d, 0x45, 0x2f, 0xad, 0xce, 0xf9, 0x23);
 
-/*! \struct _XENBUS_EVTCHN_INTERFACE_V4
-    \brief EVTCHN interface version 4
-    \ingroup interfaces
-*/
-struct _XENBUS_EVTCHN_INTERFACE_V4 {
-    INTERFACE               Interface;
-    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
-    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
-    XENBUS_EVTCHN_OPEN      EvtchnOpen;
-    XENBUS_EVTCHN_BIND      EvtchnBind;
-    XENBUS_EVTCHN_UNMASK_V4 EvtchnUnmaskVersion4;
-    XENBUS_EVTCHN_SEND_V1   EvtchnSendVersion1;
-    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
-    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
-    XENBUS_EVTCHN_CLOSE     EvtchnClose;
-};
-
 /*! \struct _XENBUS_EVTCHN_INTERFACE_V5
     \brief EVTCHN interface version 5
     \ingroup interfaces
@@ -340,7 +325,26 @@ struct _XENBUS_EVTCHN_INTERFACE_V8 {
     XENBUS_EVTCHN_CLOSE     EvtchnClose;
 };
 
-typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
+/*! \struct _XENBUS_EVTCHN_INTERFACE_V9
+    \brief EVTCHN interface version 9
+    \ingroup interfaces
+*/
+struct _XENBUS_EVTCHN_INTERFACE_V9 {
+    INTERFACE               Interface;
+    XENBUS_EVTCHN_ACQUIRE   EvtchnAcquire;
+    XENBUS_EVTCHN_RELEASE   EvtchnRelease;
+    XENBUS_EVTCHN_OPEN      EvtchnOpen;
+    XENBUS_EVTCHN_BIND      EvtchnBind;
+    XENBUS_EVTCHN_UNMASK    EvtchnUnmask;
+    XENBUS_EVTCHN_SEND      EvtchnSend;
+    XENBUS_EVTCHN_TRIGGER   EvtchnTrigger;
+    XENBUS_EVTCHN_GET_COUNT EvtchnGetCount;
+    XENBUS_EVTCHN_WAIT      EvtchnWait;
+    XENBUS_EVTCHN_GET_PORT  EvtchnGetPort;
+    XENBUS_EVTCHN_CLOSE     EvtchnClose;
+};
+
+typedef struct _XENBUS_EVTCHN_INTERFACE_V9 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVTCHN_INTERFACE;
 
 /*! \def XENBUS_EVTCHN
     \brief Macro at assist in method invocation
@@ -350,7 +354,7 @@ typedef struct _XENBUS_EVTCHN_INTERFACE_V8 XENBUS_EVTCHN_INTERFACE, *PXENBUS_EVT
 
 #endif  // _WINDLL
 
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 4
-#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 8
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MIN 5
+#define XENBUS_EVTCHN_INTERFACE_VERSION_MAX 9
 
 #endif  // _XENBUS_EVTCHN_INTERFACE_H
diff --git a/include/gnttab_interface.h b/include/gnttab_interface.h
index 48a555acf378..865c4f302444 100644
--- a/include/gnttab_interface.h
+++ b/include/gnttab_interface.h
@@ -233,21 +233,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_GNTTAB_INTERFACE,
 0x763679c5, 0xe5c2, 0x4a6d, 0x8b, 0x88, 0x6b, 0xb0, 0x2e, 0xc4, 0x2d, 0x8e);
 
-/*! \struct _XENBUS_GNTTAB_INTERFACE_V1
-    \brief GNTTAB interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_GNTTAB_INTERFACE_V1 {
-    INTERFACE                           Interface;
-    XENBUS_GNTTAB_ACQUIRE               GnttabAcquire;
-    XENBUS_GNTTAB_RELEASE               GnttabRelease;
-    XENBUS_GNTTAB_CREATE_CACHE_V1       GnttabCreateCacheVersion1;
-    XENBUS_GNTTAB_PERMIT_FOREIGN_ACCESS GnttabPermitForeignAccess;
-    XENBUS_GNTTAB_REVOKE_FOREIGN_ACCESS GnttabRevokeForeignAccess;
-    XENBUS_GNTTAB_GET_REFERENCE         GnttabGetReference;
-    XENBUS_GNTTAB_DESTROY_CACHE         GnttabDestroyCache;
-};
-
 /*! \struct _XENBUS_GNTTAB_INTERFACE_V2
     \brief GNTTAB interface version 2
     \ingroup interfaces
@@ -311,7 +296,7 @@ typedef struct _XENBUS_GNTTAB_INTERFACE_V4 XENBUS_GNTTAB_INTERFACE, *PXENBUS_GNT
 
 #endif  // _WINDLL
 
-#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 1
+#define XENBUS_GNTTAB_INTERFACE_VERSION_MIN 2
 #define XENBUS_GNTTAB_INTERFACE_VERSION_MAX 4
 
 #endif  // _XENBUS_GNTTAB_INTERFACE_H
diff --git a/include/shared_info_interface.h b/include/shared_info_interface.h
index f99bcb634cdd..27910b020a8e 100644
--- a/include/shared_info_interface.h
+++ b/include/shared_info_interface.h
@@ -60,6 +60,15 @@ typedef VOID
     IN  PINTERFACE  Interface
     );
 
+/*! \typedef XENBUS_SHARED_INFO_UPCALL_SUPPORTED
+    \brief Private method for EVTCHN inerface
+*/
+typedef BOOLEAN
+(*XENBUS_SHARED_INFO_UPCALL_SUPPORTED)(
+    IN  PINTERFACE  Interface,
+    IN  ULONG       Index
+    );
+
 /*! \typedef XENBUS_SHARED_INFO_UPCALL_PENDING
     \brief Private method for EVTCHN inerface
 */
@@ -168,7 +177,24 @@ struct _XENBUS_SHARED_INFO_INTERFACE_V3 {
     XENBUS_SHARED_INFO_GET_TIME         SharedInfoGetTime;
 };
 
-typedef struct _XENBUS_SHARED_INFO_INTERFACE_V3 XENBUS_SHARED_INFO_INTERFACE, *PXENBUS_SHARED_INFO_INTERFACE;
+/*! \struct _XENBUS_SHARED_INFO_INTERFACE_V4
+    \brief SHARED_INFO interface version 4
+    \ingroup interfaces
+*/
+struct _XENBUS_SHARED_INFO_INTERFACE_V4 {
+    INTERFACE                           Interface;
+    XENBUS_SHARED_INFO_ACQUIRE          SharedInfoAcquire;
+    XENBUS_SHARED_INFO_RELEASE          SharedInfoRelease;
+    XENBUS_SHARED_INFO_UPCALL_SUPPORTED SharedInfoUpcallSupported;
+    XENBUS_SHARED_INFO_UPCALL_PENDING   SharedInfoUpcallPending;
+    XENBUS_SHARED_INFO_EVTCHN_POLL      SharedInfoEvtchnPoll;
+    XENBUS_SHARED_INFO_EVTCHN_ACK       SharedInfoEvtchnAck;
+    XENBUS_SHARED_INFO_EVTCHN_MASK      SharedInfoEvtchnMask;
+    XENBUS_SHARED_INFO_EVTCHN_UNMASK    SharedInfoEvtchnUnmask;
+    XENBUS_SHARED_INFO_GET_TIME         SharedInfoGetTime;
+};
+
+typedef struct _XENBUS_SHARED_INFO_INTERFACE_V4 XENBUS_SHARED_INFO_INTERFACE, *PXENBUS_SHARED_INFO_INTERFACE;
 
 /*! \def XENBUS_SHARED_INFO
     \brief Macro at assist in method invocation
@@ -179,6 +205,6 @@ typedef struct _XENBUS_SHARED_INFO_INTERFACE_V3 XENBUS_SHARED_INFO_INTERFACE, *P
 #endif  // _WINDLL
 
 #define XENBUS_SHARED_INFO_INTERFACE_VERSION_MIN    2
-#define XENBUS_SHARED_INFO_INTERFACE_VERSION_MAX    3
+#define XENBUS_SHARED_INFO_INTERFACE_VERSION_MAX    4
 
 #endif  // _XENBUS_SHARED_INFO_H
diff --git a/include/store_interface.h b/include/store_interface.h
index 52f1a1dde592..e1251dd1369f 100644
--- a/include/store_interface.h
+++ b/include/store_interface.h
@@ -290,26 +290,6 @@ typedef NTSTATUS
 DEFINE_GUID(GUID_XENBUS_STORE_INTERFACE, 
 0x86824c3b, 0xd34e, 0x4753, 0xb2, 0x81, 0x2f, 0x1e, 0x3a, 0xd2, 0x14, 0xd7);
 
-/*! \struct _XENBUS_STORE_INTERFACE_V1
-    \brief STORE interface version 1
-    \ingroup interfaces
-*/
-struct _XENBUS_STORE_INTERFACE_V1 {
-    INTERFACE                       Interface;
-    XENBUS_STORE_ACQUIRE            StoreAcquire;
-    XENBUS_STORE_RELEASE            StoreRelease;
-    XENBUS_STORE_FREE               StoreFree;
-    XENBUS_STORE_READ               StoreRead;
-    XENBUS_STORE_PRINTF             StorePrintf;
-    XENBUS_STORE_REMOVE             StoreRemove;
-    XENBUS_STORE_DIRECTORY          StoreDirectory;
-    XENBUS_STORE_TRANSACTION_START  StoreTransactionStart;
-    XENBUS_STORE_TRANSACTION_END    StoreTransactionEnd;
-    XENBUS_STORE_WATCH_ADD          StoreWatchAdd;
-    XENBUS_STORE_WATCH_REMOVE       StoreWatchRemove;
-    XENBUS_STORE_POLL               StorePoll;
-};
-
 /*! \struct _XENBUS_STORE_INTERFACE_V2
     \brief STORE interface version 2
     \ingroup interfaces
@@ -341,7 +321,7 @@ typedef struct _XENBUS_STORE_INTERFACE_V2 XENBUS_STORE_INTERFACE, *PXENBUS_STORE
 
 #endif  // _WINDLL
 
-#define XENBUS_STORE_INTERFACE_VERSION_MIN  1
+#define XENBUS_STORE_INTERFACE_VERSION_MIN  2
 #define XENBUS_STORE_INTERFACE_VERSION_MAX  2
 
 #endif  // _XENBUS_STORE_INTERFACE_H
diff --git a/src/xeniface.inf b/src/xeniface.inf
index 14ebdb224238..8968d6ebc9f9 100644
--- a/src/xeniface.inf
+++ b/src/xeniface.inf
@@ -49,9 +49,9 @@ ServiceDestDir.Copy = 11
 ; DisplayName		    Section	      DeviceID
 ; -----------		    -------	      --------
 
-%XenIfaceDevice.DeviceDesc% =XenIface_Device, XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_IFACE&REV_09000006
-%XenIfaceDevice.DeviceDesc% =XenIface_Device, XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_IFACE&REV_09000006
-%XenIfaceDevice.DeviceDesc% =XenIface_Device, XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_IFACE&REV_09000006
+%XenIfaceDevice.DeviceDesc% =XenIface_Device, XENBUS\VEN_@VENDOR_PREFIX@@VENDOR_DEVICE_ID@&DEV_IFACE&REV_09000009
+%XenIfaceDevice.DeviceDesc% =XenIface_Device, XENBUS\VEN_@VENDOR_PREFIX@0001&DEV_IFACE&REV_09000009
+%XenIfaceDevice.DeviceDesc% =XenIface_Device, XENBUS\VEN_@VENDOR_PREFIX@0002&DEV_IFACE&REV_09000009
 
 [XenIface_Device]
 CopyFiles=XenIface_Device.Copy
-- 
2.17.1



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 11:08:46 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 11:08:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.87954.165217 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lE953-0005XI-MD; Mon, 22 Feb 2021 11:08:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 87954.165217; Mon, 22 Feb 2021 11:08: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 1lE953-0005XA-Iv; Mon, 22 Feb 2021 11:08:45 +0000
Received: by outflank-mailman (input) for mailman id 87954;
 Mon, 22 Feb 2021 11:08:44 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lE952-0005X5-J2
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 11:08:44 +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>
Date: Mon, 22 Feb 2021 11:08:44 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <10080669.3.1613992126320.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #217 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2_27714816.1613992124570"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


------=_Part_2_27714816.1613992124570
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #217.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/217/console to view the results.
------=_Part_2_27714816.1613992124570--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 14:42:05 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 14:42:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88132.165610 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lECPS-0003mK-U2; Mon, 22 Feb 2021 14:42:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88132.165610; Mon, 22 Feb 2021 14:42: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 1lECPS-0003mD-RB; Mon, 22 Feb 2021 14:42:02 +0000
Received: by outflank-mailman (input) for mailman id 88132;
 Mon, 22 Feb 2021 14:42:01 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lECPR-0003m8-RF
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 14:42: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>
Date: Mon, 22 Feb 2021 14:42:03 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <31448977.5.1614004923686.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVBD-master - Build #152 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_4_27023052.1614004923217"
X-Jenkins-Job: XENVBD-master
X-Jenkins-Result: SUCCESS


------=_Part_4_27023052.1614004923217
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #152.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVBD-master/152/console to view the results.
------=_Part_4_27023052.1614004923217--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 14:56:45 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 14:56:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88146.165637 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lECdg-0005BU-GW; Mon, 22 Feb 2021 14:56:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88146.165637; Mon, 22 Feb 2021 14:56:44 +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 1lECdg-0005BN-Da; Mon, 22 Feb 2021 14:56:44 +0000
Received: by outflank-mailman (input) for mailman id 88146;
 Mon, 22 Feb 2021 14:56:42 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lECde-0005BI-Oc
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 14:56: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>
Date: Mon, 22 Feb 2021 14:56:44 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <6460637.7.1614005804608.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENCONS-master - Build #33 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6_32426101.1614005804483"
X-Jenkins-Job: XENCONS-master
X-Jenkins-Result: SUCCESS


------=_Part_6_32426101.1614005804483
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #33.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENCONS-master/33/console to view the results.
------=_Part_6_32426101.1614005804483--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 15:26:54 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 15:26:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88170.165678 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lED6r-0008KD-KX; Mon, 22 Feb 2021 15:26:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88170.165678; Mon, 22 Feb 2021 15:26: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 1lED6r-0008K5-HG; Mon, 22 Feb 2021 15:26:53 +0000
Received: by outflank-mailman (input) for mailman id 88170;
 Mon, 22 Feb 2021 15:26:52 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lED6q-0008Jt-K2
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 15:26:52 +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>
Date: Mon, 22 Feb 2021 15:26:54 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <2131039.9.1614007614484.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENHID-master - Build #26 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_8_20091032.1614007614375"
X-Jenkins-Job: XENHID-master
X-Jenkins-Result: SUCCESS


------=_Part_8_20091032.1614007614375
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #26.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENHID-master/26/console to view the results.
------=_Part_8_20091032.1614007614375--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 15:55:44 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 15:55:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88188.165717 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lEDYl-0002up-Ju; Mon, 22 Feb 2021 15:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88188.165717; Mon, 22 Feb 2021 15:55:43 +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 1lEDYl-0002ui-Gw; Mon, 22 Feb 2021 15:55:43 +0000
Received: by outflank-mailman (input) for mailman id 88188;
 Mon, 22 Feb 2021 15:55:42 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Mec3=HY=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lEDYj-0002uK-TW
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 15:55:41 +0000
Received: from mail-wr1-x429.google.com (unknown [2a00:1450:4864:20::429])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id c61358c7-f662-441b-a3c6-2558e873763c;
 Mon, 22 Feb 2021 15:55:40 +0000 (UTC)
Received: by mail-wr1-x429.google.com with SMTP id b3so19601693wrj.5
 for <win-pv-devel@lists.xenproject.org>; Mon, 22 Feb 2021 07:55:40 -0800 (PST)
Received: from ?IPv6:2a00:23c5:5785:9a01:a18d:4222:f9c4:4fa0?
 ([2a00:23c5:5785:9a01:a18d:4222:f9c4:4fa0])
 by smtp.gmail.com with ESMTPSA id a1sm910017wrx.95.2021.02.22.07.55.39
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 22 Feb 2021 07:55:39 -0800 (PST)
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>
X-Inumbo-ID: c61358c7-f662-441b-a3c6-2558e873763c
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=eBZoL2IaJ449n1CScn5RtS9P11LrnZb01pVetdwDFHw=;
        b=ZXLNeP/jmV0AGgbTd46Jno6R4HpKdz6gvUtCOQYgxPYerkbc7rpScstle3nZPRZYVF
         xINleEbrL30Wjj5AZF7vKS3EZYS/xKs0iOYfyyWAe9PnTH/nbWGkftCXelAW1zYqSq1P
         eUxAgdV/vWG6rVdyDG0DDepLbC//hJS6U6jfMbk8JXco2Eu1p40MzU9+TZpGxJFSuHUV
         0PuPWPlPxlniC5PDM3RV6YbLvRusvDbwpRMMtw2Pt081lVeZqxdEbWHtePPU2QSTGhlg
         jPDATVNEsgtbXl5TirIuj9H1ZQP0fMb3YtecHVBYKNkrkJdDp76g+skEWHwsZ0lQD8uy
         H8rQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=eBZoL2IaJ449n1CScn5RtS9P11LrnZb01pVetdwDFHw=;
        b=Ay2xHBLgnLumPLL8v1+PO6UnwanZ9HN+Li/cs9BK+SA/dXngDLWmm+LEPMPMcL122b
         jrIqT8MnbXLSi4d6lHCFl+7O3zbtO3FrGtrPsVPLDJ9Xo3Ja3QyeLVb/MVURetZjJ+8n
         T4J/a29yP9EzL+Zu+gO98KkTxtMTv6kuLRHxeTcaiK1rZ/e49yuhMy2+d++VCy6e904q
         NANAPrFL/tXjREV0Kbz91rpJThz+uq0JtzjTYM6//C/HbpRagq2nbcJH5moDJiHjdoHJ
         wvGSf8ACjha0tzCyzyDdQ0mHXehCt2kuCnjKIg0CHjJcbnD3u7LprBOcGklChkROdkjo
         uzCA==
X-Gm-Message-State: AOAM532agxnVOw/32HK9pMDhrrDwvPClvwuLfm/yKDsCnhKPJ396SrGM
	RKTJhheIigXSGvXRYWQkVJkqL2CIS4A=
X-Google-Smtp-Source: ABdhPJw9xzpmNNU2OZOmJUwEaSzyOfFYBmDO/GDEoERXg+C6JaA+F0egwQkgfkj8UNc4kEja4I0eKg==
X-Received: by 2002:adf:eb8e:: with SMTP id t14mr21871582wrn.20.1614009340078;
        Mon, 22 Feb 2021 07:55:40 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [RFC-PATCH] Add CodeQL support
To: win-pv-devel@lists.xenproject.org
References: <20210219142249.492764-1-owen.smith@citrix.com>
Message-ID: <029d457b-46d4-7ae9-987b-b0ca6eb69cce@xen.org>
Date: Mon, 22 Feb 2021 15:55:39 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.7.1
MIME-Version: 1.0
In-Reply-To: <20210219142249.492764-1-owen.smith@citrix.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 19/02/2021 14:22, Owen Smith wrote:
> CodeQL results will be required for future WHQL certifications.
> https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/static-tools-and-codeql
> 
> Add option to use CodeQL to generate the appropriate log. CodeQL uses
> MSBuild to generate sarif files which are expected to be uploaded when
> submitting WHQL results. sarif files will also highlight any violations
> of the static analysis rules that will need fixing.
> 
> Note: The CodeQL doesnt seem to support passing quoted strings as MSBuild
> parameters, so add default values for Configuration and Platform.
> 

Would it be possible to spit out the msbuild command line to a temp 
batch file and then pass that to codeql on the cmdline?

   Paul

> Assumptions:
> - CodeQL binaries are installed and accessible on the path
> - Windows Driver Development Supplemental Tools are installed and are
>    ehtier in the parent directory of the project, or accessible with the
>    environment variable CODEQL_QUERY_SUITE
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   build.ps1            | 62 ++++++++++++++++++++++++++++++++++++++++++++
>   vs2015/configs.props |  4 +++
>   vs2017/configs.props |  4 +++
>   vs2019/configs.props |  4 +++
>   4 files changed, 74 insertions(+)
> 
> diff --git a/build.ps1 b/build.ps1
> index 2ea6428..b6b5515 100644
> --- a/build.ps1
> +++ b/build.ps1
> @@ -6,6 +6,7 @@ param(
>   	[Parameter(Mandatory = $true)]
>   	[string]$Type,
>   	[string]$Arch,
> +	[switch]$CodeQL,
>   	[switch]$Sdv
>   )
>   
> @@ -51,6 +52,63 @@ Function SdvBuild {
>   	& ".\msbuild.ps1" @params
>   }
>   
> +Function CodeQLBuild {
> +	$DriverList = @("xen", "xenbus", "xenfilt")
> +
> +	$visualstudioversion = $Env:VisualStudioVersion
> +	$solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; "16.0" = "vs2019"; }
> +
> +	if ([string]::IsNullOrEmpty($Env:CODEQL_QUERY_SUITE)) {
> +		$searchpath = Resolve-Path ".."
> +	} else {
> +		$searchpath = $Env:CODEQL_QUERY_SUITE
> +	}
> +
> +	if (Test-Path "database") {
> +		Remove-Item -Recurse -Force "database"
> +	}
> +	New-Item -ItemType Directory "database"
> +
> +	$DriverList | ForEach {
> +		$projpath = Resolve-Path (Join-Path $solutiondir[$visualstudioversion] $_)
> +		$proj = Join-Path $projpath ($_ + ".vcxproj")
> +		$output = Join-Path "xenbus" ($_ + ".sarif")
> +		$database = "database\" + $_
> +
> +		$c = "codeql"
> +		$c += " database"
> +		$c += " create"
> +		$c += " -l=cpp"
> +		$c += " -s=src"
> +		$c += " -c"
> +		$c += ' "msbuild.exe /t:Build /p:Platform=x64 ' + $proj + '" '
> +		$c += $database
> +
> +		Invoke-Expression $c
> +		if ($LASTEXITCODE -ne 0) {
> +			Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
> +			Exit $LASTEXITCODE
> +		}
> +
> +		$c = "codeql"
> +		$c += " database"
> +		$c += " analyze "
> +		$c += $database
> +		$c += " windows_driver_recommended.qls"
> +		$c += " --format=sarifv2.1.0"
> +		$c += " --output="
> +		$c += $output
> +		$c += " --search-path="
> +		$c += $searchpath
> +
> +		Invoke-Expression $c
> +		if ($LASTEXITCODE -ne 0) {
> +			Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
> +			Exit $LASTEXITCODE
> +		}
> +	}
> +}
> +
>   if ($Type -ne "free" -and $Type -ne "checked") {
>   	Write-Host "Invalid Type"
>   	Exit -1
> @@ -99,6 +157,10 @@ if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x64") {
>   	Build "x64" $Type
>   }
>   
> +if ($CodeQL) {
> +	CodeQLBuild
> +}
> +
>   if ($Sdv) {
>   	SdvBuild
>   }
> diff --git a/vs2015/configs.props b/vs2015/configs.props
> index cdbb3c8..4be9288 100644
> --- a/vs2015/configs.props
> +++ b/vs2015/configs.props
> @@ -1,5 +1,9 @@
>   <?xml version="1.0" encoding="utf-8"?>
>   <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
> +	<PropertyGroup>
> +		<Configuration Condition=" '$(Configuration)' == '' ">Windows 10 Release</Configuration>
> +		<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
> +	</PropertyGroup>
>   	<ItemGroup Label="ProjectConfigurations">
>   		<ProjectConfiguration Include="Windows 10 Debug|Win32">
>   			<Configuration>Windows 10 Debug</Configuration>
> diff --git a/vs2017/configs.props b/vs2017/configs.props
> index cdbb3c8..4be9288 100644
> --- a/vs2017/configs.props
> +++ b/vs2017/configs.props
> @@ -1,5 +1,9 @@
>   <?xml version="1.0" encoding="utf-8"?>
>   <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
> +	<PropertyGroup>
> +		<Configuration Condition=" '$(Configuration)' == '' ">Windows 10 Release</Configuration>
> +		<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
> +	</PropertyGroup>
>   	<ItemGroup Label="ProjectConfigurations">
>   		<ProjectConfiguration Include="Windows 10 Debug|Win32">
>   			<Configuration>Windows 10 Debug</Configuration>
> diff --git a/vs2019/configs.props b/vs2019/configs.props
> index cdbb3c8..4be9288 100644
> --- a/vs2019/configs.props
> +++ b/vs2019/configs.props
> @@ -1,5 +1,9 @@
>   <?xml version="1.0" encoding="utf-8"?>
>   <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
> +	<PropertyGroup>
> +		<Configuration Condition=" '$(Configuration)' == '' ">Windows 10 Release</Configuration>
> +		<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
> +	</PropertyGroup>
>   	<ItemGroup Label="ProjectConfigurations">
>   		<ProjectConfiguration Include="Windows 10 Debug|Win32">
>   			<Configuration>Windows 10 Debug</Configuration>
> 



From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 17:57:59 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 17:57:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88325.166007 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lEFT2-0000Sj-Ng; Mon, 22 Feb 2021 17:57:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88325.166007; Mon, 22 Feb 2021 17:57:56 +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 1lEFT2-0000Sb-Kb; Mon, 22 Feb 2021 17:57:56 +0000
Received: by outflank-mailman (input) for mailman id 88325;
 Mon, 22 Feb 2021 17:57:54 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lEFT0-0000SW-No
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 17:57: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>
Date: Mon, 22 Feb 2021 17:57:56 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <12664397.11.1614016676692.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVKBD-master - Build #28 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_10_21293945.1614016676333"
X-Jenkins-Job: XENVKBD-master
X-Jenkins-Result: SUCCESS


------=_Part_10_21293945.1614016676333
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #28.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVKBD-master/28/console to view the results.
------=_Part_10_21293945.1614016676333--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 19:58:42 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 19:58:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88361.166119 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lEHLs-00040I-Sa; Mon, 22 Feb 2021 19:58:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88361.166119; Mon, 22 Feb 2021 19:58:40 +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 1lEHLs-00040B-Pj; Mon, 22 Feb 2021 19:58:40 +0000
Received: by outflank-mailman (input) for mailman id 88361;
 Mon, 22 Feb 2021 19:58:39 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lEHLr-000406-NF
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 19:58:39 +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>
Date: Mon, 22 Feb 2021 19:58:41 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <2194539.13.1614023921727.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENIFACE-master - Build #103 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_12_10079565.1614023921539"
X-Jenkins-Job: XENIFACE-master
X-Jenkins-Result: SUCCESS


------=_Part_12_10079565.1614023921539
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #103.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENIFACE-master/103/console to view the results.
------=_Part_12_10079565.1614023921539--


From win-pv-devel-bounces@lists.xenproject.org Mon Feb 22 21:57:20 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 22 Feb 2021 21:57:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88406.166240 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lEJCg-0007e3-Rg; Mon, 22 Feb 2021 21:57:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88406.166240; Mon, 22 Feb 2021 21:57:18 +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 1lEJCg-0007du-Og; Mon, 22 Feb 2021 21:57:18 +0000
Received: by outflank-mailman (input) for mailman id 88406;
 Mon, 22 Feb 2021 21:57:16 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lEJCe-0007dp-P4
 for win-pv-devel@lists.xenproject.org; Mon, 22 Feb 2021 21:57:16 +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>
Date: Mon, 22 Feb 2021 21:57:18 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <8892147.15.1614031038856.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENNET-master - Build #113 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_14_31892074.1614031038668"
X-Jenkins-Job: XENNET-master
X-Jenkins-Result: SUCCESS


------=_Part_14_31892074.1614031038668
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #113.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENNET-master/113/console to view the results.
------=_Part_14_31892074.1614031038668--


From win-pv-devel-bounces@lists.xenproject.org Tue Feb 23 01:23:36 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 23 Feb 2021 01:23:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.88458.166346 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lEMQI-00050K-QM; Tue, 23 Feb 2021 01:23:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 88458.166346; Tue, 23 Feb 2021 01:23: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 1lEMQI-00050F-Mv; Tue, 23 Feb 2021 01:23:34 +0000
Received: by outflank-mailman (input) for mailman id 88458;
 Tue, 23 Feb 2021 01:23:33 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lEMQH-0004zz-1W
 for win-pv-devel@lists.xenproject.org; Tue, 23 Feb 2021 01:23:33 +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>
Date: Tue, 23 Feb 2021 01:23:34 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <13615635.17.1614043415253.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVIF-master - Build #184 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_16_26197987.1614043414862"
X-Jenkins-Job: XENVIF-master
X-Jenkins-Result: SUCCESS


------=_Part_16_26197987.1614043414862
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

The build system has completed build #184.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVIF-master/184/console to view the results.
------=_Part_16_26197987.1614043414862--


From win-pv-devel-bounces@lists.xenproject.org Wed Feb 24 08:21:27 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 24 Feb 2021 08:21:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.89201.167824 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lEpQD-00049t-2f; Wed, 24 Feb 2021 08:21:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 89201.167824; Wed, 24 Feb 2021 08:21:25 +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 1lEpQC-00049m-W5; Wed, 24 Feb 2021 08:21:24 +0000
Received: by outflank-mailman (input) for mailman id 89201;
 Wed, 24 Feb 2021 08:21:24 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ZPXz=H2=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lEpQB-00049h-TC
 for win-pv-devel@lists.xenproject.org; Wed, 24 Feb 2021 08:21:23 +0000
Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id ac2a355c-9e40-4ffb-8f4b-c3b16e87d106;
 Wed, 24 Feb 2021 08:21:22 +0000 (UTC)
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>
X-Inumbo-ID: ac2a355c-9e40-4ffb-8f4b-c3b16e87d106
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614154882;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=QlNi5Uct589dbcgFe2FZDQJAEoeWvCFJUhOmf2RMla0=;
  b=Hg7u6OxaPYg1K8TvDqbKkEtJVV2ZAh4XE6l4W34ktUrZ+MdA+CK1m9xv
   dUvMqGLbOknkOFqbPoof2nQ2geGegrDXA9Ea/1fKUNGdZzmbDEk4GHONo
   2JXMw5BQXL3K68P4HF6JMGzvnpaV8Y17CWiCasiDaDKIzArx9RsnLZcLh
   0=;
Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 5mTpZyA3BtPggDCdvz65UI9eVanhI+C6OPai+I+fclazabFccQH4iMSevOgUv1cjCGtXO5qgUs
 4zOg/62B3fJR9nZyzib10OulBk1+3kAElJLvXIharJ1/F8l2PvmchB/UJ/tadvKsQhomJkgc9P
 sL5skKK3fYzcGklbo13rD2BCDNy0qUbnJrFPAJ2vOPca91BDUOiap5RP7MWZyBy/6i7G69L8Hb
 C0cLRDGZolZnOGEw4noPWzg/TZyxtq7Iw7ibY4Kmw1ACumVsy0C5K+ZdSw+TlDwOAW89uNnyeo
 JO4=
X-SBRS: 5.2
X-MesageID: 38268760
X-Ironport-Server: esa1.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,202,1610427600"; 
   d="scan'208";a="38268760"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Add CodeQL build stage
Date: Wed, 24 Feb 2021 08:19:57 +0000
Message-ID: <20210224081957.2769442-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

CodeQL logs will be required for future WHQL submissions. Add a stage
that generates the required SARIF files. CodeQL is a semantic code
analysis engine, which will highlight vunerabilities that will need
fixing.

In order to use CodeQL, the CodeQL binaries must be on the path and the
Windows-Driver-Developer-Supplemental-Tools must be on the path defined
by the CODEQL_QUERY_SUITE environment variable (if defined), or under
the parent folder (if CODEQL_QUERY_SUITE variable is not defined)

Note: Due to the way the codeql command line is built, using quotes in a
MSBuild command line is not possible, so generate a batch file to wrap
the command line.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 ++++++++++++
 msbuild.ps1 | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 1 deletion(-)

diff --git a/build.ps1 b/build.ps1
index 2ea6428..346d187 100644
--- a/build.ps1
+++ b/build.ps1
@@ -6,6 +6,7 @@ param(
 	[Parameter(Mandatory = $true)]
 	[string]$Type,
 	[string]$Arch,
+	[switch]$CodeQL,
 	[switch]$Sdv
 )
 
@@ -51,6 +52,21 @@ Function SdvBuild {
 	& ".\msbuild.ps1" @params
 }
 
+function CodeQLBuild {
+	$visualstudioversion = $Env:VisualStudioVersion
+	$solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; "16.0" = "vs2019"; }
+	$configurationbase = @{ "14.0" = "Windows 10"; "15.0" = "Windows 10"; "16.0" = "Windows 10"; }
+	$arch = "x64"
+
+	$params = @{
+		SolutionDir = $solutiondir[$visualstudioversion];
+		ConfigurationBase = $configurationbase[$visualstudioversion];
+		Arch = $arch;
+		Type = "codeql"
+		}
+	& ".\msbuild.ps1" @params
+}
+
 if ($Type -ne "free" -and $Type -ne "checked") {
 	Write-Host "Invalid Type"
 	Exit -1
@@ -99,6 +115,10 @@ if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x64") {
 	Build "x64" $Type
 }
 
+if ($CodeQL) {
+	CodeQLBuild
+}
+
 if ($Sdv) {
 	SdvBuild
 }
diff --git a/msbuild.ps1 b/msbuild.ps1
index 670050c..de7ad52 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -67,11 +67,75 @@ Function Run-MSBuildSDV {
 	Set-Location $basepath
 }
 
+Function Run-CodeQL {
+	param(
+		[string]$SolutionPath,
+		[string]$Name,
+		[string]$Configuration,
+		[string]$Platform,
+		[string]$SearchPath,
+		[string]$OutputPath
+	)
+
+	$projpath = Resolve-Path (Join-Path $SolutionPath $Name)
+	$project = [string]::Format("{0}.vcxproj", $Name)
+	$output = [string]::Format("{0}.sarif", $Name)
+	$database = Join-Path "database" $Name
+
+	# write a bat file to wrap msbuild parameters
+	$bat = [string]::Format("{0}.bat", $Name)
+	if (Test-Path $bat) {
+		Remove-Item $bat
+	}
+	$a = "msbuild.exe"
+	$a += " /m:4"
+	$a += " /t:Build"
+	$a += [string]::Format(" /p:Configuration=""{0}""", $Configuration)
+	$a += [string]::Format(" /p:Platform=""{0}""", $Platform)
+	$a += " "
+	$a += Join-Path $projpath $project
+	$a | Set-Content $bat
+
+	# generate the database
+	$b = "codeql"
+	$b += " database"
+	$b += " create"
+	$b += " -l=cpp"
+	$b += " -s=src"
+	$b += " -c"
+	$b += ' "' + (Resolve-Path $bat) + '" '
+	$b += $database
+	Invoke-Expression $b
+	if ($LASTEXITCODE -ne 0) {
+		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
+		Exit $LASTEXITCODE
+	}
+	Remove-Item $bat
+
+	# perform the analysis on the database
+	$c = "codeql"
+	$c += " database"
+	$c += " analyze "
+	$c += $database
+	$c += " windows_driver_recommended.qls"
+	$c += " --format=sarifv2.1.0"
+	$c += " --output="
+	$c += (Join-Path $OutputPath $output)
+	$c += " --search-path="
+	$c += $SearchPath
+
+	Invoke-Expression $c
+	if ($LASTEXITCODE -ne 0) {
+		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
+		Exit $LASTEXITCODE
+	}
+}
+
 #
 # Script Body
 #
 
-$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; }
+$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; "codeql" = "$ConfigurationBase Release"; }
 $platform = @{ "x86" = "Win32"; "x64" = "x64" }
 $solutionpath = Resolve-Path $SolutionDir
 
@@ -83,6 +147,28 @@ if ($Type -eq "free") {
 elseif ($Type -eq "checked") {
 	Run-MSBuild $solutionpath "xenbus.sln" $configuration["checked"] $platform[$Arch]
 }
+elseif ($Type -eq "codeql") {
+	$archivepath = "xenbus"
+
+	if (-Not (Test-Path -Path $archivepath)) {
+		New-Item -Name $archivepath -ItemType Directory | Out-Null
+	}
+
+	if ([string]::IsNullOrEmpty($Env:CODEQL_QUERY_SUITE)) {
+		$searchpath = Resolve-Path ".."
+	} else {
+		$searchpath = $Env:CODEQL_QUERY_SUITE
+	}
+
+	if (Test-Path "database") {
+		Remove-Item -Recurse -Force "database"
+	}
+	New-Item -ItemType Directory "database"
+
+	Run-CodeQL $solutionpath "xen" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
+	Run-CodeQL $solutionpath "xenfilt" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
+	Run-CodeQL $solutionpath "xenbus" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
+}
 elseif ($Type -eq "sdv") {
 	$archivepath = "xenbus"
 
-- 
2.28.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Wed Feb 24 16:40:34 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 24 Feb 2021 16:40:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.89433.168455 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lExDE-0006IM-PU; Wed, 24 Feb 2021 16:40:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 89433.168455; Wed, 24 Feb 2021 16:40: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 1lExDE-0006IF-Mc; Wed, 24 Feb 2021 16:40:32 +0000
Received: by outflank-mailman (input) for mailman id 89433;
 Wed, 24 Feb 2021 16:40:31 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=AZg/=H2=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lExDD-0006Hj-5l
 for win-pv-devel@lists.xenproject.org; Wed, 24 Feb 2021 16:40:31 +0000
Received: from mail-wr1-x42c.google.com (unknown [2a00:1450:4864:20::42c])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 6d13eafb-4168-4db3-887d-bbf8cfdaf956;
 Wed, 24 Feb 2021 16:40:30 +0000 (UTC)
Received: by mail-wr1-x42c.google.com with SMTP id c7so2507042wru.8
 for <win-pv-devel@lists.xenproject.org>; Wed, 24 Feb 2021 08:40:30 -0800 (PST)
Received: from ?IPv6:2a00:23c5:5785:9a01:5df2:fdab:9690:bbff?
 ([2a00:23c5:5785:9a01:5df2:fdab:9690:bbff])
 by smtp.gmail.com with ESMTPSA id a21sm4337198wmb.5.2021.02.24.08.40.28
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Wed, 24 Feb 2021 08:40:28 -0800 (PST)
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>
X-Inumbo-ID: 6d13eafb-4168-4db3-887d-bbf8cfdaf956
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=Sz+CFl+xHqw7ROYah8kOpGe7LGZMVAE9ljZvWdjD8J4=;
        b=cl2RVAS9NWCN+rTuodsXdiRN27uRzfGWr42oytPVmsZ+WmRVKsEayH5miQBCa0ff6g
         B3z66QKKJ4alyvuJ9A7zKfbw4PTk5OesCSD2YatR+fkRQ+GoXBo3Qtve4uLrrpDkHBR+
         vgidbcBz7JdN1qyscyNey0mkU3QQd2bpoc4ggHda+RSq0wvkCCxz4indPLmjktU17PNY
         bSTfxEKW3y+hiMr10mj/rA8B6JZWOzCVN5juOL9+L0gCJ1z4Vwo2CpvrmK0Jq6HD21rS
         1fwsdKQKQiPeFA9QgoIRW2+AlBNe4jG6yED2OZD1vI+P0Ny90jjV7a2xUM8TIXdfr4nJ
         6vTA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=Sz+CFl+xHqw7ROYah8kOpGe7LGZMVAE9ljZvWdjD8J4=;
        b=PEBnBV0FkYjP45ijxqEpavSXR+aAajkC8mK0/zDpPecIw+/liFGs4iokT0O6hlKpqX
         wZ/I2jXuBUWM+lMVgCv6JlhpCg8A4DqwiVfio6VMeuC7mi65rSGDyRT7P5K5SE9tSd3F
         nY/xcd0Wdqb/WTjrxLgNoxPbXYJ0ZN3cu0q98zzHZHalrZs55H/mRduFwxP0qN9Gheaf
         MjeD/TiXprVYUOsVgvE7RFHulfeKPcyIAknGGQg1xHOcAeTE9VKbgWmxeajr70IsJvDa
         YQ0+SyEnea1peV7RoaGZrJbRThGLFgupwKpqVfbI+VElUSHTRrkwIp6+fsa6X10R7QNx
         5ahA==
X-Gm-Message-State: AOAM533LGZJHkq1FgQ1BI8BqqT/ahGdldJU0l4tG5h+4R3ZR0L0oaGC2
	5638SceJpBblvgL4orlB3r8a6S2wpKk=
X-Google-Smtp-Source: ABdhPJwYdVAJtySETIyAfFMbWzRV3va6mWCdlG1LtjKtyDS+E2aQ1sY2hSYpBPMIFgkqvx2bfcOc7w==
X-Received: by 2002:a5d:464f:: with SMTP id j15mr33524784wrs.390.1614184829305;
        Wed, 24 Feb 2021 08:40:29 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [PATCH] Add CodeQL build stage
To: win-pv-devel@lists.xenproject.org
References: <20210224081957.2769442-1-owen.smith@citrix.com>
Message-ID: <668a0b4b-9092-d07f-cb62-08e8ff9f65ce@xen.org>
Date: Wed, 24 Feb 2021 16:40:28 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.7.1
MIME-Version: 1.0
In-Reply-To: <20210224081957.2769442-1-owen.smith@citrix.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 24/02/2021 08:19, Owen Smith wrote:
> CodeQL logs will be required for future WHQL submissions. Add a stage
> that generates the required SARIF files. CodeQL is a semantic code
> analysis engine, which will highlight vunerabilities that will need
> fixing.
> 
> In order to use CodeQL, the CodeQL binaries must be on the path and the
> Windows-Driver-Developer-Supplemental-Tools must be on the path defined
> by the CODEQL_QUERY_SUITE environment variable (if defined), or under
> the parent folder (if CODEQL_QUERY_SUITE variable is not defined)
> 
> Note: Due to the way the codeql command line is built, using quotes in a
> MSBuild command line is not possible, so generate a batch file to wrap
> the command line.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

Looks ok to me, but then I'm no powershell expert.

Acked-by: Paul Durrant <paul@xen.org>

> ---
>   build.ps1   | 20 ++++++++++++
>   msbuild.ps1 | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   2 files changed, 107 insertions(+), 1 deletion(-)
> 
> diff --git a/build.ps1 b/build.ps1
> index 2ea6428..346d187 100644
> --- a/build.ps1
> +++ b/build.ps1
> @@ -6,6 +6,7 @@ param(
>   	[Parameter(Mandatory = $true)]
>   	[string]$Type,
>   	[string]$Arch,
> +	[switch]$CodeQL,
>   	[switch]$Sdv
>   )
>   
> @@ -51,6 +52,21 @@ Function SdvBuild {
>   	& ".\msbuild.ps1" @params
>   }
>   
> +function CodeQLBuild {
> +	$visualstudioversion = $Env:VisualStudioVersion
> +	$solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; "16.0" = "vs2019"; }
> +	$configurationbase = @{ "14.0" = "Windows 10"; "15.0" = "Windows 10"; "16.0" = "Windows 10"; }
> +	$arch = "x64"
> +
> +	$params = @{
> +		SolutionDir = $solutiondir[$visualstudioversion];
> +		ConfigurationBase = $configurationbase[$visualstudioversion];
> +		Arch = $arch;
> +		Type = "codeql"
> +		}
> +	& ".\msbuild.ps1" @params
> +}
> +
>   if ($Type -ne "free" -and $Type -ne "checked") {
>   	Write-Host "Invalid Type"
>   	Exit -1
> @@ -99,6 +115,10 @@ if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x64") {
>   	Build "x64" $Type
>   }
>   
> +if ($CodeQL) {
> +	CodeQLBuild
> +}
> +
>   if ($Sdv) {
>   	SdvBuild
>   }
> diff --git a/msbuild.ps1 b/msbuild.ps1
> index 670050c..de7ad52 100644
> --- a/msbuild.ps1
> +++ b/msbuild.ps1
> @@ -67,11 +67,75 @@ Function Run-MSBuildSDV {
>   	Set-Location $basepath
>   }
>   
> +Function Run-CodeQL {
> +	param(
> +		[string]$SolutionPath,
> +		[string]$Name,
> +		[string]$Configuration,
> +		[string]$Platform,
> +		[string]$SearchPath,
> +		[string]$OutputPath
> +	)
> +
> +	$projpath = Resolve-Path (Join-Path $SolutionPath $Name)
> +	$project = [string]::Format("{0}.vcxproj", $Name)
> +	$output = [string]::Format("{0}.sarif", $Name)
> +	$database = Join-Path "database" $Name
> +
> +	# write a bat file to wrap msbuild parameters
> +	$bat = [string]::Format("{0}.bat", $Name)
> +	if (Test-Path $bat) {
> +		Remove-Item $bat
> +	}
> +	$a = "msbuild.exe"
> +	$a += " /m:4"
> +	$a += " /t:Build"
> +	$a += [string]::Format(" /p:Configuration=""{0}""", $Configuration)
> +	$a += [string]::Format(" /p:Platform=""{0}""", $Platform)
> +	$a += " "
> +	$a += Join-Path $projpath $project
> +	$a | Set-Content $bat
> +
> +	# generate the database
> +	$b = "codeql"
> +	$b += " database"
> +	$b += " create"
> +	$b += " -l=cpp"
> +	$b += " -s=src"
> +	$b += " -c"
> +	$b += ' "' + (Resolve-Path $bat) + '" '
> +	$b += $database
> +	Invoke-Expression $b
> +	if ($LASTEXITCODE -ne 0) {
> +		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
> +		Exit $LASTEXITCODE
> +	}
> +	Remove-Item $bat
> +
> +	# perform the analysis on the database
> +	$c = "codeql"
> +	$c += " database"
> +	$c += " analyze "
> +	$c += $database
> +	$c += " windows_driver_recommended.qls"
> +	$c += " --format=sarifv2.1.0"
> +	$c += " --output="
> +	$c += (Join-Path $OutputPath $output)
> +	$c += " --search-path="
> +	$c += $SearchPath
> +
> +	Invoke-Expression $c
> +	if ($LASTEXITCODE -ne 0) {
> +		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
> +		Exit $LASTEXITCODE
> +	}
> +}
> +
>   #
>   # Script Body
>   #
>   
> -$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; }
> +$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; "codeql" = "$ConfigurationBase Release"; }
>   $platform = @{ "x86" = "Win32"; "x64" = "x64" }
>   $solutionpath = Resolve-Path $SolutionDir
>   
> @@ -83,6 +147,28 @@ if ($Type -eq "free") {
>   elseif ($Type -eq "checked") {
>   	Run-MSBuild $solutionpath "xenbus.sln" $configuration["checked"] $platform[$Arch]
>   }
> +elseif ($Type -eq "codeql") {
> +	$archivepath = "xenbus"
> +
> +	if (-Not (Test-Path -Path $archivepath)) {
> +		New-Item -Name $archivepath -ItemType Directory | Out-Null
> +	}
> +
> +	if ([string]::IsNullOrEmpty($Env:CODEQL_QUERY_SUITE)) {
> +		$searchpath = Resolve-Path ".."
> +	} else {
> +		$searchpath = $Env:CODEQL_QUERY_SUITE
> +	}
> +
> +	if (Test-Path "database") {
> +		Remove-Item -Recurse -Force "database"
> +	}
> +	New-Item -ItemType Directory "database"
> +
> +	Run-CodeQL $solutionpath "xen" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
> +	Run-CodeQL $solutionpath "xenfilt" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
> +	Run-CodeQL $solutionpath "xenbus" $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
> +}
>   elseif ($Type -eq "sdv") {
>   	$archivepath = "xenbus"
>   
> 



From win-pv-devel-bounces@lists.xenproject.org Thu Feb 25 06:55:40 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 25 Feb 2021 06:55:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.89606.168900 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lFAYk-0001ku-Au; Thu, 25 Feb 2021 06:55:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 89606.168900; Thu, 25 Feb 2021 06:55:38 +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 1lFAYk-0001km-7l; Thu, 25 Feb 2021 06:55:38 +0000
Received: by outflank-mailman (input) for mailman id 89606;
 Thu, 25 Feb 2021 06:55:37 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=zZ6x=H3=gmail.com=shivakonduru@srs-us1.protection.inumbo.net>)
 id 1lFAYj-0001kh-6a
 for win-pv-devel@lists.xenproject.org; Thu, 25 Feb 2021 06:55:37 +0000
Received: from mail-wr1-x42e.google.com (unknown [2a00:1450:4864:20::42e])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id bbd8cb78-feba-4335-a423-b62063d3bd3d;
 Thu, 25 Feb 2021 06:55:36 +0000 (UTC)
Received: by mail-wr1-x42e.google.com with SMTP id n4so4134417wrx.1
 for <win-pv-devel@lists.xenproject.org>; Wed, 24 Feb 2021 22:55:36 -0800 (PST)
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>
X-Inumbo-ID: bbd8cb78-feba-4335-a423-b62063d3bd3d
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:from:date:message-id:subject:to;
        bh=B4zsQ+SsKY7a2QEyaS02hIcHQmLHySVtxYeIzvGiOzY=;
        b=ncyVI8gWeZ9FfV+rov59kAr60MGX+3dQv3ILNafhLRyfOMxRhoKxBnjaStA4Wd3kH1
         Pi6UdkZJz3Q978rS3cqlNuSdS/P18a1Tx1e+RAdU4+8cHmPZfoSPPCQ3X0a5DVPkg4uz
         Xuq2ysnrIe0TRG3vifPT3od5tOn9JkRQWd+YPEr1HLCgWCIIzsw6m33EKMg39vqA7jA6
         Z64TLVWSGxbLne7MCIccoMFKSV8DuqCPiILb1U/cSmOA7vprmf31NJH8j4C8gFPVwNYZ
         rqZsQjJrWgrtqMlBkMN4se/ujNopaxzOK1Oj8m0eEgIgs2tOb4ClrVvcNWyrk4NMF0Ql
         TT7g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
        bh=B4zsQ+SsKY7a2QEyaS02hIcHQmLHySVtxYeIzvGiOzY=;
        b=VyShFHiYyoy01uqadvkLzemzghEfJicrjmXXtOio4NAC97sxlBAQzUj6YxhnRtHWP0
         kc8UFBb7ESIdfOl+1LaqRWpuJw1FCcxt0jDsVuxfO7rNIrb3OaLnPTqnY2rXnBOfZQpK
         UUm9qqq4R4gp+pMkrvgdI9+/C93hpD0c9+DTIjim5expY9+6O1Kv/tFCeizt7GpwU6Pt
         E30P5lCOPJKM9yqzPv8lSLq8aiG5DWB28Hp8xa0Orh56qA2USRDNrOv6sQhBQcI3rQ+B
         yE6VODF6OaXUFvebjs0hf6tA5mETpuDxPwMjbtZOstbdUlq5m0wx66745pxDTCaK/YGw
         yGHA==
X-Gm-Message-State: AOAM530SOvFgkoqBMXsOUOMQzryg8bkGI9RAFtlfLkGBjkyJpRe1i7PD
	bqzevXWb60z23aHwdCNA0dRm7BpYZC6gHO+uorMta+extew=
X-Google-Smtp-Source: ABdhPJx8MT7y4QadkjNFOMTL9QzpSCLp8r9MRwPpDEy9kobXtwXm/0gAlKr1HJfCRXs557ZBRNPk3q+f5Bm6GyWcf+U=
X-Received: by 2002:a05:6000:1281:: with SMTP id f1mr637126wrx.243.1614236135303;
 Wed, 24 Feb 2021 22:55:35 -0800 (PST)
MIME-Version: 1.0
From: Shiva Konduru <shivakonduru@gmail.com>
Date: Wed, 24 Feb 2021 22:55:23 -0800
Message-ID: <CAKnqCA+hxrPCHUkCj4ZSgHoXnRmtpePxA8DZvmTymXabVdYOTg@mail.gmail.com>
Subject: Help with understanding Windows boot up
To: win-pv-devel@lists.xenproject.org
Content-Type: multipart/alternative; boundary="0000000000006dab9005bc23a35a"

--0000000000006dab9005bc23a35a
Content-Type: text/plain; charset="UTF-8"

Hi,

I am trying to improve my understanding of the boot up process for a
windows machine running on top of xen and what happens behind the scenes at
hypervisor level before guest machine starts.

I tried searching the available documentation but could not manage to find
anything.

Can you please share some pointers?

Apologize in advance if this question is not relevant to this forum.



-- 
Regards,
Shiva Kiran Konduru

--0000000000006dab9005bc23a35a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>I am trying to improve my understan=
ding of the boot up process for a windows machine running on top of xen and=
 what happens behind the scenes at hypervisor level before guest machine st=
arts.</div><div><br></div><div>I tried searching the available documentatio=
n but could not manage to find anything.</div><div><br></div><div>Can you p=
lease share some pointers?</div><div><br></div><div>Apologize in advance=C2=
=A0if this question is not relevant to this forum.</div><div><br></div><div=
><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr" class=3D"gmail_si=
gnature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr">Regards,<div>S=
hiva Kiran Konduru</div></div></div></div></div>

--0000000000006dab9005bc23a35a--


From win-pv-devel-bounces@lists.xenproject.org Sun Feb 28 16:24:24 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 28 Feb 2021 16:24:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.91137.172238 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lGOrl-0003iD-Mh; Sun, 28 Feb 2021 16:24:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 91137.172238; Sun, 28 Feb 2021 16:24:21 +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 1lGOrl-0003i5-JQ; Sun, 28 Feb 2021 16:24:21 +0000
Received: by outflank-mailman (input) for mailman id 91137;
 Sun, 28 Feb 2021 16:24:20 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=qbwo=H6=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lGOrk-0003hh-Gz
 for win-pv-devel@lists.xenproject.org; Sun, 28 Feb 2021 16:24:20 +0000
Received: from mail-wm1-x329.google.com (unknown [2a00:1450:4864:20::329])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 4548a7d0-6aa3-47ce-bd32-1eec0a52b48f;
 Sun, 28 Feb 2021 16:24:19 +0000 (UTC)
Received: by mail-wm1-x329.google.com with SMTP id n22so1480534wmc.2
 for <win-pv-devel@lists.xenproject.org>; Sun, 28 Feb 2021 08:24:19 -0800 (PST)
Received: from ?IPv6:2a00:23c5:5785:9a01:b030:d9ee:2f89:c35e?
 ([2a00:23c5:5785:9a01:b030:d9ee:2f89:c35e])
 by smtp.gmail.com with ESMTPSA id p9sm21707917wma.14.2021.02.28.08.24.17
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 28 Feb 2021 08:24:17 -0800 (PST)
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>
X-Inumbo-ID: 4548a7d0-6aa3-47ce-bd32-1eec0a52b48f
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=ZO8S3eZVK+LNxaSap5cncK2p8RxmEeVcMRImioJ5BeU=;
        b=hvYKzjyl/BviUtrTFq4jUeb+iuxrONtZYaDbQZ+slNGxqT08NNtSLlEqnyv3RejKwK
         glFpE1HK5Q3hz5DxmWlPkJEnzkpv57Sg9qYwmQSMpHfGNP4bkxi2gNK+EdXI79d0+FrJ
         0285utmEY2X1VMYKBiUa1wgDS0UlFxSSwu06yQO7gRBVH+TZ/Ta0NbjDwr4LnjGQoP2a
         evjIPdo6sfLhX6vohFiRFP5XIntbpgAyZOrohA9k4LsdERReOimSOg9VgcnVh2SdOV8Q
         dFwtjsBbpP5CCHEjvSYNeqhoqAyC4j6WeduXUHrNN9TuOOjQjWivoCaqL2xPsbLOXQ1R
         7vHg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=ZO8S3eZVK+LNxaSap5cncK2p8RxmEeVcMRImioJ5BeU=;
        b=uPb0mMQdY2Geg6h6vbGkS5vbQhQ8muo3PjljhsQzln2Cn9Pm5B26ZWNIMo5StUi8Gi
         txwUthvrRPGJAbJ8n/36FPeo2a8cCmYoGu23zT+7IxiPkyWLiJA/uKZkR4nZM0W1VD7I
         a+cXe7Ev7IqfjejPXThXtaBJahD4+BoE+Uz0vey1/cK1N/nuftjuWWFmPkhQWxnEaszm
         IXwxNZPR+IXKUx8e6aWMwnPWOTLFoT4idhpnTLBACwsvkh/lU7OLqVoBLcJnXm74uNj0
         ZQB4B/KSVrsVJwUgNqRxMOLmYPh/buS+RKApkZjfozLPapfS/F/tXB/2L15QNAqdW/7g
         uddw==
X-Gm-Message-State: AOAM5335J/FIYEcAUxLeIgzvazvVJpcBBgsz14umupDvo7tAWyhR/qWM
	tyX5EEkuze2yxxJAFFj6ywnKxpDYmLc=
X-Google-Smtp-Source: ABdhPJx5GLRGiC5CmKMwS6kUJmgIeXZUncjrxWqy2vMu2xdbUXqygHdVIIh5CuSnNbPc4Rwh3WmwjQ==
X-Received: by 2002:a7b:c922:: with SMTP id h2mr11840328wml.44.1614529458459;
        Sun, 28 Feb 2021 08:24:18 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: Help with understanding Windows boot up
To: win-pv-devel@lists.xenproject.org
References: <CAKnqCA+hxrPCHUkCj4ZSgHoXnRmtpePxA8DZvmTymXabVdYOTg@mail.gmail.com>
Message-ID: <a4d8b0c5-78a5-611f-11fe-14134d90448b@xen.org>
Date: Sun, 28 Feb 2021 16:24:17 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.7.1
MIME-Version: 1.0
In-Reply-To: <CAKnqCA+hxrPCHUkCj4ZSgHoXnRmtpePxA8DZvmTymXabVdYOTg@mail.gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit

On 25/02/2021 06:55, Shiva Konduru wrote:
> Hi,
> 
> I am trying to improve my understanding of the boot up process for a 
> windows machine running on top of xen and what happens behind the scenes 
> at hypervisor level before guest machine starts.
> 
> I tried searching the available documentation but could not manage to 
> find anything.
> 
> Can you please share some pointers?
> 
> Apologize in advance if this question is not relevant to this forum.
> 

Hi Shiva,

TBH you'd be better posting to xen-devel for this question... There's 
nothing particularly special about Windows; it's essentially 'just 
another OS' running in an HVM container. The construction of that 
container does not differ according to the OS that will run inside it.
The only real difference with Windows is what happens post-boot, since 
Xen provides a certain number of 'viridian' (a.k.a. Hyper-V) 
enlightenments, which are not generally used by other OS when running in 
a Xen environment.

   Cheers,

     Paul
> 
> 
> -- 
> Regards,
> Shiva Kiran Konduru



From win-pv-devel-bounces@lists.xenproject.org Sun Feb 28 18:04:13 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sun, 28 Feb 2021 18:04:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.91153.172242 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lGQQN-0004qJ-Qx; Sun, 28 Feb 2021 18:04:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 91153.172242; Sun, 28 Feb 2021 18:04:11 +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 1lGQQN-0004qB-Ns; Sun, 28 Feb 2021 18:04:11 +0000
Received: by outflank-mailman (input) for mailman id 91153;
 Sun, 28 Feb 2021 17:32:21 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=Si+g=H6=gmail.com=jinoh.kang.kr@srs-us1.protection.inumbo.net>)
 id 1lGPvY-0001uz-TI
 for win-pv-devel@lists.xenproject.org; Sun, 28 Feb 2021 17:32:20 +0000
Received: from mail-pg1-x52a.google.com (unknown [2607:f8b0:4864:20::52a])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 986b711e-3972-49a4-8da4-b3bd7c593d95;
 Sun, 28 Feb 2021 17:32:19 +0000 (UTC)
Received: by mail-pg1-x52a.google.com with SMTP id h4so9950786pgf.13
 for <win-pv-devel@lists.xenproject.org>; Sun, 28 Feb 2021 09:32:19 -0800 (PST)
Received: from [127.0.0.1] ([175.195.196.250])
 by smtp.gmail.com with ESMTPSA id d1sm4707314pjc.24.2021.02.28.09.32.17
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 28 Feb 2021 09:32:18 -0800 (PST)
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>
X-Inumbo-ID: 986b711e-3972-49a4-8da4-b3bd7c593d95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=to:references:cc:from:subject:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=wdmx9+VI8Th+cV9KiKdMkMh/JEOLPT89/JtYrICHKts=;
        b=GMOJ9W4AgxtqucByIJM/AWpszv48B6bP54CkAi4KcTShUSodgp/9k0JsT28LjsFojx
         Lt724fkeafxxFnfASxDp4LT6MeO8X7MuVo99G67X9Gh+e/r7nsfX3ZMVZKvz4zFMIIfY
         fP9WF/d/rfEFTmaiLRarq0y8jfh3fou4b5Eck5krACVNId/I4uSX4uTDXQvcc+r3AEQr
         uSNcbBAJlt4Oil7JATqIyhaxWHXi1c5OQ8K7VlpqFxh8Vu6ZHbNqaB+k73QdAvpdvbqC
         z432HOt+LB1hJZ5o8KQVHaaYrwm6SCqbIQAo4M9kGrOkB2LqdGH4flXNq73ybbSJIiK9
         wN2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:to:references:cc:from:subject:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=wdmx9+VI8Th+cV9KiKdMkMh/JEOLPT89/JtYrICHKts=;
        b=VB1728c8IJJoFOJrwrQxgJzBjBE0kb1DBatX+BXTKhT5re893c5DPa0Wprt6amdJ/x
         b9paRTCVK2Sbbj7pwbUiNsC6K1NDdvRSmjDhE2sLp+tFVGEds2tnJ3vpfgD5MH10ttP+
         rwtFqyyn9M4gpRWuv0DmM1Wotldn1JBgmZfPguboWxXU4AdcMJUpzk1l4p2vwwiVcxVh
         TIcrM3aMgsCAC1pAE2Ae9WZ+oMDHkFhyrxXA44JTR0/DbkiEHm2B2daHC3VOQ/ZtUri1
         /oaZAY3H/u0Yi74chE/TDP1B3GdJIfL/ILJMM50pyz/2Fws7VojBkZHSNpikVGvASTeY
         Urmg==
X-Gm-Message-State: AOAM533fsFPbK36vXIZl4b0OCuYdJEr90AEhA1CMhCy5pb4Vg7p0BPbW
	IXI9xGQZNOHgdl6YzhJ489Q=
X-Google-Smtp-Source: ABdhPJwA4nbi7G7IXI/Y9Ac3DBwIvrls4K5ahxvi350JMwkXNDrm3EappMmhpKoN6onbbeFL+heD7g==
X-Received: by 2002:a63:1619:: with SMTP id w25mr10620197pgl.247.1614533538729;
        Sun, 28 Feb 2021 09:32:18 -0800 (PST)
To: Paul Durrant <paul.durrant@citrix.com>, win-pv-devel@lists.xenproject.org
References: <1517410750-4749-3-git-send-email-paul.durrant@citrix.com>
Cc: =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?=
 <marmarek@invisiblethingslab.com>
From: Jinoh Kang <jinoh.kang.kr@gmail.com>
Subject: Re: [win-pv-devel] [PATCH xenbus 3/3] Stop using BAR space to host
 Xen data structures
Message-ID: <9363c50a-bccb-c9a2-3892-7134e0bfaeba@gmail.com>
Date: Sun, 28 Feb 2021 17:31:57 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0
MIME-Version: 1.0
In-Reply-To: <1517410750-4749-3-git-send-email-paul.durrant@citrix.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit

On 1/31/18 2:59 PM, Paul Durrant wrote:
> Currently XENBUS makes use of the memory BAR of the PCI device to which it
> binds as a source of unpopulated GFNs to host Xen data structures, such as
> the shared info and grant table.
> 
> There is a problem with doing this, which is that Windows (unsurprisingly)
> sets up a non-cached MTRR for the page range covering PCI BARs so accesses
> to BAR space (and hence the Xen data structures) should be non-cached.
> However, Xen itself contains a work-around to avoid the slow access times
> that would ordinarily result from the this; it ignores the MTRRs if no
> real devices are passed through to the guest so accesses are actually
> cached. Thus, in the normal case, there is no penalty to pay... but as soon
> as hardware is passed through to a guest, the work-around no longer applies
> and there is a noticeable drop in PV driver performance. (E.g. network
> throughput can drop by ~30-40%).
> 
> This patch modifies XENBUS to allocate a 2MB area of RAM

Some time ago I have discovered that the PV driver fails with
STATUS_INSUFFICIENT_RESOURCES if the grant table configured for the
Windows HVM is larger than 2MB.

Perhaps it might be a good idea to let unpopulated GFNs to be allocated
dynamically from FdoAllocateHole, possibly reviving the original purpose
of range_set in the process.

Or at minimum, call GrantTableQuerySize early and take the
MaximumFrameCount into account when allocating the initial "unpopulated"
GFN range.

> (which will always fall into a cached MTRR),

Isn't MmAllocateContiguousNodeMemory expected to either return memory
with correct cacheability or fail completely?  In the absence of
PAGE_NOCACHE or PAGE_WRITECOMBINE flags, it makes sense for the caller
to safely assume the allocated memory to be WB-cached.

I suppose the "fail completely" case could be alleviated via dynamic
allocation.

> use a decrease_reservation hypercall to de-populate the area,

An alternative method would be to copy the unpopulated-alloc facility
in Linux merged into mainline fairly recently (5.9), which avoids being
entangled with ballooning entirely.

An obvious approach would be to have hotplug PDOs to convince the NT PnP
manager to hand us cacheable memory resources.  Implementing it sounds
pretty complicated, though.

> and then use that as a source of GFNs instead of the
> BAR. Hence, the work-around in Xen no longer has any baring on accessing of
> Xen data structures and thus there is no longer any performance penalty
> when hardware is passed through to a guest.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>


