]> xenbits.xensource.com Git - pvdrivers/win/xencons.git/log
pvdrivers/win/xencons.git
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>