]> xenbits.xensource.com Git - pvdrivers/win/xencons.git/log
pvdrivers/win/xencons.git
9 months agoUpdate MAINTAINERS master
Paul Durrant [Tue, 2 Jul 2024 08:57:19 +0000 (09:57 +0100)]
Update MAINTAINERS

Remove Ben as he is no longer involved in the project, and update Owen's
email address.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
16 months agoRemove "Win32" as a build target from VS2022 projects
Owen Smith [Mon, 20 Nov 2023 14:17:30 +0000 (14:17 +0000)]
Remove "Win32" as a build target from VS2022 projects

VS2022 is used with EWDK 22621 and later. Win32 is no longer a valid build
target for this set of tools

Signed-off-by: Owen Smith <owen.smith@cloud.com>
16 months agoRemove "Windows 8" as a build target
Owen Smith [Mon, 20 Nov 2023 14:17:29 +0000 (14:17 +0000)]
Remove "Windows 8" as a build target

Windows 8 is no longer a supported build target with Microsoft, remove
this as a build target

Signed-off-by: Owen Smith <owen.smith@cloud.com>
16 months agoRemove VS2015 and VS2017 projects and configurations
Owen Smith [Mon, 20 Nov 2023 14:17:28 +0000 (14:17 +0000)]
Remove VS2015 and VS2017 projects and configurations

Signed-off-by: Owen Smith <owen.smith@cloud.com>
19 months agoDelete CoInstaller code
Owen Smith [Mon, 2 Oct 2023 10:30:18 +0000 (11:30 +0100)]
Delete CoInstaller code

With the CoInstaller removed from the INF file, delete the CoInstaller
source code and projects.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
19 months agoRemove CoInstaller from INF
Owen Smith [Mon, 2 Oct 2023 10:30:17 +0000 (11:30 +0100)]
Remove CoInstaller from INF

Windows 11 22H2 WHQL requires INF files pass "InfVerif /k", which highlights
several issues
- PnpLockdown=1 needs to be specified
- CoInstallers are no longer allowed

The CoInstaller has several functions that will need alternative solutions:
- The AllowUpdate mechanism is no longer possible
- The safety checks that ensure interface versionings remain compatible
- Cleanup user mode service (xencons_monitor) on uninstall

Interface safety checks need to be handled by changes to child device bindings,
and assuming upgrade via emulated devices is safe.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
19 months agoAdd script to generate pooltag.txt for debugger use
Owen Smith [Wed, 13 Sep 2023 08:48:35 +0000 (09:48 +0100)]
Add script to generate pooltag.txt for debugger use

Note: script does not correctly handle src/common paths and attributes
  pool tags discovered within to 'common.sys'

Signed-off-by: Owen Smith <owen.smith@cloud.com>
23 months agoRebuild CodeQL builds
Owen Smith [Tue, 18 Apr 2023 08:50:45 +0000 (09:50 +0100)]
Rebuild CodeQL builds

CodeQL can sometimes fail to detect any source code if the codebase is
not rebuilt. Use the Rebuild target to force all intermediate build artifacts
to be cleaned beforehand.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
23 months agoCheck for zero byte allocations
Owen Smith [Mon, 17 Apr 2023 13:24:39 +0000 (14:24 +0100)]
Check for zero byte allocations

Avoid attempting to allocate zero byte buffers, which can lead to
inefficiencies in pool memory usage.

Suggested-by: Matthew Sykes <matthew.sykes@citrix.com>
Signed-off-by: Owen Smith <owen.smith@cloud.com>
2 years agoRemove trailing blank lines
Paul Durrant [Thu, 23 Mar 2023 16:08:08 +0000 (16:08 +0000)]
Remove trailing blank lines

Use the following bit of shell to remove a trailing blank line from each
file where such exists.

echo "$(echo "$(tac $file)" | tac)" > $file

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
2 years agoScripted replacement of Copyright notices in source
Owen Smith [Thu, 23 Feb 2023 09:47:26 +0000 (09:47 +0000)]
Scripted replacement of Copyright notices in source

Due to a transfer of copyright ownership from Citrix to Cloud Software Group,
the copyright notices in all source files should be updated.

Using the powershell script below replace "Copyright (c) Citrix Systems, Inc."
with "Copyright (c) Xen Project." and "Copyright (c) Cloud Software Group, Inc."

Function Multiline-Replace {
    param(
        [string]$Filename,
        [string]$ToReplace,
        [array]$ReplaceWith
    )

    $content = Get-Content $Filename
    $replace = $false
    $output = ""
    $content | ForEach {
        $line = $_
        if ($line.Contains($ToReplace)) {
            $replace = $true
            $ReplaceWith | ForEach {
                $output += $line.Replace($ToReplace, $_) + "`n"
            }
        } else {
            $output += $line + "`n"
        }
    }
    if ($replace) {
        Write-Host "Replacing: " $Filename
        $output | Set-Content $Filename
    } else {
        Write-Host "Ignoring:  " $Filename
    }
}

Function Replace-Filestrings {
    param(
        [array]$FilleTypes,
        [string]$ToReplace,
        [array]$Replacements,
        [array]$ExcludeList
    )

    $FileTypes | ForEach {
        Get-ChildItem $_ -Recurse | ForEach-Object {
            $filename = $_
            if (($ExcludeList | %{ $filename -Like $_ }) -Contains $True) {
                Write-Host "Excluding: " $filename
            } else {
                Multiline-Replace $_ $ToReplace $Replacements
            }
        }
    }
}

$ExcludeList = @("*include\xen\*", "*\obj\*")
$Replace = "Copyright (c) Citrix Systems Inc."

$Replacements = @("/* Copyright (c) Xen Project.", " * Copyright (c) Cloud Software Group, Inc.")
$FileTypes = @("*.c", "*.h", "*.rc")
Replace-Filestrings $FileTypes ('/* ' + $Replace) $Replacements $ExcludeList

$Replacements = @("; // Copyright (c) Xen Project.", "; // Copyright (c) Cloud Software Group, Inc.")
$FileTypes = @("*.mc")
Replace-Filestrings $FileTypes ('; // ' + $Replace) $Replacements $ExcludeList

$Replacements = @("; Copyright (c) Xen Project.", "; Copyright (c) Cloud Software Group, Inc.")
$FileTypes = @("*.inf", "*.def")
Replace-Filestrings $FileTypes ('; ' + $Replace) $Replacements $ExcludeList

$Replacements = @("Copyright (c) Xen Project.", "Copyright (c) Cloud Software Group, Inc.")
$FileTypes = @("LICENSE")
Replace-Filestrings $FileTypes $Replace $Replacements $ExcludeList

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Amended commit comment. Fixed whitespace.

Signed-off-by: Paul Durrant <paul@xen.org>
2 years agoAdd resource file to coinstaller
Owen Smith [Thu, 23 Feb 2023 09:47:25 +0000 (09:47 +0000)]
Add resource file to coinstaller

Signed-off-by: Owen Smith <owen.smith@citrix.com>
2 years agoAllow rebranding file copyright string
Owen Smith [Thu, 23 Feb 2023 09:47:24 +0000 (09:47 +0000)]
Allow rebranding file copyright string

Pass COPYRIGHT string from environment to override the copyright string
that is embedded in the output binaries.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
2 years agoCorrect return codes during racy destruction.
Martin Harvey [Mon, 5 Dec 2022 09:01:59 +0000 (09:01 +0000)]
Correct return codes during racy destruction.

Errors in PnP retun codes found when testing under driver
verifier with mixed VM lifecycle operations. Under some
rare cases, it is possible to get more than one PnP
"remove-like" operation. This results in a PnP remove
operation being processed whilst the device is already
in the deleted state.

This patch fixes the immediate cause of the bugfixes,
by fixing the return code. Device destruction is
unchanged. Investigation into the root cause is still
ongoing.

Signed-off-by: Martin Harvey <martin.harvey@citrix.com>
Cosmetic fixes.

Signed-off-by: Paul Durrant <paul@xen.org>
2 years agoPass SignMode to MSBuild
Owen Smith [Fri, 18 Nov 2022 10:06:10 +0000 (10:06 +0000)]
Pass SignMode to MSBuild

Allows overriding of SignMode to "Off" to prevent signing binaries with the PFX
file. This is useful if wrapper builds sign binaries with alternative signatures
or when signing is not required.

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

Signed-off-by: Paul Durrant <paul@xen.org>
2 years agoAdd build options for EWDK 22621
Paul Durrant [Mon, 31 Oct 2022 14:16:06 +0000 (14:16 +0000)]
Add build options for EWDK 22621

VisualStudioVersion = 17.0 maps to Visual Studio 2022
 * Adds project files for vs2022
 * Adds mapping from VisualStudioVersion 17.0 to "vs2022" project folder
 * Adds mapping from VisualStudioVersion 17.0 to "Windows 10" build target
 * Adds guard to build.ps1 - EWDK 22621 does not build x86 binaries
 * Adds include directive where compiler intrinsics are used
   (and removes re-definition of 'offsetof')

Suggested-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
2 years agoAdd Svr2019, Svr2022 and Win11 to Inf2Cat
Owen Smith [Thu, 30 Jun 2022 14:24:03 +0000 (15:24 +0100)]
Add Svr2019, Svr2022 and Win11 to Inf2Cat

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoAdd /CETCOMPAT to linker options
Owen Smith [Mon, 29 Nov 2021 10:02:02 +0000 (10:02 +0000)]
Add /CETCOMPAT to linker options

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoFix CodeQL warnings
Owen Smith [Thu, 12 Aug 2021 12:33:48 +0000 (13:33 +0100)]
Fix CodeQL warnings

- ExAllocatePoolWithTag is deprecated in Win10 2004, use
    ExAllocatePoolUninitialized instead

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoFix SDV/CodeQL log generation
Owen Smith [Thu, 12 Aug 2021 12:33:47 +0000 (13:33 +0100)]
Fix SDV/CodeQL log generation

- sarif files need to be stored with SDV logs when generating the DVL file
- Disable PREFast and CodeAnalysis by default
- Run a seperate CodeAnalysis build after SDV, but before generating DVL file
    DVL file should contain multiple summary lines for SDV, at least 1 line
    for CodeAnalysis and at least 1 line for Semmle (CodeQL)

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoDocument CodeQL build requirements
Owen Smith [Tue, 7 Sep 2021 08:10:46 +0000 (09:10 +0100)]
Document CodeQL build requirements

CodeQL requires an additional tool and rule set which are seperate from the
EWDK ISOs, and require manual installation and configuration

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoFix build with later WDKs
Owen Smith [Thu, 12 Aug 2021 12:33:46 +0000 (13:33 +0100)]
Fix build with later WDKs

- Adds alias for GetProjectInfoForReference target to version.vcxproj
    Later kits seemed to have renamed the build target, and will fail without
    this alias target.
- Adds "/fd sha256" to signtool command line
    WDK 20344 and later require binaries signed with a SHA256 file digest, or
    the build outputs are deleted

Signed-off-by: Owen Smith <owen.smith@citrix.com>
- Squash warnings 4061 (in xencons.vcxproj) and 26052 (in
  xencons_monitor.vcxproj) to avoid bogus noise.

Signed-off-by: Paul Durrant <paul@xen.org>
4 years agoAdd CodeQL build stage
Owen Smith [Fri, 5 Mar 2021 10:14:18 +0000 (10:14 +0000)]
Add CodeQL build stage

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>
4 years agoBring XENBUS interface versions up to date...
Paul Durrant [Mon, 22 Feb 2021 10:53:29 +0000 (10:53 +0000)]
Bring XENBUS interface versions up to date...

... and update binding accordingly.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
4 years agoInherit versioning info from environment if present
Nicholas Tsirakis [Fri, 6 Nov 2020 20:48:44 +0000 (15:48 -0500)]
Inherit versioning info from environment if present

As the drivers stabilize and mature, there is an ever-growing
chance that other opensource virtualization projects will adopt
them. Allow external projects to inject their own versioning
into the drivers instead of hardcoding the latest winpv version.

Signed-off-by: Nicholas Tsirakis <tsirakisn@ainfosec.com>
Acked-by: Owen Smith <owen.smith@citrix.com>
4 years agoAllow user to specify desired build architecture
Nicholas Tsirakis [Fri, 6 Nov 2020 20:48:43 +0000 (15:48 -0500)]
Allow user to specify desired build architecture

Often times we only need to build a driver for a single
targeted architecture. Continue to build both by default,
but allow the user to specify one if desired.

Signed-off-by: Nicholas Tsirakis <tsirakisn@ainfosec.com>
Use [string]::IsNullOrEmpty($Arch)

Signed-off-by: Paul Durrant <paul@xen.org>
4 years agoDon't pass MM_DONT_ZERO_ALLOCATION to MmAllocatePagesForMdlEx()...
Paul Durrant [Wed, 17 Jun 2020 09:37:55 +0000 (10:37 +0100)]
Don't pass MM_DONT_ZERO_ALLOCATION to MmAllocatePagesForMdlEx()...

...in __AllocatePages()

See commit 4f85d004 "Replace uses of MmAllocatePagesForMdlEx in
__AllocatePage" in XENVIF for more background.

In summary, it is to avoid BSOD 139 1e with a stack similar to the following:

nt!KeBugCheckEx
nt!KiBugCheckDispatch+0x69
nt!KiFastFailDispatch+0xd0
nt!KiRaiseSecurityCheckFailure+0x30e
nt!KiAcquireThreadStateLock+0x11fa90
nt!KeSetIdealProcessorThreadEx+0xd0
nt!MiZeroInParallelWorker+0x115016
nt!MiZeroInParallel+0x11c
nt!MiInitializeMdlBatchPages+0x2ae
nt!MiAllocatePagesForMdl+0x192
nt!MmAllocatePartitionNodePagesForMdlEx+0xc9
nt!MmAllocatePagesForMdlEx+0x4d

These bugchecks have been observed in recent updates of Server 2019.

This patch, rather than replacing calls to MmAllocatePagesForMdlEx() with
calls to MmMapLockedPagesSpecifyCache(), just avoids passing
MM_DONT_ZERO_ALLOCATION to work round the bug.

The patch instead passes MM_ALLOCATE_FULLY_REQUIRED, which arguably should
have always been passed for allocations larger than a single page. It also
fixes a formatting issue.

Reported-by: Jan Bakuwel <jan.bakuwel@gmail.com>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
5 years agoHandle return codes from MSBuild
Owen Smith [Tue, 10 Mar 2020 10:47:03 +0000 (10:47 +0000)]
Handle return codes from MSBuild

If MSBuild fails, it returns a non-zero return value. Forward this
failure to the calling scripts to fail earlier.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoMAINTAINERS: Update my email address
Paul Durrant [Tue, 10 Mar 2020 10:56:55 +0000 (10:56 +0000)]
MAINTAINERS: Update my email address

My @amazon.com address is no longer convenient to use.

Signed-off-by: Paul Durrant <paul@xen.org>
5 years agobump version to 9.1.0
Paul Durrant [Fri, 6 Dec 2019 12:11:49 +0000 (12:11 +0000)]
bump version to 9.1.0

Now that 9.0 is branched (in staging-9.0) the master version needs to be
advanced.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
5 years agoMAINTAINERS: Update my email address staging-9.0 9.0.0 9.0.0-rc1
Paul Durrant [Thu, 14 Nov 2019 10:11:28 +0000 (10:11 +0000)]
MAINTAINERS: Update my email address

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
5 years agoAdd option to elevate administrator users
Owen Smith [Thu, 7 Nov 2019 15:53:16 +0000 (15:53 +0000)]
Add option to elevate administrator users

If the user has Administrator access, add a prompt and ability to
elevate the access to the Administrator privilege level instead of
retaining the user privilege level.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
[squashed 'Improve elevation prompts']
Signed-off-by: Paul Durrant <paul@xen.org>
5 years agoDon't store password longer than required
Owen Smith [Thu, 7 Nov 2019 15:53:15 +0000 (15:53 +0000)]
Don't store password longer than required

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd support for EWDK_19h1_release_svc_prod3_18362_190416-1111
Paul Durrant [Thu, 19 Sep 2019 11:46:29 +0000 (12:46 +0100)]
Add support for EWDK_19h1_release_svc_prod3_18362_190416-1111

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoMAINTAINERS: Update my email address
Paul Durrant [Thu, 19 Sep 2019 11:39:29 +0000 (12:39 +0100)]
MAINTAINERS: Update my email address

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoRemove the old python build scripts and document use of the EWDK
Paul Durrant [Thu, 19 Sep 2019 11:38:07 +0000 (12:38 +0100)]
Remove the old python build scripts and document use of the EWDK

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoUse genfiles to set DriverVer
Owen Smith [Wed, 17 Jul 2019 12:35:11 +0000 (13:35 +0100)]
Use genfiles to set DriverVer

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd PowerShell build scripts, version.vcxproj
Owen Smith [Fri, 14 Jun 2019 16:01:11 +0000 (17:01 +0100)]
Add PowerShell build scripts, version.vcxproj

Based on the sequence of commits to xenbus, add powershell scripts to
build the solution using the EWDK
version.vcxproj generates versioned files (version.h and xencons.inf) using
 scripts/genfiles.ps1
Strips duplicated functionality from build.py toproduce consistant
builds between python and powershell.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd BUILD_NUMBER to reported version string
Owen Smith [Fri, 14 Jun 2019 15:48:21 +0000 (16:48 +0100)]
Add BUILD_NUMBER to reported version string

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoAvoid assertion failure on PdoDestroy
Owen Smith [Thu, 8 Nov 2018 10:21:54 +0000 (10:21 +0000)]
Avoid assertion failure on PdoDestroy

Avoid triggering ASSERT(IsZeroMemory(Pdo, sizeof(XENCONS_PDO))
by NULL-ing Pdo->Context.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoAdd more logging to xencons_tty
Owen Smith [Thu, 8 Nov 2018 10:18:11 +0000 (10:18 +0000)]
Add more logging to xencons_tty

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Don't restrict logging to debug builds and use 4 '=' characters in arrows,
to be consistent with other code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoDisable warning 5032
Owen Smith [Thu, 8 Nov 2018 09:52:37 +0000 (09:52 +0000)]
Disable warning 5032

WDK17763 triggers a warning (mismatched #pragma warning(push)) in
include/um/winioctl.h
Disable this warning until the WDK header has resolved this issue.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoConditionally package DPInst
Owen Smith [Fri, 24 Aug 2018 16:46:43 +0000 (17:46 +0100)]
Conditionally package DPInst

Since DPInst.exe is not shipped with the Windows Driver Kit 10, an
environment variable must point to local copies. Make the inclusion of
DPInst conditional on DPINST_REDIST being defined and that path
existing. This simplifies building packages which do not require DPInst
for installation, and removes a required step to create a working build.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoWork around bug in VS2017 SDV
Paul Durrant [Thu, 19 Jul 2018 10:18:56 +0000 (11:18 +0100)]
Work around bug in VS2017 SDV

XENBUS commit 868cd40f (of the same name) introduced a workaround for a
quoting bug in SDV. This commit applies a similar workaround for XENCONS.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoFix SDV release parameter
Paul Durrant [Thu, 19 Jul 2018 10:09:19 +0000 (11:09 +0100)]
Fix SDV release parameter

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoDisable spectre mitigation warnings
Paul Durrant [Fri, 13 Jul 2018 08:49:39 +0000 (09:49 +0100)]
Disable spectre mitigation warnings

These are not terribly useful and cause the build to fail.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoFail FrontendPrepare if backend doesn't re-initialize
Owen Smith [Fri, 2 Mar 2018 13:23:37 +0000 (13:23 +0000)]
Fail FrontendPrepare if backend doesn't re-initialize

Current backend will crash (taking out the VM) if any attempt is
made to reconnect to a backend that has transitioned to the
Closed state. Forces the frontend offline, which will fail the
frontend state transitions, and its initiating IRP.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoEnsure D0 <-> D3 transitions occur only from the correct state
Owen Smith [Fri, 2 Mar 2018 13:15:29 +0000 (13:15 +0000)]
Ensure D0 <-> D3 transitions occur only from the correct state

Attempting to set D0 when already at D0 will trigger an ASSERT
and overwrite several variables.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoImplement ring protocol
Owen Smith [Fri, 2 Mar 2018 13:09:10 +0000 (13:09 +0000)]
Implement ring protocol

Adds ring.h/.c which implements the console ring protocol and
handles the cancel safe queues for the outstanding read/write IRPs.
Connect the ring with the state protocol in the frontend.
Also fixes frontend state transitions to get allow the ring to
connect and operate correctly.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd EVTCHN and GNTTAB interfaces
Owen Smith [Fri, 2 Mar 2018 12:48:50 +0000 (12:48 +0000)]
Add EVTCHN and GNTTAB interfaces

Adds query for EVTCHN and GNTTAB interfaces, and adds
FdoGet[Evtchn|Gnttab]Interface functions

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoRespond to non-default console IOCTLs
Owen Smith [Fri, 2 Mar 2018 11:55:23 +0000 (11:55 +0000)]
Respond to non-default console IOCTLs

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd boilerplate frontend
Owen Smith [Fri, 2 Mar 2018 11:43:00 +0000 (11:43 +0000)]
Add boilerplate frontend

* Frontend is used for non-default consoles
* State changes are disabled for now, as there is insufficient
  implementation to handle the state model (no evtchn/gnttab changes)
* Reads "protocol" and "name" xenstore fields

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Re-worked create/destroy code and renamed some items

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoHide console access behind an interface
Owen Smith [Thu, 1 Mar 2018 17:21:34 +0000 (17:21 +0000)]
Hide console access behind an interface

* Allows a different implementation of the console protocol for
  non-default consoles.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
* Re-worked create/destroy and renamed some items.
* Left IsDefault as a flag on the Pdo.
* Fail to create the PDO in the non-default case.
* ASSERT the Pdo is default before attempting to use the ABI, since it
  is only valid in this case.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoEnumerate non-default consoles
Owen Smith [Thu, 1 Mar 2018 13:57:48 +0000 (13:57 +0000)]
Enumerate non-default consoles

* Add enumeration thread and watch
* Non-default consoles will fail any read/write/iocontrol IRPs

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Whitespace fix, and introduce __PdoSetDefault() rather than setting
flag directly in PdoCreate()

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoMake monitor service multi-console aware
Owen Smith [Thu, 1 Mar 2018 12:43:09 +0000 (12:43 +0000)]
Make monitor service multi-console aware

* Move console specific data to a seperate structure
* Make all threads' use the console data
* Removes the Add and Remove event in favor of inline add/remove
* Convert Win32 calls to explicit narrow/wide character set as appropriate
* Removes tchar.h include to force narrow/wide character usage
* Renames structures and thread functions
* Pipe names are based on console name
* INF file stores "Executable" under console's name subkey
* Change pipe name tty.exe uses
* Add WaitNamedPipe() before connecting to pipes in tty.exe

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd IOCTLs to query instance, name and protocol
Owen Smith [Thu, 1 Mar 2018 12:13:58 +0000 (12:13 +0000)]
Add IOCTLs to query instance, name and protocol

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Renamed __ConsolePutQueue() to __ConsoleReadWrite().
PdoDispatchReadWriteClose() should mark pending IRPs.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoMove console handler to static Pdo
Owen Smith [Thu, 1 Mar 2018 09:26:53 +0000 (09:26 +0000)]
Move console handler to static Pdo

Moves the interface and all console operations to the static Pdo.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Modified commit comment slightly since the static Pdo was introduced by a
previous patch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAdd boilerplate Pdo
Owen Smith [Wed, 28 Feb 2018 17:40:55 +0000 (17:40 +0000)]
Add boilerplate Pdo

Enumerates a single static RawPdo.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoMove console handlers to console.c
Owen Smith [Wed, 28 Feb 2018 17:21:36 +0000 (17:21 +0000)]
Move console handlers to console.c

Isolate console handler code from fdo code.
This will make the console code easier to maintain.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Rename __ConsoleDestroy() to __ConsoleDestroyHandle() and introduce
__ConsoleCreateHandle() which is called by ConsoleOpen() to allocate and
initialize a handle.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agochmod ug+x msbuild.bat
Owen Smith [Wed, 28 Feb 2018 17:16:03 +0000 (17:16 +0000)]
chmod ug+x msbuild.bat

cygwin does not like non-executable scripts

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Reduced permissions from the overly-liberal 777

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoDo more optimization in release builds and add /Qspectre flag
Paul Durrant [Tue, 30 Jan 2018 10:39:03 +0000 (10:39 +0000)]
Do more optimization in release builds and add /Qspectre flag

Spectre mitigations apparently only work on optimized code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAdd support for building with Visual Studio 2017
Paul Durrant [Tue, 30 Jan 2018 10:35:01 +0000 (10:35 +0000)]
Add support for building with Visual Studio 2017

Also remove mappings for obsolete versions of VS in build.py.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoUpdate util.h
Paul Durrant [Thu, 25 Jan 2018 14:16:12 +0000 (14:16 +0000)]
Update util.h

XENCONS does not use much of the functionality in util.h, including the
__AllocatePages() function modified by this change, however
it is good to keep the header in-sync with the other drivers.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoHandle DBT_DEVICEREMOVEPENDING and DBT_DEVICEREMOVECOMPLETE
Owen Smith [Mon, 11 Sep 2017 20:08:29 +0000 (13:08 -0700)]
Handle DBT_DEVICEREMOVEPENDING and DBT_DEVICEREMOVECOMPLETE

When surprise removed, DBT_DEVICEQUERYREMOVE is not called, and
the handles opened by the service need closing before the driver
gets the IRP_MN_REMOVE_DEVICE Irp.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoDestroy all handles on FdoD0ToD3
Owen Smith [Mon, 11 Sep 2017 20:04:22 +0000 (13:04 -0700)]
Destroy all handles on FdoD0ToD3

Since the StreamWorker holds a reference to the XENBUS_CONS interface,
xenbus will BUG_ON if the handles are not cleaned up before power down.
The service should close all handles in response to a
DBT_DEVICEQUERYREMOVE notification, but this may not be issued on
system power down.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Added missing UNREFERENCED_PARAMETER() to fix build failure.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoCancel all outstanding IRPs in StreamDestroy
Owen Smith [Tue, 29 Aug 2017 11:05:02 +0000 (12:05 +0100)]
Cancel all outstanding IRPs in StreamDestroy

After IRP_MJ_CLEANUP completes, all outstanding IRPs (for that FileObject)
are cancelled. This would attempt to use the cancel safe queue and list
which are now zeroed, and lead to a 0xCC Bugcheck.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoFlush and Disconnect pipe clients
Owen Smith [Tue, 29 Aug 2017 11:03:22 +0000 (12:03 +0100)]
Flush and Disconnect pipe clients

Named pipes should be flushed and disconnected before closed.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoUse PutString to manage short WriteFile
Owen Smith [Tue, 29 Aug 2017 10:25:51 +0000 (11:25 +0100)]
Use PutString to manage short WriteFile

PutString will now deal in UCHARs, so the calculated lengths need to be
translated into byte counts.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoEnsure handles are closed when pipe disconnects
Owen Smith [Tue, 29 Aug 2017 10:07:48 +0000 (11:07 +0100)]
Ensure handles are closed when pipe disconnects

Fixes leaks where the pipe handles were not closed, preventing new
connections. Fixes the MONITOR_PIPE context leaking when its thread
is stopped.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Since error gotos are introduced, have them do the cleanup. The scope of
Pipe and Instance needs to be widened but it keeps the code neater overall.
Also removed the unnecessary newlines in the log messages.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoRemove ZwFlushKey() from registry code
Paul Durrant [Thu, 3 Aug 2017 10:35:54 +0000 (11:35 +0100)]
Remove ZwFlushKey() from registry code

Attempting to flush registry keys early in boot causes an error to be
logged.

This patch therefore removes the explicit flushes from the registry code.
There is no option but to trust Windows lazy flush.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAdd option to not spawn child process.
Owen Smith [Tue, 25 Jul 2017 13:13:19 +0000 (14:13 +0100)]
Add option to not spawn child process.

If the "Executable" registry parameter is not found, do not spawn
a child process instead of failing.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Removed unnecessary hunk checking value for NULL before passing to
free().

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoLaunch monitored process without command line
Owen Smith [Tue, 25 Jul 2017 13:09:34 +0000 (14:09 +0100)]
Launch monitored process without command line

Changed tty to open named pipe by name, not command line argument

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoPass data through pipe
Owen Smith [Tue, 25 Jul 2017 12:47:37 +0000 (13:47 +0100)]
Pass data through pipe

All data read during the DeviceThread will be passes to all named pipes.
All data read from any named pipe will be passed to the device.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd named pipe server
Owen Smith [Tue, 25 Jul 2017 12:39:30 +0000 (13:39 +0100)]
Add named pipe server

Create a threaded NamedPipe server for the device.
This will be used to pass data from the console to child processes, and
read data from the child processes to pass to the console device.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
s/memset/ZeroMemory
Add a '__' prefix to forceinlined list manipulation primitives

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAdd asynchronous device polling thread
Owen Smith [Tue, 25 Jul 2017 12:26:27 +0000 (13:26 +0100)]
Add asynchronous device polling thread

Adds a thread that will asynchrously read the device handle.
This will be used to read console data from the device, for passing
to the named pipe.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
s/memset/ZeroMemory

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoRename ThreadEvent and Thread to Monitor[Event|Thread]
Owen Smith [Tue, 25 Jul 2017 12:14:06 +0000 (13:14 +0100)]
Rename ThreadEvent and Thread to Monitor[Event|Thread]

Add clarity to the variables used with the MonitorThread

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd BUILD.md and fix final package location
Paul Durrant [Thu, 18 May 2017 11:05:54 +0000 (12:05 +0100)]
Add BUILD.md and fix final package location

Microsoft helpfully removed the PackageDir property from package projects
in VS2015 so, as an interim fix, OutDir was used. This unfortunately means
that package output ends up in xencons/<arch>/package rather than just
xencons/<arch>.

This patch fixes the final package location by using python to do the
final copy (replacing what older VS used to do) and also adds a BUILD.md,
which was missing.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoSquash a spurious warning that is breaking SDV
Paul Durrant [Fri, 5 May 2017 16:09:24 +0000 (17:09 +0100)]
Squash a spurious warning that is breaking SDV

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd a TTY utility
Paul Durrant [Fri, 5 May 2017 15:02:26 +0000 (16:02 +0100)]
Add a TTY utility

This patch adds a new TTY utility which will open the console device and
pipe it to a command shell (cmd.exe) process. It also provides login
functionality for a local user such that the command shell is invoked as
that user.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd a monitor service
Paul Durrant [Fri, 5 May 2017 14:45:06 +0000 (15:45 +0100)]
Add a monitor service

This patch adds a basic service to monitor the xencons interface.

All it does is open the interface when it becomes available and close it
down when either the device is going away, or the service is being
stopped.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd console functionality
Paul Durrant [Fri, 5 May 2017 14:24:27 +0000 (15:24 +0100)]
Add console functionality

This patch adds a new interface so that user-space code can open a
character device to the PV console along with all the necessary dispatch
handling for basic functionality.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd basic driver and associated build scripts
Paul Durrant [Fri, 5 May 2017 14:02:24 +0000 (15:02 +0100)]
Add basic driver and associated build scripts

This driver is just the necessary boilerplate for PnP, Power and basic
interaction with XENBUS.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoInitial commit
Paul Durrant [Fri, 5 May 2017 10:59:18 +0000 (11:59 +0100)]
Initial commit

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>