From win-pv-devel-bounces@lists.xenproject.org Fri Jun 07 07:17:27 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jun 2024 07:17:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.736241.1142302 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqp-0002Jo-2C; Fri, 07 Jun 2024 07:17:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 736241.1142302; Fri, 07 Jun 2024 07:17:27 +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 1sFTqo-0002JY-Tl; Fri, 07 Jun 2024 07:17:26 +0000
Received: by outflank-mailman (input) for mailman id 736241;
 Fri, 07 Jun 2024 07:17:26 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=prRf=NJ=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sFTqo-0002HT-4u
 for win-pv-devel@lists.xenproject.org; Fri, 07 Jun 2024 07:17:26 +0000
Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com
 [2a00:1450:4864:20::32a])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fa6bea85-249d-11ef-b4bb-af5377834399;
 Fri, 07 Jun 2024 09:17:21 +0200 (CEST)
Received: by mail-wm1-x32a.google.com with SMTP id
 5b1f17b1804b1-42136faf3aeso11085405e9.2
 for <win-pv-devel@lists.xenproject.org>; Fri, 07 Jun 2024 00:17:20 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-35ef5fc1ca8sm3325343f8f.97.2024.06.07.00.17.18
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 00:17:18 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fa6bea85-249d-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1717744639; x=1718349439; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to;
        bh=/YUmLJiF8aTt0y3tW35hDwsVHf843GMtSPIG0nlfxAA=;
        b=D6ePt0IqfTadud9eclU2cuum7Qk9DL6WC0nyF/v6t8YAv9QydLPyUOZCzS0NaFOtGY
         zQhNPlIinATjA9JnMteoyW36eAUnQ/1kb6lhoveLnNlJxgylR5ZJfYx2px5VjyuW3E+7
         JIIgOcUUSGDepU7W+LkAP7iUo+Jxwvzyvd3L4=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1717744639; x=1718349439;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=/YUmLJiF8aTt0y3tW35hDwsVHf843GMtSPIG0nlfxAA=;
        b=S7fTtAuZzB2PtPCWiWz+y1myq9J1X0mUw05KjxqdjhKE7eujlBTPM8AmsGu1kCFySA
         W0d1NcYE8VqDHYxb5BunByBCWqMe/lPSmsoGbUlEPQBYzWBgKFDEKlnWadBhHfovLIzw
         9E14lX8H/da9dWpTATcVIXWNH49U7ix1RAGbuCuG1Mupjn6+KIEYhC+tWGAihW/AXgeB
         rOczpXsSyy6V67Y3f2HHy/aqiNzPLOzsoxH1gkcFtL0KPCEzbyJbvwf47pRGEaKoS5OQ
         ou7+1QlrzaOvs8u5g8baxft2gNeZOVcZntYU9ft71ZRujyqHTbpwjaSNGKBKoVFADho2
         8iuA==
X-Gm-Message-State: AOJu0YzKt/dUGu1fIV/ZzqyuYREVxOhh4lpoFLvFdR7NFFW/KoaAiufh
	05Cb/6N9o/LuDtgxnce7GNk79by918f8q3TXvqNHHKOp11xE8ltZZn/nf79z7LybjDK2zAmT4Tc
	=
X-Google-Smtp-Source: AGHT+IGbqJX4xjL7XUU+a25ILppO+Sdv26V0sM40+Hht4+4OqbrSOuuqVBNcFNtB00Qgdd6Q537HYw==
X-Received: by 2002:a05:600c:4f84:b0:421:1d8:add4 with SMTP id 5b1f17b1804b1-42164a37337mr15837295e9.35.1717744638713;
        Fri, 07 Jun 2024 00:17:18 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [RFC PATCH 0/5] Changes for Server 2025
Date: Fri,  7 Jun 2024 08:16:55 +0100
Message-ID: <20240607071700.1272-1-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

When running Server 2025 WHQL testing, issues have been identified with driver
verifier registry isolation violations (verifier.exe /rc 33 36) which are enabled
by default on certain drivers (primarily XenVbd and XenNet). Running verifier
with these additional checks exposes issues with various drivers.

These checks enforce:
* ZwOpenKey and ZwCreateKey cannot use absolute registry paths
* Only IoOpenDriverRegistryKey and IoOpenDeviceRegistryKey are used to open
  registry keys
* Access permissions are restricted based on the key requested
  IoOpenDriverRegistryKey's ParametersKey is read only
  IoOpenDriverRegistryKey's PersistentState key is read/write
  IoOpenDeviceRegistryKey's keys are read only

These patches use IoOpenDriverRegistryKey to open the ParametersKey to query any
settings made by the INF file (or any manual configuration done after install),
and move any 'banned API usage' to xen.sys (as it appears WHQL testing does not
enable driver verifier on import drivers). The attempt to rename the device's
FriendlyName to improve Device Manager's readability is dropped, and UNPLUG v3
is introduced to trigger the request for reboot and determine if boot emulated was
requested.

There will need to be a related patch series for all other drivers, in order to
use the correct APIs to open the ParametersKey, and use UNPLUG v3 to request reboots
when needed. XenNet also has additional NDIS requirements for Server 2025 which
have not been fully explored (they look relatively minor changes)

Owen Smith (5):
  Add RegistryOpenParametersKey
  Move FiltersInstall/FiltersUninstall to xen.sys
  Remove FdoSetFriendlyName
  Move Registry operations to xen.sys
  Add UNPLUG v3

 include/revision.h            |   3 +-
 include/unplug_interface.h    |  40 ++-
 include/xen.h                 |  59 ++++
 src/common/registry.c         |  22 +-
 src/common/registry.h         |   9 +-
 src/xen/config.c              | 497 ++++++++++++++++++++++++++++++++++
 src/xen/driver.c              |   2 +-
 src/{xenbus => xen}/filters.c |   4 +
 src/{xenbus => xen}/filters.h |   0
 src/xenbus/driver.c           | 469 +-------------------------------
 src/xenbus/driver.h           |  30 --
 src/xenbus/fdo.c              |  99 +------
 src/xenbus/unplug.c           |  86 ++++++
 src/xenfilt/driver.c          |  33 +--
 vs2019/xen/xen.vcxproj        |   2 +
 vs2019/xenbus/xenbus.vcxproj  |   1 -
 vs2022/xen/xen.vcxproj        |   2 +
 vs2022/xenbus/xenbus.vcxproj  |   1 -
 18 files changed, 733 insertions(+), 626 deletions(-)
 create mode 100644 src/xen/config.c
 rename src/{xenbus => xen}/filters.c (99%)
 rename src/{xenbus => xen}/filters.h (100%)

-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 07 07:17:28 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jun 2024 07:17:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.736242.1142306 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqq-0002N5-2A; Fri, 07 Jun 2024 07:17:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 736242.1142306; Fri, 07 Jun 2024 07:17:28 +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 1sFTqp-0002My-V8; Fri, 07 Jun 2024 07:17:27 +0000
Received: by outflank-mailman (input) for mailman id 736242;
 Fri, 07 Jun 2024 07:17:26 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=prRf=NJ=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sFTqo-0002HY-LM
 for win-pv-devel@lists.xenproject.org; Fri, 07 Jun 2024 07:17:26 +0000
Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com
 [2a00:1450:4864:20::434])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fba66851-249d-11ef-90a2-e314d9c70b13;
 Fri, 07 Jun 2024 09:17:23 +0200 (CEST)
Received: by mail-wr1-x434.google.com with SMTP id
 ffacd0b85a97d-35e4aaa0f33so1836755f8f.0
 for <win-pv-devel@lists.xenproject.org>; Fri, 07 Jun 2024 00:17:22 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-35ef5fc1ca8sm3325343f8f.97.2024.06.07.00.17.20
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 00:17:20 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fba66851-249d-11ef-90a2-e314d9c70b13
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1717744641; x=1718349441; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=yJOSMV8Jhwq3HJ+7+BJHVTi4sXqprwdn940khdEpbm8=;
        b=ZNmx+KLINqkdvy4aIZKCF8vgHSKMEESHsuv8alTtZre/+JjDGo2vSCJIRab/2TAhaa
         LnZYViG0LM3t9zGIgIRApHfzRZRnyWZ00zVQ3+p5mvAV3K9dHohvmzvQKdpzWsTSk1OR
         OtuRxAjHdrQTPsNktwGYG6G/5wpDlQU0n1G+s=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1717744641; x=1718349441;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=yJOSMV8Jhwq3HJ+7+BJHVTi4sXqprwdn940khdEpbm8=;
        b=KssaaYqJjZX9KRsZ2vBaZJvOAaRQa4WPpR6a3UpiMye5ZO/c3EXv7IeCL9OXWkBOmB
         IEbR2k13tADSGO2SeKPuQOI2gowpxhLnmJLTexLRADfZT/SAYGzZDe1g6GTJZ7ihs3bm
         K7MUi+j1TzXltB+a7N2EhatGnNcLDtozIzlH3omibW4f9grpFEIQN1i6Pr0JxVwcM/kO
         tlrh2JQ4hK2ef/rqAQYhiJgAUqQxPdwRvPpXQZ/8oiO3b0psLasWJB1xc3Yb1Ch1qxks
         3KvVyOnCX8JnHzuNO4zc9Wu+iZylYPuywclf6j4dOdv4ro0gERD297UXmBntpKVbxwbe
         +AZw==
X-Gm-Message-State: AOJu0Yx3S09Vg2HorpyZ477N8X+8I6z4vPNU7g6GWzLwevljizQcxTCW
	3pLV962C7lwq75p1v8n2PiQdg56PmZQBc251mWVCUs2qQcniMcnlfYfxwM5ohg3qkACYZAwKkfM
	=
X-Google-Smtp-Source: AGHT+IHbdc4a1a+u7ur17sqkSq9POzemGBY7mABx2pRTF8Zjz6xYLv9dzR/ItJxOgjYHTop+JrGtoA==
X-Received: by 2002:adf:f310:0:b0:354:db70:3815 with SMTP id ffacd0b85a97d-35efed16a1cmr1329177f8f.7.1717744641037;
        Fri, 07 Jun 2024 00:17:21 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [RFC PATCH 2/5] Move FiltersInstall/FiltersUninstall to xen.sys
Date: Fri,  7 Jun 2024 08:16:57 +0100
Message-ID: <20240607071700.1272-3-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
In-Reply-To: <20240607071700.1272-1-owen.smith@cloud.com>
References: <20240607071700.1272-1-owen.smith@cloud.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Since WHQL will enable Driver Verifier's registry isolation violation
detection on xenbus.sys, move the registry manipulation for inserting
xenfilt.sys into the appropriate device class UpperFilters to xen.sys.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 include/xen.h                 | 14 ++++++++++++++
 src/{xenbus => xen}/filters.c |  4 ++++
 src/{xenbus => xen}/filters.h |  0
 src/xenbus/driver.c           |  2 +-
 vs2019/xen/xen.vcxproj        |  1 +
 vs2019/xenbus/xenbus.vcxproj  |  1 -
 vs2022/xen/xen.vcxproj        |  1 +
 vs2022/xenbus/xenbus.vcxproj  |  1 -
 8 files changed, 21 insertions(+), 3 deletions(-)
 rename src/{xenbus => xen}/filters.c (99%)
 rename src/{xenbus => xen}/filters.h (100%)

diff --git a/include/xen.h b/include/xen.h
index f8721e8..566d9e3 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -526,4 +526,18 @@ VcpuRegisterVcpuInfo(
     IN  ULONG                       Offset
     );
 
+// FILTERS
+
+XEN_API
+VOID
+FiltersInstall(
+     VOID
+     );
+
+XEN_API
+VOID
+FiltersUninstall(
+     VOID
+     );
+
 #endif  // _XEN_H
diff --git a/src/xenbus/filters.c b/src/xen/filters.c
similarity index 99%
rename from src/xenbus/filters.c
rename to src/xen/filters.c
index 5b41e11..36a266f 100644
--- a/src/xenbus/filters.c
+++ b/src/xen/filters.c
@@ -30,6 +30,8 @@
  * SUCH DAMAGE.
  */
 
+#define XEN_API __declspec(dllexport)
+
 #define INITGUID 1
 
 #include <ntddk.h>
@@ -323,6 +325,7 @@ fail1:
 #define FILTERS_UNINSTALL_CLASS(_ClassGuid, _DriverName) \
         FiltersUninstallClass(#_ClassGuid, &GUID_ ## _ClassGuid, (_DriverName))
 
+XEN_API
 VOID
 FiltersInstall(
     VOID
@@ -332,6 +335,7 @@ FiltersInstall(
     (VOID) FILTERS_INSTALL_CLASS(DEVCLASS_HDC, "XENFILT");
 }
 
+XEN_API
 VOID
 FiltersUninstall(
     VOID
diff --git a/src/xenbus/filters.h b/src/xen/filters.h
similarity index 100%
rename from src/xenbus/filters.h
rename to src/xen/filters.h
diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index d6efe89..e8d0c1f 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -33,6 +33,7 @@
 #include <ntddk.h>
 #include <procgrp.h>
 #include <ntstrsafe.h>
+#include <xen.h>
 
 #include "registry.h"
 #include "fdo.h"
@@ -40,7 +41,6 @@
 #include "driver.h"
 #include "names.h"
 #include "mutex.h"
-#include "filters.h"
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
diff --git a/vs2019/xen/xen.vcxproj b/vs2019/xen/xen.vcxproj
index ca6cef6..ec0f7e1 100644
--- a/vs2019/xen/xen.vcxproj
+++ b/vs2019/xen/xen.vcxproj
@@ -70,6 +70,7 @@
     <ClCompile Include="..\..\src\common\registry.c" />
     <ClCompile Include="..\..\src\xen\driver.c" />
     <ClCompile Include="..\..\src\xen\event_channel.c" />
+    <ClCompile Include="..\..\src\xen\filters.c" />
     <ClCompile Include="..\..\src\xen\grant_table.c" />
     <ClCompile Include="..\..\src\xen\hvm.c" />
     <ClCompile Include="..\..\src\xen\xen_version.c" />
diff --git a/vs2019/xenbus/xenbus.vcxproj b/vs2019/xenbus/xenbus.vcxproj
index 9227e0a..ee43971 100644
--- a/vs2019/xenbus/xenbus.vcxproj
+++ b/vs2019/xenbus/xenbus.vcxproj
@@ -81,7 +81,6 @@
     <ClCompile Include="..\..\src\xenbus\evtchn_2l.c" />
     <ClCompile Include="..\..\src\xenbus\evtchn_fifo.c" />
     <ClCompile Include="..\..\src\xenbus\fdo.c" />
-    <ClCompile Include="..\..\src\xenbus\filters.c" />
     <ClCompile Include="..\..\src\xenbus\gnttab.c" />
     <ClCompile Include="..\..\src\xenbus\pdo.c" />
     <ClCompile Include="..\..\src\xenbus\shared_info.c" />
diff --git a/vs2022/xen/xen.vcxproj b/vs2022/xen/xen.vcxproj
index 2304a4b..7efdce8 100644
--- a/vs2022/xen/xen.vcxproj
+++ b/vs2022/xen/xen.vcxproj
@@ -65,6 +65,7 @@
     <ClCompile Include="..\..\src\common\registry.c" />
     <ClCompile Include="..\..\src\xen\driver.c" />
     <ClCompile Include="..\..\src\xen\event_channel.c" />
+    <ClCompile Include="..\..\src\xen\filters.c" />
     <ClCompile Include="..\..\src\xen\grant_table.c" />
     <ClCompile Include="..\..\src\xen\hvm.c" />
     <ClCompile Include="..\..\src\xen\xen_version.c" />
diff --git a/vs2022/xenbus/xenbus.vcxproj b/vs2022/xenbus/xenbus.vcxproj
index 422f610..939654a 100644
--- a/vs2022/xenbus/xenbus.vcxproj
+++ b/vs2022/xenbus/xenbus.vcxproj
@@ -73,7 +73,6 @@
     <ClCompile Include="..\..\src\xenbus\evtchn_2l.c" />
     <ClCompile Include="..\..\src\xenbus\evtchn_fifo.c" />
     <ClCompile Include="..\..\src\xenbus\fdo.c" />
-    <ClCompile Include="..\..\src\xenbus\filters.c" />
     <ClCompile Include="..\..\src\xenbus\gnttab.c" />
     <ClCompile Include="..\..\src\xenbus\pdo.c" />
     <ClCompile Include="..\..\src\xenbus\shared_info.c" />
-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 07 07:17:27 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jun 2024 07:17:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.736240.1142297 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqo-0002JU-V6; Fri, 07 Jun 2024 07:17:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 736240.1142297; Fri, 07 Jun 2024 07:17:26 +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 1sFTqo-0002JN-SL; Fri, 07 Jun 2024 07:17:26 +0000
Received: by outflank-mailman (input) for mailman id 736240;
 Fri, 07 Jun 2024 07:17:26 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=prRf=NJ=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sFTqo-0002HY-09
 for win-pv-devel@lists.xenproject.org; Fri, 07 Jun 2024 07:17:26 +0000
Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com
 [2a00:1450:4864:20::536])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fc263cb2-249d-11ef-90a2-e314d9c70b13;
 Fri, 07 Jun 2024 09:17:23 +0200 (CEST)
Received: by mail-ed1-x536.google.com with SMTP id
 4fb4d7f45d1cf-57aa64c6bbfso1832846a12.3
 for <win-pv-devel@lists.xenproject.org>; Fri, 07 Jun 2024 00:17:23 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-35ef5fc1ca8sm3325343f8f.97.2024.06.07.00.17.21
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 00:17:21 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fc263cb2-249d-11ef-90a2-e314d9c70b13
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1717744642; x=1718349442; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=h5qFfrmYAFHvJNwEsFy424VbTYGtomAApWoPelrC7nU=;
        b=Io6aak5Inah5DsgayiHC3L+rW0VSQGL96iAqJglABVHXtTro9LESJa1Ir7i9j3RXPI
         q5cWHcu0d2vBBbR+ftX4mbshlpSCBPIA99htyblgqeLkH5WmO/O1RsFXdpzh9PzEYcK6
         wGdBcyHhNxTFEMQvYaIlCo5cLjGfUFWqsaEhA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1717744642; x=1718349442;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=h5qFfrmYAFHvJNwEsFy424VbTYGtomAApWoPelrC7nU=;
        b=JJDlVN+9WfUG+nO71+Ej7KxXQDEPtqyxVmVAnUU4XNcgZ6K0LtfXqYhX3m1LIoJDbC
         ywZJDbJ0Zp/DdNOtWR2TjnjmWe+rOkIDT+lqMZg/ESUdTFC/iUxDuYm3YhdOT2GcH7Q3
         /RIEdPhme1siZrrihLWJZ0pmoxxAel+9ahcoFdj8VWG2fm1GPgbL54vc3n0Hb9+iqIAH
         7GhRmwUYAJ5EZbxXxl1N7W3ySbqiN5LUeDSK4YM7OQTvVVMTk04M1XJB0D1VJUfosBy5
         zSw9qVU9TZQojx1nbqBy+InobazYRQp0R+y7SMNb8Tli1cHQVm0dlj8O7hUusc3MbrRA
         laJg==
X-Gm-Message-State: AOJu0YwFozKT9AREd5qhaZR0ZYWyHclMas9OZyIHJBUvjcbYt0ZCHdgI
	yKX62goOqVPxXQ79eMkqAEsMinEO+4LgD84b+kchcD+c+DDx4yud0xdGbcmTCumV51iOdDXvFzA
	=
X-Google-Smtp-Source: AGHT+IFgmOMN7fRU6GPEgaKeompbRA3QGfVx7CtXFkyFA+aZRhf1oYa17UA04lQw8XWYJlaFxPIQBw==
X-Received: by 2002:a17:906:dfe9:b0:a67:da88:149a with SMTP id a640c23a62f3a-a6cdaa0f56dmr113553566b.55.1717744642397;
        Fri, 07 Jun 2024 00:17:22 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [RFC PATCH 3/5] Remove FdoSetFriendlyName
Date: Fri,  7 Jun 2024 08:16:58 +0100
Message-ID: <20240607071700.1272-4-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
In-Reply-To: <20240607071700.1272-1-owen.smith@cloud.com>
References: <20240607071700.1272-1-owen.smith@cloud.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

RegistryOpenHardwareKey uses an absolute path to open the parent key
of IoOpenDeviceRegistryKey. Since this is a violation of the registry
isolation rules in Driver Verifier, its not possible to open the correct
registry key to set the device instance's friendly name.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 src/xenbus/fdo.c | 87 ------------------------------------------------
 1 file changed, 87 deletions(-)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index a5ebd19..429933c 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -819,91 +819,6 @@ __FdoIsActive(
     return Fdo->Active;
 }
 
-static NTSTATUS
-FdoSetFriendlyName(
-    IN  PXENBUS_FDO Fdo,
-    IN  USHORT      DeviceID
-    )
-{
-    HANDLE          SoftwareKey;
-    HANDLE          HardwareKey;
-    PANSI_STRING    DriverDesc;
-    CHAR            Buffer[MAXNAMELEN];
-    ANSI_STRING     FriendlyName[2];
-    NTSTATUS        status;
-
-    status = RegistryOpenSoftwareKey(__FdoGetPhysicalDeviceObject(Fdo),
-                                     KEY_READ,
-                                     &SoftwareKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryOpenHardwareKey(__FdoGetPhysicalDeviceObject(Fdo),
-                                     KEY_ALL_ACCESS,
-                                     &HardwareKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = RegistryQuerySzValue(SoftwareKey,
-                                  "DriverDesc",
-                                  NULL,
-                                  &DriverDesc);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    status = RtlStringCbPrintfA(Buffer,
-                                MAXNAMELEN,
-                                "%Z (%04X)",
-                                &DriverDesc[0],
-                                DeviceID
-                                );
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    RtlZeroMemory(FriendlyName, sizeof (ANSI_STRING) * 2);
-    RtlInitAnsiString(&FriendlyName[0], Buffer);
-
-    status = RegistryUpdateSzValue(HardwareKey,
-                                   "FriendlyName",
-                                   REG_SZ,
-                                   FriendlyName);
-    if (!NT_SUCCESS(status))
-        goto fail5;
-
-    Info("%Z\n", &FriendlyName[0]);
-
-    RegistryFreeSzValue(DriverDesc);
-
-    RegistryCloseKey(HardwareKey);
-
-    RegistryCloseKey(SoftwareKey);
-
-    return STATUS_SUCCESS;
-
-fail5:
-    Error("fail5\n");
-
-fail4:
-    Error("fail4\n");
-
-    RegistryFreeSzValue(DriverDesc);
-
-fail3:
-    Error("fail3\n");
-
-    RegistryCloseKey(HardwareKey);
-
-fail2:
-    Error("fail2\n");
-
-    RegistryCloseKey(SoftwareKey);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
 #define DEFINE_FDO_GET_CONTEXT(_Interface, _Type)               \
 static FORCEINLINE _Type                                        \
 __FdoGet ## _Interface ## Context(                              \
@@ -5958,8 +5873,6 @@ done:
     InitializeListHead(&Fdo->List);
     Fdo->References = 1;
 
-    (VOID) FdoSetFriendlyName(Fdo, Header.DeviceID);
-
     FdoSetWatchdog(Fdo);
 
     Info("%p (%s) %s\n",
-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 07 07:17:27 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jun 2024 07:17:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.736239.1142294 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqn-0002Hh-Th; Fri, 07 Jun 2024 07:17:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 736239.1142294; Fri, 07 Jun 2024 07:17: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 1sFTqn-0002Ha-Qq; Fri, 07 Jun 2024 07:17:25 +0000
Received: by outflank-mailman (input) for mailman id 736239;
 Fri, 07 Jun 2024 07:17:25 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=prRf=NJ=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sFTqn-0002HT-Fj
 for win-pv-devel@lists.xenproject.org; Fri, 07 Jun 2024 07:17:25 +0000
Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com
 [2a00:1450:4864:20::42f])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fb870632-249d-11ef-b4bb-af5377834399;
 Fri, 07 Jun 2024 09:17:22 +0200 (CEST)
Received: by mail-wr1-x42f.google.com with SMTP id
 ffacd0b85a97d-35dc984b3d2so1278596f8f.1
 for <win-pv-devel@lists.xenproject.org>; Fri, 07 Jun 2024 00:17:22 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-35ef5fc1ca8sm3325343f8f.97.2024.06.07.00.17.20
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 00:17:20 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fb870632-249d-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1717744640; x=1718349440; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=/YX2Wsk5PWYXTZQjqr6M3Z8oVN5kSn7cewtyc78vfVA=;
        b=KHlxwvpb06xYukpCRqVBx5Qgf7ikMAJXAkuVQwyert+vqtIwEClwZaUOF+1qaLYAPl
         LRCy/LfiAg1DqXlhN9g9+JjIA9KakbirjjaxJ1Opv9uU69Dl7+DG0OC9XzOp1IaIOZ9h
         vcdMu52e7VjKuPAyz3CyKcEOfAVyHkednJBDs=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1717744640; x=1718349440;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=/YX2Wsk5PWYXTZQjqr6M3Z8oVN5kSn7cewtyc78vfVA=;
        b=CCmyk74kSeVDT+qJRngJ6gI9tycu5jfZw/GJZS/uFcI7yCDEj3COZVMvCWCElprtHe
         VF0ZEWgVBHkuvKY6rKNgxuwJUn6dcyTkuBPMxNLQ0xX0D9MYPntLXhKpTWi6PBZnVGx+
         wX7/jeeQLEI/EzXykx1rrxF8dTOfifF47ZQKlHj9gbJH1JBmlD1gy6SXnR4kxc5mzqOX
         5IywfXm7LLfqq/G5gs+ax+17SWB5l8qyQ0CvqJ8Vtu5u2dd3015gz9+cK3R5KElDL/SV
         teMycU/baSGl/iql3gBaaHA5bCgRdpFObw5Ur5+EI8KQY6I03f0Im6MDd6ec0qrBJz0A
         xeOw==
X-Gm-Message-State: AOJu0YwcUBeI77qGuONBrA52h+UoHYcmtBOx05EhlP+O5hBthFRj3YBQ
	HyZ5+SQEnW3qf3XrL4pWQW4+gBJoqo84h5fn+nHfYOv1y61WLBjXMaXLA4EWtiVfyseS3gxgb8c
	=
X-Google-Smtp-Source: AGHT+IGGxtNBbqbWK8YY0AlPmSobOyJiE0eHqQt3CwmrH8Yh1zBKYRLEbyuE2w9y1f1UZqbc3T7qXg==
X-Received: by 2002:a05:6000:e4a:b0:359:b737:51e4 with SMTP id ffacd0b85a97d-35efed08eebmr1475046f8f.2.1717744640564;
        Fri, 07 Jun 2024 00:17:20 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [RFC PATCH 1/5] Add RegistryOpenParametersKey
Date: Fri,  7 Jun 2024 08:16:56 +0100
Message-ID: <20240607071700.1272-2-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
In-Reply-To: <20240607071700.1272-1-owen.smith@cloud.com>
References: <20240607071700.1272-1-owen.smith@cloud.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Use IoOpenDriverRegistryKey to avoid opening an absolute registry path.
Driver Verifier can detect registry isolation violations when running WHQL
tests on Server 2025. The rule states that a driver may not open an absolute
registry key path. Use the specific API to open the 'Parameters' key with
KEY_READ when querying settings.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 src/common/registry.c | 22 +++++++++++++++++++++-
 src/common/registry.h |  9 ++++++++-
 src/xen/driver.c      |  2 +-
 src/xenbus/driver.c   | 19 ++-----------------
 src/xenfilt/driver.c  | 33 +++------------------------------
 5 files changed, 35 insertions(+), 50 deletions(-)

diff --git a/src/common/registry.c b/src/common/registry.c
index 0d29ddc..73a55d2 100644
--- a/src/common/registry.c
+++ b/src/common/registry.c
@@ -38,6 +38,7 @@
 
 #define REGISTRY_TAG 'GERX'
 
+static PDRIVER_OBJECT   DriverObject;
 static UNICODE_STRING   RegistryPath;
 
 static FORCEINLINE PVOID
@@ -58,7 +59,8 @@ __RegistryFree(
 
 NTSTATUS
 RegistryInitialize(
-    IN PUNICODE_STRING  Path
+    IN  PDRIVER_OBJECT  DrvObj,
+    IN  PUNICODE_STRING Path
     )
 {
     NTSTATUS            status;
@@ -69,6 +71,9 @@ RegistryInitialize(
     if (!NT_SUCCESS(status))
         goto fail1;
 
+    ASSERT3P(DriverObject, ==, NULL);
+    DriverObject = DrvObj;
+
     return STATUS_SUCCESS;
 
 fail1:
@@ -82,11 +87,26 @@ RegistryTeardown(
     VOID
     )
 {
+    DriverObject = NULL;
+
     RtlFreeUnicodeString(&RegistryPath);
     RegistryPath.Buffer = NULL;
     RegistryPath.MaximumLength = RegistryPath.Length = 0;
 }
 
+NTSTATUS
+RegistryOpenParametersKey(
+    IN  ACCESS_MASK     DesiredAccess,
+    OUT PHANDLE         Key
+    )
+{
+    return IoOpenDriverRegistryKey(DriverObject,
+                                   DriverRegKeyParameters,
+                                   DesiredAccess,
+                                   0,
+                                   Key);
+}
+
 NTSTATUS
 RegistryOpenKey(
     IN  HANDLE          Parent,
diff --git a/src/common/registry.h b/src/common/registry.h
index cbe9015..efa96ea 100644
--- a/src/common/registry.h
+++ b/src/common/registry.h
@@ -37,7 +37,8 @@
 
 extern NTSTATUS
 RegistryInitialize(
-    IN PUNICODE_STRING  Path
+    IN  PDRIVER_OBJECT  DrvObj,
+    IN  PUNICODE_STRING Path
     );
 
 extern VOID
@@ -45,6 +46,12 @@ RegistryTeardown(
     VOID
     );
 
+extern NTSTATUS
+RegistryOpenParametersKey(
+    IN  ACCESS_MASK     DesiredAccess,
+    OUT PHANDLE         Key
+    );
+
 extern NTSTATUS
 RegistryOpenKey(
     IN  HANDLE          Parent,
diff --git a/src/xen/driver.c b/src/xen/driver.c
index 8fe6c5c..e04a772 100644
--- a/src/xen/driver.c
+++ b/src/xen/driver.c
@@ -515,7 +515,7 @@ DllInitialize(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    status = RegistryInitialize(RegistryPath);
+    status = RegistryInitialize(NULL, RegistryPath);
     if (!NT_SUCCESS(status))
         goto fail2;
 
diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index 522acef..d6efe89 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -811,7 +811,6 @@ DriverEntry(
     IN  PUNICODE_STRING RegistryPath
     )
 {
-    HANDLE              ServiceKey;
     HANDLE              ParametersKey;
     ULONG               Index;
     LOG_LEVEL           LogLevel;
@@ -839,21 +838,14 @@ DriverEntry(
          MONTH,
          YEAR);
 
-    status = RegistryInitialize(RegistryPath);
+    status = RegistryInitialize(DriverObject, RegistryPath);
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    status = RegistryOpenServiceKey(KEY_READ, &ServiceKey);
+    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
     if (!NT_SUCCESS(status))
         goto fail2;
 
-    status = RegistryOpenSubKey(ServiceKey,
-                                "Parameters",
-                                KEY_READ,
-                                &ParametersKey);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
     __DriverSetParametersKey(ParametersKey);
 
     status = LogReadLogLevel(ParametersKey,
@@ -864,8 +856,6 @@ DriverEntry(
 
     __DriverSetConsoleLogLevel(LogLevel);
 
-    RegistryCloseKey(ServiceKey);
-
     status = XenTouch(__MODULE__,
                       MAJOR_VERSION,
                       MINOR_VERSION,
@@ -900,11 +890,6 @@ done:
 
     return STATUS_SUCCESS;
 
-fail3:
-    Error("fail3\n");
-
-    RegistryCloseKey(ServiceKey);
-
 fail2:
     Error("fail2\n");
 
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index 724d418..aee663a 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -113,33 +113,6 @@ DriverGetDriverObject(
     return __DriverGetDriverObject();
 }
 
-static FORCEINLINE NTSTATUS
-__DriverOpenParametersKey(
-    OUT PHANDLE     ParametersKey
-    )
-{
-    HANDLE          ServiceKey;
-    NTSTATUS        status;
-
-    status = RegistryOpenServiceKey(KEY_READ, &ServiceKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryOpenSubKey(ServiceKey, "Parameters", KEY_READ, ParametersKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    RegistryCloseKey(ServiceKey);
-
-    return STATUS_SUCCESS;
-
-fail2:
-    RegistryCloseKey(ServiceKey);
-
-fail1:
-    return status;
-}
-
 static FORCEINLINE VOID
 __DriverSetEmulatedContext(
     IN  PXENFILT_EMULATED_CONTEXT   Context
@@ -247,7 +220,7 @@ __DriverGetActive(
 
     ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
 
-    status = __DriverOpenParametersKey(&ParametersKey);
+    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
     if (!NT_SUCCESS(status))
         goto fail1;
 
@@ -752,7 +725,7 @@ DriverGetEmulatedType(
     ULONG                           Index;
     NTSTATUS                        status;
 
-    status = __DriverOpenParametersKey(&ParametersKey);
+    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
     if (!NT_SUCCESS(status))
         goto fail1;
 
@@ -947,7 +920,7 @@ DriverEntry(
     if (!NT_SUCCESS(status))
         goto done;
 
-    status = RegistryInitialize(RegistryPath);
+    status = RegistryInitialize(DriverObject, RegistryPath);
     if (!NT_SUCCESS(status))
         goto fail1;
 
-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 07 07:17:28 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jun 2024 07:17:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.736243.1142312 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqq-0002NT-6Z; Fri, 07 Jun 2024 07:17:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 736243.1142312; Fri, 07 Jun 2024 07:17:28 +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 1sFTqq-0002N9-0L; Fri, 07 Jun 2024 07:17:28 +0000
Received: by outflank-mailman (input) for mailman id 736243;
 Fri, 07 Jun 2024 07:17:27 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=prRf=NJ=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sFTqp-0002HT-5o
 for win-pv-devel@lists.xenproject.org; Fri, 07 Jun 2024 07:17:27 +0000
Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com
 [2a00:1450:4864:20::42f])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id fd144446-249d-11ef-b4bb-af5377834399;
 Fri, 07 Jun 2024 09:17:24 +0200 (CEST)
Received: by mail-wr1-x42f.google.com with SMTP id
 ffacd0b85a97d-35e4be5bd7fso1553434f8f.1
 for <win-pv-devel@lists.xenproject.org>; Fri, 07 Jun 2024 00:17:24 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-35ef5fc1ca8sm3325343f8f.97.2024.06.07.00.17.22
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 00:17:22 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fd144446-249d-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1717744643; x=1718349443; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=EEtiFRgn8HJBa97mvONC002b1SrL0iPs3Q6HWWvbFQY=;
        b=QW2Dg/LCaEbpTpWMQiSQ7BSlUVaQ+gygLzdckd8SXvRCyW7cu1RUVCVDAbtmGqQ+R1
         aIGt9xoQz6AWf4CDUs3fLH16cD47smMiK84vtN+nzoKmEsXVJGwBnsSUjhWqp+tZosfW
         UzbWSVuQBJzEv9uf+M+KRgG7cPFAsYvkRHlUg=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1717744643; x=1718349443;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=EEtiFRgn8HJBa97mvONC002b1SrL0iPs3Q6HWWvbFQY=;
        b=FsmSspbI8VviAVR8TFyz21KeIb0rDDKpv55gzGzWP5lLhh0Z947zAfoh6Ut3EzaFSJ
         vdMxQDcnpEYhSsxyBRM07cEwELgiE7RjFWrN2cXskg7hRma3ZQamSuGqDlc85kJylSyw
         BWYk5J4d912KCQvwT9JnMlJbhar/IsdvsxMz/zvHPCzOPt3AiwRC3NRvSzepYNdHfEIe
         Dk5Ph4tYGz8a+DNc6oGBrz2Bo58lUWFFBo88QYfmX9pmylf1SSW4lpH/Emt3T7PRyAid
         YwLMRMGqod0xD6TDVC/Evb5IhvXvDpMeKH1KNLtxYkn5GQytqwRswN812PQ/QpF+2BU/
         tU7w==
X-Gm-Message-State: AOJu0YyUQZ+i9n6zUtBFCBRvpPUy8+Qd562ZL9GBwNmFwhnsVbIjuDbh
	8YWAo0kYr3J36oy7tfiQgKFSA9GOHOF0hhIHsO6ydMKxlHHbW6HGSbwYxIPKMe9gAZSfDsfWs20
	=
X-Google-Smtp-Source: AGHT+IHJ/mPZY+wMZU/ZQ6ZTRfA6SdVInMnUxO8VpSOuhs/YEAGZ3mw4Uw1RwssopaMtq4brz+JAvA==
X-Received: by 2002:a5d:5f53:0:b0:35e:7d2b:de73 with SMTP id ffacd0b85a97d-35efedf2870mr1598261f8f.52.1717744643300;
        Fri, 07 Jun 2024 00:17:23 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [RFC PATCH 4/5] Move Registry operations to xen.sys
Date: Fri,  7 Jun 2024 08:16:59 +0100
Message-ID: <20240607071700.1272-5-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
In-Reply-To: <20240607071700.1272-1-owen.smith@cloud.com>
References: <20240607071700.1272-1-owen.smith@cloud.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Driver Verifier's registry isolation rules are not applied to xen.sys during
WHQL testing. Move remaining operations that do not comply to xen.sys.
Operations related to Active Device, Reboot Requests and SystemStartOptions
are exposed by xen.sys to allow xenbus.sys and other drivers to successfully
execute with Driver Verifier enabled.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 include/xen.h          |  45 ++++
 src/xen/config.c       | 497 +++++++++++++++++++++++++++++++++++++++++
 src/xenbus/driver.c    | 448 +------------------------------------
 src/xenbus/driver.h    |  30 ---
 src/xenbus/fdo.c       |  12 +-
 vs2019/xen/xen.vcxproj |   1 +
 vs2022/xen/xen.vcxproj |   1 +
 7 files changed, 551 insertions(+), 483 deletions(-)
 create mode 100644 src/xen/config.c

diff --git a/include/xen.h b/include/xen.h
index 566d9e3..a874ed1 100644
--- a/include/xen.h
+++ b/include/xen.h
@@ -540,4 +540,49 @@ FiltersUninstall(
      VOID
      );
 
+// CONFIG
+
+XEN_API
+NTSTATUS
+ConfigGetActive(
+    IN  const CHAR  *Key,
+    OUT PCHAR       *Value
+    );
+
+XEN_API
+NTSTATUS
+ConfigSetActive(
+    IN  PCHAR   DeviceID,
+    IN  PCHAR   InstanceID,
+    IN  PCHAR   LocationInformation
+    );
+
+XEN_API
+NTSTATUS
+ConfigUpdateActive(
+    IN  PCHAR   DeviceID,
+    IN  PCHAR   InstanceID,
+    IN  PCHAR   LocationInformation
+    );
+
+XEN_API
+NTSTATUS
+ConfigClearActive(
+    VOID
+    );
+
+XEN_API
+NTSTATUS
+ConfigRequestReboot(
+    IN  HANDLE      ParametersKey,
+    IN  PCHAR       Module
+    );
+
+XEN_API
+NTSTATUS
+ConfigQuerySystemStartOption(
+    IN  PCHAR           Key,
+    OUT PANSI_STRING    *Option
+    );
+
 #endif  // _XEN_H
diff --git a/src/xen/config.c b/src/xen/config.c
new file mode 100644
index 0000000..e600732
--- /dev/null
+++ b/src/xen/config.c
@@ -0,0 +1,497 @@
+/* Copyright (c) Xen Project.
+ * Copyright (c) Cloud Software Group, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * *   Redistributions of source code must retain the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer.
+ * *   Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the
+ *     following disclaimer in the documentation and/or other
+ *     materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#define XEN_API __declspec(dllexport)
+
+#define INITGUID 1
+
+#include <ntddk.h>
+#include <ntstrsafe.h>
+#include <devguid.h>
+#include <xen.h>
+
+#include "registry.h"
+#include "driver.h"
+#include "dbg_print.h"
+#include "assert.h"
+#include "util.h"
+
+#define MAXNAMELEN  128
+
+//
+// The canonical location for active device information is the XENFILT
+// Parameters key.
+//
+#define ACTIVE_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\XENFILT\\Parameters"
+
+XEN_API
+NTSTATUS
+ConfigGetActive(
+    IN  const CHAR  *Key,
+    OUT PCHAR       *Value
+    )
+{
+    HANDLE          ActiveKey;
+    CHAR            Name[MAXNAMELEN];
+    PANSI_STRING    Ansi;
+    ULONG           Length;
+    NTSTATUS        status;
+
+    Trace("====>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    status = RegistryOpenSubKey(NULL,
+                                ACTIVE_PATH,
+                                KEY_READ,
+                                &ActiveKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = RtlStringCbPrintfA(Name, MAXNAMELEN, "Active%s", Key);
+    ASSERT(NT_SUCCESS(status));
+
+    status = RegistryQuerySzValue(ActiveKey,
+                                  Name,
+                                  NULL,
+                                  &Ansi);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    Length = Ansi[0].Length + sizeof (CHAR);
+    *Value = __AllocatePoolWithTag(PagedPool, Length, 'SUB');
+
+    status = STATUS_NO_MEMORY;
+    if (*Value == NULL)
+        goto fail3;
+
+    status = RtlStringCbPrintfA(*Value,
+                                Length,
+                                "%Z",
+                                &Ansi[0]);
+    ASSERT(NT_SUCCESS(status));
+
+    RegistryFreeSzValue(Ansi);
+
+    RegistryCloseKey(ActiveKey);
+
+    Trace("<====\n");
+
+    return STATUS_SUCCESS;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    if (status != STATUS_OBJECT_NAME_NOT_FOUND)
+        Error("fail2\n");
+
+    RegistryCloseKey(ActiveKey);
+
+fail1:
+    if (status != STATUS_OBJECT_NAME_NOT_FOUND)
+        Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+static FORCEINLINE BOOLEAN
+__ConfigIsDeviceLegacy(
+    IN  PCHAR   DeviceID
+    )
+{
+    UNREFERENCED_PARAMETER(DeviceID);
+
+#ifdef VENDOR_DEVICE_ID_STR
+    const CHAR  *VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR;
+
+    return _strnicmp(DeviceID, VendorDeviceID, strlen(VendorDeviceID)) != 0;
+#endif
+
+    return TRUE;
+}
+
+#define ENUM_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum"
+
+static FORCEINLINE BOOLEAN
+__ConfigIsVendorDevicePresent(
+    VOID
+    )
+{
+#ifdef VENDOR_DEVICE_ID_STR
+    HANDLE      EnumKey;
+    HANDLE      DeviceKey;
+    BOOLEAN     Found;
+    NTSTATUS    status;
+    const CHAR  *VendorDeviceID = "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR "&SUBSYS_C0005853&REV_01";
+
+    status = RegistryOpenSubKey(NULL,
+                                ENUM_PATH,
+                                KEY_READ,
+                                &EnumKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    Found = FALSE;
+
+    status = RegistryOpenSubKey(EnumKey,
+                                (PCHAR)VendorDeviceID,
+                                KEY_READ,
+                                &DeviceKey);
+    if (!NT_SUCCESS(status))
+        goto done;
+
+    RegistryCloseKey(DeviceKey);
+    Found = TRUE;
+
+done:
+    RegistryCloseKey(EnumKey);
+
+    return Found;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+#endif
+    return FALSE;
+}
+
+XEN_API
+NTSTATUS
+ConfigSetActive(
+    IN  PCHAR   DeviceID,
+    IN  PCHAR   InstanceID,
+    IN  PCHAR   LocationInformation
+    )
+{
+    HANDLE      ActiveKey;
+    ANSI_STRING Ansi[2];
+    NTSTATUS    status;
+
+    Trace("====>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    status = RegistryOpenSubKey(NULL,
+                                ACTIVE_PATH,
+                                KEY_ALL_ACCESS,
+                                &ActiveKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (__ConfigIsDeviceLegacy(DeviceID) &&
+        __ConfigIsVendorDevicePresent())
+        goto fail2;
+
+    RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
+
+    RtlInitAnsiString(&Ansi[0], DeviceID);
+
+    status = RegistryUpdateSzValue(ActiveKey,
+                                   "ActiveDeviceID",
+                                   REG_SZ,
+                                   Ansi);
+    if (!NT_SUCCESS(status))
+        goto fail3;
+
+    RtlInitAnsiString(&Ansi[0], InstanceID);
+
+    status = RegistryUpdateSzValue(ActiveKey,
+                                   "ActiveInstanceID",
+                                   REG_SZ,
+                                   Ansi);
+    if (!NT_SUCCESS(status))
+        goto fail4;
+
+    RtlInitAnsiString(&Ansi[0], LocationInformation);
+
+    status = RegistryUpdateSzValue(ActiveKey,
+                                   "ActiveLocationInformation",
+                                   REG_SZ,
+                                   Ansi);
+    if (!NT_SUCCESS(status))
+        goto fail5;
+
+    Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation);
+
+    RegistryCloseKey(ActiveKey);
+
+    Trace("<====\n");
+
+    return STATUS_SUCCESS;
+
+fail5:
+    Error("fail5\n");
+
+fail4:
+    Error("fail4\n");
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    RegistryCloseKey(ActiveKey);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+XEN_API
+NTSTATUS
+ConfigUpdateActive(
+    IN  PCHAR   DeviceID,
+    IN  PCHAR   InstanceID,
+    IN  PCHAR   LocationInformation
+    )
+{
+    HANDLE      ActiveKey;
+    ANSI_STRING Ansi[2];
+    PCHAR       ActiveInstanceID;
+    PCHAR       ActiveLocationInformation;
+    NTSTATUS    status;
+
+    Trace("====>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    status = RegistryOpenSubKey(NULL,
+                                ACTIVE_PATH,
+                                KEY_ALL_ACCESS,
+                                &ActiveKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = STATUS_UNSUCCESSFUL;
+    if (__ConfigIsDeviceLegacy(DeviceID) &&
+        __ConfigIsVendorDevicePresent())
+        goto fail2;
+
+    RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
+
+    status = ConfigGetActive("InstanceID", &ActiveInstanceID);
+    if (NT_SUCCESS(status)) {
+        ExFreePool(ActiveInstanceID);
+    } else {
+        RtlInitAnsiString(&Ansi[0], InstanceID);
+
+        status = RegistryUpdateSzValue(ActiveKey,
+                                       "ActiveInstanceID",
+                                       REG_SZ,
+                                       Ansi);
+        if (!NT_SUCCESS(status))
+            goto fail3;
+    }
+
+    status = ConfigGetActive("LocationInformation", &ActiveLocationInformation);
+    if (NT_SUCCESS(status)) {
+        ExFreePool(ActiveLocationInformation);
+    } else {
+        RtlInitAnsiString(&Ansi[0], LocationInformation);
+
+        status = RegistryUpdateSzValue(ActiveKey,
+                                       "ActiveLocationInformation",
+                                       REG_SZ,
+                                       Ansi);
+        if (!NT_SUCCESS(status))
+            goto fail4;
+    }
+
+    Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation);
+
+    RegistryCloseKey(ActiveKey);
+
+    Trace("<====\n");
+
+    return STATUS_SUCCESS;
+
+fail4:
+    Error("fail4\n");
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    RegistryCloseKey(ActiveKey);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+XEN_API
+NTSTATUS
+ConfigClearActive(
+    VOID
+    )
+{
+    HANDLE      ActiveKey;
+    NTSTATUS    status;
+
+    Trace("====>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    status = RegistryOpenSubKey(NULL,
+                                ACTIVE_PATH,
+                                KEY_ALL_ACCESS,
+                                &ActiveKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = RegistryDeleteValue(ActiveKey,
+                                 "ActiveDeviceID");
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    status = RegistryDeleteValue(ActiveKey,
+                                 "ActiveInstanceID");
+    if (!NT_SUCCESS(status))
+        goto fail3;
+
+    Info("DONE\n");
+
+    RegistryCloseKey(ActiveKey);
+
+    Trace("<====\n");
+
+    return STATUS_SUCCESS;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+
+    RegistryCloseKey(ActiveKey);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+XEN_API
+NTSTATUS
+ConfigRequestReboot(
+    IN  HANDLE      ParametersKey,
+    IN  PCHAR       Module
+    )
+{
+    PANSI_STRING    Ansi;
+    CHAR            RequestKeyName[MAXNAMELEN];
+    HANDLE          RequestKey;
+    HANDLE          SubKey;
+    NTSTATUS        status;
+
+    Info("====>\n");
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    status = RegistryQuerySzValue(ParametersKey,
+                                  "RequestKey",
+                                  NULL,
+                                  &Ansi);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = RtlStringCbPrintfA(RequestKeyName,
+                                MAXNAMELEN,
+                                "\\Registry\\Machine\\%Z",
+                                &Ansi[0]);
+    ASSERT(NT_SUCCESS(status));
+
+    status = RegistryCreateSubKey(NULL,
+                                  RequestKeyName,
+                                  REG_OPTION_NON_VOLATILE,
+                                  &RequestKey);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    status = RegistryCreateSubKey(RequestKey,
+                                  Module,
+                                  REG_OPTION_VOLATILE,
+                                  &SubKey);
+    if (!NT_SUCCESS(status))
+        goto fail3;
+
+    status = RegistryUpdateDwordValue(SubKey,
+                                      "Reboot",
+                                      1);
+    if (!NT_SUCCESS(status))
+        goto fail4;
+
+    RegistryCloseKey(SubKey);
+
+    RegistryFreeSzValue(Ansi);
+
+    Info("<====\n");
+
+    return STATUS_SUCCESS;
+
+fail4:
+    Error("fail4\n");
+
+    RegistryCloseKey(SubKey);
+
+fail3:
+    Error("fail3\n");
+
+    RegistryCloseKey(RequestKey);
+
+fail2:
+    Error("fail2\n");
+
+    RegistryFreeSzValue(Ansi);
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
+XEN_API
+NTSTATUS
+ConfigQuerySystemStartOption(
+    IN  PCHAR           Key,
+    OUT PANSI_STRING    *Option
+    )
+{
+    return RegistryQuerySystemStartOption(Key, Option);
+}
diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
index e8d0c1f..4aae2cc 100644
--- a/src/xenbus/driver.c
+++ b/src/xenbus/driver.c
@@ -149,83 +149,6 @@ DriverGetConsoleLogLevel(
     return __DriverGetConsoleLogLevel();
 }
 
-#define MAXNAMELEN  128
-
-static FORCEINLINE VOID
-__DriverRequestReboot(
-    VOID
-    )
-{
-    PANSI_STRING    Ansi;
-    CHAR            RequestKeyName[MAXNAMELEN];
-    HANDLE          RequestKey;
-    HANDLE          SubKey;
-    NTSTATUS        status;
-
-    Info("====>\n");
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    status = RegistryQuerySzValue(__DriverGetParametersKey(),
-                                  "RequestKey",
-                                  NULL,
-                                  &Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RtlStringCbPrintfA(RequestKeyName,
-                                MAXNAMELEN,
-                                "\\Registry\\Machine\\%Z",
-                                &Ansi[0]);
-    ASSERT(NT_SUCCESS(status));
-
-    status = RegistryCreateSubKey(NULL,
-                                  RequestKeyName,
-                                  REG_OPTION_NON_VOLATILE,
-                                  &RequestKey);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = RegistryCreateSubKey(RequestKey,
-                                  __MODULE__,
-                                  REG_OPTION_VOLATILE,
-                                  &SubKey);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    status = RegistryUpdateDwordValue(SubKey,
-                                      "Reboot",
-                                      1);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    RegistryCloseKey(SubKey);
-
-    RegistryFreeSzValue(Ansi);
-
-    Info("<====\n");
-
-    return;
-
-fail4:
-    Error("fail4\n");
-
-    RegistryCloseKey(SubKey);
-
-fail3:
-    Error("fail3\n");
-
-    RegistryCloseKey(RequestKey);
-
-fail2:
-    Error("fail2\n");
-
-    RegistryFreeSzValue(Ansi);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-}
-
 static FORCEINLINE VOID
 __DriverAcquireMutex(
     VOID
@@ -299,375 +222,6 @@ DriverRemoveFunctionDeviceObject(
         FiltersUninstall();
 }
 
-//
-// The canonical location for active device information is the XENFILT
-// Parameters key.
-//
-#define ACTIVE_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services\\XENFILT\\Parameters"
-
-NTSTATUS
-DriverGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
-    )
-{
-    HANDLE          ActiveKey;
-    CHAR            Name[MAXNAMELEN];
-    PANSI_STRING    Ansi;
-    ULONG           Length;
-    NTSTATUS        status;
-
-    Trace("====>\n");
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    status = RegistryOpenSubKey(NULL,
-                                ACTIVE_PATH,
-                                KEY_READ,
-                                &ActiveKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RtlStringCbPrintfA(Name, MAXNAMELEN, "Active%s", Key);
-    ASSERT(NT_SUCCESS(status));
-
-    status = RegistryQuerySzValue(ActiveKey,
-                                  Name,
-                                  NULL,
-                                  &Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    Length = Ansi[0].Length + sizeof (CHAR);
-    *Value = __AllocatePoolWithTag(PagedPool, Length, 'SUB');
-
-    status = STATUS_NO_MEMORY;
-    if (*Value == NULL)
-        goto fail3;
-
-    status = RtlStringCbPrintfA(*Value,
-                                Length,
-                                "%Z",
-                                &Ansi[0]);
-    ASSERT(NT_SUCCESS(status));
-
-    RegistryFreeSzValue(Ansi);
-
-    RegistryCloseKey(ActiveKey);
-
-    Trace("<====\n");
-
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    if (status != STATUS_OBJECT_NAME_NOT_FOUND)
-        Error("fail2\n");
-
-    RegistryCloseKey(ActiveKey);
-
-fail1:
-    if (status != STATUS_OBJECT_NAME_NOT_FOUND)
-        Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-static const CHAR *DriverLegacyDevicePrefix[] = {
-    "PCI\\VEN_5853&DEV_0001",
-    "PCI\\VEN_5853&DEV_0002"
-};
-
-static FORCEINLINE BOOLEAN
-__DriverIsDeviceLegacy(
-    IN  PCHAR   DeviceID
-    )
-{
-    ULONG       Index;
-
-    for (Index = 0; Index < ARRAYSIZE(DriverLegacyDevicePrefix); Index++) {
-        const CHAR  *Prefix = DriverLegacyDevicePrefix[Index];
-
-        if (_strnicmp(DeviceID, Prefix, strlen(Prefix)) == 0)
-            return TRUE;
-    }
-
-    return FALSE;
-}
-
-static const CHAR *DriverVendorDeviceID =
-#ifdef VENDOR_DEVICE_ID_STR
-    "PCI\\VEN_5853&DEV_" VENDOR_DEVICE_ID_STR "&SUBSYS_C0005853&REV_01";
-#else
-    NULL;
-#endif
-
-#define ENUM_PATH "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Enum"
-
-static FORCEINLINE BOOLEAN
-__DriverIsVendorDevicePresent(
-    VOID
-    )
-{
-    HANDLE      EnumKey;
-    HANDLE      DeviceKey;
-    BOOLEAN     Found;
-    NTSTATUS    status;
-
-    if (DriverVendorDeviceID == NULL)
-        return FALSE;
-
-    status = RegistryOpenSubKey(NULL,
-                                ENUM_PATH,
-                                KEY_READ,
-                                &EnumKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    Found = FALSE;
-
-    status = RegistryOpenSubKey(EnumKey,
-                                (PCHAR)DriverVendorDeviceID,
-                                KEY_READ,
-                                &DeviceKey);
-    if (!NT_SUCCESS(status))
-        goto done;
-
-    RegistryCloseKey(DeviceKey);
-    Found = TRUE;
-
-done:
-    RegistryCloseKey(EnumKey);
-
-    return Found;
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return FALSE;
-}
-
-NTSTATUS
-DriverSetActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
-    )
-{
-    HANDLE      ActiveKey;
-    ANSI_STRING Ansi[2];
-    NTSTATUS    status;
-
-    Trace("====>\n");
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    status = RegistryOpenSubKey(NULL,
-                                ACTIVE_PATH,
-                                KEY_ALL_ACCESS,
-                                &ActiveKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = STATUS_UNSUCCESSFUL;
-    if (__DriverIsDeviceLegacy(DeviceID) &&
-        __DriverIsVendorDevicePresent())
-        goto fail2;
-
-    RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
-
-    RtlInitAnsiString(&Ansi[0], DeviceID);
-
-    status = RegistryUpdateSzValue(ActiveKey,
-                                   "ActiveDeviceID",
-                                   REG_SZ,
-                                   Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    RtlInitAnsiString(&Ansi[0], InstanceID);
-
-    status = RegistryUpdateSzValue(ActiveKey,
-                                   "ActiveInstanceID",
-                                   REG_SZ,
-                                   Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail4;
-
-    RtlInitAnsiString(&Ansi[0], LocationInformation);
-
-    status = RegistryUpdateSzValue(ActiveKey,
-                                   "ActiveLocationInformation",
-                                   REG_SZ,
-                                   Ansi);
-    if (!NT_SUCCESS(status))
-        goto fail5;
-
-    Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation);
-
-    RegistryCloseKey(ActiveKey);
-
-    Trace("<====\n");
-
-    return STATUS_SUCCESS;
-
-fail5:
-    Error("fail5\n");
-
-fail4:
-    Error("fail4\n");
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    Error("fail2\n");
-
-    RegistryCloseKey(ActiveKey);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-NTSTATUS
-DriverUpdateActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
-    )
-{
-    HANDLE      ActiveKey;
-    ANSI_STRING Ansi[2];
-    PCHAR       ActiveInstanceID;
-    PCHAR       ActiveLocationInformation;
-    NTSTATUS    status;
-
-    Trace("====>\n");
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    status = RegistryOpenSubKey(NULL,
-                                ACTIVE_PATH,
-                                KEY_ALL_ACCESS,
-                                &ActiveKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = STATUS_UNSUCCESSFUL;
-    if (__DriverIsDeviceLegacy(DeviceID) &&
-        __DriverIsVendorDevicePresent())
-        goto fail2;
-
-    RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
-
-    status = DriverGetActive("InstanceID", &ActiveInstanceID);
-    if (NT_SUCCESS(status)) {
-        ExFreePool(ActiveInstanceID);
-    } else {
-        RtlInitAnsiString(&Ansi[0], InstanceID);
-
-        status = RegistryUpdateSzValue(ActiveKey,
-                                       "ActiveInstanceID",
-                                       REG_SZ,
-                                       Ansi);
-        if (!NT_SUCCESS(status))
-            goto fail3;
-    }
-
-    status = DriverGetActive("LocationInformation", &ActiveLocationInformation);
-    if (NT_SUCCESS(status)) {
-        ExFreePool(ActiveLocationInformation);
-    } else {
-        RtlInitAnsiString(&Ansi[0], LocationInformation);
-
-        status = RegistryUpdateSzValue(ActiveKey,
-                                       "ActiveLocationInformation",
-                                       REG_SZ,
-                                       Ansi);
-        if (!NT_SUCCESS(status))
-            goto fail4;
-    }
-
-    Info("%s\\%s: %s\n", DeviceID, InstanceID, LocationInformation);
-
-    RegistryCloseKey(ActiveKey);
-
-    Trace("<====\n");
-
-    return STATUS_SUCCESS;
-
-fail4:
-    Error("fail4\n");
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    Error("fail2\n");
-
-    RegistryCloseKey(ActiveKey);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
-NTSTATUS
-DriverClearActive(
-    VOID
-    )
-{
-    HANDLE      ActiveKey;
-    NTSTATUS    status;
-
-    Trace("====>\n");
-
-    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
-
-    status = RegistryOpenSubKey(NULL,
-                                ACTIVE_PATH,
-                                KEY_ALL_ACCESS,
-                                &ActiveKey);
-    if (!NT_SUCCESS(status))
-        goto fail1;
-
-    status = RegistryDeleteValue(ActiveKey,
-                                 "ActiveDeviceID");
-    if (!NT_SUCCESS(status))
-        goto fail2;
-
-    status = RegistryDeleteValue(ActiveKey,
-                                 "ActiveInstanceID");
-    if (!NT_SUCCESS(status))
-        goto fail3;
-
-    Info("DONE\n");
-
-    RegistryCloseKey(ActiveKey);
-
-    Trace("<====\n");
-
-    return STATUS_SUCCESS;
-
-fail3:
-    Error("fail3\n");
-
-fail2:
-    Error("fail2\n");
-
-    RegistryCloseKey(ActiveKey);
-
-fail1:
-    Error("fail1 (%08x)\n", status);
-
-    return status;
-}
-
 DRIVER_UNLOAD       DriverUnload;
 
 VOID
@@ -867,7 +421,7 @@ DriverEntry(
             // Insert XenFilt to avoid a 2nd reboot in upgrade cases, as AddDevice
             // will not be called to insert XenFilt.
             FiltersInstall();
-            __DriverRequestReboot();
+            ConfigRequestReboot(DriverGetParametersKey(), __MODULE__);
         }
 
         goto done;
diff --git a/src/xenbus/driver.h b/src/xenbus/driver.h
index 7cd5add..99290e0 100644
--- a/src/xenbus/driver.h
+++ b/src/xenbus/driver.h
@@ -50,11 +50,6 @@ DriverGetConsoleLogLevel(
     VOID
     );
 
-extern VOID
-DriverRequestReboot(
-    VOID
-    );
-
 extern VOID
 DriverAcquireMutex(
     VOID
@@ -65,31 +60,6 @@ DriverReleaseMutex(
     VOID
      );
 
-extern NTSTATUS
-DriverGetActive(
-    IN  const CHAR  *Key,
-    OUT PCHAR       *Value
-    );
-
-NTSTATUS
-DriverSetActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
-    );
-
-NTSTATUS
-DriverUpdateActive(
-    IN  PCHAR   DeviceID,
-    IN  PCHAR   InstanceID,
-    IN  PCHAR   LocationInformation
-    );
-
-NTSTATUS
-DriverClearActive(
-    VOID
-    );
-
 typedef struct _XENBUS_FDO      XENBUS_FDO, *PXENBUS_FDO;
 typedef struct _XENBUS_PDO      XENBUS_PDO, *PXENBUS_PDO;
 
diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 429933c..3a4a1a2 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -765,16 +765,16 @@ FdoSetActive(
     if (!NT_SUCCESS(status))
         goto fail3;
 
-    status = DriverGetActive("DeviceID", &ActiveDeviceID);
+    status = ConfigGetActive("DeviceID", &ActiveDeviceID);
     if (NT_SUCCESS(status)) {
         Fdo->Active = (_stricmp(DeviceID, ActiveDeviceID) == 0) ? TRUE : FALSE;
 
         if (Fdo->Active)
-            (VOID) DriverUpdateActive(DeviceID, InstanceID, LocationInformation);
+            (VOID) ConfigUpdateActive(DeviceID, InstanceID, LocationInformation);
 
         ExFreePool(ActiveDeviceID);
     } else {
-        status = DriverSetActive(DeviceID, InstanceID, LocationInformation);
+        status = ConfigSetActive(DeviceID, InstanceID, LocationInformation);
         if (NT_SUCCESS(status))
             Fdo->Active = TRUE;
     }
@@ -806,7 +806,7 @@ FdoClearActive(
     IN  PXENBUS_FDO Fdo
     )
 {
-    (VOID) DriverClearActive();
+    (VOID) ConfigClearActive();
 
     Fdo->Active = FALSE;
 }
@@ -5626,7 +5626,7 @@ FdoBalloonInitialize(
 
     Enabled = TRUE;
 
-    status = RegistryQuerySystemStartOption(Key, &Option);
+    status = ConfigQuerySystemStartOption(Key, &Option);
     if (!NT_SUCCESS(status))
         goto done;
 
@@ -5667,7 +5667,7 @@ FdoSetWatchdog(
     ULONG           Value;
     NTSTATUS        status;
 
-    status = RegistryQuerySystemStartOption(Key, &Option);
+    status = ConfigQuerySystemStartOption(Key, &Option);
     if (!NT_SUCCESS(status))
         return;
 
diff --git a/vs2019/xen/xen.vcxproj b/vs2019/xen/xen.vcxproj
index ec0f7e1..08d18f6 100644
--- a/vs2019/xen/xen.vcxproj
+++ b/vs2019/xen/xen.vcxproj
@@ -68,6 +68,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\common\registry.c" />
+    <ClCompile Include="..\..\src\xen\config.c" />
     <ClCompile Include="..\..\src\xen\driver.c" />
     <ClCompile Include="..\..\src\xen\event_channel.c" />
     <ClCompile Include="..\..\src\xen\filters.c" />
diff --git a/vs2022/xen/xen.vcxproj b/vs2022/xen/xen.vcxproj
index 7efdce8..f857269 100644
--- a/vs2022/xen/xen.vcxproj
+++ b/vs2022/xen/xen.vcxproj
@@ -63,6 +63,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\common\registry.c" />
+    <ClCompile Include="..\..\src\xen\config.c" />
     <ClCompile Include="..\..\src\xen\driver.c" />
     <ClCompile Include="..\..\src\xen\event_channel.c" />
     <ClCompile Include="..\..\src\xen\filters.c" />
-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Jun 07 07:17:29 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 07 Jun 2024 07:17:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.736244.1142313 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqr-0002Ql-5b; Fri, 07 Jun 2024 07:17:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 736244.1142313; Fri, 07 Jun 2024 07:17:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sFTqr-0002Qd-35; Fri, 07 Jun 2024 07:17:29 +0000
Received: by outflank-mailman (input) for mailman id 736244;
 Fri, 07 Jun 2024 07:17:27 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=prRf=NJ=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sFTqp-0002HY-LV
 for win-pv-devel@lists.xenproject.org; Fri, 07 Jun 2024 07:17:27 +0000
Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com
 [2a00:1450:4864:20::431])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id fda5f38d-249d-11ef-90a2-e314d9c70b13;
 Fri, 07 Jun 2024 09:17:25 +0200 (CEST)
Received: by mail-wr1-x431.google.com with SMTP id
 ffacd0b85a97d-35f089e35e7so160158f8f.0
 for <win-pv-devel@lists.xenproject.org>; Fri, 07 Jun 2024 00:17:25 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-35ef5fc1ca8sm3325343f8f.97.2024.06.07.00.17.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 07 Jun 2024 00:17:23 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: fda5f38d-249d-11ef-90a2-e314d9c70b13
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1717744644; x=1718349444; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to;
        bh=bspsPmLIDvF1cA41Q0f7LncsNzNcyQAHncLqF2qmUvw=;
        b=UqRTSjkN08sv2CaybKiIf5aCXuBMfKSxpL4edpX66PsJsczR73oIZqk812ltlo9WzZ
         y4nbrFT7eNYLBYb31C7pO6vd2bQnjGT/DDY9jN4m7N4yc1gdi62rxhGZGAiAOv8I+ci5
         YymDTcHitCAtdI8LsWa+WtxlWVpVGXtWGaFIY=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1717744644; x=1718349444;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
         :subject:date:message-id:reply-to;
        bh=bspsPmLIDvF1cA41Q0f7LncsNzNcyQAHncLqF2qmUvw=;
        b=jNCAU/Z6arR6dLeWxVbk1frvKeuMPE/N8d9U46gOh1xxRD3n/qyyfom8FIfrVuyXG1
         41OHzxKk8wujnLuKluUNTXs7ivfO3Rh9iq4FVGZGfoHQdtzotB32QKBJ6Kw2ZRLX367j
         EYz1Sv4AySQWvjzl35MixJa+wP9MVi3RmFpSE33MhEoqGzS2x0Xav0xKnY39g8o1TUwV
         bxMXQiiKHV9K/9G0222Q+E6XQUsFmaA4PudIg3H3o2Wp4hVe4C0eS7sGsXt9rv0jS+8n
         6+ISseNKJT3GuAk6kGWedlTRFiboyYHlyQLsH/n29xwlXYygPA+PRToyeXVM+Nh8187Y
         1scQ==
X-Gm-Message-State: AOJu0YyqPaJyZQz5+NkQNO5CGjCAGDMu19yTsNmT8EunN8MOEo+1KlOw
	YTVg02a5e2fxExgBWwDs7KOpIn+ZIYK32zxZszRatkpoi0fKJaeQPGgFcoT+58xWNE+KcTWQnDM
	=
X-Google-Smtp-Source: AGHT+IHrZublYDSkN3ezOFsnz+Dr3wJdtNoxz4+RSeHP9kyJHpSYZsR5TxIxuCmyhJKSBr5hL4Jgtg==
X-Received: by 2002:adf:db42:0:b0:357:ac48:9676 with SMTP id ffacd0b85a97d-35efedca93dmr1582736f8f.51.1717744643853;
        Fri, 07 Jun 2024 00:17:23 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [RFC PATCH 5/5] Add UNPLUG v3
Date: Fri,  7 Jun 2024 08:17:00 +0100
Message-ID: <20240607071700.1272-6-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
In-Reply-To: <20240607071700.1272-1-owen.smith@cloud.com>
References: <20240607071700.1272-1-owen.smith@cloud.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Adds UnplugBootEmulated, which reports if the SystemStartOptions indicates
the boot disk should remain emulated (i.e. not unplugged)
Adds UnplugReboot, which can be used to issue the reboot request, so that
child drivers can abide by Driver Verifier's registry isolation rules

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 include/revision.h         |  3 +-
 include/unplug_interface.h | 40 +++++++++++++++++-
 src/xenbus/unplug.c        | 86 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 3 deletions(-)

diff --git a/include/revision.h b/include/revision.h
index 9577fdb..4c5607a 100644
--- a/include/revision.h
+++ b/include/revision.h
@@ -58,6 +58,7 @@
     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(0x09000009,  1,  4,  9,  1,  2,  1,  2,  4,  1,  1,  2), \
-    DEFINE_REVISION(0x0900000A,  1,  4,  9,  1,  2,  1,  2,  4,  2,  1,  2)
+    DEFINE_REVISION(0x0900000A,  1,  4,  9,  1,  2,  1,  2,  4,  2,  1,  2), \
+    DEFINE_REVISION(0x0900000B,  1,  4,  9,  1,  2,  1,  2,  4,  3,  1,  2)
 
 #endif  // _REVISION_H
diff --git a/include/unplug_interface.h b/include/unplug_interface.h
index dbdc76d..dad3afc 100644
--- a/include/unplug_interface.h
+++ b/include/unplug_interface.h
@@ -99,6 +99,28 @@ typedef BOOLEAN
     IN  XENBUS_UNPLUG_DEVICE_TYPE   Type
     );
 
+/*! \typedef XENBUS_UNPLUG_BOOT_EMULATED
+    \brief Should the boot disk be emulated
+
+    \param Interface The interface header
+*/
+typedef BOOLEAN
+(*XENBUS_UNPLUG_BOOT_EMULATED)(
+    IN  PINTERFACE                  Interface
+    );
+
+/*! \typedef XENBUS_UNPLUG_REBOOT
+    \brief Request a reboot to complete setup
+
+    \param Interface The interface header
+    \param Module The module name requesting a reboot
+*/
+typedef VOID
+(*XENBUS_UNPLUG_REBOOT)(
+    IN  PINTERFACE                  Interface,
+    IN  PCHAR                       Module
+    );
+
 // {73db6517-3d06-4937-989f-199b7501e229}
 DEFINE_GUID(GUID_XENBUS_UNPLUG_INTERFACE,
 0x73db6517, 0x3d06, 0x4937, 0x98, 0x9f, 0x19, 0x9b, 0x75, 0x01, 0xe2, 0x29);
@@ -126,7 +148,21 @@ struct _XENBUS_UNPLUG_INTERFACE_V2 {
     XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
 };
 
-typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
+/*! \struct _XENBUS_UNPLUG_INTERFACE_V3
+    \brief UNPLUG interface version 3
+    \ingroup interfaces
+*/
+struct _XENBUS_UNPLUG_INTERFACE_V3 {
+    INTERFACE                   Interface;
+    XENBUS_UNPLUG_ACQUIRE       UnplugAcquire;
+    XENBUS_UNPLUG_RELEASE       UnplugRelease;
+    XENBUS_UNPLUG_REQUEST       UnplugRequest;
+    XENBUS_UNPLUG_IS_REQUESTED  UnplugIsRequested;
+    XENBUS_UNPLUG_BOOT_EMULATED UnplugBootEmulated;
+    XENBUS_UNPLUG_REBOOT        UnplugReboot;
+};
+
+typedef struct _XENBUS_UNPLUG_INTERFACE_V3 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNPLUG_INTERFACE;
 
 /*! \def XENBUS_UNPLUG
     \brief Macro at assist in method invocation
@@ -137,6 +173,6 @@ typedef struct _XENBUS_UNPLUG_INTERFACE_V2 XENBUS_UNPLUG_INTERFACE, *PXENBUS_UNP
 #endif  // _WINDLL
 
 #define XENBUS_UNPLUG_INTERFACE_VERSION_MIN  1
-#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  2
+#define XENBUS_UNPLUG_INTERFACE_VERSION_MAX  3
 
 #endif  // _XENBUS_UNPLUG_INTERFACE_H
diff --git a/src/xenbus/unplug.c b/src/xenbus/unplug.c
index 7c5ffc4..a3f9b71 100644
--- a/src/xenbus/unplug.c
+++ b/src/xenbus/unplug.c
@@ -42,6 +42,7 @@
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
+#include "registry.h"
 
 struct _XENBUS_UNPLUG_CONTEXT {
     KSPIN_LOCK  Lock;
@@ -144,6 +145,64 @@ UnplugIsRequested(
     return Requested;
 }
 
+__drv_requiresIRQL(PASSIVE_LEVEL)
+static BOOLEAN
+UnplugBootEmulated(
+    IN  PINTERFACE                  Interface
+    )
+{
+    PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
+    CHAR                            KeyName[] = "XEN:BOOT_EMULATED=";
+    PANSI_STRING                    Option;
+    PCHAR                           Value;
+    NTSTATUS                        status;
+    BOOLEAN                         BootEmulated;
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    AcquireMutex(&Context->Mutex);
+
+    BootEmulated = FALSE;
+
+    status = ConfigQuerySystemStartOption(KeyName, &Option);
+    if (!NT_SUCCESS(status))
+        goto done;
+
+    Value = Option->Buffer + sizeof (KeyName) - 1;
+
+    if (strcmp(Value, "TRUE") == 0)
+        BootEmulated = TRUE;
+    else if (strcmp(Value, "FALSE") != 0)
+        Warning("UNRECOGNIZED VALUE OF %s: %s\n", KeyName, Value);
+
+    RegistryFreeSzValue(Option);
+
+done:
+    ReleaseMutex(&Context->Mutex);
+
+    return BootEmulated;
+}
+
+__drv_requiresIRQL(PASSIVE_LEVEL)
+static VOID
+UnplugReboot(
+    IN  PINTERFACE                  Interface,
+    IN  PCHAR                       Module
+    )
+{
+    PXENBUS_UNPLUG_CONTEXT          Context = Interface->Context;
+
+    ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
+
+    AcquireMutex(&Context->Mutex);
+
+    ConfigRequestReboot(DriverGetParametersKey(), Module);
+
+    ReleaseMutex(&Context->Mutex);
+
+    return;
+}
+
 static NTSTATUS
 UnplugAcquire(
     IN  PINTERFACE          Interface
@@ -199,6 +258,16 @@ static struct _XENBUS_UNPLUG_INTERFACE_V2 UnplugInterfaceVersion2 = {
     UnplugIsRequested
 };
 
+static struct _XENBUS_UNPLUG_INTERFACE_V3 UnplugInterfaceVersion3 = {
+    { sizeof (struct _XENBUS_UNPLUG_INTERFACE_V3), 3, NULL, NULL, NULL },
+    UnplugAcquire,
+    UnplugRelease,
+    UnplugRequest,
+    UnplugIsRequested,
+    UnplugBootEmulated,
+    UnplugReboot
+};
+
 NTSTATUS
 UnplugInitialize(
     IN  PXENBUS_FDO             Fdo,
@@ -277,6 +346,23 @@ UnplugGetInterface(
         status = STATUS_SUCCESS;
         break;
     }
+    case 3: {
+        struct _XENBUS_UNPLUG_INTERFACE_V3   *UnplugInterface;
+
+        UnplugInterface = (struct _XENBUS_UNPLUG_INTERFACE_V3 *)Interface;
+
+        status = STATUS_BUFFER_OVERFLOW;
+        if (Size < sizeof (struct _XENBUS_UNPLUG_INTERFACE_V3))
+            break;
+
+        *UnplugInterface = UnplugInterfaceVersion3;
+
+        ASSERT3U(Interface->Version, ==, Version);
+        Interface->Context = Context;
+
+        status = STATUS_SUCCESS;
+        break;
+    }
     default:
         status = STATUS_NOT_SUPPORTED;
         break;
-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Tue Jun 11 15:03:42 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 11 Jun 2024 15:03:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.738505.1145286 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sH32D-0002jE-10; Tue, 11 Jun 2024 15:03:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 738505.1145286; Tue, 11 Jun 2024 15: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 1sH32C-0002j7-U1; Tue, 11 Jun 2024 15:03:40 +0000
Received: by outflank-mailman (input) for mailman id 738505;
 Tue, 11 Jun 2024 15:03:40 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=NEC5=NN=cloud.com=owen.smith@srs-se1.protection.inumbo.net>)
 id 1sH32C-0002j1-Hh
 for win-pv-devel@lists.xenproject.org; Tue, 11 Jun 2024 15:03:40 +0000
Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com
 [2a00:1450:4864:20::32a])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id c7eea11b-2803-11ef-90a3-e314d9c70b13;
 Tue, 11 Jun 2024 17:03:39 +0200 (CEST)
Received: by mail-wm1-x32a.google.com with SMTP id
 5b1f17b1804b1-42122ac2f38so35644895e9.1
 for <win-pv-devel@lists.xenproject.org>; Tue, 11 Jun 2024 08:03:38 -0700 (PDT)
Received: from localhost.localdomain
 (host109-154-214-112.range109-154.btcentralplus.com. [109.154.214.112])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4217e9e903bsm111385005e9.24.2024.06.11.08.03.36
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 11 Jun 2024 08:03:36 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: c7eea11b-2803-11ef-90a3-e314d9c70b13
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=cloud.com; s=cloud; t=1718118217; x=1718723017; darn=lists.xenproject.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to;
        bh=Zx0N9wjTd4lemziP1gju4jLrX7rhK6imRSki8rd1T0c=;
        b=jMoSoQyjeDtVCjnoUZUbDn0l6KP4+vP5GIusTJSQStGkf628Q9xGHJGgHFRKsehtXz
         +gL0kRxVQOWo2Na0B/t3yffaGWREtsn7J9/41UrPnexPdfhr/A8c8KBeI4Llp7H0X0nH
         TgXvrUQa9LptRXA5pYjkVHBFnIFbuSRo7rn0Y=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1718118217; x=1718723017;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=Zx0N9wjTd4lemziP1gju4jLrX7rhK6imRSki8rd1T0c=;
        b=AoPAPP3Edl9LtP6Jon6R5KrfJBzAC9gTivO0yY3qTGd3HKVxeYhWEog/zrpOHWRIkZ
         sONLt1YVZ9ifKR3L2PmJzAJ3h+hKmn+dBSHHwQFA3nnTFAnTobUClb74LaP37Oh/a0WP
         YbYKEpETtCDlwiXs9px2/qrmtyBlIV2iye6obZ+hamQNUcuDxT1DcpqGCyMg5S9V3JAD
         h+tumU3mR9aIgxt/dCkIL5RE2UVfi1VH+Gd8HtW9DMf1m7EHmIitcrPSts3gVPORCaE8
         wdZf5nU609rIeuR3Q+KqLaIcUZJAM/xBYvMaC98fM3nmO5hSlBugxocxzsK/rvl2BtMy
         bitA==
X-Gm-Message-State: AOJu0Yyk0wYtyDs9GP+awg1nSIRIXKWP8x9yd1b1PmTuFlfvQs5ToTOm
	jiCiKE3IUNIrD7tnr774U8RlvhXZxSAImyzZpCvgQhdikntn48qDmAdqS9x0LKYcqpmIE5Es3F8
	=
X-Google-Smtp-Source: AGHT+IGverCEKWTwHvDJ6U8NkApU8zkQ2OyaBCM9FRhb7oqY8WYl541fWWc1BHut27meI0NxVYWbhA==
X-Received: by 2002:a05:600c:358d:b0:421:81eb:7d5c with SMTP id 5b1f17b1804b1-4223c91d19fmr28274215e9.18.1718118216852;
        Tue, 11 Jun 2024 08:03:36 -0700 (PDT)
From: Owen Smith <owen.smith@cloud.com>
To: win-pv-devel@lists.xenproject.org
Cc: Owen Smith <owen.smith@cloud.com>
Subject: [PATCH] Avoid returning STATUS_PNP_REBOOT_REQUIRED
Date: Tue, 11 Jun 2024 16:03:23 +0100
Message-ID: <20240611150323.2010-1-owen.smith@cloud.com>
X-Mailer: git-send-email 2.44.0.windows.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

When emulated devices are present, returning STATUS_PNP_REBOOT_REQUIRED
will display the 'reboot required' toast popup, but will also count as
a failure when distributing XenNet via Windows Update, which will
result in Microsoft pulling the XenNet update.
Note: PnpUnplugRequest is called twice in this startup codepath, as
      the reference count is decreased by PdoStopDevice later and
      keeping the reference count above zero is needed to unplug
      the emulated device.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
---
 src/xenvif/pdo.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index a3ae061..8ec9814 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -1407,7 +1407,6 @@ PdoStartDevice(
     IN  PIRP            Irp
     )
 {
-    PIO_STACK_LOCATION  StackLocation;
     HANDLE              SoftwareKey;
     HANDLE              HardwareKey;
     NTSTATUS            status;
@@ -1438,18 +1437,15 @@ PdoStartDevice(
 
     status = PdoParseMibTable(Pdo, SoftwareKey);
     if (status == STATUS_PNP_REBOOT_REQUIRED || !PdoUnplugRequested(Pdo)) {
-        PdoUnplugRequest(Pdo, TRUE);
+        PdoUnplugRequest(Pdo, TRUE); // fix unplug reference count
         DriverRequestReboot();
 
-        status = STATUS_PNP_REBOOT_REQUIRED;
-        goto fail5;
+        status = STATUS_SUCCESS;
     }
 
-    StackLocation = IoGetCurrentIrpStackLocation(Irp);
-
     status = PdoD3ToD0(Pdo);
     if (!NT_SUCCESS(status))
-        goto fail6;
+        goto fail5;
 
     PdoUnplugRequest(Pdo, TRUE);
 
@@ -1463,9 +1459,6 @@ PdoStartDevice(
 
     return STATUS_SUCCESS;
 
-fail6:
-    Error("fail6\n");
-
 fail5:
     Error("fail5\n");
 
-- 
2.44.0.windows.1



From win-pv-devel-bounces@lists.xenproject.org Sat Jun 29 15:30:55 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 29 Jun 2024 15:30:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.750923.1158872 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNa2O-0001ZZ-Hq; Sat, 29 Jun 2024 15:30:52 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 750923.1158872; Sat, 29 Jun 2024 15:30:52 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNa2O-0001ZS-Ev; Sat, 29 Jun 2024 15:30:52 +0000
Received: by outflank-mailman (input) for mailman id 750923;
 Sat, 29 Jun 2024 15:30:50 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+97O=N7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1sNa2M-0001ZK-Q7
 for win-pv-devel@lists.xenproject.org; Sat, 29 Jun 2024 15:30:50 +0000
Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com
 [2a00:1450:4864:20::331])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 8edf50b5-362c-11ef-b4bb-af5377834399;
 Sat, 29 Jun 2024 17:30:48 +0200 (CEST)
Received: by mail-wm1-x331.google.com with SMTP id
 5b1f17b1804b1-42565697036so15919095e9.1
 for <win-pv-devel@lists.xenproject.org>; Sat, 29 Jun 2024 08:30:47 -0700 (PDT)
Received: from ?IPV6:2a00:23c7:df82:3001:20f1:15b5:79c7:cb20?
 ([2a00:23c7:df82:3001:20f1:15b5:79c7:cb20])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3675a0cd66fsm5247375f8f.8.2024.06.29.08.30.46
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 29 Jun 2024 08:30:46 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 8edf50b5-362c-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1719675047; x=1720279847; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to;
        bh=SBONBMmu4Nhk6c2YYhGmgD0Q/Ug7zpLOZVdGBMuLMsU=;
        b=VOrhFpjidjI/DcWYt3DQzHRiKdUcglnDx+7QINSnrBgx8p7rXdXwyd6PzKiaCGO4hH
         QuZs1OBLG3fK4zw35D6jVKaI51ByJLTIPQkbCk5oaCjIE12jfoNpZiaIizIqGkWLeA93
         C6WZyQZa9EaByZNKQTgj3X0gxxxKji6JRVIeG0gIFGwqA9YMnPw/k4RvfBuyCK98HXCO
         bLgIfQEvRo4Q5lYCK3ZAA9+meCfq6kvQyp12hHGK3STuk8/3/25bbVytgnuKD20y87re
         gVmtPT+zYUOIq7CoAyU6aW8Vg3PL0Ib1FeARSpilke42DXoL/LEQt0wWiE/EjZG+9a20
         oqCw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719675047; x=1720279847;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=SBONBMmu4Nhk6c2YYhGmgD0Q/Ug7zpLOZVdGBMuLMsU=;
        b=bayNB8++SJ270yoTJ9JOgS+afxv2/i/oMbpFRsEaYqo/av3JmTp05pK8piWqldwqeL
         Y4MtAx4U5wuuY5RLXA7CmA9irvXAX8pAENPfqUQUxxOJOh37k7B1an5n5NAu9VZhCM0x
         gQjL+7ABxTMtDagNJEwBNBCQ0TY5IlDAp7+awww7z2Wr/Hx4x9H5tqErQAhRTJPXLXUL
         P3RnhZr5sBJByPS5tBDE73HjNt4LY9SAw/YTZnmuDCgFP+B/ePdMJO/9z13AoWvWBSlY
         W7veZb3z7jHwF8WoZvHYgk8kfXyfpw4Tob419Fc3F1V16i5qmgpgd9MEaoHGZOrRiYio
         m5SA==
X-Gm-Message-State: AOJu0YySF6Wf0789mvDrvkAro8P7K3eElaodBKiINghIXkfYRKUwoaqn
	UORusTPspO/1lFg9CSqoqihaV3FLJXFV9aTKh2flQDZQJjgG62od0FYVGg==
X-Google-Smtp-Source: AGHT+IFYW38LVR37iiW2FvYtgI8Rzu/9hG70ehsIomDR3j5HnF28/lW2Jz9iBWlh8IYEJ4dr6dg8pw==
X-Received: by 2002:adf:fe89:0:b0:362:23d5:3928 with SMTP id ffacd0b85a97d-36760a782dfmr3860760f8f.17.1719675046889;
        Sat, 29 Jun 2024 08:30:46 -0700 (PDT)
Message-ID: <3bee5512-9bf6-4e4d-a6d1-9fedd889210a@gmail.com>
Date: Sat, 29 Jun 2024 16:30:45 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [PATCH] Avoid returning STATUS_PNP_REBOOT_REQUIRED
To: win-pv-devel@lists.xenproject.org
References: <20240611150323.2010-1-owen.smith@cloud.com>
Content-Language: en-US
From: "Durrant, Paul" <xadimgnik@gmail.com>
In-Reply-To: <20240611150323.2010-1-owen.smith@cloud.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 11/06/2024 16:03, Owen Smith wrote:
> When emulated devices are present, returning STATUS_PNP_REBOOT_REQUIRED
> will display the 'reboot required' toast popup, but will also count as
> a failure when distributing XenNet via Windows Update, which will
> result in Microsoft pulling the XenNet update.
> Note: PnpUnplugRequest is called twice in this startup codepath, as
>        the reference count is decreased by PdoStopDevice later and
>        keeping the reference count above zero is needed to unplug
>        the emulated device.
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>
> ---
>   src/xenvif/pdo.c | 13 +++----------
>   1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
> index a3ae061..8ec9814 100644
> --- a/src/xenvif/pdo.c
> +++ b/src/xenvif/pdo.c
> @@ -1407,7 +1407,6 @@ PdoStartDevice(
>       IN  PIRP            Irp
>       )
>   {
> -    PIO_STACK_LOCATION  StackLocation;
>       HANDLE              SoftwareKey;
>       HANDLE              HardwareKey;
>       NTSTATUS            status;
> @@ -1438,18 +1437,15 @@ PdoStartDevice(
>   
>       status = PdoParseMibTable(Pdo, SoftwareKey);
>       if (status == STATUS_PNP_REBOOT_REQUIRED || !PdoUnplugRequested(Pdo)) {

Isn't the status check here now pointless?

> -        PdoUnplugRequest(Pdo, TRUE);
> +        PdoUnplugRequest(Pdo, TRUE); // fix unplug reference count
>           DriverRequestReboot();
>   
> -        status = STATUS_PNP_REBOOT_REQUIRED;
> -        goto fail5;
> +        status = STATUS_SUCCESS;
>       }
>   
> -    StackLocation = IoGetCurrentIrpStackLocation(Irp);
> -
>       status = PdoD3ToD0(Pdo);
>       if (!NT_SUCCESS(status))
> -        goto fail6;
> +        goto fail5;
>   
>       PdoUnplugRequest(Pdo, TRUE);
>   
> @@ -1463,9 +1459,6 @@ PdoStartDevice(
>   
>       return STATUS_SUCCESS;
>   
> -fail6:
> -    Error("fail6\n");
> -
>   fail5:
>       Error("fail5\n");
>   



From win-pv-devel-bounces@lists.xenproject.org Sat Jun 29 15:40:40 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 29 Jun 2024 15:40:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.750932.1158875 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNaBr-0002kE-7h; Sat, 29 Jun 2024 15:40:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 750932.1158875; Sat, 29 Jun 2024 15:40: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 1sNaBr-0002k7-54; Sat, 29 Jun 2024 15:40:39 +0000
Received: by outflank-mailman (input) for mailman id 750932;
 Sat, 29 Jun 2024 15:40:37 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+97O=N7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1sNaBp-0002k0-8e
 for win-pv-devel@lists.xenproject.org; Sat, 29 Jun 2024 15:40:37 +0000
Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com
 [2a00:1450:4864:20::332])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id ecdc6cf7-362d-11ef-b4bb-af5377834399;
 Sat, 29 Jun 2024 17:40:35 +0200 (CEST)
Received: by mail-wm1-x332.google.com with SMTP id
 5b1f17b1804b1-424720e73e1so12185715e9.1
 for <win-pv-devel@lists.xenproject.org>; Sat, 29 Jun 2024 08:40:35 -0700 (PDT)
Received: from ?IPV6:2a00:23c7:df82:3001:20f1:15b5:79c7:cb20?
 ([2a00:23c7:df82:3001:20f1:15b5:79c7:cb20])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4256b064f16sm80520445e9.27.2024.06.29.08.40.33
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 29 Jun 2024 08:40:33 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ecdc6cf7-362d-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1719675634; x=1720280434; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to;
        bh=vqr2bX2F6KKR0zjdHu8qZv2F6K/9H2VtLwRLrk0L01w=;
        b=Br0b/dWB8//px6WQDugWp8MhUwuxCqtR3jLpyIK4choNl/xlnn/9/22RYZ2XbTEQCI
         S8YiilmiNWZ5K75qAgHTZpRVbmscsSx4zGiIDhUT2G6rl9t4zmeaAVTIuvpn+aycX2vM
         wkYy5SdNxMvP+7AmyYnARK6x/XTrt83Cfh8m+25LLfJtYS7VxsXLlHpaxnWTk2wJgwXJ
         3nFahc2vRJGmxbYR3KohB8ME96SxAJ39lCk1mPUmFU+cv256GBVXz8J54ZUil1mgvkNe
         bFpdmxFJY7c1I240iMMupUK6u0Sf7UGZvvYHCK2jkzfR+cHwuYERxs3yBW4uLCxUkHXt
         V23w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719675634; x=1720280434;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=vqr2bX2F6KKR0zjdHu8qZv2F6K/9H2VtLwRLrk0L01w=;
        b=QloaQLy1T7FUTroZweXPu8DHuXKEQlKlsj6nzY7JPddV+cOJk0cAr0lwAwZaKmQGaO
         zjhTdUA7sfzYWgpKKUVmvJMYQ4GIGymK3eVsUh+gjKvryyGqJJfcAgiH5Eol5+EHp0pn
         zoVCVgLphqbk9SbunBVgfWBcZNwDWdKHBxx/stAWzhzXf2ADnzo2xTcY86StQrKKIKrx
         woQJfgHXQ2lDSEFWQwMWuG6/v416iCa4vIY0t2pavcheFyxL4Bj8N7y6HQWAdjxuSjG+
         m0FJ07rEahfk2BCAj4qcE4ba4DO4wAVxFfB8eQ+hIRD5ZN2N+gNvqfxHkWUfthaHcNSN
         Rhyg==
X-Gm-Message-State: AOJu0YyGx2hFK+nN9iAr+FpXfrG5OB6xZIXQ22yS9h3u7juoLNXAT8S4
	h8/TRsnkPxDhWOdM2h33kuD+f06/L7vo8o919Sg/PqfYoMuplrPZVZCCnQ==
X-Google-Smtp-Source: AGHT+IEGlUyBvNJhoIRBdszMQ6ij/s0n/OHy/sSbpq/Ea/Z4a6ZNZ5jVzDQECh1xPrxxYdSpLilJFA==
X-Received: by 2002:a05:600c:4181:b0:424:a3c7:4710 with SMTP id 5b1f17b1804b1-4257a02f219mr10723635e9.34.1719675634133;
        Sat, 29 Jun 2024 08:40:34 -0700 (PDT)
Message-ID: <9d3a92f1-58ec-4976-8d2d-aa17d0353a37@gmail.com>
Date: Sat, 29 Jun 2024 16:40:33 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [RFC PATCH 1/5] Add RegistryOpenParametersKey
To: win-pv-devel@lists.xenproject.org
References: <20240607071700.1272-1-owen.smith@cloud.com>
 <20240607071700.1272-2-owen.smith@cloud.com>
Content-Language: en-US
From: "Durrant, Paul" <xadimgnik@gmail.com>
In-Reply-To: <20240607071700.1272-2-owen.smith@cloud.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 07/06/2024 08:16, Owen Smith wrote:
> Use IoOpenDriverRegistryKey to avoid opening an absolute registry path.
> Driver Verifier can detect registry isolation violations when running WHQL
> tests on Server 2025. The rule states that a driver may not open an absolute
> registry key path. Use the specific API to open the 'Parameters' key with
> KEY_READ when querying settings.
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>
> ---
>   src/common/registry.c | 22 +++++++++++++++++++++-
>   src/common/registry.h |  9 ++++++++-
>   src/xen/driver.c      |  2 +-
>   src/xenbus/driver.c   | 19 ++-----------------
>   src/xenfilt/driver.c  | 33 +++------------------------------
>   5 files changed, 35 insertions(+), 50 deletions(-)
> 
> diff --git a/src/common/registry.c b/src/common/registry.c
> index 0d29ddc..73a55d2 100644
> --- a/src/common/registry.c
> +++ b/src/common/registry.c
> @@ -38,6 +38,7 @@
>   
>   #define REGISTRY_TAG 'GERX'
>   
> +static PDRIVER_OBJECT   DriverObject;
>   static UNICODE_STRING   RegistryPath;
>   
>   static FORCEINLINE PVOID
> @@ -58,7 +59,8 @@ __RegistryFree(
>   
>   NTSTATUS
>   RegistryInitialize(
> -    IN PUNICODE_STRING  Path
> +    IN  PDRIVER_OBJECT  DrvObj,
> +    IN  PUNICODE_STRING Path

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

... but I don't like the 'DrvObj' thing.... I'll call it 'DriverObject' 
and change the global to 'RegistryDriverObject'.

>       )
>   {
>       NTSTATUS            status;
> @@ -69,6 +71,9 @@ RegistryInitialize(
>       if (!NT_SUCCESS(status))
>           goto fail1;
>   
> +    ASSERT3P(DriverObject, ==, NULL);
> +    DriverObject = DrvObj;
> +
>       return STATUS_SUCCESS;
>   
>   fail1:
> @@ -82,11 +87,26 @@ RegistryTeardown(
>       VOID
>       )
>   {
> +    DriverObject = NULL;
> +
>       RtlFreeUnicodeString(&RegistryPath);
>       RegistryPath.Buffer = NULL;
>       RegistryPath.MaximumLength = RegistryPath.Length = 0;
>   }
>   
> +NTSTATUS
> +RegistryOpenParametersKey(
> +    IN  ACCESS_MASK     DesiredAccess,
> +    OUT PHANDLE         Key
> +    )
> +{
> +    return IoOpenDriverRegistryKey(DriverObject,
> +                                   DriverRegKeyParameters,
> +                                   DesiredAccess,
> +                                   0,
> +                                   Key);
> +}
> +
>   NTSTATUS
>   RegistryOpenKey(
>       IN  HANDLE          Parent,
> diff --git a/src/common/registry.h b/src/common/registry.h
> index cbe9015..efa96ea 100644
> --- a/src/common/registry.h
> +++ b/src/common/registry.h
> @@ -37,7 +37,8 @@
>   
>   extern NTSTATUS
>   RegistryInitialize(
> -    IN PUNICODE_STRING  Path
> +    IN  PDRIVER_OBJECT  DrvObj,
> +    IN  PUNICODE_STRING Path
>       );
>   
>   extern VOID
> @@ -45,6 +46,12 @@ RegistryTeardown(
>       VOID
>       );
>   
> +extern NTSTATUS
> +RegistryOpenParametersKey(
> +    IN  ACCESS_MASK     DesiredAccess,
> +    OUT PHANDLE         Key
> +    );
> +
>   extern NTSTATUS
>   RegistryOpenKey(
>       IN  HANDLE          Parent,
> diff --git a/src/xen/driver.c b/src/xen/driver.c
> index 8fe6c5c..e04a772 100644
> --- a/src/xen/driver.c
> +++ b/src/xen/driver.c
> @@ -515,7 +515,7 @@ DllInitialize(
>       if (!NT_SUCCESS(status))
>           goto fail1;
>   
> -    status = RegistryInitialize(RegistryPath);
> +    status = RegistryInitialize(NULL, RegistryPath);
>       if (!NT_SUCCESS(status))
>           goto fail2;
>   
> diff --git a/src/xenbus/driver.c b/src/xenbus/driver.c
> index 522acef..d6efe89 100644
> --- a/src/xenbus/driver.c
> +++ b/src/xenbus/driver.c
> @@ -811,7 +811,6 @@ DriverEntry(
>       IN  PUNICODE_STRING RegistryPath
>       )
>   {
> -    HANDLE              ServiceKey;
>       HANDLE              ParametersKey;
>       ULONG               Index;
>       LOG_LEVEL           LogLevel;
> @@ -839,21 +838,14 @@ DriverEntry(
>            MONTH,
>            YEAR);
>   
> -    status = RegistryInitialize(RegistryPath);
> +    status = RegistryInitialize(DriverObject, RegistryPath);
>       if (!NT_SUCCESS(status))
>           goto fail1;
>   
> -    status = RegistryOpenServiceKey(KEY_READ, &ServiceKey);
> +    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
>       if (!NT_SUCCESS(status))
>           goto fail2;
>   
> -    status = RegistryOpenSubKey(ServiceKey,
> -                                "Parameters",
> -                                KEY_READ,
> -                                &ParametersKey);
> -    if (!NT_SUCCESS(status))
> -        goto fail3;
> -
>       __DriverSetParametersKey(ParametersKey);
>   
>       status = LogReadLogLevel(ParametersKey,
> @@ -864,8 +856,6 @@ DriverEntry(
>   
>       __DriverSetConsoleLogLevel(LogLevel);
>   
> -    RegistryCloseKey(ServiceKey);
> -
>       status = XenTouch(__MODULE__,
>                         MAJOR_VERSION,
>                         MINOR_VERSION,
> @@ -900,11 +890,6 @@ done:
>   
>       return STATUS_SUCCESS;
>   
> -fail3:
> -    Error("fail3\n");
> -
> -    RegistryCloseKey(ServiceKey);
> -
>   fail2:
>       Error("fail2\n");
>   
> diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
> index 724d418..aee663a 100644
> --- a/src/xenfilt/driver.c
> +++ b/src/xenfilt/driver.c
> @@ -113,33 +113,6 @@ DriverGetDriverObject(
>       return __DriverGetDriverObject();
>   }
>   
> -static FORCEINLINE NTSTATUS
> -__DriverOpenParametersKey(
> -    OUT PHANDLE     ParametersKey
> -    )
> -{
> -    HANDLE          ServiceKey;
> -    NTSTATUS        status;
> -
> -    status = RegistryOpenServiceKey(KEY_READ, &ServiceKey);
> -    if (!NT_SUCCESS(status))
> -        goto fail1;
> -
> -    status = RegistryOpenSubKey(ServiceKey, "Parameters", KEY_READ, ParametersKey);
> -    if (!NT_SUCCESS(status))
> -        goto fail2;
> -
> -    RegistryCloseKey(ServiceKey);
> -
> -    return STATUS_SUCCESS;
> -
> -fail2:
> -    RegistryCloseKey(ServiceKey);
> -
> -fail1:
> -    return status;
> -}
> -
>   static FORCEINLINE VOID
>   __DriverSetEmulatedContext(
>       IN  PXENFILT_EMULATED_CONTEXT   Context
> @@ -247,7 +220,7 @@ __DriverGetActive(
>   
>       ASSERT3U(KeGetCurrentIrql(), ==, PASSIVE_LEVEL);
>   
> -    status = __DriverOpenParametersKey(&ParametersKey);
> +    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
>       if (!NT_SUCCESS(status))
>           goto fail1;
>   
> @@ -752,7 +725,7 @@ DriverGetEmulatedType(
>       ULONG                           Index;
>       NTSTATUS                        status;
>   
> -    status = __DriverOpenParametersKey(&ParametersKey);
> +    status = RegistryOpenParametersKey(KEY_READ, &ParametersKey);
>       if (!NT_SUCCESS(status))
>           goto fail1;
>   
> @@ -947,7 +920,7 @@ DriverEntry(
>       if (!NT_SUCCESS(status))
>           goto done;
>   
> -    status = RegistryInitialize(RegistryPath);
> +    status = RegistryInitialize(DriverObject, RegistryPath);
>       if (!NT_SUCCESS(status))
>           goto fail1;
>   



From win-pv-devel-bounces@lists.xenproject.org Sat Jun 29 15:43:18 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 29 Jun 2024 15:43:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.750942.1158881 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNaEP-0002sR-Fu; Sat, 29 Jun 2024 15:43:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 750942.1158881; Sat, 29 Jun 2024 15:43:17 +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 1sNaEP-0002sK-Bv; Sat, 29 Jun 2024 15:43:17 +0000
Received: by outflank-mailman (input) for mailman id 750942;
 Sat, 29 Jun 2024 15:43:15 +0000
Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254]
 helo=se1-gles-sth1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+97O=N7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1sNaEN-0002sA-F5
 for win-pv-devel@lists.xenproject.org; Sat, 29 Jun 2024 15:43:15 +0000
Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com
 [2a00:1450:4864:20::22e])
 by se1-gles-sth1.inumbo.com (Halon) with ESMTPS
 id 4bcf0ea4-362e-11ef-90a3-e314d9c70b13;
 Sat, 29 Jun 2024 17:43:14 +0200 (CEST)
Received: by mail-lj1-x22e.google.com with SMTP id
 38308e7fff4ca-2ec50a5e230so15065881fa.0
 for <win-pv-devel@lists.xenproject.org>; Sat, 29 Jun 2024 08:43:14 -0700 (PDT)
Received: from ?IPV6:2a00:23c7:df82:3001:20f1:15b5:79c7:cb20?
 ([2a00:23c7:df82:3001:20f1:15b5:79c7:cb20])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4256af5b61bsm81653605e9.17.2024.06.29.08.43.12
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 29 Jun 2024 08:43:12 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 4bcf0ea4-362e-11ef-90a3-e314d9c70b13
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1719675793; x=1720280593; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to;
        bh=Ms35rvryAwfh3UzCOPVIo0iZFt6YNCu5VI1nghxs0IY=;
        b=IBKAoBSp75KjLVk0ZIo7FZBFQfDfVmEQfVLA11ZOx4euhbymiKWOdSdP4pax2IwzTK
         d6y8FarzYfzMVpvJTRLKUwvr88GOigbIqN3pD8PeC2eUpjInoSSCtCd4uxV6w1ksKHm8
         3trissNMCCgdKypR97JCbictJgPSWArOuH6lLZquKGtKAMEsFyT4d6snykEf8lP5bL/5
         fq0JyLYytDvJ4RhVf7Tjqw1wlmVS5js9Y7hkpCGavPvb5I9zwCxM8OduqniOiHVbdUNB
         MX6Q2SmYPL1ypo/4ifZm9WC9nERp/9/SdEsMg5cVS1kIfbAcAMzbD0dcapEzfObmRh6v
         EpJg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719675793; x=1720280593;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=Ms35rvryAwfh3UzCOPVIo0iZFt6YNCu5VI1nghxs0IY=;
        b=hWqLsgATqmUefs3w4X53wyjYl+PcN4N5SdohEs3sWYxjh9MwJ1e8z/m5hOv8Ch+6XD
         DGvmks5xrvxJUQPvU95ijnbuG3r3QYhzvrhYp/aekkMr4Yw66DHMkSMFjx1Fznj7Oit/
         in017Rp9C4xSPZxDk8kMI9AhFW5seAQZiGgreXKHif9iAOQ1TvwiExnLWTGoOJaeYT8N
         0B7GRiZY12CfAC2TiJrmrWW96fVyHx/2ukoC07HgDbwcQuHEQH9GwnmZW5H3RqVEnB+i
         zYgYpz/ocG4OWMuoK9ORu0R0syuhUFVC548FhcfX1uNpzmwlasfta194zi7OZTw+I26Z
         SfFg==
X-Gm-Message-State: AOJu0Yy+/NpvwpcxDFSib4/2TbUdvgxOZGTf8+9/bApSKVxiXRiKnPCs
	akxEsuPn8YYsXx0JoxNUUgXwsEU9U7lJ3DDfNPi8bCHZc2Zw/yu89dN44w==
X-Google-Smtp-Source: AGHT+IGfNOBnhxSNhN1HlwfGd3/JUpzdVYYO4++2QGVnKAt5KiHlKkEfS8aT5H6FjbkhnFTkT8W4eQ==
X-Received: by 2002:a05:651c:b21:b0:2ee:4ab4:f752 with SMTP id 38308e7fff4ca-2ee5e6cd8d4mr10443191fa.49.1719675793311;
        Sat, 29 Jun 2024 08:43:13 -0700 (PDT)
Message-ID: <763b497f-274c-4e34-8258-d7a95736ffb0@gmail.com>
Date: Sat, 29 Jun 2024 16:43:12 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [RFC PATCH 2/5] Move FiltersInstall/FiltersUninstall to xen.sys
To: win-pv-devel@lists.xenproject.org
References: <20240607071700.1272-1-owen.smith@cloud.com>
 <20240607071700.1272-3-owen.smith@cloud.com>
Content-Language: en-US
From: "Durrant, Paul" <xadimgnik@gmail.com>
In-Reply-To: <20240607071700.1272-3-owen.smith@cloud.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 07/06/2024 08:16, Owen Smith wrote:
> Since WHQL will enable Driver Verifier's registry isolation violation
> detection on xenbus.sys, move the registry manipulation for inserting
> xenfilt.sys into the appropriate device class UpperFilters to xen.sys.
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>
> ---
>   include/xen.h                 | 14 ++++++++++++++
>   src/{xenbus => xen}/filters.c |  4 ++++
>   src/{xenbus => xen}/filters.h |  0
>   src/xenbus/driver.c           |  2 +-
>   vs2019/xen/xen.vcxproj        |  1 +
>   vs2019/xenbus/xenbus.vcxproj  |  1 -
>   vs2022/xen/xen.vcxproj        |  1 +
>   vs2022/xenbus/xenbus.vcxproj  |  1 -
>   8 files changed, 21 insertions(+), 3 deletions(-)
>   rename src/{xenbus => xen}/filters.c (99%)
>   rename src/{xenbus => xen}/filters.h (100%)
> 

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



From win-pv-devel-bounces@lists.xenproject.org Sat Jun 29 15:44:28 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 29 Jun 2024 15:44:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.750950.1158884 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNaFY-0002yD-Il; Sat, 29 Jun 2024 15:44:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 750950.1158884; Sat, 29 Jun 2024 15:44:28 +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 1sNaFY-0002y5-Fz; Sat, 29 Jun 2024 15:44:28 +0000
Received: by outflank-mailman (input) for mailman id 750950;
 Sat, 29 Jun 2024 15:44:26 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+97O=N7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1sNaFW-0002xg-JJ
 for win-pv-devel@lists.xenproject.org; Sat, 29 Jun 2024 15:44:26 +0000
Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com
 [2a00:1450:4864:20::32d])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 75e65c53-362e-11ef-b4bb-af5377834399;
 Sat, 29 Jun 2024 17:44:24 +0200 (CEST)
Received: by mail-wm1-x32d.google.com with SMTP id
 5b1f17b1804b1-424acf3226fso12974655e9.1
 for <win-pv-devel@lists.xenproject.org>; Sat, 29 Jun 2024 08:44:24 -0700 (PDT)
Received: from ?IPV6:2a00:23c7:df82:3001:20f1:15b5:79c7:cb20?
 ([2a00:23c7:df82:3001:20f1:15b5:79c7:cb20])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4256b09aa32sm81360825e9.34.2024.06.29.08.44.23
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 29 Jun 2024 08:44:23 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 75e65c53-362e-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1719675864; x=1720280664; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to;
        bh=qKcLkUxtO5W46KMe/1yXVYBsXIQ9ly6l7Bzj8Fz69k4=;
        b=YpDo03t3yq6Ubbb2+ksRB02Qkh64i7k1MqEiQN/XEb89Bv6VyL8BlWiOk7HBy5hUl8
         pvEkQG57oPj4DdCurK1gNCJDTm/MH1JZZjqyC9nrE4SuZZmIi5zNP4wqNunPpfyLxI9v
         RtF3gGjh2N7IJLRTDxyIqmKsJOkXNVTm9J/xtFUFO9HcwwEWh7KNlNVoyJdf3g3mDK0P
         VByYy6Ygy0wXxX+UUmO0AE6rlArMInhJ3VfYajBQqZWsGa2ERASkZileQGDEkdxYh5YI
         k1lDeOJDyMmPRwfjcnjQH5Kp5B7a8B3G20S+0W73805ErZTUwgZe7mOIKGDelIw9TSVR
         V91Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719675864; x=1720280664;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=qKcLkUxtO5W46KMe/1yXVYBsXIQ9ly6l7Bzj8Fz69k4=;
        b=M2hnk3Lvq1LFNU9yeQdR+IIlhKiuF3vTQB/0sq3DOAUPf46f2iGVaw2+vhb4TuRbRe
         8ns3AS2tI2OtU5+lDdOWxX5ysvXypG+jn1asiVUshEdn4WdZktVaP3w8O/+aTAzbPxLb
         3yjZ9VNiuVOrZon3Xrp8Yvo/D8nY+/JQ7/nFtaVig7cE7rnPKGT3BW9EIZjdckqfXiDh
         tdcdyOwkHZtnWpvD/eaSoFsqWo8ufyXp1b8PkupR8vwnssubdXEm/pWPkG25KZ/9TMHV
         dPoFk9WUcCEsm/GSibM4o4SQpzprOvfdfkx9wY72CE5qkciNSmzSI0lX3JpIgvQKjKes
         sRfQ==
X-Gm-Message-State: AOJu0YwglbhGcvxXmzfzauVB3MIirWML22VKKQmW09C0dEu7m5aXxoYu
	/HjBSGYGaOhocpO1GLz8weiG4lyyib1v1hOCn4ze/GD10lYfTmVkg28XkA==
X-Google-Smtp-Source: AGHT+IHl4PF3gywwlSD2jGJJ5D5OjRwCS5eihiGqBYavaqHzlivuYbogRJIY6LBx72B0YmXyS3iGAQ==
X-Received: by 2002:a05:600c:4f12:b0:425:675a:d52e with SMTP id 5b1f17b1804b1-4257a02147cmr9458355e9.2.1719675864023;
        Sat, 29 Jun 2024 08:44:24 -0700 (PDT)
Message-ID: <f1b446ce-3e9b-46b0-86cd-a940c2bee495@gmail.com>
Date: Sat, 29 Jun 2024 16:44:23 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [RFC PATCH 3/5] Remove FdoSetFriendlyName
To: win-pv-devel@lists.xenproject.org
References: <20240607071700.1272-1-owen.smith@cloud.com>
 <20240607071700.1272-4-owen.smith@cloud.com>
Content-Language: en-US
From: "Durrant, Paul" <xadimgnik@gmail.com>
In-Reply-To: <20240607071700.1272-4-owen.smith@cloud.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 07/06/2024 08:16, Owen Smith wrote:
> RegistryOpenHardwareKey uses an absolute path to open the parent key
> of IoOpenDeviceRegistryKey. Since this is a violation of the registry
> isolation rules in Driver Verifier, its not possible to open the correct
> registry key to set the device instance's friendly name.
> 

Boo.

> Signed-off-by: Owen Smith <owen.smith@cloud.com>
> ---
>   src/xenbus/fdo.c | 87 ------------------------------------------------
>   1 file changed, 87 deletions(-)
> 

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



From win-pv-devel-bounces@lists.xenproject.org Sat Jun 29 15:46:17 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 29 Jun 2024 15:46:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.750960.1158888 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNaHI-000348-O2; Sat, 29 Jun 2024 15:46:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 750960.1158888; Sat, 29 Jun 2024 15:46: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 1sNaHI-000341-LJ; Sat, 29 Jun 2024 15:46:16 +0000
Received: by outflank-mailman (input) for mailman id 750960;
 Sat, 29 Jun 2024 15:46:14 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+97O=N7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1sNaHG-00033v-Sn
 for win-pv-devel@lists.xenproject.org; Sat, 29 Jun 2024 15:46:14 +0000
Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com
 [2a00:1450:4864:20::32e])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id b653f349-362e-11ef-b4bb-af5377834399;
 Sat, 29 Jun 2024 17:46:12 +0200 (CEST)
Received: by mail-wm1-x32e.google.com with SMTP id
 5b1f17b1804b1-4256788e13bso11975665e9.2
 for <win-pv-devel@lists.xenproject.org>; Sat, 29 Jun 2024 08:46:12 -0700 (PDT)
Received: from ?IPV6:2a00:23c7:df82:3001:20f1:15b5:79c7:cb20?
 ([2a00:23c7:df82:3001:20f1:15b5:79c7:cb20])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-4256b09aa32sm81439465e9.34.2024.06.29.08.46.11
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 29 Jun 2024 08:46:11 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: b653f349-362e-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1719675972; x=1720280772; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to;
        bh=mJ40Zfqs0kCWOvo/v4dQJrvhFkLELGbiEoub/uWyslQ=;
        b=V/d5D7LdjGFYqC67un+pCvQtl00SvfT/NOzLfmKZUa5kK25q/YiiyhOy61tQgQtXIp
         ymR5UGEIqXavmPg99wb3jCS/khKtwA5Lsix4k9/7p8dx/DK9xQBIBFWiQUw39OBfrLtv
         MbALEZZvUcYBUc6volUcxPK/VObRFUKVEHTw5qGciGIxVb+TaU2qs38hnC43G3pdVhEW
         cpr0GnNYhhPAApQPTkyNhcEZvM/Rb+7Mftrt2ZcKjPmTmg7moTwO9DMZzJlx/zOIsu8f
         8fQ7eiGaOBDUnvQZd19mCvdphAZhx867btMRQslst44l+htsNM2J/uLUSUY+OFxkGBWO
         hJxg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719675972; x=1720280772;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=mJ40Zfqs0kCWOvo/v4dQJrvhFkLELGbiEoub/uWyslQ=;
        b=jFK06pE1a2TonYQZDCo0KCkv9+VhkhqJeMQJfyrCcR4iIIlXqubpwkQ0N2FaCxhLwN
         9ASdm4z7gwXBNBR83ZWN0PcVVEWgtp9roAcyt1jR96gqweW817jUyWvJG6t7OpWomd7s
         hr47X58odJatMyh+UwoYJZiXCNWK/unC6TnEysPXDP3rC8WUMwgfbFIZPwQM1SjW/wqQ
         nIXqzpRODYE100HWj/iBot8cn1konzCXZ7zFalpDcKIf+o5QtfQCWxb37XIDMANcfnZH
         CRVMx2d4E0NUoAAc0IZz5ASNJbRSmvd/zKmhYwJYJohrekxON4iP8VRhr/NtrKbzfXGE
         koGw==
X-Gm-Message-State: AOJu0YxePdBYL3/y8q0MtsSuhCTKtG4HDRGYxkyFOkTVkVcR5XRxLIcr
	0fntD04O0Z274Ho3IdBb+j6TeYSBsWEs2+yYR2FsqMQZZNQ1whIUT+xIDQ==
X-Google-Smtp-Source: AGHT+IGKnYt5zNUE5+3fGt4Yv9sjVjUNhSJotSbCRbshehv7Z95fEc18dQC0o5bKPjCLTlOF65a34A==
X-Received: by 2002:a05:600c:12c6:b0:421:de92:a9b1 with SMTP id 5b1f17b1804b1-4257a030224mr9252945e9.16.1719675972136;
        Sat, 29 Jun 2024 08:46:12 -0700 (PDT)
Message-ID: <27ac1e50-9b9d-4b06-859e-3e10c3a6f9b2@gmail.com>
Date: Sat, 29 Jun 2024 16:46:11 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [RFC PATCH 4/5] Move Registry operations to xen.sys
To: win-pv-devel@lists.xenproject.org
References: <20240607071700.1272-1-owen.smith@cloud.com>
 <20240607071700.1272-5-owen.smith@cloud.com>
Content-Language: en-US
From: "Durrant, Paul" <xadimgnik@gmail.com>
In-Reply-To: <20240607071700.1272-5-owen.smith@cloud.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 07/06/2024 08:16, Owen Smith wrote:
> Driver Verifier's registry isolation rules are not applied to xen.sys during
> WHQL testing. Move remaining operations that do not comply to xen.sys.
> Operations related to Active Device, Reboot Requests and SystemStartOptions
> are exposed by xen.sys to allow xenbus.sys and other drivers to successfully
> execute with Driver Verifier enabled.
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>
> ---
>   include/xen.h          |  45 ++++
>   src/xen/config.c       | 497 +++++++++++++++++++++++++++++++++++++++++
>   src/xenbus/driver.c    | 448 +------------------------------------
>   src/xenbus/driver.h    |  30 ---
>   src/xenbus/fdo.c       |  12 +-
>   vs2019/xen/xen.vcxproj |   1 +
>   vs2022/xen/xen.vcxproj |   1 +
>   7 files changed, 551 insertions(+), 483 deletions(-)
>   create mode 100644 src/xen/config.c
> 

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



From win-pv-devel-bounces@lists.xenproject.org Sat Jun 29 15:48:49 2024
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Sat, 29 Jun 2024 15:48:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.750971.1158891 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1sNaJk-0003EO-Ve; Sat, 29 Jun 2024 15:48:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 750971.1158891; Sat, 29 Jun 2024 15:48: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 1sNaJk-0003EH-T8; Sat, 29 Jun 2024 15:48:48 +0000
Received: by outflank-mailman (input) for mailman id 750971;
 Sat, 29 Jun 2024 15:48:48 +0000
Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50]
 helo=se1-gles-flk1.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=+97O=N7=gmail.com=xadimgnik@srs-se1.protection.inumbo.net>)
 id 1sNaJk-0003EB-BU
 for win-pv-devel@lists.xenproject.org; Sat, 29 Jun 2024 15:48:48 +0000
Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com
 [2a00:1450:4864:20::336])
 by se1-gles-flk1.inumbo.com (Halon) with ESMTPS
 id 11d7a4bf-362f-11ef-b4bb-af5377834399;
 Sat, 29 Jun 2024 17:48:46 +0200 (CEST)
Received: by mail-wm1-x336.google.com with SMTP id
 5b1f17b1804b1-42562e4b5d1so11917535e9.1
 for <win-pv-devel@lists.xenproject.org>; Sat, 29 Jun 2024 08:48:46 -0700 (PDT)
Received: from ?IPV6:2a00:23c7:df82:3001:20f1:15b5:79c7:cb20?
 ([2a00:23c7:df82:3001:20f1:15b5:79c7:cb20])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-3675a0fb92fsm5228302f8f.88.2024.06.29.08.48.45
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sat, 29 Jun 2024 08:48:45 -0700 (PDT)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 11d7a4bf-362f-11ef-b4bb-af5377834399
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20230601; t=1719676126; x=1720280926; darn=lists.xenproject.org;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:from:to:cc:subject:date:message-id:reply-to;
        bh=y6udAw2jnddYP8b1/6ElXZ3yq5ugsV+C7LiQMIiZx7I=;
        b=QOeZDlCA2R4jNrXmlsX/3qGlA+Wz9Y2+YhBBPp/aMhc+X4wtrhjeogH3AfNc/shbb2
         l9Cc42PcTriCcEXPl2gT3pkWnPHlou8lP45dc7PPaEK5uopuOKJ/rPxHqXvji4oYTQ+4
         f81ekdI97tckNhlE/WV9GJKQ5Tu06jVnpk9oYKzcdO6NnrM2+gHKh+H1p9GiGk9EXuF8
         Void1lPfohfV2ZXGv52qxg3qV+yz7HKOrBedEr9hVnZZYq0cHOIm2BSve3/Qon71wNxP
         acTEPF9SZs7GuFVlSdEIedhfoVSNaj51H0IuAnueqWHyXnlg8mOVmJmod1Io4ONu9lKh
         k7lw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1719676126; x=1720280926;
        h=content-transfer-encoding:in-reply-to:from:content-language
         :references:to:subject:reply-to:user-agent:mime-version:date
         :message-id:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=y6udAw2jnddYP8b1/6ElXZ3yq5ugsV+C7LiQMIiZx7I=;
        b=IRSFhiUeGFWGmJDqeqdEq+uroRf6mSqa9wi0Dk5/OEWtmljnxhmxCmzKC7J6UBej0n
         rUFsTe/tTHTOtEQlrQ8HtfNQvsqmyB55LN3isbHITacL2vsqHorKzOL5A4upBLDpC+L/
         uxzmX10VuG2Poeo3akiT34DU0ZSGDC/Fla8KJd6QClc66yptDWptbvFV4rtIQDATOESg
         y1cY7gbEiSMd8pvXhtHXK9xmZk45gHK3rhHpsPk9QwvpQvgiYEFjRvq9dbSTNpImS2QA
         oQs9PUJ9gQc/qqQuvmUUd3728wSDbwxpr8ss9loOb6hn/JKC6IWRz5ACQhzM6y8YeXss
         KNOg==
X-Gm-Message-State: AOJu0Yw2CzkuKjSFRakIz0nnInxbycY3Khr2Xr3KGP7gaQoXieAKlidt
	+EXa7EqAB7cil/826AFxw4ZW+81+B9WGpv8+hif3go9Xl1JG6pj8dibdLA==
X-Google-Smtp-Source: AGHT+IEFI8Rwv5Z6+vy8d81rLWhFY8B2k1+MYQjToc0ZOxQOpg0K2c4ydkrY9czBHuiuDsQnyUzRRQ==
X-Received: by 2002:a5d:54c9:0:b0:367:6b05:356a with SMTP id ffacd0b85a97d-367756bb441mr733517f8f.36.1719676125680;
        Sat, 29 Jun 2024 08:48:45 -0700 (PDT)
Message-ID: <c941fcc8-1d8b-4425-8f6e-d117b82fe358@gmail.com>
Date: Sat, 29 Jun 2024 16:48:44 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Reply-To: paul@xen.org
Subject: Re: [RFC PATCH 5/5] Add UNPLUG v3
To: win-pv-devel@lists.xenproject.org
References: <20240607071700.1272-1-owen.smith@cloud.com>
 <20240607071700.1272-6-owen.smith@cloud.com>
Content-Language: en-US
From: "Durrant, Paul" <xadimgnik@gmail.com>
In-Reply-To: <20240607071700.1272-6-owen.smith@cloud.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 07/06/2024 08:17, Owen Smith wrote:
> Adds UnplugBootEmulated, which reports if the SystemStartOptions indicates
> the boot disk should remain emulated (i.e. not unplugged)
> Adds UnplugReboot, which can be used to issue the reboot request, so that
> child drivers can abide by Driver Verifier's registry isolation rules
> 
> Signed-off-by: Owen Smith <owen.smith@cloud.com>
> ---
>   include/revision.h         |  3 +-
>   include/unplug_interface.h | 40 +++++++++++++++++-
>   src/xenbus/unplug.c        | 86 ++++++++++++++++++++++++++++++++++++++
>   3 files changed, 126 insertions(+), 3 deletions(-)
> 

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


