From win-pv-devel-bounces@lists.xenproject.org Thu Mar 04 10:35:40 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Thu, 04 Mar 2021 10:35:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93095.175742 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lHlKU-0005sc-Bv; Thu, 04 Mar 2021 10:35:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93095.175742; Thu, 04 Mar 2021 10:35:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lHlKU-0005sV-97; Thu, 04 Mar 2021 10:35:38 +0000
Received: by outflank-mailman (input) for mailman id 93095;
 Thu, 04 Mar 2021 10:35:37 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lHlKT-0005sO-FV
 for win-pv-devel@lists.xenproject.org; Thu, 04 Mar 2021 10:35:37 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Thu, 4 Mar 2021 10:35:46 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <9417350.19.1614854146980.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #218 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_18_15170821.1614854146840"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #218.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/218/console to view the results.
------=_Part_18_15170821.1614854146840--


From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:15:49 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:15:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93568.176526 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7Up-0003I4-CU; Fri, 05 Mar 2021 10:15:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93568.176526; Fri, 05 Mar 2021 10:15:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7Up-0003Hx-9d; Fri, 05 Mar 2021 10:15:47 +0000
Received: by outflank-mailman (input) for mailman id 93568;
 Fri, 05 Mar 2021 10:15:46 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7Uo-0003Hs-F7
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:15:46 +0000
Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 848b5eca-32a8-4067-a5af-b13c1ba4cdeb;
 Fri, 05 Mar 2021 10:15:45 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 848b5eca-32a8-4067-a5af-b13c1ba4cdeb
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614939345;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=YXnE2AjIlSu1bVeoAZQxqLVTx9qfQCWoTbZw3Hsx7Rg=;
  b=Z5WxQFhhvNmSn1shiIMADVRU4fNz0oE49hfGL5Mo4zoKy+MlXn5L0DID
   lEjAp6bZ2nyZu2qx85mhsLWOeP6EQfvs/ERJSEaEExPYAna6zwglPQh9j
   bgpI1zoO5gDP75udyrOxV2H5QY8dSYFBYXWOnIZd3BrVfY7ejA9bkVJ6z
   U=;
Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 8dXO3u2ycaOLGrb+rhOqO6d3bL+oIy9Osx6JrFzYBp98gl1N0tuCT9arkW/kJiHQjicHXIeShI
 xaMLJr5HKxN6HAZqXDTKoEtzOpqcVp0xrCykQgCRc5SoHAMRmh/VdIyTl6fBopM150uWff6hTS
 EQnh3iQCVPjNxYgma60KSI9a0S8dx35SKMwjDk0fTVOg7h+Lm6gFxjtCknIJq2RJX+wMhRrKZv
 EhB8zwgblQCysAUoOHr2UTAB0UsX5vk0OmRsiRl3hqUuDwXjvcnqDQpjDL8rJPQK5NKK0ckCug
 WUI=
X-SBRS: 5.1
X-MesageID: 38989243
X-Ironport-Server: esa1.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="38989243"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENIFACE] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:15:25 +0000
Message-ID: <20210305101525.706887-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 111 insertions(+), 4 deletions(-)

diff --git a/build.ps1 b/build.ps1
index 4714591..89dc12d 100644
--- a/build.ps1
+++ b/build.ps1
@@ -6,6 +6,7 @@ param(
 	[Parameter(Mandatory = $true)]
 	[string]$Type,
 	[string]$Arch,
+	[switch]$CodeQL,
 	[switch]$Sdv
 )
 
@@ -51,6 +52,21 @@ Function SdvBuild {
 	& ".\msbuild.ps1" @params
 }
 
+function CodeQLBuild {
+	$visualstudioversion = $Env:VisualStudioVersion
+	$solutiondir = @{ "14.0" = "vs2015"; "15.0" = "vs2017"; "16.0" = "vs2019"; }
+	$configurationbase = @{ "14.0" = "Windows 10"; "15.0" = "Windows 10"; "16.0" = "Windows 10"; }
+	$arch = "x64"
+
+	$params = @{
+		SolutionDir = $solutiondir[$visualstudioversion];
+		ConfigurationBase = $configurationbase[$visualstudioversion];
+		Arch = $arch;
+		Type = "codeql"
+		}
+	& ".\msbuild.ps1" @params
+}
+
 if ($Type -ne "free" -and $Type -ne "checked") {
 	Write-Host "Invalid Type"
 	Exit -1
@@ -103,6 +119,10 @@ if ([string]::IsNullOrEmpty($Arch) -or $Arch -eq "x64") {
 	Build "x64" $Type
 }
 
+if ($CodeQL) {
+	CodeQLBuild
+}
+
 if ($Sdv) {
 	SdvBuild
 }
diff --git a/msbuild.ps1 b/msbuild.ps1
index dadf127..5234339 100644
--- a/msbuild.ps1
+++ b/msbuild.ps1
@@ -66,15 +66,82 @@ Function Run-MSBuildSDV {
 
 	Set-Location $basepath
 }
+ 
+Function Run-CodeQL {
+	param(
+		[string]$SolutionPath,
+		[string]$Name,
+		[string]$Configuration,
+		[string]$Platform,
+		[string]$SearchPath,
+		[string]$OutputPath
+	)
+
+	$projpath = Resolve-Path (Join-Path $SolutionPath $Name)
+	$project = [string]::Format("{0}.vcxproj", $Name)
+	$output = [string]::Format("{0}.sarif", $Name)
+	$database = Join-Path "database" $Name
+
+	# write a bat file to wrap msbuild parameters
+	$bat = [string]::Format("{0}.bat", $Name)
+	if (Test-Path $bat) {
+		Remove-Item $bat
+	}
+	$a = "msbuild.exe"
+	$a += " /m:4"
+	$a += " /t:Build"
+	$a += [string]::Format(" /p:Configuration=""{0}""", $Configuration)
+	$a += [string]::Format(" /p:Platform=""{0}""", $Platform)
+	$a += " "
+	$a += Join-Path $projpath $project
+	$a | Set-Content $bat
+
+	# generate the database
+	$b = "codeql"
+	$b += " database"
+	$b += " create"
+	$b += " -l=cpp"
+	$b += " -s=src"
+	$b += " -c"
+	$b += ' "' + (Resolve-Path $bat) + '" '
+	$b += $database
+	Invoke-Expression $b
+	if ($LASTEXITCODE -ne 0) {
+		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
+		Exit $LASTEXITCODE
+	}
+	Remove-Item $bat
+
+	# perform the analysis on the database
+	$c = "codeql"
+	$c += " database"
+	$c += " analyze "
+	$c += $database
+	$c += " windows_driver_recommended.qls"
+	$c += " --format=sarifv2.1.0"
+	$c += " --output="
+	$c += (Join-Path $OutputPath $output)
+	$c += " --search-path="
+	$c += $SearchPath
+
+	Invoke-Expression $c
+	if ($LASTEXITCODE -ne 0) {
+		Write-Host -ForegroundColor Red "ERROR: CodeQL failed, code:" $LASTEXITCODE
+		Exit $LASTEXITCODE
+	}
+}
 
 #
 # Script Body
 #
 
-$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; }
+$configuration = @{ "free" = "$ConfigurationBase Release"; "checked" = "$ConfigurationBase Debug"; "sdv" = "$ConfigurationBase Release"; "codeql" = "$ConfigurationBase Release"; }
 $platform = @{ "x86" = "Win32"; "x64" = "x64" }
 $solutionpath = Resolve-Path $SolutionDir
 
+$archivepath = "xeniface"
+$projectlist = @( "xeniface" )
+
 Set-ExecutionPolicy -Scope CurrentUser -Force Bypass
 
 if ($Type -eq "free") {
@@ -83,14 +150,34 @@ if ($Type -eq "free") {
 elseif ($Type -eq "checked") {
 	Run-MSBuild $solutionpath "xeniface.sln" $configuration["checked"] $platform[$Arch]
 }
-elseif ($Type -eq "sdv") {
-	$archivepath = "xeniface"
+elseif ($Type -eq "codeql") {
+	if (-Not (Test-Path -Path $archivepath)) {
+		New-Item -Name $archivepath -ItemType Directory | Out-Null
+	}
 
+	if ([string]::IsNullOrEmpty($Env:CODEQL_QUERY_SUITE)) {
+		$searchpath = Resolve-Path ".."
+	} else {
+		$searchpath = $Env:CODEQL_QUERY_SUITE
+	}
+
+	if (Test-Path "database") {
+		Remove-Item -Recurse -Force "database"
+	}
+	New-Item -ItemType Directory "database" | Out-Null
+
+	$projectlist | ForEach {
+		Run-CodeQL $solutionpath $_ $configuration["codeql"] $platform[$Arch] $searchpath $archivepath
+	}
+}
+elseif ($Type -eq "sdv") {
 	if (-Not (Test-Path -Path $archivepath)) {
 		New-Item -Name $archivepath -ItemType Directory | Out-Null
 	}
 
-	Run-MSBuildSDV $solutionpath "xeniface" $configuration["sdv"] $platform[$Arch]
+	$projectlist | ForEach {
+		Run-MSBuildSDV $solutionpath $_ $configuration["sdv"] $platform[$Arch]
+	}
 
 	Copy-Item -Path (Join-Path -Path $SolutionPath -ChildPath "*DVL*") -Destination $archivepath
 }
-- 
2.30.1.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:16:22 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:16:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93571.176531 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7VO-0003L8-FI; Fri, 05 Mar 2021 10:16:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93571.176531; Fri, 05 Mar 2021 10:16:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7VO-0003L1-CK; Fri, 05 Mar 2021 10:16:22 +0000
Received: by outflank-mailman (input) for mailman id 93571;
 Fri, 05 Mar 2021 10:16:21 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7VN-0003Kr-5V
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:16:21 +0000
Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id dd4f2cf9-e615-4c24-ad67-66eabefed795;
 Fri, 05 Mar 2021 10:16:18 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: dd4f2cf9-e615-4c24-ad67-66eabefed795
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614939378;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=1QfZVjShw3810nWFZ6VZ3DOqi6/yqgjR4D59HfiLcz4=;
  b=h97FC0M/uZ96Gdso/0kMo3TI5mAajgH28PxYT/42Q0raUNJp3ymS5/jw
   bJ2OT+dIT9eOk4Yb9TW6RykB7xoXpYmU8Qpk04ng4kzH5iUGpBbhezObP
   V8r4fQVUBpfQ4tJfGCTQvFeePgF9VVz5GYuqrnB2d/4EVxWaheAARvKMS
   w=;
Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 3G8KqCC3Sy53NJowd3VqB5Z+MXCgFQePt1Kqdj+8VhBa2rvbfG5gesL9Ylrw+E6n9HcVU2NEe5
 YfNZ9+Tlt8j/lI6ZuJV/z1XIWM6WrA1K8EuwWUa09QKDOx3n+QtK3fYMbFo26xJlmFNyZ4u2Jz
 ze3UFRkg0HWiLyN9E7El6HO8CTLtVM1QTn3k1cbs85S9hBBvWZdL6Gtl9TlhfM30/lOugyiJjH
 +RGjb15/iSdLMrwT6/H11OdeXcVf9b4UPvHgIABUc67CU1Oz4eTQ0NM+CTIRWlpa/l3bnDzzp8
 ymQ=
X-SBRS: 5.1
X-MesageID: 40031310
X-Ironport-Server: esa4.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="40031310"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENCONS] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:14:18 +0000
Message-ID: <20210305101418.706772-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 111 insertions(+), 4 deletions(-)

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



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:16:31 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:16:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93573.176534 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7VX-0003MI-Gv; Fri, 05 Mar 2021 10:16:31 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93573.176534; Fri, 05 Mar 2021 10:16:31 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7VX-0003MB-E0; Fri, 05 Mar 2021 10:16:31 +0000
Received: by outflank-mailman (input) for mailman id 93573;
 Fri, 05 Mar 2021 10:16:30 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7VW-0003M2-84
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:16:30 +0000
Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 71883017-f882-49ff-b9ad-9ab4dc71656f;
 Fri, 05 Mar 2021 10:16:28 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 71883017-f882-49ff-b9ad-9ab4dc71656f
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614939388;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=zOGFE4dSeINu61x/vwKIdUTmfFYxM9ddGz9lXboYXDA=;
  b=AmVFadtB0vdebSpvGLegrxil0fsiyemZbNk7fxqd3jbNtiMmqh7O+i9a
   JNDOhGHLjaWJOVXkls3CJA/DutzFGwBotEZEPhAn64p+N19FQsCNIB8Xr
   SdL+3aUPK+4rDSbeH7ZmHOyTgjb433qajTXP3SypqJZPTL49dlRA5l2D+
   o=;
Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 28x3b2VDWkAyS5VIbELYBfa/MysyKWma7XSC+Qx4eVpz+qWjdc+6GAg06opb/qgHDbNQ4jmlDO
 MFnZpc3HqbveXlodmORCbqgfZYheERODP3Lit004YwjfrkdIS5JsMZZYmfy3Sjekeot6zljU6W
 SEzl//b34l8ZT+rLJylRvy0ZYqpla4YqTQy9ekjPJCyXuz/5BRenTU/f+vawp9mY+CPXGOWp27
 I4chbMcRwDPE8soKiGCjsXUPJmvk1iF0ORNMYXsRsJJSMz5tsZGm6GyvuacmwNKDS+NlOeTEvd
 xqg=
X-SBRS: 5.1
X-MesageID: 40031319
X-Ironport-Server: esa4.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="40031319"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENVBD] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:16:05 +0000
Message-ID: <20210305101605.706977-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 111 insertions(+), 6 deletions(-)

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



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:16:49 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:16:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93579.176538 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7Vp-0003Oi-J1; Fri, 05 Mar 2021 10:16:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93579.176538; Fri, 05 Mar 2021 10:16:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7Vp-0003Ob-Fz; Fri, 05 Mar 2021 10:16:49 +0000
Received: by outflank-mailman (input) for mailman id 93579;
 Fri, 05 Mar 2021 10:16:48 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7Vo-0003OP-Mt
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:16:48 +0000
Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 5d3d01c0-f1c8-4f46-9492-22cc87e16df5;
 Fri, 05 Mar 2021 10:16:47 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 5d3d01c0-f1c8-4f46-9492-22cc87e16df5
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614939406;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=sZba48LP7BXRnJR2H8V6VOPYgxsYKBM/A8n/0rWYpcM=;
  b=Ba2Mofw2gw7VqLS8y4CZcIdHYNfC0dn7gGe/ZYjZ/PaI1onxmYEHIS9M
   sPxkavu/rvyA+Do+yKebcOsU1gWo3uTTs3k7gyk6MxlEdNclGtDvlr9Jw
   HfByz4rd8v99+0L3pL+q2CVb2QfgIe+aiUtkxBogH/9NZThnePgEhYCSP
   A=;
Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 72Mu1T93AsPvoII7y8QY//cHX3vU7yywsLeOFzZj9bvkn74mEGxs4odTMbmTVSdZcwT9SxIm/d
 hB1ziwezGTCrI21A8YJOHp+mY1gkrkn4D2cnirrK0wTeYqHJXCdYwzB53DUWWt/GlfIH1UmmdW
 dkZWRd6NZ3L6ZSIxDKz9bmJvtUoDYcn9+gu4tIrY1actrwv52Vphg3prsvDSyR4s1jQ2i24wGp
 rlJgE/J5qvRsLB33j+fZQLkWjgksM+acv24OujdCNjDha2Kf3XUxb/RoVV8TsT5FmXecu4UcV8
 CP8=
X-SBRS: 5.1
X-MesageID: 38807302
X-Ironport-Server: esa6.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="38807302"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENVIF] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:16:20 +0000
Message-ID: <20210305101620.707051-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 111 insertions(+), 4 deletions(-)

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



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:29:38 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:29:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93603.176555 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7iD-0004cn-QB; Fri, 05 Mar 2021 10:29:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93603.176555; Fri, 05 Mar 2021 10:29:37 +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 1lI7iD-0004cf-N4; Fri, 05 Mar 2021 10:29:37 +0000
Received: by outflank-mailman (input) for mailman id 93603;
 Fri, 05 Mar 2021 10:29:35 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7iB-0004cU-QT
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:29:35 +0000
Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 7454710e-2b06-415d-b1d5-19f0d461e066;
 Fri, 05 Mar 2021 10:29:34 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7454710e-2b06-415d-b1d5-19f0d461e066
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614940174;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=6QcJ9eZ++DpoeSRt/k7ZeWuQNxF4VryEaexne8WGJZs=;
  b=KFuVCqeOiA2TEftZxdjtp41vf9/b+/I3IkzCsvnAW/m1b4h40eskfRnJ
   AgqnQwynAZXRq2aTZxiwds21hWJk0bWrsca1GL8Mx0uclSjW0rsZDP2VY
   yZ8tBnHgtR44GFX/OYDhHA/6a63gcruLH/ZO8lU8JZe/rjABePHhFgRhH
   M=;
Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: uBmPG3j64EqbGBki2DiPLUhhTXO0iCoVQKRVE/qWjb1bWz9WzxUm8GW8yaKTM+DAn7Iln3K0g7
 Bsuwf2qrLLuIkXx0vj6m5ylWiD3toAUtZsl30GB+Q4jAEJqYxbBM1lm+BZQY6eOCZGCbLydZuI
 S8F1sycIlN2qTq8rrtQp1xEX7u0Enz7C4hFU7MgYW6htfDhk6KprSWgFOOnQBV4/CgAB/EVfIZ
 O1Og5E1uhAVkHbDxWHoF6lvqt5wI2ZH6MpKFaHnrCS6SQmEfdEbzeLBsakaJGbxACwYAGAP98A
 MTs=
X-SBRS: 5.1
X-MesageID: 38615634
X-Ironport-Server: esa3.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="38615634"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENNET] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:15:49 +0000
Message-ID: <20210305101549.706932-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 111 insertions(+), 4 deletions(-)

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



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:30:58 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:30:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93609.176559 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7jV-0005M5-UX; Fri, 05 Mar 2021 10:30:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93609.176559; Fri, 05 Mar 2021 10:30:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7jV-0005Ly-RY; Fri, 05 Mar 2021 10:30:57 +0000
Received: by outflank-mailman (input) for mailman id 93609;
 Fri, 05 Mar 2021 10:30:56 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7jU-0005Lt-Hg
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:30:56 +0000
Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 7100f26b-99ed-4adb-8932-dec383eeef88;
 Fri, 05 Mar 2021 10:30:55 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 7100f26b-99ed-4adb-8932-dec383eeef88
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614940254;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=WfqyiP42qoR0EU49qLV95tP/Ii0P+DhhKn8i2bhaKxY=;
  b=UMwF3L7K0faVn5OfKsa541iUIfLPq9K8WEa459F33pPZ309VQFGEKDC2
   Q0dz8pS7SoqeqClW/InaMfQtpG88ruTsnq4gJegCGq7WPCJEPGR2N94hK
   m4TM0UcXgLl4GWDeXGvSutwxJ6AMbWpUeSqZtbjUzOHR57c45GS2+wSs2
   4=;
Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: 03RuuvXKqVrVoGJ6haXGNG0wty9FTn7j4uSv0e4a8jb0ZRaiITrZVsb5gDgy87FD8yx2/0vOUi
 D3lQoH3W/SdarPoNNKmooVcDGosnX52dNNNWrEx60la0sD8GyU6Pliz3Xb3i1TZ5U5GhQSiUXT
 Ryb/ny2znVTTTIqK142B6p1tT+JuyHNGgxEZ0lbeRgKWKZnC7zx8p2gPgnF6QxrNvYVtX9hSLh
 WqhRxNSpl+WWLuqGNvvhjuwcL337KskwSCnu4ijSEhjiM+DTslSMSM1hYzB8srHL+b5aXeszHC
 ank=
X-SBRS: 5.1
X-MesageID: 40031970
X-Ironport-Server: esa4.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="40031970"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENHID] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:26:49 +0000
Message-ID: <20210305102649.712696-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 111 insertions(+), 4 deletions(-)

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



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 05 10:39:17 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 05 Mar 2021 10:39:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.93618.176575 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lI7rY-0005iV-S0; Fri, 05 Mar 2021 10:39:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 93618.176575; Fri, 05 Mar 2021 10:39: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 1lI7rY-0005iL-Ob; Fri, 05 Mar 2021 10:39:16 +0000
Received: by outflank-mailman (input) for mailman id 93618;
 Fri, 05 Mar 2021 10:39:15 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=1jr2=ID=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lI7rX-0005iG-LO
 for win-pv-devel@lists.xenproject.org; Fri, 05 Mar 2021 10:39:15 +0000
Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 6b0b55df-8b28-4b2a-b063-da1239d51e52;
 Fri, 05 Mar 2021 10:39:15 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 6b0b55df-8b28-4b2a-b063-da1239d51e52
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1614940755;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=vwlV5oGpE8OvmTQ+8PJAAX30iI/ipM5c14v4TMEBDag=;
  b=TXxLYveWCknXeks4NDYPWJCFXRaHaMN65ECs4PO/0lmMRdMUZqZFjiCe
   yudS+o1c0IwJTbNijkE3YKxWx7rHPmGnpGHEx6OBWsmk28KSVmaDFFW73
   jcrp6P5Glasi1siuqnO9HuvnyiUoRqNzz5xsbfuo7HLyXuJdO514uVlVt
   Y=;
Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: x/BqB7lZdrBiez4n5S3YAMuBin9LdeI2tMfpaJAvHTl7YYf1XXXHhckFj3yJQ6nF7t+gv+i/Ol
 uapJP+zCQn/HgK+HKu45FaFRuY0WPWvOzFHYvXo+C8Qhbm5vzonhXi9XcUOLuDWd8qp0w1AdAN
 Nrh34dnebeVdFjr1x/n2JCCU1/gTusdkPJTL/zA+QFuJHWwd5DNF1RM6xuMtMbQmbgj27yRqBm
 EBF69KkZRayiG00tICr8rYigX85ER+9HhPydgXv3jMMe8gQ3o6U59lcKMsQ+bq8fS0h804EB8f
 e+Y=
X-SBRS: 5.1
X-MesageID: 38808213
X-Ironport-Server: esa6.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
X-IronPort-AV: E=Sophos;i="5.81,224,1610427600"; 
   d="scan'208";a="38808213"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH-XENVKBD] Add CodeQL build stage
Date: Fri, 5 Mar 2021 10:36:03 +0000
Message-ID: <20210305103603.714120-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

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

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 build.ps1   | 20 +++++++++++
 msbuild.ps1 | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 111 insertions(+), 4 deletions(-)

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



From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 13:51:55 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 13:51:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95028.180240 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJcm9-00069b-Mp; Tue, 09 Mar 2021 13:51:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95028.180240; Tue, 09 Mar 2021 13:51:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJcm9-00069T-Jj; Tue, 09 Mar 2021 13:51:53 +0000
Received: by outflank-mailman (input) for mailman id 95028;
 Mon, 08 Mar 2021 16:47:56 +0000
Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]
 helo=us1-amaz-eas2.inumbo.com)
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <SRS0=gC/1=IG=pm.me=connojd@srs-us1.protection.inumbo.net>)
 id 1lJJ2x-0007jb-KD
 for win-pv-devel@lists.xenproject.org; Mon, 08 Mar 2021 16:47:56 +0000
Received: from mail-40134.protonmail.ch (unknown [185.70.40.134])
 by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS
 id 9b5b730b-edcb-471f-8cd7-e30337499c15;
 Mon, 08 Mar 2021 16:47:53 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 9b5b730b-edcb-471f-8cd7-e30337499c15
Date: Mon, 08 Mar 2021 16:47:48 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail;
	t=1615222072; bh=eqv9xNOUAou5Aors3JalxD79o7RcIuNOaDtsAQBNSvQ=;
	h=Date:To:From:Reply-To:Subject:From;
	b=dhCvD+FO7kLxF96/YjCqeanz1r7ODhGhSMQYLDkUuDsPNl2T9oWc8ORauUwLZ5c77
	 KhD8Awh10XcPtgATkSkuVuYvLi6hP3wH8dwGIPcObUVOab8DUadOtus0sIjY06Mj+F
	 RwMBQq3waPG2TZ7pXiVJFYc+2tP0IERhRhe8p8+Jg1It6AaWUZFIBrxNK4kOzy3HY/
	 5kHUSfYNvxKDZqiimIUM+T8UCCRX10qrVNdm6rIaALQqs3LG8FeK9ijL0R2AOvOl4C
	 vdL65fhUfLsgkqYdtlfLiNMKEZYDtH7UEKrXhlJsVFo/cW1hht4PxTQOpGk1VdqLLc
	 G/P0Sccci2uPg==
To: "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
From: Connor Davis <connojd@pm.me>
Reply-To: Connor Davis <connojd@pm.me>
Subject: Device ID for PCI platform
Message-ID: <FrRGQU4Qv35OSpJ6veCjcl0RHu2l7CzO0NqDFXv-IvzdjBx10Y79j9xJb5LRZFHX3kD_wiLSy_S3ds1KHe5J_ZvmiQwRONsOMDmivQKas5g=@pm.me>
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="b1_PPZ9OGaUCK6TH39hJzBHLpxlBz991Xb1tBUoDnigRhc"
X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE shortcircuit=no
	autolearn=disabled version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
	mailout.protonmail.ch

This is a multi-part message in MIME format.

--b1_PPZ9OGaUCK6TH39hJzBHLpxlBz991Xb1tBUoDnigRhc
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64

SGkgYWxsLAoKQUlTIGlzIHdvcmtpbmcgb24gZ2V0dGluZyBtb2RpZmllZCB3aW5wdiBkcml2ZXJz
IHNpZ25lZC4gVG8gdGhpcyBwb2ludCB3ZSd2ZSBiZWVuIHVzaW5nIGRldmljZSBJRCAwMDAxIGZv
ciB0aGUgcGxhdGZvcm0gZGV2aWNlLCBidXQgSSB0aGluayBpdCBpcyBiZXN0IHRvIHVzZSBhIGRp
ZmZlcmVudCBvbmUgc28gbm8gdW53YW50ZWQgY29sbGlzaW9ucyBvY2N1ciBvbiB3aW5kb3dzIHVw
ZGF0ZS4gV2hhdCBpcyB0aGUgcHJvY2VzcyBmb3IgbmV3IGRldmljZSBJRCBhc3NpZ25tZW50PwoK
QlRXLCB0aGUgY29kZSB3YXMgcmVjZW50bHkgb3BlbiBzb3VyY2VkIGZvciBvdXIgV2luZG93cyBk
b20wIHJlc2VhcmNoLiBUaGUgZHJpdmVycyBhcmUgbG9jYXRlZCBoZXJlWzBdIGluIGNhc2UgeW91
IHdhbnQgdG8gcGVlayBhdCBpdC4KClRoYW5rcywKQ29ubm9yCgpbMF0gaHR0cHM6Ly9naXRodWIu
Y29tL0JhcmVmbGFuay9NaWNyb1YvdHJlZS9tb25vL2RyaXZlcnMvd2lucHY=

--b1_PPZ9OGaUCK6TH39hJzBHLpxlBz991Xb1tBUoDnigRhc
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64

SGkgYWxsLDxicj48YnI+QUlTIGlzIHdvcmtpbmcgb24gZ2V0dGluZyBtb2RpZmllZCB3aW5wdiBk
cml2ZXJzIHNpZ25lZC4gVG8gdGhpcyBwb2ludCB3ZSd2ZSBiZWVuIHVzaW5nIGRldmljZSBJRCAw
MDAxIGZvciB0aGUgcGxhdGZvcm0gZGV2aWNlLCBidXQgSSB0aGluayBpdCBpcyBiZXN0IHRvIHVz
ZSBhIGRpZmZlcmVudCBvbmUgc28gbm8gdW53YW50ZWQgY29sbGlzaW9ucyBvY2N1ciBvbiB3aW5k
b3dzIHVwZGF0ZS4gV2hhdCBpcyB0aGUgcHJvY2VzcyBmb3IgbmV3IGRldmljZSBJRCBhc3NpZ25t
ZW50Pzxicj48YnI+QlRXLCB0aGUgY29kZSB3YXMgcmVjZW50bHkgb3BlbiBzb3VyY2VkIGZvciBv
dXIgV2luZG93cyBkb20wIHJlc2VhcmNoLiBUaGUgZHJpdmVycyBhcmUgbG9jYXRlZCBoZXJlWzBd
IGluIGNhc2UgeW91IHdhbnQgdG8gcGVlayBhdCBpdC48YnI+PGJyPlRoYW5rcyw8YnI+Q29ubm9y
PGJyPjxicj5bMF0gPGEgaHJlZj0iaHR0cHM6Ly9naXRodWIuY29tL0JhcmVmbGFuay9NaWNyb1Yv
dHJlZS9tb25vL2RyaXZlcnMvd2lucHYiPmh0dHBzOi8vZ2l0aHViLmNvbS9CYXJlZmxhbmsvTWlj
cm9WL3RyZWUvbW9uby9kcml2ZXJzL3dpbnB2PC9hPiA8YnI+PGJyPjxicj4=


--b1_PPZ9OGaUCK6TH39hJzBHLpxlBz991Xb1tBUoDnigRhc--



From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 14:28:43 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 14:28:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95494.180304 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJdLm-0001Dh-Na; Tue, 09 Mar 2021 14:28:42 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95494.180304; Tue, 09 Mar 2021 14:28:42 +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 1lJdLm-0001Da-Kc; Tue, 09 Mar 2021 14:28:42 +0000
Received: by outflank-mailman (input) for mailman id 95494;
 Tue, 09 Mar 2021 14:28:41 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=lWBa=IH=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lJdLl-0001DV-5i
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 14:28:41 +0000
Received: from mail-wr1-x42b.google.com (unknown [2a00:1450:4864:20::42b])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 5b832abe-97ef-4b67-9aaa-49c3a5a6b778;
 Tue, 09 Mar 2021 14:28:40 +0000 (UTC)
Received: by mail-wr1-x42b.google.com with SMTP id j2so15982241wrx.9
 for <win-pv-devel@lists.xenproject.org>; Tue, 09 Mar 2021 06:28:40 -0800 (PST)
Received: from [192.168.1.186]
 (host86-180-176-157.range86-180.btcentralplus.com. [86.180.176.157])
 by smtp.gmail.com with ESMTPSA id m11sm24274558wrz.40.2021.03.09.06.28.38
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 09 Mar 2021 06:28:39 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 5b832abe-97ef-4b67-9aaa-49c3a5a6b778
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=zh+NazKXJVISCcb0i9GVVa5BiOCOdQAITcXH3LVwhxw=;
        b=NH28f0aGOvXD1ud3hCFvorD8M8U1iQioQ8PJw4RVkkhty3P85EoYou0KDDQUY7463u
         erACW3EvQ6h+fS9pf0ViNRd5jQVuIUoq34WQmp5MoiLKS7bzTu2908JfdvQwvJvKb7VV
         SQG+Y7CfmitDZGi+iH2qchNBDK74MhWauyrmJOw/VcpoeffPbj7ILgUjLd6igtcwhrHq
         TAT0u14WzvC5VzXfIVchTk4eFocwzjPtJVmQFTeW/CwLP/Ankij8GatGvAirGs4eBZWA
         oIutLNwwFPc9jq3/LpFAuRORG5fJW0rRvFkKmEyBGEmVB7txhWvFBkSujm4dAWcqxdJU
         5HZQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=zh+NazKXJVISCcb0i9GVVa5BiOCOdQAITcXH3LVwhxw=;
        b=piSj/F3fmWv1h2E+37wnzsrw4UlT28umA4K/P0/kDNZiKRoDRV2bBSMh83SrZ1yzfe
         +UCbZuuHwDlsGq5qyROYPGRtdrRYDqxXE51SPe718G6frmIefuYz7euCwbOyWy+ddhfH
         PvS1IXFw1JwImqJhl9uo5B8bSvI8HODPr3okKStwtEBi142l0qMpicIHBrQ5QnfH542q
         L0j/JpqERJye4fJiEhnveFkbBvWE7p6BwYoIFEhg2jb05QCGR3hC2h+fnfXVQQvzK+6h
         LeHi7dq9Ttfn0i0p+gYi0vIwdbpmVj5/76bw5ATtI27HvJYfEcfKOxnadgU5EnnmQFwp
         LO0w==
X-Gm-Message-State: AOAM531ytHNy1gBvhM7KppBmMx6WFF0fhP1s2fBj6G9i0nd8vGHJT9pM
	50NsKvBvXY7mEykQfFo997GedC/G3Ck=
X-Google-Smtp-Source: ABdhPJyGgZOx15m98jR6C8ZkBViikFnDsIhsVB5+R4jFl6z4oFVn7DTWflpausqGOMX/GJaAFwCojw==
X-Received: by 2002:adf:f150:: with SMTP id y16mr28463717wro.414.1615300119429;
        Tue, 09 Mar 2021 06:28:39 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: Device ID for PCI platform
To: win-pv-devel@lists.xenproject.org
References: <FrRGQU4Qv35OSpJ6veCjcl0RHu2l7CzO0NqDFXv-IvzdjBx10Y79j9xJb5LRZFHX3kD_wiLSy_S3ds1KHe5J_ZvmiQwRONsOMDmivQKas5g=@pm.me>
Message-ID: <eed0dd3d-ca01-7c48-0aaf-900137a90065@xen.org>
Date: Tue, 9 Mar 2021 14:28:38 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.8.0
MIME-Version: 1.0
In-Reply-To: <FrRGQU4Qv35OSpJ6veCjcl0RHu2l7CzO0NqDFXv-IvzdjBx10Y79j9xJb5LRZFHX3kD_wiLSy_S3ds1KHe5J_ZvmiQwRONsOMDmivQKas5g=@pm.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 08/03/2021 16:47, Connor Davis wrote:
> Hi all,
> 
> AIS is working on getting modified winpv drivers signed. To this point 
> we've been using device ID 0001 for the platform device, but I think it 
> is best to use a different one so no unwanted collisions occur on 
> windows update. What is the process for new device ID assignment?

Hi Connor,

   You need to send a patch to 
docs/man/xen-pci-device-reservations.7.pod in xen.git, so git send-email 
to xen-devel. In that file you'll see there are PCI device id ranges 
reserved for various purposes. I suspect you'll want to grab c300 - c3ff 
for AIS.

   BTW, in case you don't know, the correct thing to do to expose a 
device with your reserved id to the guest is to add a 'xen-pvdevice' to 
your guest:

root@debian:~# /usr/local/lib/xen/bin/qemu-system-i386 -device 
xen-pvdevice,help
xen-pvdevice options:
   addr=<int32>           - Slot and optional function number, example: 
06.0 or 06 (default: -1)
   device-id=<uint16>     -  (default: 65535)

   Paul


> 
> BTW, the code was recently open sourced for our Windows dom0 research. 
> The drivers are located here[0] in case you want to peek at it.
> 
> Thanks,
> Connor
> 
> [0] https://github.com/Bareflank/MicroV/tree/mono/drivers/winpv 
> <https://github.com/Bareflank/MicroV/tree/mono/drivers/winpv>
> 
> 



From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 15:30:01 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 15:30:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95575.180490 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJeJ5-0008Of-Sc; Tue, 09 Mar 2021 15:29:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95575.180490; Tue, 09 Mar 2021 15:29:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJeJ5-0008OY-Pc; Tue, 09 Mar 2021 15:29:59 +0000
Received: by outflank-mailman (input) for mailman id 95575;
 Tue, 09 Mar 2021 15:29:58 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=lWBa=IH=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lJeJ4-0008OT-Rq
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 15:29:58 +0000
Received: from mail-wm1-x329.google.com (unknown [2a00:1450:4864:20::329])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id f0590529-4757-4c75-be6d-5c1b7362020d;
 Tue, 09 Mar 2021 15:29:57 +0000 (UTC)
Received: by mail-wm1-x329.google.com with SMTP id
 m20-20020a7bcb940000b029010cab7e5a9fso6680296wmi.3
 for <win-pv-devel@lists.xenproject.org>; Tue, 09 Mar 2021 07:29:57 -0800 (PST)
Received: from [192.168.1.186]
 (host86-180-176-157.range86-180.btcentralplus.com. [86.180.176.157])
 by smtp.gmail.com with ESMTPSA id p14sm4491413wmc.30.2021.03.09.07.29.56
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 09 Mar 2021 07:29:56 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: f0590529-4757-4c75-be6d-5c1b7362020d
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=b+wbb4u6V0wKluaiKWJ0IkdIWkFUc9manIMg14oJWAA=;
        b=rqPfiUVQuo7Hyhl6Mt015ZYs48UaL/J9QlfVOSpVpQM+/mqmlhlKsEGoYsgDs1RtPL
         XEfGyhRWPaPyzI5fFRu2RsJKnS/osFKXiljA+LZz33FIoERw7turpT8pB5QB+Jzv/FYu
         yb4TFI9iQUoRZ7yfvJPucxnerIF1jdLKuNPv86vCFJfiO0K7XDmLplyMyMDUDhzYloyR
         URY8jUcARs93T8HDEiIVWzQFANu2cwNnh8wsPA/cXjl8yELWP4oFIO8YXzUmcWFpE9+o
         M1VouY6nyQC3MhBbXQ1aGckLX0Hw7GhzSO92cmdrPGVbrCZ6OOv2XAFScuOOWX44xa6d
         eJBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=b+wbb4u6V0wKluaiKWJ0IkdIWkFUc9manIMg14oJWAA=;
        b=DcJ5QHribmkFLZaIHBBvasfhtD0DF3pkhXJ4E/NxdqZwmsFbmJI3zwkjaOHUgTIEI7
         s0ZDZWi4PeVsztOzSyB0ax+dlTIj2aEUyIfhtukIDXwCi3t5KLkHDLFQkN8897n2F4qX
         A/2xMEisvaUPFaCuVHiXkEdB7+QeZavJum89tzuahM2sUhXGFL0NXot5unr8iIXF9as0
         stLtduLBK+Kf0muxpHeoYIhG6aOct85Fim6j9T4NJRAUquNQKlCNTPrpyYkjNYLTkE0R
         919gsTXREWtHf4Bt7ka5MePQmKwCyXy/g3WWDlWNY4yB9cx83lJLPFrEzwzOa2EfXp4+
         ZsBQ==
X-Gm-Message-State: AOAM532syAgzrciBfr7s0Gkweq+S2cPkueD0ZYG2RFzzOVq59xaE52oX
	9H0CYkiBdCvd/tLuVbjuKOHCQYoqX2I=
X-Google-Smtp-Source: ABdhPJyW9x4KFbpC6P3Ww9zcKvkn1yw08B+qPtlaAeO5d87ullBCgupJPlZUZP5M7YZPNQq0zsTtgQ==
X-Received: by 2002:a05:600c:409:: with SMTP id q9mr4709394wmb.105.1615303796812;
        Tue, 09 Mar 2021 07:29:56 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [win-pv-devel] [PATCH xenbus 3/3] Stop using BAR space to host
 Xen data structures
To: win-pv-devel@lists.xenproject.org
References: <1517410750-4749-3-git-send-email-paul.durrant@citrix.com>
 <9363c50a-bccb-c9a2-3892-7134e0bfaeba@gmail.com>
Message-ID: <8065fbc8-b916-97b0-d873-4770a40c56e5@xen.org>
Date: Tue, 9 Mar 2021 15:29:55 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.8.0
MIME-Version: 1.0
In-Reply-To: <9363c50a-bccb-c9a2-3892-7134e0bfaeba@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 28/02/2021 17:31, Jinoh Kang wrote:
> On 1/31/18 2:59 PM, Paul Durrant wrote:
>> Currently XENBUS makes use of the memory BAR of the PCI device to which it
>> binds as a source of unpopulated GFNs to host Xen data structures, such as
>> the shared info and grant table.
>>
>> There is a problem with doing this, which is that Windows (unsurprisingly)
>> sets up a non-cached MTRR for the page range covering PCI BARs so accesses
>> to BAR space (and hence the Xen data structures) should be non-cached.
>> However, Xen itself contains a work-around to avoid the slow access times
>> that would ordinarily result from the this; it ignores the MTRRs if no
>> real devices are passed through to the guest so accesses are actually
>> cached. Thus, in the normal case, there is no penalty to pay... but as soon
>> as hardware is passed through to a guest, the work-around no longer applies
>> and there is a noticeable drop in PV driver performance. (E.g. network
>> throughput can drop by ~30-40%).
>>
>> This patch modifies XENBUS to allocate a 2MB area of RAM
> 
> Some time ago I have discovered that the PV driver fails with
> STATUS_INSUFFICIENT_RESOURCES if the grant table configured for the
> Windows HVM is larger than 2MB.
> 
> Perhaps it might be a good idea to let unpopulated GFNs to be allocated
> dynamically from FdoAllocateHole, possibly reviving the original purpose
> of range_set in the process.
> 
> Or at minimum, call GrantTableQuerySize early and take the
> MaximumFrameCount into account when allocating the initial "unpopulated"
> GFN range.
> 
>> (which will always fall into a cached MTRR),
> 
> Isn't MmAllocateContiguousNodeMemory expected to either return memory
> with correct cacheability or fail completely?  In the absence of
> PAGE_NOCACHE or PAGE_WRITECOMBINE flags, it makes sense for the caller
> to safely assume the allocated memory to be WB-cached.
> 

I'd assume that is the case, hence we now allocate memory that way and 
then decrease_reservation it out, to ensure we have a hole in a cached 
region.

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

Yes, we could conceivably grab memory a page at a time. Perhaps that 
would be the best way to go. We do take the hit of potentially 
shattering superpage mappings if we don't grab in 2M chunks though.

>> use a decrease_reservation hypercall to de-populate the area,
> 
> An alternative method would be to copy the unpopulated-alloc facility
> in Linux merged into mainline fairly recently (5.9), which avoids being
> entangled with ballooning entirely.
> 
> An obvious approach would be to have hotplug PDOs to convince the NT PnP
> manager to hand us cacheable memory resources.  Implementing it sounds
> pretty complicated, though.

Yep, I've wanted to sort out hotplug memory for a long time and that may 
well offer a way to get hold of suitable ranges.

   Paul

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



From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 15:32:37 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 15:32:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95581.180494 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJeLd-0000il-3o; Tue, 09 Mar 2021 15:32:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95581.180494; Tue, 09 Mar 2021 15:32:37 +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 1lJeLd-0000ie-0w; Tue, 09 Mar 2021 15:32:37 +0000
Received: by outflank-mailman (input) for mailman id 95581;
 Tue, 09 Mar 2021 15:32:36 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=lWBa=IH=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lJeLc-0000iZ-4m
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 15:32:36 +0000
Received: from mail-wr1-x436.google.com (unknown [2a00:1450:4864:20::436])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id bc842ac0-1de3-4596-870e-8c35e6eeade6;
 Tue, 09 Mar 2021 15:32:35 +0000 (UTC)
Received: by mail-wr1-x436.google.com with SMTP id v15so16473164wrx.4
 for <win-pv-devel@lists.xenproject.org>; Tue, 09 Mar 2021 07:32:35 -0800 (PST)
Received: from [192.168.1.186]
 (host86-180-176-157.range86-180.btcentralplus.com. [86.180.176.157])
 by smtp.gmail.com with ESMTPSA id f22sm4445934wmc.33.2021.03.09.07.32.33
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 09 Mar 2021 07:32:33 -0800 (PST)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: bc842ac0-1de3-4596-870e-8c35e6eeade6
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=7bLbtB/NBzS/FmsfSiXcpoUpnVRERIDSkUBKDxk4ZDw=;
        b=AyEJh7v2OxGas3/swPEpG/RSQw//Ff4QYu/JfYL2oK3oy4ZdQVy+W9tRlZQj/hN/Zr
         JAnSsr1fHFbZo3eHjRmsqFRE+8tC4pbF4GraRXqcmTZ8RhoqCn0/L98mbHBzGhUphidy
         9gzcfbj8prqEf2L/rY04D2Zjg4juurkUV0yZ3IHHBvvt12JffRrAFSxPYc391FUeLnSH
         FzeGAmVzU7HejX69IssNuC3hM1Oe+mDPE08X6NuHP6L8R5qf7orThs7vZUGTBm6NR/ih
         pR14ceRS+bFN3eKkKh8KR5SFzrgcRBurrPv9ponng9ZXHNHQ/ycuYNhu74d+SvNq0b2u
         ZOWQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=7bLbtB/NBzS/FmsfSiXcpoUpnVRERIDSkUBKDxk4ZDw=;
        b=Pwasrxl9kPf77I/DbAVvVb62EbvCxQedfag1jCZzI2fyJsx6x7PMH52hfne2LJjd/j
         s8F9oNKOGMrSDRCJsMTE7Lr+qC6O5pZdmOvZyoGcb/LgQ4xErFJjpaMZkwnelmNQ6bdX
         /znfxZn2Feo9zvsYQvZ0UR15S1Co9UDuFfExHnqBxeLngATiPWH3Ims+PAFpkvXoPXxN
         2cLSrPXRJdXwBIcfuSCBVxjQHTGEu3Ni4M30oTFKe0TXDJwYi4aq8fHbkgOcEZBh5YXT
         dA0MprRp2DG+UPr+F+0/tpToeBzw2pTkVIwrE0pPnILVqWJLVYv9COiifOGxLRJdtrv+
         vaDQ==
X-Gm-Message-State: AOAM532A8xKn1bMRDe+b6HBWyEMBHAZA6CGQ1XLuWaSjCRS5waYDqfDz
	dTyVAyxGSFmsah1CBORcWmFF8X+N8zI=
X-Google-Smtp-Source: ABdhPJzNQnwdf/Zuw/FNHoftc4XBQ3d1VMgOyeGaJEyQGY4EzdGNdvQziVjbycV6eK832Du50pYEKQ==
X-Received: by 2002:a5d:5051:: with SMTP id h17mr28604590wrt.80.1615303954342;
        Tue, 09 Mar 2021 07:32:34 -0800 (PST)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [PATCH-XENVKBD] Add CodeQL build stage
To: win-pv-devel@lists.xenproject.org
References: <20210305103603.714120-1-owen.smith@citrix.com>
Message-ID: <1d6619b3-c7f6-d228-b6d6-26524156689e@xen.org>
Date: Tue, 9 Mar 2021 15:32:33 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.8.0
MIME-Version: 1.0
In-Reply-To: <20210305103603.714120-1-owen.smith@citrix.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

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

This, and similar patches for the other drivers...

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

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



From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 18:30:45 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 18:30:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95688.180664 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJh7z-0001ii-I0; Tue, 09 Mar 2021 18:30:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95688.180664; Tue, 09 Mar 2021 18:30:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJh7z-0001ib-FE; Tue, 09 Mar 2021 18:30:43 +0000
Received: by outflank-mailman (input) for mailman id 95688;
 Tue, 09 Mar 2021 18:30:41 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJh7x-0001iW-O6
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 18:30:41 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 9 Mar 2021 18:30:21 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <33337717.1.1615314623906.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENHID-master - Build #27 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_Part_0_3838146.1615314622781"
X-Jenkins-Job: XENHID-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #27.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENHID-master/27/console to view the results.
------=_Part_0_3838146.1615314622781--


From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 18:53:46 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 18:53:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95698.180675 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJhUH-0003Z9-BW; Tue, 09 Mar 2021 18:53:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95698.180675; Tue, 09 Mar 2021 18:53:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJhUH-0003Z1-8O; Tue, 09 Mar 2021 18:53:45 +0000
Received: by outflank-mailman (input) for mailman id 95698;
 Tue, 09 Mar 2021 18:53:44 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJhUG-0003Yw-C6
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 18:53:44 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 9 Mar 2021 18:53:26 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <17641798.3.1615316006438.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENIFACE-master - Build #104 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_Part_2_1391453.1615316006266"
X-Jenkins-Job: XENIFACE-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #104.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENIFACE-master/104/console to view the results.
------=_Part_2_1391453.1615316006266--


From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 19:58:06 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 19:58:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95734.180727 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJiUW-00010U-3J; Tue, 09 Mar 2021 19:58:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95734.180727; Tue, 09 Mar 2021 19:58:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJiUV-00010M-W6; Tue, 09 Mar 2021 19:58:03 +0000
Received: by outflank-mailman (input) for mailman id 95734;
 Tue, 09 Mar 2021 19:58:03 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJiUV-00010H-7z
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 19:58:03 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 9 Mar 2021 19:57:45 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <8934490.5.1615319865346.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENCONS-master - Build #34 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_4_27643411.1615319865111"
X-Jenkins-Job: XENCONS-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #34.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENCONS-master/34/console to view the results.
------=_Part_4_27643411.1615319865111--


From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 20:19:26 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 20:19:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95755.180758 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJipB-00037R-4R; Tue, 09 Mar 2021 20:19:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95755.180758; Tue, 09 Mar 2021 20:19: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 1lJipB-00037K-1Z; Tue, 09 Mar 2021 20:19:25 +0000
Received: by outflank-mailman (input) for mailman id 95755;
 Tue, 09 Mar 2021 20:19:23 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJip9-00037F-BC
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 20:19:23 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 9 Mar 2021 20:19:05 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <25726185.7.1615321145456.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENNET-master - Build #114 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6_20142352.1615321145284"
X-Jenkins-Job: XENNET-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #114.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENNET-master/114/console to view the results.
------=_Part_6_20142352.1615321145284--


From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 21:08:19 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 21:08:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95775.180783 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJjaU-0007fr-2O; Tue, 09 Mar 2021 21:08:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95775.180783; Tue, 09 Mar 2021 21:08:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJjaT-0007fj-Vf; Tue, 09 Mar 2021 21:08:17 +0000
Received: by outflank-mailman (input) for mailman id 95775;
 Tue, 09 Mar 2021 21:08:16 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJjaS-0007fc-Cg
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 21:08:16 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 9 Mar 2021 21:07:58 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <8353681.9.1615324078520.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVBD-master - Build #153 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_8_14762483.1615324078442"
X-Jenkins-Job: XENVBD-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #153.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVBD-master/153/console to view the results.
------=_Part_8_14762483.1615324078442--


From win-pv-devel-bounces@lists.xenproject.org Tue Mar 09 21:46:12 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Tue, 09 Mar 2021 21:46:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95792.180811 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJkB9-0002sB-Bt; Tue, 09 Mar 2021 21:46:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95792.180811; Tue, 09 Mar 2021 21:46:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJkB9-0002s3-8p; Tue, 09 Mar 2021 21:46:11 +0000
Received: by outflank-mailman (input) for mailman id 95792;
 Tue, 09 Mar 2021 21:46:10 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJkB8-0002ry-GE
 for win-pv-devel@lists.xenproject.org; Tue, 09 Mar 2021 21:46:10 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Tue, 9 Mar 2021 21:45:52 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <28779313.11.1615326352646.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVKBD-master - Build #29 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_10_7505275.1615326352412"
X-Jenkins-Job: XENVKBD-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #29.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVKBD-master/29/console to view the results.
------=_Part_10_7505275.1615326352412--


From win-pv-devel-bounces@lists.xenproject.org Wed Mar 10 07:08:26 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 10 Mar 2021 07:08:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.95869.180992 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJsxE-0006VG-Ep; Wed, 10 Mar 2021 07:08:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 95869.180992; Wed, 10 Mar 2021 07:08:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lJsxE-0006V9-C7; Wed, 10 Mar 2021 07:08:24 +0000
Received: by outflank-mailman (input) for mailman id 95869;
 Wed, 10 Mar 2021 07:08:23 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lJsxD-0006V4-I0
 for win-pv-devel@lists.xenproject.org; Wed, 10 Mar 2021 07:08:23 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Wed, 10 Mar 2021 07:08:05 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <2119961.13.1615360086007.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVIF-master - Build #185 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_12_11282902.1615360085663"
X-Jenkins-Job: XENVIF-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #185.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVIF-master/185/console to view the results.
------=_Part_12_11282902.1615360085663--


From win-pv-devel-bounces@lists.xenproject.org Wed Mar 10 16:53:31 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Wed, 10 Mar 2021 16:53:31 +0000
Received: from list by lists.xenproject.org with outflank-mailman.96233.181901 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lK25R-0000uT-Qi; Wed, 10 Mar 2021 16:53:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 96233.181901; Wed, 10 Mar 2021 16:53: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 1lK25R-0000uM-Nx; Wed, 10 Mar 2021 16:53:29 +0000
Received: by outflank-mailman (input) for mailman id 96233;
 Wed, 10 Mar 2021 16:53:28 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lK25Q-0000uH-SB
 for win-pv-devel@lists.xenproject.org; Wed, 10 Mar 2021 16:53:28 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Wed, 10 Mar 2021 16:53:11 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <10748094.15.1615395191650.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENVIF-master - Build #186 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_14_18523005.1615395191384"
X-Jenkins-Job: XENVIF-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #186.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENVIF-master/186/console to view the results.
------=_Part_14_18523005.1615395191384--


From win-pv-devel-bounces@lists.xenproject.org Mon Mar 15 11:26:09 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Mon, 15 Mar 2021 11:26:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.97952.185746 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lLlMN-0000DM-Cl; Mon, 15 Mar 2021 11:26:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 97952.185746; Mon, 15 Mar 2021 11:26:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lLlMN-0000DE-9V; Mon, 15 Mar 2021 11:26:07 +0000
Received: by outflank-mailman (input) for mailman id 97952;
 Mon, 15 Mar 2021 11:26:06 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=ClMy=IN=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lLlMM-0000D9-52
 for win-pv-devel@lists.xenproject.org; Mon, 15 Mar 2021 11:26:06 +0000
Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 75791a74-85b7-495d-918a-354ee6988905;
 Mon, 15 Mar 2021 11:26:04 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: 75791a74-85b7-495d-918a-354ee6988905
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1615807564;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=izrVM+71aDLwqe65ev2+my1D0BhJhegtUUXiEbtmhuU=;
  b=Qdprve4t8N8YajCXqRqdwCHxYGYCC2Tx6YerhngbgKItMVKRMu6KpF6H
   M1houXFRxpyNQIIOY+zxTqBIV0cRjaAFUIoVoGlPQorPL4aIMQZuZAIhj
   VEufWhMJFJwDfkwYOirnvMmnP/QDoDpZxhzFAuVN6jlhQkMHM+JeW0cpm
   o=;
Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: ebkdLSOuvzbAFmaC258zJ3V139OA3gWnWY3AJKtvxFGgrMD9eLseY1ADyLHYL8ZuiASpxiTQ9O
 BIAM7f2Te1oXLBGkc92idhfwcDCnJdkw+6fhspBAQMhW2qUmeU/1AGOX5/LNo1N3JT9s90FEIy
 AIH36T83A6p2VtO1jtMDYOshZbFZcPk9dm6DDKDz/B53RjycS8gq5DLzGJEEMtH5xSceIfCSIR
 l7wm9xoBeYRkqF9L3HUK/J2PZ4pEGi/D/evpwP6gk2qi6RWElCdQS8NGw+o5wkEPVPxOtLs4Ns
 kKY=
X-SBRS: 5.1
X-MesageID: 40699761
X-Ironport-Server: esa4.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
IronPort-HdrOrdr: A9a23:soWA6aswHIxiTtTIM8ipn4xe7skDkNV00zAX/kB9WHVpW+az/v
 rOoN0w0xjohDENHEw6kdebN6WaBV/a/5h54Y4eVI3SOzXOkm2uMY1k8M/e0yTtcheOj9J1+K
 98f8FFeb7NJHdgi8KS2maFOvIB5PXCz6yyn+fZyB5WPGVXQoVt9R1wBAreMmAefnglObMDGJ
 CR5tVKqlObEBx9BKnWOlA/U/XevNqOrZr6YHc9dngawTOThjCl4qOSKXil9yoZOgkg/Z4StU
 zMkwn0/cyYwpSG9iM=
X-IronPort-AV: E=Sophos;i="5.81,249,1610427600"; 
   d="scan'208";a="40699761"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override
Date: Mon, 15 Mar 2021 11:25:45 +0000
Message-ID: <20210315112545.1082776-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

EMULATED(IsDiskPresent) currently only reports if IDE disks are present.
Add the option to override the emulated type of any given PDO to allow
the emulated NVMe device to report its emulated device type as NVME.
Adds the override for the QEMU emulated NVMe controller
(PCI\VEN_8086&DEV_5845) to indicate it is a NVMe controller, and
exposes disk 0.
Also extends XENFILT_EMULATED_OBJECT_TYPE to include NVME

This is to fix an issue where XenVbd can incorrectly identify that disk
0 is not present, when disk 0 is infact the present emulated NVMe
device. This is problematic if the VM boots off the emulated device, not
the PV device (due to the missing unplug) and then rebinds XENVBD which
is unable to determine the presense of the emulated disk and attempts to
connect to an in-use ring.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xenbus.inf         |  1 +
 src/xenfilt/driver.c   | 24 +++++++++++++++---
 src/xenfilt/driver.h   |  7 ++++++
 src/xenfilt/emulated.c | 40 ++++++++++++++++++++++++++++++
 src/xenfilt/emulated.h |  3 ++-
 src/xenfilt/pdo.c      | 55 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 125 insertions(+), 5 deletions(-)

diff --git a/src/xenbus.inf b/src/xenbus.inf
index f9a5475..d2f2477 100644
--- a/src/xenbus.inf
+++ b/src/xenbus.inf
@@ -119,6 +119,7 @@ AddReg = XenFilt_Parameters
 HKR,"Parameters",,0x00000010
 HKR,"Parameters","*PNP0A03",0x00000000,"PCI"
 HKR,"Parameters","Internal_IDE_Channel",0x00000000,"IDE"
+HKR,"Parameters\Override","PCI\VEN_8086&DEV_5845&SUBSYS_11001AF4&REV_02",0x00000000,"NVME"
 
 [Monitor_Service]
 DisplayName=%MonitorName%
diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
index e9e6673..eb2ca42 100644
--- a/src/xenfilt/driver.c
+++ b/src/xenfilt/driver.c
@@ -723,6 +723,25 @@ fail1:
     return status;
 }
 
+XENFILT_EMULATED_OBJECT_TYPE
+DriverParseEmulatedType(
+    IN  PANSI_STRING                Ansi
+    )
+{
+    XENFILT_EMULATED_OBJECT_TYPE    Type;
+
+    Type = XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN;
+
+    if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
+        Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
+    else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
+        Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
+    else if (_strnicmp(Ansi->Buffer, "NVME", Ansi->Length) == 0)
+        Type = XENFILT_EMULATED_OBJECT_TYPE_NVME;
+
+    return Type;
+}
+
 static XENFILT_EMULATED_OBJECT_TYPE
 DriverGetEmulatedType(
     IN  PCHAR                       Id
@@ -753,10 +772,7 @@ DriverGetEmulatedType(
         if (NT_SUCCESS(status)) {
             Info("MATCH: %s -> %Z\n", &Id[Index], Ansi);
 
-            if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
-                Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
-            else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
-                Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
+            Type = DriverParseEmulatedType(Ansi);
 
             RegistryFreeSzValue(Ansi);
         } else {
diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h
index 286580b..2129054 100644
--- a/src/xenfilt/driver.h
+++ b/src/xenfilt/driver.h
@@ -32,6 +32,8 @@
 #ifndef _XENFILT_DRIVER_H
 #define _XENFILT_DRIVER_H
 
+#include "emulated.h"
+
 extern PDRIVER_OBJECT
 DriverGetDriverObject(
     VOID
@@ -58,6 +60,11 @@ DriverGetActive(
     OUT PCHAR       *Value
     );
 
+extern XENFILT_EMULATED_OBJECT_TYPE
+DriverParseEmulatedType(
+    IN  PANSI_STRING                Ansi
+    );
+
 typedef enum _XENFILT_FILTER_STATE {
     XENFILT_FILTER_ENABLED = 0,
     XENFILT_FILTER_PENDING,
diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c
index 827c905..97da61b 100644
--- a/src/xenfilt/emulated.c
+++ b/src/xenfilt/emulated.c
@@ -87,6 +87,33 @@ __EmulatedFree(
     __FreePoolWithTag(Buffer, XENFILT_EMULATED_TAG);
 }
 
+static NTSTATUS
+EmulatedSetObjectNvmeData(
+    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
+    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
+    IN  PCHAR                           DeviceID,
+    IN  PCHAR                           InstanceID
+    )
+{
+    NTSTATUS                            status;
+
+    UNREFERENCED_PARAMETER(DeviceID);
+    UNREFERENCED_PARAMETER(InstanceID);
+
+    status = STATUS_INVALID_PARAMETER;
+    if (Type != XENFILT_EMULATED_OBJECT_TYPE_NVME)
+        goto fail1;
+
+    EmulatedObject->Data.Disk.Index = 0;
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
 static NTSTATUS
 EmulatedSetObjectDeviceData(
     IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
@@ -210,6 +237,13 @@ EmulatedAddObject(
         goto fail1;
 
     switch (Type) {
+    case XENFILT_EMULATED_OBJECT_TYPE_NVME:
+        status = EmulatedSetObjectNvmeData(*EmulatedObject,
+                                           Type,
+                                           DeviceID,
+                                           InstanceID);
+        break;
+
     case XENFILT_EMULATED_OBJECT_TYPE_PCI:
         status = EmulatedSetObjectDeviceData(*EmulatedObject,
                                              Type,
@@ -338,6 +372,12 @@ EmulatedIsDiskPresent(
             Trace("FOUND\n");
             break;
         }
+        if (EmulatedObject->Type == XENFILT_EMULATED_OBJECT_TYPE_NVME &&
+            Index == EmulatedObject->Data.Disk.Index) {
+            Trace("FOUND\n");
+            break;
+        }
+
 
         ListEntry = ListEntry->Flink;
     }
diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h
index 57edee2..499e43c 100644
--- a/src/xenfilt/emulated.h
+++ b/src/xenfilt/emulated.h
@@ -41,7 +41,8 @@ typedef struct _XENFILT_EMULATED_CONTEXT XENFILT_EMULATED_CONTEXT, *PXENFILT_EMU
 typedef enum _XENFILT_EMULATED_OBJECT_TYPE {
     XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN = 0,
     XENFILT_EMULATED_OBJECT_TYPE_PCI,
-    XENFILT_EMULATED_OBJECT_TYPE_IDE
+    XENFILT_EMULATED_OBJECT_TYPE_IDE,
+    XENFILT_EMULATED_OBJECT_TYPE_NVME
 } XENFILT_EMULATED_OBJECT_TYPE, *PXENFILT_EMULATED_OBJECT_TYPE;
 
 typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, *PXENFILT_EMULATED_OBJECT;
diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
index 0f6e6ce..41b0b10 100644
--- a/src/xenfilt/pdo.c
+++ b/src/xenfilt/pdo.c
@@ -42,6 +42,7 @@
 #include "pdo.h"
 #include "thread.h"
 #include "driver.h"
+#include "registry.h"
 #include "dbg_print.h"
 #include "assert.h"
 #include "util.h"
@@ -251,6 +252,58 @@ __PdoGetFdo(
     return Pdo->Fdo;
 }
 
+static VOID
+__PdoGetEmulatedTypeOverride(
+    IN  PXENFILT_PDO                Pdo,
+    IN  PCHAR                       DeviceID
+    )
+{
+    HANDLE                          ParametersKey;
+    HANDLE                          OverrideKey;
+    ULONG                           ValueType;
+    PANSI_STRING                    Ansi;
+    XENFILT_EMULATED_OBJECT_TYPE    Type;
+    NTSTATUS                        status;
+
+    ParametersKey = DriverGetParametersKey();
+
+    status = RegistryOpenSubKey(ParametersKey,
+                                "Override",
+                                GENERIC_READ,
+                                &OverrideKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = RegistryQuerySzValue(OverrideKey,
+                                  DeviceID,
+                                  &ValueType,
+                                  &Ansi);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    if (ValueType != REG_SZ)
+        goto fail3;
+
+    Type = DriverParseEmulatedType(Ansi);
+    if (Type != XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN)
+        Pdo->Type = Type;
+
+    RegistryFreeSzValue(Ansi);
+
+    RegistryCloseKey(OverrideKey);
+
+    return;
+
+fail3:
+    RegistryFreeSzValue(Ansi);
+
+fail2:
+    RegistryCloseKey(OverrideKey);
+
+fail1:
+    return;
+}
+
 static NTSTATUS
 PdoSetDeviceInformation(
     IN  PXENFILT_PDO    Pdo
@@ -310,6 +363,8 @@ PdoSetDeviceInformation(
             LocationInformation = NULL;
     }
 
+    __PdoGetEmulatedTypeOverride(Pdo, DeviceID);
+
     Dx->DeviceID = DeviceID;
     Dx->InstanceID = InstanceID;
     Dx->LocationInformation = LocationInformation;
-- 
2.30.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 19 14:16:48 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 19 Mar 2021 14:16:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.99320.188846 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lNFvi-0005hg-H5; Fri, 19 Mar 2021 14:16:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 99320.188846; Fri, 19 Mar 2021 14:16:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lNFvi-0005hY-Do; Fri, 19 Mar 2021 14:16:46 +0000
Received: by outflank-mailman (input) for mailman id 99320;
 Fri, 19 Mar 2021 14:16:44 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=75+M=IR=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lNFvg-0005hT-TV
 for win-pv-devel@lists.xenproject.org; Fri, 19 Mar 2021 14:16:44 +0000
Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id ee859f2a-553c-4748-8fcc-d1ba189b79d6;
 Fri, 19 Mar 2021 14:16:44 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: ee859f2a-553c-4748-8fcc-d1ba189b79d6
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1616163403;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=2wSqXOOIb/isuLzyRjAmYaTOhd/4vImSgQOcjrgaex4=;
  b=XegTOTkSdou3hwVdr3TNxiDSfXXbm725/hGlE48UBhkL4dI8felTxqDq
   csUBCOvabCu8ppTwmvDkLj8628zyxPGpsLmw1wdXK+Mw9vV6u3cQVOdFM
   ldCWow13zimPOeUjfDw+2grdR1DcrW4mU/M/UN92KxsFk3zWsr5c+FIKK
   A=;
Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
IronPort-SDR: sDyVEgoL3H18gsI0w7Vt067FaVdlwxJzf0OLiQvgv5OwDd0q0xlwxJd8tHh7RiGLqUo3o9APnA
 SF03UPt482BQdNQKoomRuNShV2MXmseYrrIfGIlo0Yks3WDlaNAOeW5jexsWKHjwrzKWSA/XRr
 ylUpgKAROJFTy/iFxgklpPZaF0uBY7BXZL/5at08z3A/YTo0Na8DHpfkcdm0Ai1l2eBgb7Paoy
 2gDpPQzxB7rXyKIO6n9AG6qUqlmW4LoxWnio3y4dRfMfxj73Zx5DPTll35p1TDaPC/GiRFtVKl
 auY=
X-SBRS: 5.1
X-MesageID: 39677307
X-Ironport-Server: esa3.hc3370-68.iphmx.com
X-Remote-IP: 162.221.158.21
X-Policy: $RELAYED
IronPort-HdrOrdr: A9a23:OBiH5qhP2aszDbc1baxTiM6+x3BQXj4ji2hD6mlwRA09T+Wzva
 mV8sgz/xnylToXRTUcgtiGIqaNWjfx8pRy7IkXM96ZLW3bkUGvK5xv6pan/i34F0TFh4hg/I
 ppbqQWMr3NJHdgi8KS2mWFOvIB5PXCz6yyn+fZyB5WPGRXQoVt9R1wBAreMmAefngkObMDGJ
 CR5tVKqlObEBx9BKmGL0IIQvTZoJnznI/mCCR2YCIP0hWEjj+j9dfBciSw4xF2aVxy6IZn1W
 DElgDjj5/T0c2G9g==
X-IronPort-AV: E=Sophos;i="5.81,262,1610427600"; 
   d="scan'208";a="39677307"
From: Owen Smith <owen.smith@citrix.com>
To: <win-pv-devel@lists.xenproject.org>
CC: Owen Smith <owen.smith@citrix.com>
Subject: [PATCH] Avoid ASSERT in SystemTeardown
Date: Fri, 19 Mar 2021 14:16:25 +0000
Message-ID: <20210319141625.3583180-1-owen.smith@citrix.com>
X-Mailer: git-send-email 2.27.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xen/system.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/xen/system.c b/src/xen/system.c
index ffa41a7..f85efc4 100644
--- a/src/xen/system.c
+++ b/src/xen/system.c
@@ -1334,7 +1334,10 @@ fail4:
 fail3:
     Error("fail3\n");
 
+    Context->RegisterVcpuInfo = FALSE;
+
     __SystemFree(Context->Processor);
+    Context->Processor = NULL;
 
 fail2:
     Error("fail2\n");
@@ -1444,7 +1447,10 @@ SystemTeardown(
     Context->MaximumPhysicalAddress.QuadPart = 0;
 
     __SystemFree(Context->Processor);
+    Context->Processor = NULL;
+
     Context->ProcessorCount = 0;
+    Context->RegisterVcpuInfo = FALSE;
 
     (VOID) InterlockedDecrement(&Context->References);
 
-- 
2.30.2.windows.1



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 26 07:52:07 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 26 Mar 2021 07:52:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.101618.194508 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPhGH-00086Q-5W; Fri, 26 Mar 2021 07:52:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 101618.194508; Fri, 26 Mar 2021 07:52:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPhGH-00086G-2F; Fri, 26 Mar 2021 07:52:05 +0000
Received: by outflank-mailman (input) for mailman id 101618;
 Fri, 26 Mar 2021 07:52:04 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=G2QT=IY=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lPhGG-00086B-4M
 for win-pv-devel@lists.xenproject.org; Fri, 26 Mar 2021 07:52:04 +0000
Received: from mail-wm1-x335.google.com (unknown [2a00:1450:4864:20::335])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 52326662-b38c-4c8f-a379-df74a7db949f;
 Fri, 26 Mar 2021 07:52:03 +0000 (UTC)
Received: by mail-wm1-x335.google.com with SMTP id 12so2458553wmf.5
 for <win-pv-devel@lists.xenproject.org>; Fri, 26 Mar 2021 00:52:03 -0700 (PDT)
Received: from ?IPv6:2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec?
 ([2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec])
 by smtp.gmail.com with ESMTPSA id p10sm11511292wrw.33.2021.03.26.00.52.01
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 26 Mar 2021 00:52:02 -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: 52326662-b38c-4c8f-a379-df74a7db949f
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=ei1H7491k9mjF4qVsY+W4YgSikde+uacdCCzHvwHyuU=;
        b=VSpJUrc83TYjBc6aWXX9ZPIGAT+SVwJx2GViSDzKLW9FT8PIpDEBPqCeE/SArLh1lk
         eGosmuiLxD94fB9WZd8tkp61MjUepZoqxyungD5t4dmV5dDs8NVOV9AwV90iujEMEXyd
         /WCqqacC0JZnin9nx10zgDam793vK3NNpoC6AkMI+K0gKijOmX2XJ+51+of6FoRzHkGc
         td2Rkv2F0ujjjhFOTkNWoLaEEDe9ECRC9osBrIcPjtruWoyVeC88MP1t3BTxYs9DlguS
         doSvSndrIWqphVa2WyimG/3Jej0vpxhyoVQB0Jdaf64Kux0oj+fAOuxI9mKkfqPuG7TK
         zcnA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=ei1H7491k9mjF4qVsY+W4YgSikde+uacdCCzHvwHyuU=;
        b=Jf18spipfLiKAsSM/2phWZNvpw1JlJMOtws01mnlTU4090/sk1zeNuk+GEfqoj55kx
         OgUJJlZsyVSsbr9/jww+VvQsS4B5RhBkWtphYblaQ05QHx2o8PHeCrFWhK6UQ54Ne/Ge
         X5/QqTfyiw75OmtQSHQfMd1XtvuAD4BFaoaa1BrOgaJgB2U8CJpgKtCWZddDObSagMP9
         cnf6zkmAgvNtSpf+AJ2szc37e0asYBnr4YJGr8FkHxOKwyzTrGkIzgjpdCS7+J95GS2h
         dgMEU7ghiiAM4ly8f/jHzK/51I6C3nSP+SLGpQ0nZDNF7w+2RC5wMvfquRr/gmDY+r4j
         7ziA==
X-Gm-Message-State: AOAM5333Dy1GB+cPkeI3mp+dw1IQTEGWvu092FJ7xp68zuzRRVJNZxQl
	7ZynCVxUF3r+nNWoJ2TirBRoD8wN24M=
X-Google-Smtp-Source: ABdhPJz2XjFn5BYzV1bC6fYLhhK8V2lqmczc13Gy94V+tyov/GmubTwzlKZqA3ZIw0CLkyOn7ZtZnw==
X-Received: by 2002:a1c:dd89:: with SMTP id u131mr11439571wmg.54.1616745122602;
        Fri, 26 Mar 2021 00:52:02 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [PATCH] Avoid ASSERT in SystemTeardown
To: win-pv-devel@lists.xenproject.org
References: <20210319141625.3583180-1-owen.smith@citrix.com>
Message-ID: <7cc528fa-abfc-753c-e48e-841d0f718c70@xen.org>
Date: Fri, 26 Mar 2021 07:52:01 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.8.1
MIME-Version: 1.0
In-Reply-To: <20210319141625.3583180-1-owen.smith@citrix.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 19/03/2021 14:16, Owen Smith wrote:
> Signed-off-by: Owen Smith <owen.smith@citrix.com>

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

> ---
>   src/xen/system.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/src/xen/system.c b/src/xen/system.c
> index ffa41a7..f85efc4 100644
> --- a/src/xen/system.c
> +++ b/src/xen/system.c
> @@ -1334,7 +1334,10 @@ fail4:
>   fail3:
>       Error("fail3\n");
>   
> +    Context->RegisterVcpuInfo = FALSE;
> +
>       __SystemFree(Context->Processor);
> +    Context->Processor = NULL;
>   
>   fail2:
>       Error("fail2\n");
> @@ -1444,7 +1447,10 @@ SystemTeardown(
>       Context->MaximumPhysicalAddress.QuadPart = 0;
>   
>       __SystemFree(Context->Processor);
> +    Context->Processor = NULL;
> +
>       Context->ProcessorCount = 0;
> +    Context->RegisterVcpuInfo = FALSE;
>   
>       (VOID) InterlockedDecrement(&Context->References);
>   
> 



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 26 08:10:27 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 26 Mar 2021 08:10:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.101632.194530 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPhY2-0002TA-26; Fri, 26 Mar 2021 08:10:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 101632.194530; Fri, 26 Mar 2021 08:10: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 1lPhY1-0002T2-V7; Fri, 26 Mar 2021 08:10:25 +0000
Received: by outflank-mailman (input) for mailman id 101632;
 Fri, 26 Mar 2021 08:10:24 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=G2QT=IY=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lPhY0-0002Se-Bp
 for win-pv-devel@lists.xenproject.org; Fri, 26 Mar 2021 08:10:24 +0000
Received: from mail-wm1-x32f.google.com (unknown [2a00:1450:4864:20::32f])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id e6935b82-3256-4c40-93dd-ed9f67d40def;
 Fri, 26 Mar 2021 08:10:22 +0000 (UTC)
Received: by mail-wm1-x32f.google.com with SMTP id
 f22-20020a7bc8d60000b029010c024a1407so4420393wml.2
 for <win-pv-devel@lists.xenproject.org>; Fri, 26 Mar 2021 01:10:22 -0700 (PDT)
Received: from ?IPv6:2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec?
 ([2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec])
 by smtp.gmail.com with ESMTPSA id a15sm1510431wrr.53.2021.03.26.01.10.21
 for <win-pv-devel@lists.xenproject.org>
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 26 Mar 2021 01:10: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: e6935b82-3256-4c40-93dd-ed9f67d40def
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=Mzyl4s8oBlRqs/eb27liZhxiSntm/nVUJM+5/LiToI8=;
        b=K+9D3jPsFYn8yG3Dga+aWxSwCHhyH9KqncH+IYz6VzhuK95Y+0iKJEm7js4NUV2FFk
         H+iBfUh2ZuTJ+m5210oGtGtFfHT6aE6ySDzeujj51fitCQZO6BS2glYYZZyOT6AmjVPV
         J0Sxvn+HkgbxUt32Uod4OHcShEychAcH3xJUJhbICSe/jPA149K3sGDfegkPxjHNVePt
         PNoB+f4crb1742Ru95/J0yCGi4VRSs59YmesqQ0JGqzH43hcrMIBXtkXCpE4bgRwQiln
         +scCi5NMQI4DPHnr9Sd0BiSalDg7LH1Mt0/MgQFLL26kyzatak/Q4/itx1/tOAV9S18l
         Lt3Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=Mzyl4s8oBlRqs/eb27liZhxiSntm/nVUJM+5/LiToI8=;
        b=BKY7qMUvESF01VtYskjuaKnkQc7cnYtjiBQon5FPn1RDQvjCWYFqSFuoE+OzSXLhH7
         1T1diHvSK6yQ3/LIcZQ82HmMV8bq5ujhGygLDVbIQKEjs++pP/m/jN7VV7mSkNxt2gbC
         dEzkhNU6zsmMIi2R+nEFbr5i44klTUHKiGnvWM79JWfN555I2t3tDFGVIPGZPJ3m0rwm
         Qpgo0PFlxM+iUR7qMTMG10PVo3eeggW+G6/13XyOSD2Ahyi0VU7wv/LW4KjsyDJjiIjl
         nwlf/+yiUs6w/YMgIoltQUMx16OP4ZJa7sZSpXkmeEPYo5cfnVjnWe2iDjiWvoc63hHv
         3XdQ==
X-Gm-Message-State: AOAM530HbGqldZQmCmsmTHfKkMJPrSiU5u+R0I1b+DgNCUdkPYJ/rgd/
	VJbr9dBLPEJaCedttrkCV41FXZe+X8M=
X-Google-Smtp-Source: ABdhPJzijy+OqrTBr2RG2LcGkpVe/2BOVNkFhC9Y5b5TB5hDUVh1GnLE6QOTMQaaVxlmueRiRzdLMQ==
X-Received: by 2002:a05:600c:2109:: with SMTP id u9mr11729565wml.44.1616746221997;
        Fri, 26 Mar 2021 01:10:21 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override
To: win-pv-devel@lists.xenproject.org
References: <20210315112545.1082776-1-owen.smith@citrix.com>
Message-ID: <46cd5cb3-cae2-5263-caa7-06d54002942c@xen.org>
Date: Fri, 26 Mar 2021 08:10:20 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.8.1
MIME-Version: 1.0
In-Reply-To: <20210315112545.1082776-1-owen.smith@citrix.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 15/03/2021 11:25, Owen Smith wrote:
> EMULATED(IsDiskPresent) currently only reports if IDE disks are present.
> Add the option to override the emulated type of any given PDO to allow
> the emulated NVMe device to report its emulated device type as NVME.
> Adds the override for the QEMU emulated NVMe controller
> (PCI\VEN_8086&DEV_5845) to indicate it is a NVMe controller, and
> exposes disk 0.
> Also extends XENFILT_EMULATED_OBJECT_TYPE to include NVME
> 
> This is to fix an issue where XenVbd can incorrectly identify that disk
> 0 is not present, when disk 0 is infact the present emulated NVMe
> device. This is problematic if the VM boots off the emulated device, not
> the PV device (due to the missing unplug) and then rebinds XENVBD which
> is unable to determine the presense of the emulated disk and attempts to
> connect to an in-use ring.
> 
> Signed-off-by: Owen Smith <owen.smith@citrix.com>
> ---
>   src/xenbus.inf         |  1 +
>   src/xenfilt/driver.c   | 24 +++++++++++++++---
>   src/xenfilt/driver.h   |  7 ++++++
>   src/xenfilt/emulated.c | 40 ++++++++++++++++++++++++++++++
>   src/xenfilt/emulated.h |  3 ++-
>   src/xenfilt/pdo.c      | 55 ++++++++++++++++++++++++++++++++++++++++++
>   6 files changed, 125 insertions(+), 5 deletions(-)
> 
> diff --git a/src/xenbus.inf b/src/xenbus.inf
> index f9a5475..d2f2477 100644
> --- a/src/xenbus.inf
> +++ b/src/xenbus.inf
> @@ -119,6 +119,7 @@ AddReg = XenFilt_Parameters
>   HKR,"Parameters",,0x00000010
>   HKR,"Parameters","*PNP0A03",0x00000000,"PCI"
>   HKR,"Parameters","Internal_IDE_Channel",0x00000000,"IDE"
> +HKR,"Parameters\Override","PCI\VEN_8086&DEV_5845&SUBSYS_11001AF4&REV_02",0x00000000,"NVME"

That's a very strict match. How confident are we that the QEMU device 
won't need to deal with e.g. multiple revisions of the QEMU device? 
Perhaps it would be better to look at class code or is there something 
else that may be a more stable identifier?

   Paul

>   
>   [Monitor_Service]
>   DisplayName=%MonitorName%
> diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
> index e9e6673..eb2ca42 100644
> --- a/src/xenfilt/driver.c
> +++ b/src/xenfilt/driver.c
> @@ -723,6 +723,25 @@ fail1:
>       return status;
>   }
>   
> +XENFILT_EMULATED_OBJECT_TYPE
> +DriverParseEmulatedType(
> +    IN  PANSI_STRING                Ansi
> +    )
> +{
> +    XENFILT_EMULATED_OBJECT_TYPE    Type;
> +
> +    Type = XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN;
> +
> +    if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
> +        Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
> +    else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
> +        Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
> +    else if (_strnicmp(Ansi->Buffer, "NVME", Ansi->Length) == 0)
> +        Type = XENFILT_EMULATED_OBJECT_TYPE_NVME;
> +
> +    return Type;
> +}
> +
>   static XENFILT_EMULATED_OBJECT_TYPE
>   DriverGetEmulatedType(
>       IN  PCHAR                       Id
> @@ -753,10 +772,7 @@ DriverGetEmulatedType(
>           if (NT_SUCCESS(status)) {
>               Info("MATCH: %s -> %Z\n", &Id[Index], Ansi);
>   
> -            if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
> -                Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
> -            else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
> -                Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
> +            Type = DriverParseEmulatedType(Ansi);
>   
>               RegistryFreeSzValue(Ansi);
>           } else {
> diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h
> index 286580b..2129054 100644
> --- a/src/xenfilt/driver.h
> +++ b/src/xenfilt/driver.h
> @@ -32,6 +32,8 @@
>   #ifndef _XENFILT_DRIVER_H
>   #define _XENFILT_DRIVER_H
>   
> +#include "emulated.h"
> +
>   extern PDRIVER_OBJECT
>   DriverGetDriverObject(
>       VOID
> @@ -58,6 +60,11 @@ DriverGetActive(
>       OUT PCHAR       *Value
>       );
>   
> +extern XENFILT_EMULATED_OBJECT_TYPE
> +DriverParseEmulatedType(
> +    IN  PANSI_STRING                Ansi
> +    );
> +
>   typedef enum _XENFILT_FILTER_STATE {
>       XENFILT_FILTER_ENABLED = 0,
>       XENFILT_FILTER_PENDING,
> diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c
> index 827c905..97da61b 100644
> --- a/src/xenfilt/emulated.c
> +++ b/src/xenfilt/emulated.c
> @@ -87,6 +87,33 @@ __EmulatedFree(
>       __FreePoolWithTag(Buffer, XENFILT_EMULATED_TAG);
>   }
>   
> +static NTSTATUS
> +EmulatedSetObjectNvmeData(
> +    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
> +    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
> +    IN  PCHAR                           DeviceID,
> +    IN  PCHAR                           InstanceID
> +    )
> +{
> +    NTSTATUS                            status;
> +
> +    UNREFERENCED_PARAMETER(DeviceID);
> +    UNREFERENCED_PARAMETER(InstanceID);
> +
> +    status = STATUS_INVALID_PARAMETER;
> +    if (Type != XENFILT_EMULATED_OBJECT_TYPE_NVME)
> +        goto fail1;
> +
> +    EmulatedObject->Data.Disk.Index = 0;
> +
> +    return STATUS_SUCCESS;
> +
> +fail1:
> +    Error("fail1 (%08x)\n", status);
> +
> +    return status;
> +}
> +
>   static NTSTATUS
>   EmulatedSetObjectDeviceData(
>       IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
> @@ -210,6 +237,13 @@ EmulatedAddObject(
>           goto fail1;
>   
>       switch (Type) {
> +    case XENFILT_EMULATED_OBJECT_TYPE_NVME:
> +        status = EmulatedSetObjectNvmeData(*EmulatedObject,
> +                                           Type,
> +                                           DeviceID,
> +                                           InstanceID);
> +        break;
> +
>       case XENFILT_EMULATED_OBJECT_TYPE_PCI:
>           status = EmulatedSetObjectDeviceData(*EmulatedObject,
>                                                Type,
> @@ -338,6 +372,12 @@ EmulatedIsDiskPresent(
>               Trace("FOUND\n");
>               break;
>           }
> +        if (EmulatedObject->Type == XENFILT_EMULATED_OBJECT_TYPE_NVME &&
> +            Index == EmulatedObject->Data.Disk.Index) {
> +            Trace("FOUND\n");
> +            break;
> +        }
> +
>   
>           ListEntry = ListEntry->Flink;
>       }
> diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h
> index 57edee2..499e43c 100644
> --- a/src/xenfilt/emulated.h
> +++ b/src/xenfilt/emulated.h
> @@ -41,7 +41,8 @@ typedef struct _XENFILT_EMULATED_CONTEXT XENFILT_EMULATED_CONTEXT, *PXENFILT_EMU
>   typedef enum _XENFILT_EMULATED_OBJECT_TYPE {
>       XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN = 0,
>       XENFILT_EMULATED_OBJECT_TYPE_PCI,
> -    XENFILT_EMULATED_OBJECT_TYPE_IDE
> +    XENFILT_EMULATED_OBJECT_TYPE_IDE,
> +    XENFILT_EMULATED_OBJECT_TYPE_NVME
>   } XENFILT_EMULATED_OBJECT_TYPE, *PXENFILT_EMULATED_OBJECT_TYPE;
>   
>   typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, *PXENFILT_EMULATED_OBJECT;
> diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
> index 0f6e6ce..41b0b10 100644
> --- a/src/xenfilt/pdo.c
> +++ b/src/xenfilt/pdo.c
> @@ -42,6 +42,7 @@
>   #include "pdo.h"
>   #include "thread.h"
>   #include "driver.h"
> +#include "registry.h"
>   #include "dbg_print.h"
>   #include "assert.h"
>   #include "util.h"
> @@ -251,6 +252,58 @@ __PdoGetFdo(
>       return Pdo->Fdo;
>   }
>   
> +static VOID
> +__PdoGetEmulatedTypeOverride(
> +    IN  PXENFILT_PDO                Pdo,
> +    IN  PCHAR                       DeviceID
> +    )
> +{
> +    HANDLE                          ParametersKey;
> +    HANDLE                          OverrideKey;
> +    ULONG                           ValueType;
> +    PANSI_STRING                    Ansi;
> +    XENFILT_EMULATED_OBJECT_TYPE    Type;
> +    NTSTATUS                        status;
> +
> +    ParametersKey = DriverGetParametersKey();
> +
> +    status = RegistryOpenSubKey(ParametersKey,
> +                                "Override",
> +                                GENERIC_READ,
> +                                &OverrideKey);
> +    if (!NT_SUCCESS(status))
> +        goto fail1;
> +
> +    status = RegistryQuerySzValue(OverrideKey,
> +                                  DeviceID,
> +                                  &ValueType,
> +                                  &Ansi);
> +    if (!NT_SUCCESS(status))
> +        goto fail2;
> +
> +    if (ValueType != REG_SZ)
> +        goto fail3;
> +
> +    Type = DriverParseEmulatedType(Ansi);
> +    if (Type != XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN)
> +        Pdo->Type = Type;
> +
> +    RegistryFreeSzValue(Ansi);
> +
> +    RegistryCloseKey(OverrideKey);
> +
> +    return;
> +
> +fail3:
> +    RegistryFreeSzValue(Ansi);
> +
> +fail2:
> +    RegistryCloseKey(OverrideKey);
> +
> +fail1:
> +    return;
> +}
> +
>   static NTSTATUS
>   PdoSetDeviceInformation(
>       IN  PXENFILT_PDO    Pdo
> @@ -310,6 +363,8 @@ PdoSetDeviceInformation(
>               LocationInformation = NULL;
>       }
>   
> +    __PdoGetEmulatedTypeOverride(Pdo, DeviceID);
> +
>       Dx->DeviceID = DeviceID;
>       Dx->InstanceID = InstanceID;
>       Dx->LocationInformation = LocationInformation;
> 



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 26 08:59:07 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 26 Mar 2021 08:59:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.101642.194540 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPiJ7-00072G-PT; Fri, 26 Mar 2021 08:59:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 101642.194540; Fri, 26 Mar 2021 08:59:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPiJ7-000728-MN; Fri, 26 Mar 2021 08:59:05 +0000
Received: by outflank-mailman (input) for mailman id 101642;
 Fri, 26 Mar 2021 08:59:03 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=aACs=IY=citrix.com=owen.smith@srs-us1.protection.inumbo.net>)
 id 1lPiJ5-000723-D8
 for win-pv-devel@lists.xenproject.org; Fri, 26 Mar 2021 08:59:03 +0000
Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id a7ee2d22-f635-489b-9fc0-87fb7e3bc990;
 Fri, 26 Mar 2021 08:59:01 +0000 (UTC)
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
X-Inumbo-ID: a7ee2d22-f635-489b-9fc0-87fb7e3bc990
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=citrix.com; s=securemail; t=1616749141;
  h=from:to:subject:date:message-id:references:in-reply-to:
   content-transfer-encoding:mime-version;
  bh=1M6nsaB2KqLj8KFQJIZf2N8Kq5D7TLGabdp99LwP3RY=;
  b=RF5DJe0ZbM1naEJoz3ZgDyfMO/u+dAvIps/Uxw+fXUmT1IDqwfdCBiiu
   wEXb7pQo6ZkyhtXkeO7U7NYPGph71hEutDiEBcYKie6aXa2lrSh0ulN4o
   wi8p3g3IT3/4jTfYALsCK2EsGEobEDreOU6fRlGdHCgRHY36B+Ax7kwA4
   A=;
Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
IronPort-SDR: UMQkTdbKYMvbahFSMJWiohn1t6O140cs6IXFTYFr4Wit2sj+kLQjDzixltO54toASb9AiFlKgU
 64d1e6mokDawiihLW29mZw67/Ffdp98XERz1qg+lCEMBxMXdR7BcrLEpHxDgNRtDgA7hJGcvIf
 TJcSdIG5VuehOs8z2HssUHGdag1MIZPS3WyRj09RElgQuvFs+KxOoEI4C4Scm/HZCwRNrfBgYy
 YF4OvzBg+XjWceAxLOc1zEw5Re5SNNDDKdGO2d8iwzBq6zvs+CGrQarrWSXxFGXyYzNTwMGsk7
 XXE=
X-SBRS: 5.2
X-MesageID: 40203988
X-Ironport-Server: esa2.hc3370-68.iphmx.com
X-Remote-IP: 162.221.156.83
X-Policy: $RELAYED
IronPort-HdrOrdr: A9a23:BJg4taEjrPhPNN30pLqFTZTXdLJzesId70hD6mlYcjYQWtCEls
 yogfQQ3QL1jjFUY307hdWcIsC7Lk/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeNJwTXzcQY76
 tpdsFFZeHYJVJxgd/mpCyxFNg9yNeKmZrY/9v25XFrUA1sduVE5wB2Fg6UHiRNNXR7LLA+E4
 eR4dcCmiGpfm4ZYt/+Kn4OWeXCoNOjruOrXTctARk75A6SyQ658bKSKWnU4j4ycRNqhY0j/2
 /MjhDj6syY3c2T5xfA2wbonvJrsfT7zN8rPr3utuE0LXHWhh+sdMBdXdS5zUsIicWOzHpvr9
 XWuRcnOK1ImjzsV0W4uwHk1QWl8BtG0Q6a9XaijXHuodP0SVsBYqIr7+M4TjLj50Utp9162q
 5Qtljpz6Z/Nh/cgD/7o+HBShACrDvsnVMZjeURg3ZDOLFuDYN5kI0F8EtZVLcGES7qgbpXd9
 VGMcDG6P5aNW6ddnDS11MfpOCEY3JbJGblfmEy/uiulxRGlnFwyEUVgOYFmG0byZ47Q55Yo8
 zZL6VBjth1P4ErRJM4IN1Ebdq8C2TLTx6JGnmVO07bGKYOPG+Ig4Lr4Y8y+PqhdPUzvdoPsa
 WEdGkdmX85ekroB8HL9oZM6ArxTGK0Wimo7c1C+Z5juPnZSKDwOSOODHAi+vHQ48k3M4n+Yb
 KeKZhWC/jsIS/FAoBSxTDzXJFUND0QS8sQttEnW0+fo87CJ4Hw39arMsr7Ff7IK3IJS2n/Cn
 wMUHzYP8Nb9H2mXXf+nVzQVhrWCwnC1KM1NJKf0/kYyYALOIEJmBMSk06F6saCLiAHtqQ3eU
 B5Ma72i6/TnxjzwU/4q0FSfjZNBEdc57vtF1lQoxURDk/yebEf/9OFeW5T23ODLgRlT9zfFR
 Neo1gfw9P1E7WggQQZT/63OGOTiHUe4FiQSY0Hp6GF7cD5Po8jAo0+Q6x3HwXTHxlzkQJnwV
 0zLzMsdwv6LHfDmK+lhJsbCKXjbNF6mh6sOtMRg2nYr1+gqcYmQWY7UzaiXdWMuxsnQyNZiz
 RKgukiqYvFvQzqCGMkxMwkLVVHaQ2scc57JTXAQL8Rp5fGV0VbS3yQiTmTlhcpE1CaiHk6ty
 jGNi2befbCH1xHnGtXu5yaqG9cfnmBfk52d3BxuZB8E2ODoXpozeqXfMOIohWsQ0pHzecHPD
 7fZzwOZgto2tCszRaQ3C2PDHM82/wVT6TgJaVmd7HYwXW2LoKU0akAAv9P5Z5gXeqexNMjQK
 aaewWPKin/BP5s0wuJpmw9MC0xrHU/i/vn1Fnk62e/tURPSMb6MRBjR7sBJcub4HWhT/GU0I
 9hhdZwpPCuKAzKG6u74LCSayQGJgLYoGawQe1toZdIvbgqvL82G5XASzPH2HxOwR1WFra+qG
 oOBKBgpLzRMI5meMIfPzhU+Vckj9yDJkomuA6eOJ5IQXg9y3vAe9+Z6bvBrrQiRlCbrAzrIF
 +F7mlT+ezGUybr789RN4sgZWBNLE4y53Rp8LncK8neCAC2e/pC+1T/OHmna7NZQLWEH7JVrh
 sS2aD6o8aHMy7jnAbXtn9nJ6gL9WCtS8a7GhiNFu5F6MbSAyX5voK6pMqoyC7qQj66YVkCjY
 JLdUYMft1O4wNS/LEfw2y3UOjruUornFtV/CF/mlPs0oag5n3HHUsuC3yqvrxGGT9JMnaJis
 zZ8e+XkHTliQI1qKX+KA==
X-IronPort-AV: E=Sophos;i="5.81,280,1610427600"; 
   d="scan'208";a="40203988"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=iaiRKle2CTG5YZv+E6Mo5Lj97bC05/9pt1kYWBrrN/502A6HtXoUdyfjqksXYnjO/C6Sx4l2WbiI5AxIVGuN1/+cTOW3OxFVI1RlBU1Kd8Bfqmn0d8i4cFm3+6AoVT8z3xjsf5oOXpYIBFv0azS2o0uFp0/vgjzAjykq+eCJxvrUJDSkvK0cEgTj7v0jkLrSVpN/yh/MGVoJY7h/JqHux2Pp0kmRIiNUbPkHYV0Dl37f2Prgk6VKDt0eJKCjwWdEDIwQULA6yNBk9vAgfqAlNcihsZzS7/nt4/8HXb27sxisi0kTNRzt19nwwwJalqpD57ZpeDpWE8ce87I2NBoMVQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qxwxhtB6L7Jmphmap0pyZxpLOjNIBPevM7FsqWV2UQs=;
 b=XpNevKZUCBb84AcPkVoxUw+DdjKpzr7T6JIeQsMfbyGm3k9E7e6kJwq0jmiySK2LdWh/zRheo7GPt/D8nuAfILdYXXG01/cuiRzrqoxlM/4209j39bMfwtlbu+QMioCOxOdy1gck3sy2hrrhkro9A9hk49P+6Z5kSfd6WpF75dp0O5dhcEislb74BerCLNFosKTvQZmea3T4qrfvGk04RUV0qVsflIm4eUxHyTEfXJcpReCKUgNO9ea5oLufVbeWcQ6qTSim3TQaFfhFteWl8LiuAKdv0x9DMCZJdY3+b6lW6zZXayTJuFy+kygTvKGQgjkTV5GEWyEj6swmwQ04NA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com;
 dkim=pass header.d=citrix.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qxwxhtB6L7Jmphmap0pyZxpLOjNIBPevM7FsqWV2UQs=;
 b=nCMAa0aFhJzmobKHP2qc+B+vsTwYuzgmecMyJr+kr6ldPKeyv1le3L9TMzrgYlWmySXzeu07SM+O/AoyNCDlChn8K/Dl98vRu8DjdeRpQmrj5ovG42+Kh5WbZGX3vbCjEnNVGg5HbKW4QxS4R9f3QvusIhWhPnkIahEN5biFAl0=
From: Owen Smith <owen.smith@citrix.com>
To: "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>,
	"paul@xen.org" <paul@xen.org>
Subject: Re: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override
Thread-Topic: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override
Thread-Index: AQHXGY38KqmEOTOVDEu7tbhlky6tiKqV+9EAgAAMJ7E=
Date: Fri, 26 Mar 2021 08:58:57 +0000
Message-ID: <DS7PR03MB54774E4C6372D1CC23647EE4FE619@DS7PR03MB5477.namprd03.prod.outlook.com>
References: <20210315112545.1082776-1-owen.smith@citrix.com>,<46cd5cb3-cae2-5263-caa7-06d54002942c@xen.org>
In-Reply-To: <46cd5cb3-cae2-5263-caa7-06d54002942c@xen.org>
Accept-Language: en-GB, en-US
Content-Language: en-GB
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 0d06cf89-d73e-4a33-4849-08d8f0356427
x-ms-traffictypediagnostic: DM5PR03MB2809:
x-microsoft-antispam-prvs: <DM5PR03MB280989EF4B3A940ECF5A923FFE619@DM5PR03MB2809.namprd03.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:9508;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: wK3/5peVIMR7dQq9+Jj/Cc8gao75DujYsGd6HKWYBizh56Lkb8e7ZzYh4lqcTzNorZ9WPHKTBncsHYUevij1wJD5m6wbeaC/r1t7FXISq0godl4jvMNPEFaBa4lh0AAlpmK9YjYRJJf7PlkBVvmZJckPODmDQXo1ElBWBmEtzpHQnHR0IS+qgAmMR+CvWiYDv00m2tziSl8RQnsYQwcIgcOG1/3GjUM5gTV4v/HZFU5Y1cLSHn+TW7vS1asvGMHNrtulYPRZ4VJY6hhT2xfO8T5yWBJ0siXNnGO2+eRLivVGsLKFa5/eA8n8AHc9cyUs06TYVSX05WLVCbIk0d9gz4nTlwRZvvSEuqWdlcR+8daN89jpWCpbKapUJ7pNx5avVy2gODx98DIoWwskDWm4HM/s9aeIB0ycpIUdsOMfEcySQamnWD3y55+9Wf8m3M30rT3HUi3P357GBG8t9pqo9/Rf+5JNl8yEsNzyQP/Hc4zXkEyHWc58jQG62LMZP4TVgncbO2aaaOIn5lje5WbKv/LL/iGF5tJ7pJoB0R5l+cd1phnObMierItH4hQyrjQy2PJe6A76HYivTpCcrhjD+k+Nkn4wDQbCMHsl3gDQY3b3umi6WzOXfwG81FBUvmn3fPdojVQ4fECyMbbtfaWGaOA6YrQBBF47yBMEgmS+hELB9DC3D4kM4ieyBbvQ0jVi
x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5477.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(396003)(376002)(136003)(39860400002)(346002)(44832011)(5660300002)(38100700001)(9686003)(6506007)(83380400001)(52536014)(55016002)(33656002)(7696005)(186003)(110136005)(8936002)(66476007)(64756008)(71200400001)(66946007)(86362001)(26005)(316002)(478600001)(53546011)(2906002)(66446008)(91956017)(66556008)(76116006)(8676002)(586874002);DIR:OUT;SFP:1101;
x-ms-exchange-antispam-messagedata: =?iso-8859-1?Q?8dbrY3Sz6Lm2M6IzJYac63mR5Ls3ViFu3TTDZHj3qDlLNTfStFaLKUMIqe?=
 =?iso-8859-1?Q?8YuflfPgwcWl2rJKK5MMuWLa5lRw2D2Bp8vwjxapZOjJMxgYvv2VbDz39W?=
 =?iso-8859-1?Q?HNXMGQBD8GEL6RwWAUS/7PWoysTObry0W29lo/2dl+t0zwTGdqzq+UxX2G?=
 =?iso-8859-1?Q?xmMhk35OzuiMUcdDQUQBOBXuCRl/A6DUus78Yh650nKKbVfnt+ZJe2ya/2?=
 =?iso-8859-1?Q?A8Q5uhUJA/kAYsMBUr6yuWGJwPqv/taZncNQPV6iJ4wtyNSzjx5TfWZ67P?=
 =?iso-8859-1?Q?iDwyIsCg8eGEW7twCKQZgQs3IGVVOB/Ok/c2520rfDMzpXQoIAsdgrz8hx?=
 =?iso-8859-1?Q?GlLgWbnpZ0+9XHW41mieB0FQHjFZX37r1viPtBUSMUiWtcAP6xqpJyYSlY?=
 =?iso-8859-1?Q?AZKF+TX7QV2/qIc4SMzX3w1VaMUypucmCEusEndCW9ISBJlB1AUPVEBvQ1?=
 =?iso-8859-1?Q?yBYCOdgfzOigUMSl7Vvlm6I11y4J9QOAuilb2DOORL7c+0yBWnPKcgybm+?=
 =?iso-8859-1?Q?w+CwvvX5z9ORLLgz2A0x8B2/eVbw0dq4veitLPObWAdRArG8EotwUyopaS?=
 =?iso-8859-1?Q?pXfUvc5TZ7n7gbnGOtRvfDZfJsl52Olhsin9h7XX31XxfptcSj75fi/sG/?=
 =?iso-8859-1?Q?obW0Ml3bWrCxDOllCm3kTTzkJtqhKxYJ8Bkg3AV2hj0uXtoBzRk9YAS6ml?=
 =?iso-8859-1?Q?oLPNx4apa394IGUPplZ3zHFtGmWl/FyquFYr+dy/vfh6CMw3EZFv7K57RN?=
 =?iso-8859-1?Q?PzkFTRDrIKspAKDisAVbQFlDQQC0QXujMRL/zZTPXDMvvQIx/O02yKG16w?=
 =?iso-8859-1?Q?hF7yE+BskHRKTUplrnOHh5UcTpEhq5M5u4KL18UyO0qTixbkDX77VF8bvB?=
 =?iso-8859-1?Q?rwy9FXuOdrfAYWS+wlp2/aq/MqZf22IFUB/Rge5UV4qQp9RJcwDOTEnNII?=
 =?iso-8859-1?Q?heqb6Mi3a+Hr63Djp3+ZictCo6f6LFg/Or0g2DKCFyf0sjMqghG8BYsemh?=
 =?iso-8859-1?Q?AYx4ds+ZY4n9XXBwHhFxQ+qhnnhfyP798DbucimlYdBy1qIr0b276gxA5x?=
 =?iso-8859-1?Q?PYx5fcByT4cdMZHofecGsHhLHS8sKf/k5KVANTILbTPntB8fe2dLG1SPQu?=
 =?iso-8859-1?Q?vnaUqHUgmcqradIuf+SWvnkokB9oCz2ZlD+8bY63mOFdzAQI2JBSwy/Ke+?=
 =?iso-8859-1?Q?q9fd+IsZuP65Ru4IVBGZLBFF8C27At7BSTn3TeA0hXMVnQ//bE2Pi/oQzF?=
 =?iso-8859-1?Q?m1gJje+GCUYD1/xPfo7a1f//fqvQqcUpR189e9NtbNhKAsgaYNGPbRIvFN?=
 =?iso-8859-1?Q?f1bdNsgC/5cDKDWteQxXgfcyCeu8I6zqzt58uTAsbUyvwiI=3D?=
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5477.namprd03.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 0d06cf89-d73e-4a33-4849-08d8f0356427
X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Mar 2021 08:58:57.6516
 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 335836de-42ef-43a2-b145-348c2ee9ca5b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: IGz2pK7ajOxmK+iKWdfSYxdjkyijVbxN0wmQLayACB4uLlhjjiAdckJObUYxGcogBYkQ1oS9dGji6Xu2cAB/wQ==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR03MB2809
X-OriginatorOrg: citrix.com

________________________________________=0A=
From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of=
 Paul Durrant <xadimgnik@gmail.com>=0A=
Sent: 26 March 2021 08:10=0A=
To: win-pv-devel@lists.xenproject.org=0A=
Subject: Re: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override=0A=
=0A=
[CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments u=
nless you have verified the sender and know the content is safe.=0A=
=0A=
On 15/03/2021 11:25, Owen Smith wrote:=0A=
> EMULATED(IsDiskPresent) currently only reports if IDE disks are present.=
=0A=
> Add the option to override the emulated type of any given PDO to allow=0A=
> the emulated NVMe device to report its emulated device type as NVME.=0A=
> Adds the override for the QEMU emulated NVMe controller=0A=
> (PCI\VEN_8086&DEV_5845) to indicate it is a NVMe controller, and=0A=
> exposes disk 0.=0A=
> Also extends XENFILT_EMULATED_OBJECT_TYPE to include NVME=0A=
>=0A=
> This is to fix an issue where XenVbd can incorrectly identify that disk=
=0A=
> 0 is not present, when disk 0 is infact the present emulated NVMe=0A=
> device. This is problematic if the VM boots off the emulated device, not=
=0A=
> the PV device (due to the missing unplug) and then rebinds XENVBD which=
=0A=
> is unable to determine the presense of the emulated disk and attempts to=
=0A=
> connect to an in-use ring.=0A=
>=0A=
> Signed-off-by: Owen Smith <owen.smith@citrix.com>=0A=
> ---=0A=
>   src/xenbus.inf         |  1 +=0A=
>   src/xenfilt/driver.c   | 24 +++++++++++++++---=0A=
>   src/xenfilt/driver.h   |  7 ++++++=0A=
>   src/xenfilt/emulated.c | 40 ++++++++++++++++++++++++++++++=0A=
>   src/xenfilt/emulated.h |  3 ++-=0A=
>   src/xenfilt/pdo.c      | 55 ++++++++++++++++++++++++++++++++++++++++++=
=0A=
>   6 files changed, 125 insertions(+), 5 deletions(-)=0A=
>=0A=
> diff --git a/src/xenbus.inf b/src/xenbus.inf=0A=
> index f9a5475..d2f2477 100644=0A=
> --- a/src/xenbus.inf=0A=
> +++ b/src/xenbus.inf=0A=
> @@ -119,6 +119,7 @@ AddReg =3D XenFilt_Parameters=0A=
>   HKR,"Parameters",,0x00000010=0A=
>   HKR,"Parameters","*PNP0A03",0x00000000,"PCI"=0A=
>   HKR,"Parameters","Internal_IDE_Channel",0x00000000,"IDE"=0A=
> +HKR,"Parameters\Override","PCI\VEN_8086&DEV_5845&SUBSYS_11001AF4&REV_02"=
,0x00000000,"NVME"=0A=
=0A=
That's a very strict match. How confident are we that the QEMU device=0A=
won't need to deal with e.g. multiple revisions of the QEMU device?=0A=
Perhaps it would be better to look at class code or is there something=0A=
else that may be a more stable identifier?=0A=
=0A=
   Paul=0A=
=0A=
=0A=
My intention here was to make the match as specific as possible given the i=
nformation immidiately available at the time the override is applied. By ke=
eping it specific, its reducing the chances of wrongly overriding a device.=
=0A=
=0A=
Using device class code may catch devices that are passed through, or are n=
ot otherwise the emulated device that corresponds to the PV device.=0A=
=0A=
Owen=0A=
=0A=
>=0A=
>   [Monitor_Service]=0A=
>   DisplayName=3D%MonitorName%=0A=
> diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c=0A=
> index e9e6673..eb2ca42 100644=0A=
> --- a/src/xenfilt/driver.c=0A=
> +++ b/src/xenfilt/driver.c=0A=
> @@ -723,6 +723,25 @@ fail1:=0A=
>       return status;=0A=
>   }=0A=
>=0A=
> +XENFILT_EMULATED_OBJECT_TYPE=0A=
> +DriverParseEmulatedType(=0A=
> +    IN  PANSI_STRING                Ansi=0A=
> +    )=0A=
> +{=0A=
> +    XENFILT_EMULATED_OBJECT_TYPE    Type;=0A=
> +=0A=
> +    Type =3D XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN;=0A=
> +=0A=
> +    if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) =3D=3D 0)=0A=
> +        Type =3D XENFILT_EMULATED_OBJECT_TYPE_PCI;=0A=
> +    else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) =3D=3D 0)=0A=
> +        Type =3D XENFILT_EMULATED_OBJECT_TYPE_IDE;=0A=
> +    else if (_strnicmp(Ansi->Buffer, "NVME", Ansi->Length) =3D=3D 0)=0A=
> +        Type =3D XENFILT_EMULATED_OBJECT_TYPE_NVME;=0A=
> +=0A=
> +    return Type;=0A=
> +}=0A=
> +=0A=
>   static XENFILT_EMULATED_OBJECT_TYPE=0A=
>   DriverGetEmulatedType(=0A=
>       IN  PCHAR                       Id=0A=
> @@ -753,10 +772,7 @@ DriverGetEmulatedType(=0A=
>           if (NT_SUCCESS(status)) {=0A=
>               Info("MATCH: %s -> %Z\n", &Id[Index], Ansi);=0A=
>=0A=
> -            if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) =3D=3D 0)=
=0A=
> -                Type =3D XENFILT_EMULATED_OBJECT_TYPE_PCI;=0A=
> -            else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) =3D=3D=
 0)=0A=
> -                Type =3D XENFILT_EMULATED_OBJECT_TYPE_IDE;=0A=
> +            Type =3D DriverParseEmulatedType(Ansi);=0A=
>=0A=
>               RegistryFreeSzValue(Ansi);=0A=
>           } else {=0A=
> diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h=0A=
> index 286580b..2129054 100644=0A=
> --- a/src/xenfilt/driver.h=0A=
> +++ b/src/xenfilt/driver.h=0A=
> @@ -32,6 +32,8 @@=0A=
>   #ifndef _XENFILT_DRIVER_H=0A=
>   #define _XENFILT_DRIVER_H=0A=
>=0A=
> +#include "emulated.h"=0A=
> +=0A=
>   extern PDRIVER_OBJECT=0A=
>   DriverGetDriverObject(=0A=
>       VOID=0A=
> @@ -58,6 +60,11 @@ DriverGetActive(=0A=
>       OUT PCHAR       *Value=0A=
>       );=0A=
>=0A=
> +extern XENFILT_EMULATED_OBJECT_TYPE=0A=
> +DriverParseEmulatedType(=0A=
> +    IN  PANSI_STRING                Ansi=0A=
> +    );=0A=
> +=0A=
>   typedef enum _XENFILT_FILTER_STATE {=0A=
>       XENFILT_FILTER_ENABLED =3D 0,=0A=
>       XENFILT_FILTER_PENDING,=0A=
> diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c=0A=
> index 827c905..97da61b 100644=0A=
> --- a/src/xenfilt/emulated.c=0A=
> +++ b/src/xenfilt/emulated.c=0A=
> @@ -87,6 +87,33 @@ __EmulatedFree(=0A=
>       __FreePoolWithTag(Buffer, XENFILT_EMULATED_TAG);=0A=
>   }=0A=
>=0A=
> +static NTSTATUS=0A=
> +EmulatedSetObjectNvmeData(=0A=
> +    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,=0A=
> +    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,=0A=
> +    IN  PCHAR                           DeviceID,=0A=
> +    IN  PCHAR                           InstanceID=0A=
> +    )=0A=
> +{=0A=
> +    NTSTATUS                            status;=0A=
> +=0A=
> +    UNREFERENCED_PARAMETER(DeviceID);=0A=
> +    UNREFERENCED_PARAMETER(InstanceID);=0A=
> +=0A=
> +    status =3D STATUS_INVALID_PARAMETER;=0A=
> +    if (Type !=3D XENFILT_EMULATED_OBJECT_TYPE_NVME)=0A=
> +        goto fail1;=0A=
> +=0A=
> +    EmulatedObject->Data.Disk.Index =3D 0;=0A=
> +=0A=
> +    return STATUS_SUCCESS;=0A=
> +=0A=
> +fail1:=0A=
> +    Error("fail1 (%08x)\n", status);=0A=
> +=0A=
> +    return status;=0A=
> +}=0A=
> +=0A=
>   static NTSTATUS=0A=
>   EmulatedSetObjectDeviceData(=0A=
>       IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,=0A=
> @@ -210,6 +237,13 @@ EmulatedAddObject(=0A=
>           goto fail1;=0A=
>=0A=
>       switch (Type) {=0A=
> +    case XENFILT_EMULATED_OBJECT_TYPE_NVME:=0A=
> +        status =3D EmulatedSetObjectNvmeData(*EmulatedObject,=0A=
> +                                           Type,=0A=
> +                                           DeviceID,=0A=
> +                                           InstanceID);=0A=
> +        break;=0A=
> +=0A=
>       case XENFILT_EMULATED_OBJECT_TYPE_PCI:=0A=
>           status =3D EmulatedSetObjectDeviceData(*EmulatedObject,=0A=
>                                                Type,=0A=
> @@ -338,6 +372,12 @@ EmulatedIsDiskPresent(=0A=
>               Trace("FOUND\n");=0A=
>               break;=0A=
>           }=0A=
> +        if (EmulatedObject->Type =3D=3D XENFILT_EMULATED_OBJECT_TYPE_NVM=
E &&=0A=
> +            Index =3D=3D EmulatedObject->Data.Disk.Index) {=0A=
> +            Trace("FOUND\n");=0A=
> +            break;=0A=
> +        }=0A=
> +=0A=
>=0A=
>           ListEntry =3D ListEntry->Flink;=0A=
>       }=0A=
> diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h=0A=
> index 57edee2..499e43c 100644=0A=
> --- a/src/xenfilt/emulated.h=0A=
> +++ b/src/xenfilt/emulated.h=0A=
> @@ -41,7 +41,8 @@ typedef struct _XENFILT_EMULATED_CONTEXT XENFILT_EMULAT=
ED_CONTEXT, *PXENFILT_EMU=0A=
>   typedef enum _XENFILT_EMULATED_OBJECT_TYPE {=0A=
>       XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN =3D 0,=0A=
>       XENFILT_EMULATED_OBJECT_TYPE_PCI,=0A=
> -    XENFILT_EMULATED_OBJECT_TYPE_IDE=0A=
> +    XENFILT_EMULATED_OBJECT_TYPE_IDE,=0A=
> +    XENFILT_EMULATED_OBJECT_TYPE_NVME=0A=
>   } XENFILT_EMULATED_OBJECT_TYPE, *PXENFILT_EMULATED_OBJECT_TYPE;=0A=
>=0A=
>   typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, *PXENF=
ILT_EMULATED_OBJECT;=0A=
> diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c=0A=
> index 0f6e6ce..41b0b10 100644=0A=
> --- a/src/xenfilt/pdo.c=0A=
> +++ b/src/xenfilt/pdo.c=0A=
> @@ -42,6 +42,7 @@=0A=
>   #include "pdo.h"=0A=
>   #include "thread.h"=0A=
>   #include "driver.h"=0A=
> +#include "registry.h"=0A=
>   #include "dbg_print.h"=0A=
>   #include "assert.h"=0A=
>   #include "util.h"=0A=
> @@ -251,6 +252,58 @@ __PdoGetFdo(=0A=
>       return Pdo->Fdo;=0A=
>   }=0A=
>=0A=
> +static VOID=0A=
> +__PdoGetEmulatedTypeOverride(=0A=
> +    IN  PXENFILT_PDO                Pdo,=0A=
> +    IN  PCHAR                       DeviceID=0A=
> +    )=0A=
> +{=0A=
> +    HANDLE                          ParametersKey;=0A=
> +    HANDLE                          OverrideKey;=0A=
> +    ULONG                           ValueType;=0A=
> +    PANSI_STRING                    Ansi;=0A=
> +    XENFILT_EMULATED_OBJECT_TYPE    Type;=0A=
> +    NTSTATUS                        status;=0A=
> +=0A=
> +    ParametersKey =3D DriverGetParametersKey();=0A=
> +=0A=
> +    status =3D RegistryOpenSubKey(ParametersKey,=0A=
> +                                "Override",=0A=
> +                                GENERIC_READ,=0A=
> +                                &OverrideKey);=0A=
> +    if (!NT_SUCCESS(status))=0A=
> +        goto fail1;=0A=
> +=0A=
> +    status =3D RegistryQuerySzValue(OverrideKey,=0A=
> +                                  DeviceID,=0A=
> +                                  &ValueType,=0A=
> +                                  &Ansi);=0A=
> +    if (!NT_SUCCESS(status))=0A=
> +        goto fail2;=0A=
> +=0A=
> +    if (ValueType !=3D REG_SZ)=0A=
> +        goto fail3;=0A=
> +=0A=
> +    Type =3D DriverParseEmulatedType(Ansi);=0A=
> +    if (Type !=3D XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN)=0A=
> +        Pdo->Type =3D Type;=0A=
> +=0A=
> +    RegistryFreeSzValue(Ansi);=0A=
> +=0A=
> +    RegistryCloseKey(OverrideKey);=0A=
> +=0A=
> +    return;=0A=
> +=0A=
> +fail3:=0A=
> +    RegistryFreeSzValue(Ansi);=0A=
> +=0A=
> +fail2:=0A=
> +    RegistryCloseKey(OverrideKey);=0A=
> +=0A=
> +fail1:=0A=
> +    return;=0A=
> +}=0A=
> +=0A=
>   static NTSTATUS=0A=
>   PdoSetDeviceInformation(=0A=
>       IN  PXENFILT_PDO    Pdo=0A=
> @@ -310,6 +363,8 @@ PdoSetDeviceInformation(=0A=
>               LocationInformation =3D NULL;=0A=
>       }=0A=
>=0A=
> +    __PdoGetEmulatedTypeOverride(Pdo, DeviceID);=0A=
> +=0A=
>       Dx->DeviceID =3D DeviceID;=0A=
>       Dx->InstanceID =3D InstanceID;=0A=
>       Dx->LocationInformation =3D LocationInformation;=0A=
>=0A=
=0A=
=0A=


From win-pv-devel-bounces@lists.xenproject.org Fri Mar 26 09:32:25 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 26 Mar 2021 09:32:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.101657.194551 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPipM-0002bY-El; Fri, 26 Mar 2021 09:32:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 101657.194551; Fri, 26 Mar 2021 09:32:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPipM-0002bP-At; Fri, 26 Mar 2021 09:32:24 +0000
Received: by outflank-mailman (input) for mailman id 101657;
 Fri, 26 Mar 2021 09:32:23 +0000
Received: from us1-rack-iad1.inumbo.com ([172.99.69.81])
 by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from
 <SRS0=G2QT=IY=gmail.com=xadimgnik@srs-us1.protection.inumbo.net>)
 id 1lPipK-0002bK-Uz
 for win-pv-devel@lists.xenproject.org; Fri, 26 Mar 2021 09:32:23 +0000
Received: from mail-wm1-x32b.google.com (unknown [2a00:1450:4864:20::32b])
 by us1-rack-iad1.inumbo.com (Halon) with ESMTPS
 id 12e09d50-b0c8-4713-8178-4e6c75b46de2;
 Fri, 26 Mar 2021 09:32:21 +0000 (UTC)
Received: by mail-wm1-x32b.google.com with SMTP id
 w203-20020a1c49d40000b029010c706d0642so5602662wma.0
 for <win-pv-devel@lists.xenproject.org>; Fri, 26 Mar 2021 02:32:21 -0700 (PDT)
Received: from ?IPv6:2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec?
 ([2a00:23c5:5785:9a01:ad9a:ab78:5748:a7ec])
 by smtp.gmail.com with ESMTPSA id p18sm12984974wro.18.2021.03.26.02.32.19
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 26 Mar 2021 02:32: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: 12e09d50-b0c8-4713-8178-4e6c75b46de2
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=from:reply-to:subject:to:references:message-id:date:user-agent
         :mime-version:in-reply-to:content-language:content-transfer-encoding;
        bh=XgeTfiLjvDNa9igbHPZt6mXpFRGWGoQp9rOOBeI3t7k=;
        b=jEE1xhCjI2IA6aHhC/ZSBl/tgugDBhPbBzEhboBd7Rg/zpo6eFtJyQrQBN0ls/RVPI
         XmYIm1Wg3AN6NKblD5Sv63vqNNqscT1Dvmd1P2R0A1ZhsmaLZ14Iq6aI9GGLurWuaQhD
         XsyF3ShwKeKYTAS+sNi6doG30b/crUSAIlUk2t9R27F8OKQFbwRu9lJlMWpnHOMDyhU+
         b0d/LQUvLgfJivpHz7yahZJVWTraFpgjOBtmt3PZgsGF3sC59ICoZULouSW9lJLPFEP0
         f0Z+raNxKa6fQUQJysYnhRB718ORGbJjisF136pTj7+c5mlVCtAKDG6pc4GUhTMlRQU0
         6pJA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:reply-to:subject:to:references:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=XgeTfiLjvDNa9igbHPZt6mXpFRGWGoQp9rOOBeI3t7k=;
        b=dV0RQeVB53NFxoLn/z/UmDf3BDGXQj3zQ/PEmeDvfANdXoyaM2vwx3Lgv8OHFoG7zj
         cZ3LW1m9Bl/wap9yjd3N/SrXwJSnMxHyoTC0yuLBjyN8uFI6abJU1sCpOFQh4RSwIxjQ
         uPFXRwF13xCxynyhmvcPvjwL/VFmo8nhVziOGdF++bUUdUprFlEWfxh4Tg59QbftH50M
         lwuBmtJ1Zi/X2RM/G5amVZE14FXkatWdzsNiqp0lL3EbPLUYTaQlv2Vv1c54qBR5/L6b
         F8Q1mQQAoC8N98e8dSN+V3yy9Taou5WPnoFsJALnDORy2Ig1xV2Q8qwSBMwqiQxSIkdn
         rToA==
X-Gm-Message-State: AOAM532loc0Sze3NH+HZQTF7N8H2gdfLg5o2prFSNuF0ESryuKf4lec1
	y0HQfYbvXc001HVE3bc/9gV5b0NYopI=
X-Google-Smtp-Source: ABdhPJyJi0pd2spw41kp5tcOKn0yvRVVVLTLC+u/Q1VXf4JCyPqWYTZIMUTkGW70GT8x7XRtTR6C+g==
X-Received: by 2002:a1c:7fc9:: with SMTP id a192mr11552419wmd.15.1616751140697;
        Fri, 26 Mar 2021 02:32:20 -0700 (PDT)
From: Paul Durrant <xadimgnik@gmail.com>
X-Google-Original-From: Paul Durrant <paul@xen.org>
Reply-To: paul@xen.org
Subject: Re: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override
To: Owen Smith <owen.smith@citrix.com>,
 "win-pv-devel@lists.xenproject.org" <win-pv-devel@lists.xenproject.org>
References: <20210315112545.1082776-1-owen.smith@citrix.com>
 <46cd5cb3-cae2-5263-caa7-06d54002942c@xen.org>
 <DS7PR03MB54774E4C6372D1CC23647EE4FE619@DS7PR03MB5477.namprd03.prod.outlook.com>
Message-ID: <8e4ff604-d2f1-3796-9924-9d96d876e52f@xen.org>
Date: Fri, 26 Mar 2021 09:32:19 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
 Thunderbird/78.8.1
MIME-Version: 1.0
In-Reply-To: <DS7PR03MB54774E4C6372D1CC23647EE4FE619@DS7PR03MB5477.namprd03.prod.outlook.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit

On 26/03/2021 08:58, Owen Smith wrote:
> ________________________________________
> From: win-pv-devel <win-pv-devel-bounces@lists.xenproject.org> on behalf of Paul Durrant <xadimgnik@gmail.com>
> Sent: 26 March 2021 08:10
> To: win-pv-devel@lists.xenproject.org
> Subject: Re: [PATCH] Add XENFILT_EMULATED_OBJECT_TYPE override
> 
> [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments unless you have verified the sender and know the content is safe.
> 
> On 15/03/2021 11:25, Owen Smith wrote:
>> EMULATED(IsDiskPresent) currently only reports if IDE disks are present.
>> Add the option to override the emulated type of any given PDO to allow
>> the emulated NVMe device to report its emulated device type as NVME.
>> Adds the override for the QEMU emulated NVMe controller
>> (PCI\VEN_8086&DEV_5845) to indicate it is a NVMe controller, and
>> exposes disk 0.
>> Also extends XENFILT_EMULATED_OBJECT_TYPE to include NVME
>>
>> This is to fix an issue where XenVbd can incorrectly identify that disk
>> 0 is not present, when disk 0 is infact the present emulated NVMe
>> device. This is problematic if the VM boots off the emulated device, not
>> the PV device (due to the missing unplug) and then rebinds XENVBD which
>> is unable to determine the presense of the emulated disk and attempts to
>> connect to an in-use ring.
>>
>> Signed-off-by: Owen Smith <owen.smith@citrix.com>
>> ---
>>    src/xenbus.inf         |  1 +
>>    src/xenfilt/driver.c   | 24 +++++++++++++++---
>>    src/xenfilt/driver.h   |  7 ++++++
>>    src/xenfilt/emulated.c | 40 ++++++++++++++++++++++++++++++
>>    src/xenfilt/emulated.h |  3 ++-
>>    src/xenfilt/pdo.c      | 55 ++++++++++++++++++++++++++++++++++++++++++
>>    6 files changed, 125 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/xenbus.inf b/src/xenbus.inf
>> index f9a5475..d2f2477 100644
>> --- a/src/xenbus.inf
>> +++ b/src/xenbus.inf
>> @@ -119,6 +119,7 @@ AddReg = XenFilt_Parameters
>>    HKR,"Parameters",,0x00000010
>>    HKR,"Parameters","*PNP0A03",0x00000000,"PCI"
>>    HKR,"Parameters","Internal_IDE_Channel",0x00000000,"IDE"
>> +HKR,"Parameters\Override","PCI\VEN_8086&DEV_5845&SUBSYS_11001AF4&REV_02",0x00000000,"NVME"
> 
> That's a very strict match. How confident are we that the QEMU device
> won't need to deal with e.g. multiple revisions of the QEMU device?
> Perhaps it would be better to look at class code or is there something
> else that may be a more stable identifier?
> 
>     Paul
> 
> 
> My intention here was to make the match as specific as possible given the information immidiately available at the time the override is applied. By keeping it specific, its reducing the chances of wrongly overriding a device.

Fair enough, but I wonder how much this ties us to specfic versions of QEMU.

> 
> Using device class code may catch devices that are passed through, or are not otherwise the emulated device that corresponds to the PV device.

Actually shouldn't we be installing XENFILT on the controller? It's 
going to the thing enumerating the disk PDOs and (if they're anything 
like the real NVMe device in my laptop) they have a more specific id 
string in the hardware ids. That may allow us to install the filter on 
any device with a class code of 010802 (i.e. mass storage/non-volatile 
memory/NVMe) and then spot the actual QEMU NVMe disks.

   Paul

> 
> Owen
> 
>>
>>    [Monitor_Service]
>>    DisplayName=%MonitorName%
>> diff --git a/src/xenfilt/driver.c b/src/xenfilt/driver.c
>> index e9e6673..eb2ca42 100644
>> --- a/src/xenfilt/driver.c
>> +++ b/src/xenfilt/driver.c
>> @@ -723,6 +723,25 @@ fail1:
>>        return status;
>>    }
>>
>> +XENFILT_EMULATED_OBJECT_TYPE
>> +DriverParseEmulatedType(
>> +    IN  PANSI_STRING                Ansi
>> +    )
>> +{
>> +    XENFILT_EMULATED_OBJECT_TYPE    Type;
>> +
>> +    Type = XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN;
>> +
>> +    if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
>> +        Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
>> +    else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
>> +        Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
>> +    else if (_strnicmp(Ansi->Buffer, "NVME", Ansi->Length) == 0)
>> +        Type = XENFILT_EMULATED_OBJECT_TYPE_NVME;
>> +
>> +    return Type;
>> +}
>> +
>>    static XENFILT_EMULATED_OBJECT_TYPE
>>    DriverGetEmulatedType(
>>        IN  PCHAR                       Id
>> @@ -753,10 +772,7 @@ DriverGetEmulatedType(
>>            if (NT_SUCCESS(status)) {
>>                Info("MATCH: %s -> %Z\n", &Id[Index], Ansi);
>>
>> -            if (_strnicmp(Ansi->Buffer, "PCI", Ansi->Length) == 0)
>> -                Type = XENFILT_EMULATED_OBJECT_TYPE_PCI;
>> -            else if (_strnicmp(Ansi->Buffer, "IDE", Ansi->Length) == 0)
>> -                Type = XENFILT_EMULATED_OBJECT_TYPE_IDE;
>> +            Type = DriverParseEmulatedType(Ansi);
>>
>>                RegistryFreeSzValue(Ansi);
>>            } else {
>> diff --git a/src/xenfilt/driver.h b/src/xenfilt/driver.h
>> index 286580b..2129054 100644
>> --- a/src/xenfilt/driver.h
>> +++ b/src/xenfilt/driver.h
>> @@ -32,6 +32,8 @@
>>    #ifndef _XENFILT_DRIVER_H
>>    #define _XENFILT_DRIVER_H
>>
>> +#include "emulated.h"
>> +
>>    extern PDRIVER_OBJECT
>>    DriverGetDriverObject(
>>        VOID
>> @@ -58,6 +60,11 @@ DriverGetActive(
>>        OUT PCHAR       *Value
>>        );
>>
>> +extern XENFILT_EMULATED_OBJECT_TYPE
>> +DriverParseEmulatedType(
>> +    IN  PANSI_STRING                Ansi
>> +    );
>> +
>>    typedef enum _XENFILT_FILTER_STATE {
>>        XENFILT_FILTER_ENABLED = 0,
>>        XENFILT_FILTER_PENDING,
>> diff --git a/src/xenfilt/emulated.c b/src/xenfilt/emulated.c
>> index 827c905..97da61b 100644
>> --- a/src/xenfilt/emulated.c
>> +++ b/src/xenfilt/emulated.c
>> @@ -87,6 +87,33 @@ __EmulatedFree(
>>        __FreePoolWithTag(Buffer, XENFILT_EMULATED_TAG);
>>    }
>>
>> +static NTSTATUS
>> +EmulatedSetObjectNvmeData(
>> +    IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
>> +    IN  XENFILT_EMULATED_OBJECT_TYPE    Type,
>> +    IN  PCHAR                           DeviceID,
>> +    IN  PCHAR                           InstanceID
>> +    )
>> +{
>> +    NTSTATUS                            status;
>> +
>> +    UNREFERENCED_PARAMETER(DeviceID);
>> +    UNREFERENCED_PARAMETER(InstanceID);
>> +
>> +    status = STATUS_INVALID_PARAMETER;
>> +    if (Type != XENFILT_EMULATED_OBJECT_TYPE_NVME)
>> +        goto fail1;
>> +
>> +    EmulatedObject->Data.Disk.Index = 0;
>> +
>> +    return STATUS_SUCCESS;
>> +
>> +fail1:
>> +    Error("fail1 (%08x)\n", status);
>> +
>> +    return status;
>> +}
>> +
>>    static NTSTATUS
>>    EmulatedSetObjectDeviceData(
>>        IN  PXENFILT_EMULATED_OBJECT        EmulatedObject,
>> @@ -210,6 +237,13 @@ EmulatedAddObject(
>>            goto fail1;
>>
>>        switch (Type) {
>> +    case XENFILT_EMULATED_OBJECT_TYPE_NVME:
>> +        status = EmulatedSetObjectNvmeData(*EmulatedObject,
>> +                                           Type,
>> +                                           DeviceID,
>> +                                           InstanceID);
>> +        break;
>> +
>>        case XENFILT_EMULATED_OBJECT_TYPE_PCI:
>>            status = EmulatedSetObjectDeviceData(*EmulatedObject,
>>                                                 Type,
>> @@ -338,6 +372,12 @@ EmulatedIsDiskPresent(
>>                Trace("FOUND\n");
>>                break;
>>            }
>> +        if (EmulatedObject->Type == XENFILT_EMULATED_OBJECT_TYPE_NVME &&
>> +            Index == EmulatedObject->Data.Disk.Index) {
>> +            Trace("FOUND\n");
>> +            break;
>> +        }
>> +
>>
>>            ListEntry = ListEntry->Flink;
>>        }
>> diff --git a/src/xenfilt/emulated.h b/src/xenfilt/emulated.h
>> index 57edee2..499e43c 100644
>> --- a/src/xenfilt/emulated.h
>> +++ b/src/xenfilt/emulated.h
>> @@ -41,7 +41,8 @@ typedef struct _XENFILT_EMULATED_CONTEXT XENFILT_EMULATED_CONTEXT, *PXENFILT_EMU
>>    typedef enum _XENFILT_EMULATED_OBJECT_TYPE {
>>        XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN = 0,
>>        XENFILT_EMULATED_OBJECT_TYPE_PCI,
>> -    XENFILT_EMULATED_OBJECT_TYPE_IDE
>> +    XENFILT_EMULATED_OBJECT_TYPE_IDE,
>> +    XENFILT_EMULATED_OBJECT_TYPE_NVME
>>    } XENFILT_EMULATED_OBJECT_TYPE, *PXENFILT_EMULATED_OBJECT_TYPE;
>>
>>    typedef struct _XENFILT_EMULATED_OBJECT XENFILT_EMULATED_OBJECT, *PXENFILT_EMULATED_OBJECT;
>> diff --git a/src/xenfilt/pdo.c b/src/xenfilt/pdo.c
>> index 0f6e6ce..41b0b10 100644
>> --- a/src/xenfilt/pdo.c
>> +++ b/src/xenfilt/pdo.c
>> @@ -42,6 +42,7 @@
>>    #include "pdo.h"
>>    #include "thread.h"
>>    #include "driver.h"
>> +#include "registry.h"
>>    #include "dbg_print.h"
>>    #include "assert.h"
>>    #include "util.h"
>> @@ -251,6 +252,58 @@ __PdoGetFdo(
>>        return Pdo->Fdo;
>>    }
>>
>> +static VOID
>> +__PdoGetEmulatedTypeOverride(
>> +    IN  PXENFILT_PDO                Pdo,
>> +    IN  PCHAR                       DeviceID
>> +    )
>> +{
>> +    HANDLE                          ParametersKey;
>> +    HANDLE                          OverrideKey;
>> +    ULONG                           ValueType;
>> +    PANSI_STRING                    Ansi;
>> +    XENFILT_EMULATED_OBJECT_TYPE    Type;
>> +    NTSTATUS                        status;
>> +
>> +    ParametersKey = DriverGetParametersKey();
>> +
>> +    status = RegistryOpenSubKey(ParametersKey,
>> +                                "Override",
>> +                                GENERIC_READ,
>> +                                &OverrideKey);
>> +    if (!NT_SUCCESS(status))
>> +        goto fail1;
>> +
>> +    status = RegistryQuerySzValue(OverrideKey,
>> +                                  DeviceID,
>> +                                  &ValueType,
>> +                                  &Ansi);
>> +    if (!NT_SUCCESS(status))
>> +        goto fail2;
>> +
>> +    if (ValueType != REG_SZ)
>> +        goto fail3;
>> +
>> +    Type = DriverParseEmulatedType(Ansi);
>> +    if (Type != XENFILT_EMULATED_OBJECT_TYPE_UNKNOWN)
>> +        Pdo->Type = Type;
>> +
>> +    RegistryFreeSzValue(Ansi);
>> +
>> +    RegistryCloseKey(OverrideKey);
>> +
>> +    return;
>> +
>> +fail3:
>> +    RegistryFreeSzValue(Ansi);
>> +
>> +fail2:
>> +    RegistryCloseKey(OverrideKey);
>> +
>> +fail1:
>> +    return;
>> +}
>> +
>>    static NTSTATUS
>>    PdoSetDeviceInformation(
>>        IN  PXENFILT_PDO    Pdo
>> @@ -310,6 +363,8 @@ PdoSetDeviceInformation(
>>                LocationInformation = NULL;
>>        }
>>
>> +    __PdoGetEmulatedTypeOverride(Pdo, DeviceID);
>> +
>>        Dx->DeviceID = DeviceID;
>>        Dx->InstanceID = InstanceID;
>>        Dx->LocationInformation = LocationInformation;
>>
> 
> 



From win-pv-devel-bounces@lists.xenproject.org Fri Mar 26 17:25:39 2021
Return-path: <win-pv-devel-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xenproject.org
Delivery-date: Fri, 26 Mar 2021 17:25:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.101987.195417 (Exim 4.92)
	(envelope-from <win-pv-devel-bounces@lists.xenproject.org>)
	id 1lPqDJ-0003mC-Iu; Fri, 26 Mar 2021 17:25:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 101987.195417; Fri, 26 Mar 2021 17:25:37 +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 1lPqDJ-0003m5-Fs; Fri, 26 Mar 2021 17:25:37 +0000
Received: by outflank-mailman (input) for mailman id 101987;
 Fri, 26 Mar 2021 17:25:36 +0000
Received: from winpvdrvbuild.xenproject.org ([162.242.160.44])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <paul.durrant@xenproject.org>) id 1lPqDH-0003lz-W4
 for win-pv-devel@lists.xenproject.org; Fri, 26 Mar 2021 17:25:36 +0000
X-BeenThere: win-pv-devel@lists.xenproject.org
List-Id: Developer list for the Windows PV Drivers subproject
 <win-pv-devel.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:win-pv-devel@lists.xenproject.org>
List-Help: <mailto:win-pv-devel-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/win-pv-devel>, 
 <mailto:win-pv-devel-request@lists.xenproject.org?subject=subscribe>
Errors-To: win-pv-devel-bounces@lists.xenproject.org
Precedence: list
Sender: "win-pv-devel" <win-pv-devel-bounces@lists.xenproject.org>
Date: Fri, 26 Mar 2021 17:25:39 +0000 (UTC)
From: paul.durrant@xenproject.org
To: win-pv-devel@lists.xenproject.org
Message-ID: <5410728.1.1616779541197.JavaMail.WINPVDRVBUILD$@winpvdrvbuild>
Subject: XENBUS-master - Build #219 - Successful
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_0_32472269.1616779540541"
X-Jenkins-Job: XENBUS-master
X-Jenkins-Result: SUCCESS


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

The build system has completed build #219.

Check console output at https://winpvdrvbuild.xenproject.org:8080/job/XENBUS-master/219/console to view the results.
------=_Part_0_32472269.1616779540541--


