]> xenbits.xensource.com Git - pvdrivers/win/xeniface.git/log
pvdrivers/win/xeniface.git
16 months ago__CaptureUserBuffer(): zero CapturedBuffer on failure in all cases
Rafał Wojdyła [Tue, 12 Dec 2023 09:38:45 +0000 (10:38 +0100)]
__CaptureUserBuffer(): zero CapturedBuffer on failure in all cases

Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
16 months agoFix parameter annotation for __FreeCapturedBuffer()
Rafał Wojdyła [Tue, 12 Dec 2023 09:38:44 +0000 (10:38 +0100)]
Fix parameter annotation for __FreeCapturedBuffer()

CapturedBuffer is optional, mark it so.

Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
16 months agoFix minor xencontrol issues
Rafał Wojdyła [Tue, 12 Dec 2023 09:38:43 +0000 (10:38 +0100)]
Fix minor xencontrol issues

- Fix mismatched XcStoreRead() function signatures
- Fix memory leak in XcOpen()
- Fix IOCTL names in error messages

Signed-off-by: Rafał Wojdyła <omeg@invisiblethingslab.com>
16 months agoRemove "Win32" as a build target from VS2022 projects
Owen Smith [Mon, 20 Nov 2023 14:44:45 +0000 (14:44 +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:44:44 +0000 (14:44 +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:44:43 +0000 (14:44 +0000)]
Remove VS2015 and VS2017 projects and configurations

Signed-off-by: Owen Smith <owen.smith@cloud.com>
19 months agoDelete CoInstaller code
Owen Smith [Fri, 29 Sep 2023 08:33:43 +0000 (09:33 +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 [Fri, 29 Sep 2023 08:33:42 +0000 (09:33 +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
- The cleanup of xenagent on uninstall.

Also updates the INF binding to match the version of XenBus with CoInstaller removed

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>
23 months agoDont disable warning 4100
Matthew Sykes [Tue, 18 Apr 2023 08:50:43 +0000 (09:50 +0100)]
Dont disable warning 4100

Adds UNREFERENCED_PARAMETER macros instead of suppressing the warning.

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 15:58:05 +0000 (15:58 +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:49:54 +0000 (09:49 +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:49:53 +0000 (09:49 +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:49:52 +0000 (09:49 +0000)]
Allow rebranding file copyright string

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

Note: Does not change the copyright string in xencontrol.dll, which is
assigned to "Invisible Things Lab". This string is not rebrandable

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:01:18 +0000 (14:01 +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

Suggested-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
2 years agoUse empty brace initializers
Paul Durrant [Mon, 31 Oct 2022 13:52:59 +0000 (13:52 +0000)]
Use empty brace initializers

This avoids a build warning with EWDK_co_release_svc_prod3_22000_220715-1440

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>
2 years agoFix compiler options
Owen Smith [Thu, 5 May 2022 07:03:27 +0000 (08:03 +0100)]
Fix compiler options

Adds '/ZH:SHA_256' '/CETCOMPAT' '/sdl' to compiler and '/SafeSEH' to x86 linker
command lines
These changes were prompted by binskim https://github.com/microsoft/binskim

Note: Rule BA2004 (Warning_NativeWithInsecureStaticLibraryCompilands) is still
      reported for xeniface_coinst.dll, xencontrol.dll and xenagent.exe

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoReduce log spam
Owen Smith [Thu, 21 Apr 2022 12:29:45 +0000 (13:29 +0100)]
Reduce log spam

Squash errors generated by IoctlDirectory returning no sub-paths
Reduce logging level in ThreadCreate

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoRefactor Wmi.c
Owen Smith [Wed, 30 Mar 2022 09:32:23 +0000 (10:32 +0100)]
Refactor Wmi.c

* Moves functions to be in related locations in file
* Formats code to appropriate code style
* Inlines some functions that are only called from 1 location
* Uses LIST_ENTRY macros to access linked lists

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoReplace UTF8_STRING with OEM_STRING
Owen Smith [Tue, 21 Sep 2021 10:45:52 +0000 (11:45 +0100)]
Replace UTF8_STRING with OEM_STRING

The UTF8 conversion functions treat UTF8_STRING as:
  struct {
      USHORT  Length;
      CHAR    Buffer[ANYSIZE_ARRAY];
  } UTF8_STRING;

But UTF8_STRING is defined by later WDKs as:
  struct {
      USHORT  Length;
      USHORT  MaximumLength;
      PCHAR   Buffer;
  } UTF8_STRING;

This difference leads to an 0x3B BSOD when anything attempts to use any WMI
method that deals with strings.

Replace UTF8_STRING with OEM_STRING which is available in all WDKs, and has
the same definition as UTF8_STRING from later WDKs, simplifying the usage
of retrieving strings from, or putting strings into, WMI buffers.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoRefactor string conversion in wmi.c
Owen Smith [Tue, 21 Sep 2021 10:45:51 +0000 (11:45 +0100)]
Refactor string conversion in wmi.c

Colocates related string functions, removes unused functions, adjusts
whitespace and reformats functions into a consistant code style.
There are no functional changes

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

- ExAllocatePoolWithTag is deprecated for Win10 2004, use
    ExAllocatePoolUninitialized instead
- Add "(VOID)" before AccessWmiBuffer, where the return value is not needed

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Extend patch to cover ioctl_gnttab.c, ioctl_store.c and ioctl_suspend.c

Signed-off-by: Paul Durrant <paul@xen.org>
3 years agoFix SDV/CodeQL log generation
Owen Smith [Thu, 12 Aug 2021 12:36:11 +0000 (13:36 +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:36:10 +0000 (13:36 +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 warning 4061.

Signed-off-by: Paul Durrant <paul@xen.org>
3 years agoLog if Windows Update requires a reboot
Owen Smith [Mon, 5 Jul 2021 12:59:51 +0000 (13:59 +0100)]
Log if Windows Update requires a reboot

Output log line if Windows Update requires a reboot, as soon as a shutdown or
reboot has been requested, in addition to when the service shuts down. The
service shutdown will output its log line *after* the "Installing Windows
Updates" screen has completed during shutdown.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
3 years agoRefactor XenAgent
Owen Smith [Mon, 5 Jul 2021 12:59:50 +0000 (13:59 +0100)]
Refactor XenAgent

- Merge IDeviceCreator interface into CDeviceList base class
- Add CXenIfaceDeviceList and CConvDeviceList, derived from CDeviceList
- Moves IFace functionality to CXenIfaceDeviceList
- Moves Conv device functionality to CConvDeviceList
- Seperate RegisterDeviceNotification from SetupApi enumeration, so that static
  devices do not need to hold the handle open (i.e. Conv device)
- CConvDeviceList only opens the handle when neccessary, as the MS driver for
  the ACPI device only allows 1 open handle at a time.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
4 years agoAdd CodeQL build stage
Owen Smith [Fri, 5 Mar 2021 10:15:25 +0000 (10:15 +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 11:05:28 +0000 (11:05 +0000)]
Bring XENBUS interface versions up to date...

... and amend 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 agoAvoid unnecessary assertion.
Troy Crosley [Tue, 1 Sep 2020 17:27:39 +0000 (13:27 -0400)]
Avoid unnecessary assertion.

Add the missing brackets to an if statement so that FdoS4ToS3() is not
always called in __FdoSetSystemPowerUp().

Signed-off-by: Troy Crosley <troycrosley@gmail.com>
Reviewed-by: Owen Smith <owen.smith@citrix.com>
4 years agoNo longer terminate xenagent for S3/S4 transition.
Troy Crosley [Tue, 1 Sep 2020 17:27:38 +0000 (13:27 -0400)]
No longer terminate xenagent for S3/S4 transition.

Signed-off-by: Troy Crosley <troycrosley@gmail.com>
Reviewed-by: Owen Smith <owen.smith@citrix.com>
4 years agoPrevent a xenagent timeout on S3/S4 transition.
Troy Crosley [Tue, 1 Sep 2020 17:27:37 +0000 (13:27 -0400)]
Prevent a xenagent timeout on S3/S4 transition.

Prevent a xenagent timeout (and live kernel dump) on S3/S4 transition by
changing CXenIfaceCreator::Log to use TryEnterCriticalSection.
Otherwise, a timeout occurs when the service control handler fails to
return due to attempting to enter a critical section object that the
main service thread already owns while responding to the
control/shutdown xenstore watch.

Signed-off-by: Troy Crosley <troycrosley@gmail.com>
[Re-ordered if statement]
Signed-off-by: Paul Durrant <paul@xen.org>
4 years agoClear rather than remove control/feature-XXX keys.
Troy Crosley [Thu, 3 Sep 2020 14:53:58 +0000 (10:53 -0400)]
Clear rather than remove control/feature-XXX keys.

These keys should stick around when disabled since they're present at
boot. This also fixes an issue where the keys are unable to be written
on wake from S3 or S4.

Signed-off-by: Troy Crosley <troycrosley@gmail.com>
Reviewed-by: Paul Durrant <paul@xen.org>
4 years agoAvoid redefinition of UTF8_STRING
Owen Smith [Tue, 30 Jun 2020 10:44:44 +0000 (11:44 +0100)]
Avoid redefinition of UTF8_STRING

UTF8_STRING is defined by MSVC 14.23 (_MSC_VER 1923, VisualStudio 16.3)
Use preprocessor to only define UTF8_STRING on earlier compiler
versions. This allows XenIface to build with both EWDK 19h1 18362.84 and
EWDK vb_release 19041.1

Signed-off-by: Owen Smith <owen.smith@citrix.com>
4 years agoDon't pass MM_DONT_ZERO_ALLOCATION to MmAllocatePagesForMdlEx()...
Paul Durrant [Wed, 17 Jun 2020 09:06:27 +0000 (10:06 +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.

NOTE: Nothing in XENIFACE currently calls __AllocatePages() so this patch is
      not strictly necessary. However, in case a caller is added in future,
      it is best to keep util.h in sync with the other drivers.

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 support for EWDK_19h1_release_svc_prod3_18362_190416-1111
Paul Durrant [Thu, 19 Sep 2019 11:28:34 +0000 (12:28 +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:10:53 +0000 (12:10 +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:09:59 +0000 (12:09 +0100)]
Remove the old python build scripts and document use of the EWDK

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoUpdate XENBUS interfaces and use new XENBUS_SHARED_INFO GetTime...
Paul Durrant [Tue, 17 Sep 2019 14:10:36 +0000 (15:10 +0100)]
Update XENBUS interfaces and use new XENBUS_SHARED_INFO GetTime...

...to determine how to interpret Xen wall-clock.

The Xen wall-clock value may be interpreted as local time or UTC, depending
on how Windows programs the emulated RTC. The updated method provides this
extra information, so used this rather than reading the registry directly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
5 years agoGet rid of bogus time adjustment
Paul Durrant [Mon, 16 Sep 2019 13:23:08 +0000 (14:23 +0100)]
Get rid of bogus time adjustment

Xen maintains synchronization between the wallclock (as reported in the
shared info) and the emulated RTC. Thus all the guest agent needs to know,
to correctly interpret the wallclock, is whether Windows is setting the
RTC in local time or UTC. No adjustment of the wallclock is required.

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

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

Signed-off-by: Owen Smith <owen.smith@citrix.com>
5 years agoAdd PowerShell build scripts, version.vcxproj
Owen Smith [Fri, 14 Jun 2019 14:32:57 +0000 (15:32 +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, xeniface.inf and
wmi.mof) 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>
6 years agoCheck WinTime and XenTime for drift
Owen Smith [Tue, 16 Apr 2019 16:43:39 +0000 (17:43 +0100)]
Check WinTime and XenTime for drift

Windows 10/Server 2016 changed how Windows maintains the accuracy of its
clock
This can allow reported time to drift away from host time, and Windows time
will need to be updated regularly in order to minimise the drift.

* Add a wrapper for SetXenTime to manage the critical section
* Remove SetXenTime from CheckSuspend and call it from the calling function
* Add a timeout to the WaitForMultipleObjectsEx, which calls SetXenTime
* Prevent SetXenTime from updating the time if its not changed (and avoid
  outputting the log lines)

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Moved the call to get current time earlier in SetXenTime() and also made
it call GetSystemTime() if the RTC is in UTC. Also added missing
__fallthrough annotation for case WAIT_TIMEOUT in ServiceMainLoop().

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoSet local time to UTC if Windows has "RealTimeIsUniversal"
Paul Durrant [Mon, 1 Apr 2019 10:25:09 +0000 (11:25 +0100)]
Set local time to UTC if Windows has "RealTimeIsUniversal"

Commit 3b8723b1 "Set VM's time based on host's time exposed by Xen"
modified the guest agent to adjust Xen time to UTC before setting the
system time (i.e. the emulated RTC) if a vendor specific registry value
was set.

Windows' idea of whether the RTC is programmed in UTC is actually
controlled by:

[HKLM\System\CurrentControlSet\Control\TimeZoneInformation]
DWORD:RealTimeIsUniversal

If this value is present and non-zero then the RTC is set in UTC otherwise
it is in local time. So, there is no need for a vendor specific key.

This patch removes use of the vendor specific key and checks
"RealTimeIsUniversal" directly to determine how to set the system time.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoHandle QueryRemoveFailed
Owen Smith [Tue, 23 Oct 2018 13:19:20 +0000 (14:19 +0100)]
Handle QueryRemoveFailed

Its possible for the QueryRemove to fail, in which case, the xenagent
should re-open the device and inform the client code.
This allows a the XenIface device to re-write the control/feature-*
flags if XenIface failed the QueryRemove

Also replaces Tabs with 4 spaces.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoDisable warning 5032
Owen Smith [Tue, 16 Oct 2018 09:12:25 +0000 (10:12 +0100)]
Disable warning 5032

xencontrol also throws up warning 5032 with WLK 17763, and was missed
off the previous patch.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoRe-enable warning 5032 under VS2015
Paul Durrant [Tue, 16 Oct 2018 09:11:16 +0000 (10:11 +0100)]
Re-enable warning 5032 under VS2015

There is no need to disable the warning for VS2015 since it is not possible
to use the broken WDK with that compiler.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoDisable warning 5032
Owen Smith [Mon, 15 Oct 2018 09:20:29 +0000 (10:20 +0100)]
Disable warning 5032

WDK 17763 throws a warning 5032 (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 agoCall OnDeviceRemoved callback(s) during DeviceList.Stop()
Owen Smith [Thu, 19 Jul 2018 11:55:31 +0000 (12:55 +0100)]
Call OnDeviceRemoved callback(s) during DeviceList.Stop()

OnDeviceAdded is called for every pre-attached device during
DeviceList.Start(), the corresponding call to OnDeviceRemoved should be
called for each attached device during the DeviceList.Stop() call.
By calling the OnDeviceRemoved callback during the service stop, the
xenagent service can remove the "feature-[poweroff|reboot|s3|s4]" flags.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
6 years agoWork around bug in VS2017 SDV
Paul Durrant [Thu, 19 Jul 2018 10:07:57 +0000 (11:07 +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 XENIFACE.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoFix SDV release parameter
Paul Durrant [Wed, 18 Jul 2018 13:19:37 +0000 (14:19 +0100)]
Fix SDV release parameter

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
6 years agoAdd a user mode library wrapper for XENIFACE IOCTLs
Rafal Wojdyla [Wed, 4 Jul 2018 00:53:39 +0000 (02:53 +0200)]
Add a user mode library wrapper for XENIFACE IOCTLs

Signed-off-by: Rafal Wojdyla <omeg@invisiblethingslab.com>
[fix compile warnings, update visual studio files]
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
6 years agoFix compile warnings
Marek Marczykowski-Górecki [Tue, 10 Jul 2018 14:51:58 +0000 (15:51 +0100)]
Fix compile warnings

Fix two warnings:

e:\xeniface\src\xenagent\service.cpp(684): warning C26439: This kind offunction may not throw.
Declare it 'noexcept' (f.6). [E:\xeniface\vs2017\xenagent\xenagent.vcxproj]

e:\xeniface\src\xenagent\xenifacedevice.cpp(57): warning C26451: Arithmetic overflow: Using operator
'+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before
calling operator '+' to avoid overflow (io.2). [E:\xeniface\vs2017\xenagent\xenagent.vcxproj]

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
6 years agoDisable warning about spectre mitigation
Marek Marczykowski-Górecki [Tue, 10 Jul 2018 14:44:32 +0000 (15:44 +0100)]
Disable warning about spectre mitigation

CL emits a warning about every place that will get spectre mitigation
when compiled with /Qspectre. Even if this option is already used. This
breaks the build, as warnings are treated as errors in xeniface.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Also disable warning for co-installer build.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoAck actionable "control/shutdown" requests as soon as possible
Paul Durrant [Tue, 10 Apr 2018 16:17:03 +0000 (17:17 +0100)]
Ack actionable "control/shutdown" requests as soon as possible

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoRevert "Ack "control/shutdown" as soon as possible."
Paul Durrant [Tue, 10 Apr 2018 15:10:02 +0000 (16:10 +0100)]
Revert "Ack "control/shutdown" as soon as possible."

This reverts commit c370c7d2. This patch has the effect of 'acking' any
write to control/shutdown rather than just the ones that the agent acts
upon. Consequentially it therefore 'acks' its own writes and ends up in
an infinite loop.

7 years agoAck "control/shutdown" as soon as possible.
Owen Smith [Thu, 22 Mar 2018 11:20:05 +0000 (11:20 +0000)]
Ack "control/shutdown" as soon as possible.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoDo more optimization in release builds and add /Qspectre flag
Paul Durrant [Tue, 30 Jan 2018 10:15:00 +0000 (10:15 +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:10:53 +0000 (10:10 +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 13:54:10 +0000 (13:54 +0000)]
Update util.h

XENIFACE 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 agoSuppress warning (28159)
Owen Smith [Fri, 3 Nov 2017 17:40:53 +0000 (17:40 +0000)]
Suppress warning (28159)

Setting "control/shutdown" to "poweroff" or "reboot" is intended
to trigger a shutdown/reboot!

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoAdd log message if Windows Update requires a reboot
Owen Smith [Fri, 3 Nov 2017 17:39:21 +0000 (17:39 +0000)]
Add log message if Windows Update requires a reboot

When Windows requires a reboot to install updates, the reboot and shutdown
operations can take a long time. The agent will have acknowledged the
request, but the operation may not complete in a suitable timeout period.
Add a log entry to help indicate an additional unknown amount of time
will be required for shutdown/reboot.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
7 years agoDon't allow user-supplied values to be used as a format specifier
Ben Chalmers [Tue, 19 Sep 2017 10:43:48 +0000 (11:43 +0100)]
Don't allow user-supplied values to be used as a format specifier

Signed-off-by: Ben Chalmers <ben.chalmers@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoUpdate registry code
Paul Durrant [Thu, 3 Aug 2017 10:30:21 +0000 (11:30 +0100)]
Update registry code

Bring the code into like with the latest XENBUS code, which has a few
fixes that are missing here.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
7 years agoPrevent events getting lost, and remove xenstore polling
Ben Chalmers [Wed, 5 Jul 2017 08:48:24 +0000 (09:48 +0100)]
Prevent events getting lost, and remove xenstore polling

Auto-resetting events, on occasion, are getting lost.  This
can be avoided by ensuring events are manually reset.

As events are no longer lost, there is no longer a need to
poll shudown or suspend every minute

Also fix invocation of CreateEvent methods.

Signed-Off-By: Ben.Chalmers@citrix.com
7 years agoRemove VS2012 and VS2013 build scripts
Paul Durrant [Thu, 18 May 2017 14:18:59 +0000 (15:18 +0100)]
Remove VS2012 and VS2013 build scripts

This patch removes the scripts for building under VS2013 and VS2013 and
also fixes the package destination when building using VS2015.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd a new CConvCreator object to handle laptop/slate mode switch
Paul Durrant [Wed, 29 Mar 2017 12:47:49 +0000 (13:47 +0100)]
Add a new CConvCreator object to handle laptop/slate mode switch

This patch adds a new object derived from IDeviceCreator to interact
with the laptop/slate mode switch interface provided by a Windows
driver that binds to the ACPI CONV device.

It also adds code to support the documented PV interface for triggering
laptop/slate mode switch [1].

http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=3bdb1400

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoOnly add device if the guid matches
Paul Durrant [Wed, 29 Mar 2017 14:48:35 +0000 (15:48 +0100)]
Only add device if the guid matches

The IDeviceCreator::OnDeviceAdded() method should only be called for
devices matching the GUID specified to the CDeviceList object creator.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoSplit xeniface specific parts out of CXenAgent into CXenIfaceCreator
Paul Durrant [Wed, 29 Mar 2017 12:48:31 +0000 (13:48 +0100)]
Split xeniface specific parts out of CXenAgent into CXenIfaceCreator

In preparation for supporting more than one device interface, the
one-to-one correspondence between the IDeviceCreator interface and the
CXenAgent object needs to be broken.

This patch separates all code that interacts with the CXenIfaceDevice
object (as well as the CDevice and CDeviceList instances for the xeniface
interface) into a new CXenIfaceCreator object.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAvoid repeatedly acting as if returning from suspend
Ben Chalmers [Wed, 29 Mar 2017 14:01:20 +0000 (15:01 +0100)]
Avoid repeatedly acting as if returning from suspend

Setting m_count to equal count means we will fall out of CheckSuspend
early, if initiated by a timeout when a new suspend has not occurred.

Signed-off-by : <Ben Chalmers> ben.chalmers@citrix.com

8 years agoFix SDV build
Paul Durrant [Fri, 6 Jan 2017 16:49:42 +0000 (16:49 +0000)]
Fix SDV build

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix memory leak in __FreePage()
Paul Durrant [Fri, 6 Jan 2017 15:52:26 +0000 (15:52 +0000)]
Fix memory leak in __FreePage()

The pool memory for the MDL also needs to be freed.

Also, generalise __AllocatePage() and __FreePage() to __AllocatePages()
and __FreePages() to allow for multi-page allocations in future.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate BUILD.md with VS2015/WDK10 information
Paul Durrant [Wed, 14 Dec 2016 16:27:50 +0000 (16:27 +0000)]
Update BUILD.md with VS2015/WDK10 information

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFixes for VS2015/WDK10 build
Paul Durrant [Wed, 14 Dec 2016 16:19:07 +0000 (16:19 +0000)]
Fixes for VS2015/WDK10 build

The package build was not working correctly and caused the overall build
to fail.
At least part of the reason for this is that Microsoft, in their infinite
wisdom, have removed the DIFx redist from WDK10. This patch makes use of
a new environment variable 'DPINST_REDIST' to find the copy of dpinst.exe
to package such that this can be pointed at an older WDK or alternative
location where dpinst.exe can be found.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoAdd support for building under VS2015/WDK10
Paul Durrant [Tue, 13 Dec 2016 16:39:10 +0000 (16:39 +0000)]
Add support for building under VS2015/WDK10

Moving to the new toolchain also threw up a few new warnings, which this
patch either fixes or squashes. Also, SDV appears to be fragile in new
ways (and whinge about some new things) so there are fixes for that too.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoUpdate driver version from 8.2.0 to 9.0.0
Paul Durrant [Tue, 13 Dec 2016 15:16:05 +0000 (15:16 +0000)]
Update driver version from 8.2.0 to 9.0.0

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoLog some more information at build time
Paul Durrant [Tue, 13 Dec 2016 15:07:52 +0000 (15:07 +0000)]
Log some more information at build time

The OBJECT_PREFIX and REG_KEY_NAME were not being logged by build.py.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoReduce severity of some debug messages 8.2.0 8.2.0-rc1
Owen Smith [Tue, 22 Nov 2016 14:58:37 +0000 (14:58 +0000)]
Reduce severity of some debug messages

Error and Warning were used for Info level messages

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoRemove XenIfaceDebugPrint
Owen Smith [Tue, 22 Nov 2016 14:52:03 +0000 (14:52 +0000)]
Remove XenIfaceDebugPrint

Replace "XenIfaceDebugPrint(TRACE," with "Trace("
Replace "XenIfaceDebugPrint(INFO," with "Info("
Replace "XenIfaceDebugPrint(WARNING," with "Warning("
Replace "XenIfaceDebugPrint(ERROR," with "Error("

Signed-off-by: Owen Smith <owen.smith@citrix.com>
8 years agoDon't call DbgPrint (or variants) from an event channel callback
Paul Durrant [Fri, 11 Nov 2016 14:58:25 +0000 (14:58 +0000)]
Don't call DbgPrint (or variants) from an event channel callback

Windows debug primitives will IPI so it's not a good idea to use them
from within an interrupt handler which may get called at HIGH_LEVEL.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoStop using FAST_MUTEX
Paul Durrant [Wed, 9 Nov 2016 12:29:56 +0000 (12:29 +0000)]
Stop using FAST_MUTEX

There are several build warnings because of functions that must be called
at PASSIVE_LEVEL being called at APC_LEVEL. This is because acquiring a
FAST_MUTEX raises IRQL to APC_LEVEL which is an annoying semantic that
basically renders them useless.

This patch replaces occurences of FAST_MUTEX with XENIFACE_MUTEX acquisition
of which does not modify IRQL.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoEnsure session stays locked...
Ben Chalmers [Wed, 9 Nov 2016 11:58:18 +0000 (11:58 +0000)]
Ensure session stays locked...

...until the reference to WatchThread is stored in it.

This prevents us trying to dispose of an uniintialised WatchThread
if a session is removed (by the driver being removed) while the
session is still being created

Signed-off-by: Ben Chalmers <ben.chalmers@citrix.com>
8 years agoTry to make sure the agent always always handles shutdown events
Paul Durrant [Wed, 9 Nov 2016 11:37:13 +0000 (11:37 +0000)]
Try to make sure the agent always always handles shutdown events

It seems that on Server 2008 the agent does not reliably wake up on
shutdown watch events. This does not seem to occur on any other OS so
it is likely that this is a bug in Server 2008.

To work around the problem this patch nodifies the agent wake up once a
minute and check for a shutdown event (or a suspend event, for
completeness) and act accordingly.

Also this patch squashes the uninteresting error messages that occur
when an attempt is made to read a non-existent xenstore key.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoIndirect user space watch events through a thread
Paul Durrant [Tue, 8 Nov 2016 18:08:11 +0000 (18:08 +0000)]
Indirect user space watch events through a thread

It is useful, for diagnostic purposes, to log the path of a user-space
registered watch when we are about to signal it. To do this create a
thread to handle each user-space watch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoFix build warnings
Paul Durrant [Thu, 3 Nov 2016 10:48:37 +0000 (10:48 +0000)]
Fix build warnings

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
8 years agoxenagent: use new Start/StopShutdownWatch() functions in resume from suspend
Paul Durrant [Mon, 1 Aug 2016 15:23:11 +0000 (16:23 +0100)]
xenagent: use new Start/StopShutdownWatch() functions in resume from suspend

The patch removes some code duplication by using the StopShutdownwatch()
and StartShutdownWatch() functions on resume from suspend rather than
duplicating their content.

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