Commit Graph
59 Commits
Author SHA1 Message Date
Yuri Benditovich 13788aef60 vioinput: fix VirtIO printouts
They did not appear with ETW. Fixed.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:55:04 +01:00
Yuri Benditovich e6ca4eb543 wdf drivers: set common features in WDF VirtIO library
Before this commit each WDF driver called VirtIOWdfSetDriverFeatures
from its PrepareHardware WDF callback. Many drivers do not have any
specific needs for features but needed to make this call in order
just to set VIRTIO_F_VERSION_1 and VIRTIO_F_ANY_LAYOUT properly.
So, even when the  call VirtIOWdfSetDriverFeatures is optional in
general, it is mandatory to handle V1 devices.
Current commit moves ack for VIRTIO_F_VERSION_1 and VIRTIO_F_ANY_LAYOUT
features to WDF VirtIO library. If the driver does not call
VirtIOWdfSetDriverFeatures, these features are set properly at time of
queues' initialization. So, drivers need to make this call only if
they need to enable some type-spefific features or if they need to
disable some common features which WDF library handles automatically
(currently VIRTIO_F_VERSION_1, VIRTIO_F_ANY_LAYOUT).

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:55:04 +01:00
Yuri Benditovich f10f740e04 vioinput: output also VirtIO logs as ETW events
Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:55:04 +01:00
Yuri Benditovich 80a41e2665 vioinput: use VirtIO WDF DMA API
Allocate 2 blocks of 4K. One will be sliced for input events
(8 bytes each, i.e. 512 events, when the queue size is usually 64).
Another one for sporadic output of keyboard reports, 16 bytes
allocated for each.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:55:04 +01:00
Yuri Benditovich 29ee1861bf vioinput: some absolute devices do not function at all
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/413

When logical limits of an absolute device are not default (0..0x7fff),
the device, redirected over input-host, does not function at all
in Windows. Addition of physical limits definition makes it function.
Note that this does not solve completely the problem of touchpads
especially ones that report absolute coordinates like mice do:
they require more effort to function correctly.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:30:04 +01:00
Yuri Benditovich 0102e5bf8d vioinput: fix problem with high resolution mouse
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/385

High resultion mouse often provides values out of range (-127,+127).
Unfortunately the interface of vioinput does not provide any
information about logical limits of relative pointer.
So, let's keep the value inside the range.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:30:04 +01:00
Yuri Benditovich be2529d928 vioinput: Fix mistakes in commit 4c99427549
https://bugzilla.redhat.com/show_bug.cgi?id=1588425
The mentioned commit fixes the problem it was intended to fix
but contains 2 mistakes. The purpose of said commit was to allow
some relative non-XY axes (expecially REL_WHEEL) to be used with
absolute pointing devices (i.e. ABS_XY+REL_WHEEL).
Problem1: in case of combined device (ABS_XY+REL_XY+REL_WHEEL)
the change in the code causes absolute and relative axes to be
exposed in the same mouse device.
Windows HID stack rejects such devices, so the rule is to expose
absolute ABS_XY only if REL_XY are not present (as described in
commit 52e521d2e9). The mistake was in use of InputCfgDataHasBit
after DecodeNextBit on the same structure (DecodeNextBit clears
bits of interest in the bitmap and later InputCfgDataHasBit returns
unexpected result).
Problem2: for example in case of (REL_X+ABS_XY), the driver will
expose REL_X which is not planned (see also commit 52e521d2e9).
Current commit fixes both problems and still allows exposing
relative wheel with absolute axes.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-06-04 13:56:06 +03:00
Yuri Benditovich 5d544898ab build: prepare vioinput for ARM64 build
Signed-off-by: Yuri Benditovich <[email protected]>
2019-04-23 16:40:12 +03:00
Gal Hammer cb822e36bf Fix LICENSE and source files license inconsistency.
virtio-win is released under the 3-clause BSD License. Make sure
both LICENSE and source files state that.

Reported-by: Darren Kenny
2019-01-31 15:06:33 +02:00
Yuri Benditovich 563cedc052 netkvm: solve problem building projects when higher WDK was installed
This commit is preparation for build with VS2017, which requires
WDK higher than 15063 to be installed.
When VS2015 and VS2017 coexist and VS2015 is used for drivers
build, but higher WDK(s) are also installed, the files under
"Windows Kits\10\build" are modified causing failure when build runs.
Current commit fixes it by importing Driver.Initial.props prior
to any other imported project. In order to ensure proper order of
importing projects, we remove direct importing of Visual studio
.props files and now each driver package project includes
only its own .props file and Tools\Driver.Common.props file,
which includes Visual Studio .props files and Driver.Initial.props
file in proper order.

Signed-off-by: Yuri Benditovich <[email protected]>
2018-11-09 23:23:31 +02:00
Sameeh Jubran 1efbe2ade9 Vioinput: Enable WPP tracing
Signed-off-by: Sameeh Jubran <[email protected]>
2018-03-24 22:47:57 +03:00
Sameeh Jubran 397649f1f2 Vioinput: WPP: Fix compilation errors
Signed-off-by: Sameeh Jubran <[email protected]>
2018-03-24 22:47:57 +03:00
Justin Gatzen 4c99427549 vioinput: Allow mouse wheels and other relative axes on tablets
All relative axes including mouse wheels are ignored whenever REL_X and
REL_Y inputs are missing, such as for virtio-tablet-pci devices. This
patch restores support for all relative axes in tablet mode.

Signed-off-by: Justin Gatzen <[email protected]>
2018-03-15 09:36:44 +02:00
Ilya Rudakov 02838d72da install: Add compatible id to .infs
When vendor uses its own subvendor id, the resulting driver
package will not formally be compatible with devices of RedHat and other
vendors, because of hardware ID changing in the .inf file. Using
Compatible ID provides compatibility between drivers of different vendors.
If several versions of the driver packages were found during installation,
configuration manager will select a package with a exactly matching
Hardware ID, it is important especially when driver was obtained
automatically from Windows Update.

Signed-off-by: Ilya Rudakov <[email protected]>
2018-01-22 13:41:32 +02:00
Ladi Prosek 143b5c3638 vioinput: Static analysis: driver tweaks and fixes
Static analysis was failing with:

hidpassthrough\hidpassthrough.c(109): warning C28169: The dispatch function 'HidPassthroughDispatchIoctl' does not have any _Dispatch_type_ annotations:  This can be corrected by adding appropriate _Dispatch_type_ annotations to the function. Unnecessary casts can cause this warning.

sys\device.c(271): warning C28170: The function 'VIOInputCreateChildPdo' has been declared to be in a paged segment, but neither PAGED_CODE nor PAGED_CODE_LOCKED was found:  This warning is not emitted for functions that are __forceinline.
sys\driver.c(88): warning C28208: Function VIOInputEvtDriverContextCleanup was previously defined with a different parameter list at c:\kvm-guest-drivers-windows\vioinput\sys\driver.c(38). Some analysis tools will yield incorrect results.
sys\driver.c(91): warning C28118: The current function is permitted to run at an IRQ level above the maximum permitted for '__PREfastPagedCode' (1). Prior function calls or annotation are inconsistent with use of that function:  The current function may need _IRQL_requires_max_, or it may be that the limit is set by some prior call. Maximum legal IRQL was last set to 2 at line 90.
sys\hidkeyboard.c(162): warning C28625: Function call used to clear sensitive data will be optimized away.
sys\keymap.c(660): warning C6385: Reading invalid data from 'ReportCodeToUsageCodeTable':  the readable size is '2456' bytes, but 'uEventCode' bytes may be read.

Signed-off-by: Ladi Prosek <[email protected]>
2017-12-16 21:38:14 +02:00
Ladi Prosek 99caebe0d0 vioinput: Reset device before detaching unused buffers
The virtio-input driver has the same bug as virtio-serial, see
https://bugzilla.redhat.com/show_bug.cgi?id=1520352.

It's much harder to hit it with virtio-input because of its much lower
data rate and, to a smaller extend, also a smaller number of "receive"
buffers that can be pushed on the event queue (64 vs. 128 in virtio-
serial).

The fix here is simply to reset the device before touching the event
queue with virtqueue_detach_unused_buf() so it doesn't race with the
device processing it. With virtio 1.0, the reset is synchronous (the
driver waits for the reset to be acknowledged by the device) and
virtio-input is exposed as a virtio 1.0-only device.

Long-term it may be nicer to eliminate the virtqueue_detach_unused_buf()
API altogether and have the drivers track what's been pushed with a
simple linked list or similar.

Signed-off-by: Ladi Prosek <[email protected]>
2017-12-04 16:54:08 +01:00
Ladi Prosek fe860fc3bf vioinput: Remove all uses of bEnableInterruptSuppression
The field has no effect and will be removed.

Signed-off-by: Ladi Prosek <[email protected]>
2017-12-04 09:56:59 +01:00
Ladi Prosek 7c5c36a96b Introduce SUBSYSTEM_VENDOR_ID
It is important that all parties shipping virtio-win drivers use their
own vendor-specific HW ID to avoid driving somebody else's device.
This is especially critical for WHQL'ed drivers distributed with Windows
Update, as these could be installed without any explicit user action.

This commit introduces a new build-time variable SUBSYSTEM_VENDOR_ID
to be set by vendors in their respective Driver.$(_VENDOR_).props file.
The default value is 1AF4, exposed by VirtIO devices in upstream QEMU
and reserved by Red Hat.

Signed-off-by: Ladi Prosek <[email protected]>
2017-11-08 15:51:26 +02:00
Ladi Prosek 2ddc0c3481 build: Eliminate vendor.check.h
Now that the build system has proven stable, the check header is
no longer needed. Also lowering the importance of "Adding {0}=>{1}"
messages produced by the SubstituteFileContent task to Low to cut
down on verbosity.

Signed-off-by: Ladi Prosek <[email protected]>
2017-09-17 13:22:34 +02:00
Yan Vugenfirer b8f8cc073c BZ#1480139 - Switch to BSD license
The project is switching from GPL to BSD.

Signed-off-by: Yan Vugenfirer <[email protected]>
2017-08-14 10:59:48 +03:00
Ladi Prosek 3853cf804a vioinput: Switch to BSD license
The project is switching from GPL to BSD.

Signed-off-by: Ladi Prosek <[email protected]>
2017-08-08 11:28:16 +03:00
xuxi0513 a582ed09aa Fix incorrect condition for send led status
uPendingLedCode initial value is 0xFF, which means invalid code, and uShortPendingLedValue initial value is 0.
Using "uShortPendingLedValue != 0xFF" as condition to send kbd led status, it will send invalid code 0xFF and value 0 to backend.

Signed-off-by: xuxi0513 <[email protected]>
Signed-off-by: Yi Wang <[email protected]>
2017-07-17 10:54:34 +02:00
Ladi Prosek 52e521d2e9 vioinput: Mouse HID fixes
This commit contains fixes to the mouse HID report descriptor
building code to make the resulting descriptor compatible with
Windows.

* Axes, both relative and absolute, are exposed only if at
  least X and Y are present.

* Absolute axes are exposed only if relative ones are not.
  Windows does not seem to like the rel+abs combination.

* Unknown absolute axes are ignored. Previously they were
  exposed as the catch-all HID_USAGE_GENERIC_SLIDER usage but
  Windows does not seem to like it.

Signed-off-by: Ladi Prosek <[email protected]>
2017-05-09 11:38:30 +02:00
Ladi Prosek e36be0711e vioinput: Don't fail driver init if no input device was found
Before this commit the driver failed to load if it didn't create
a HID report descriptor for at least one device. The host evdev
device connected to the VM may be arbitrarily obscure and not being
able to drive it should not be an error condition.

In general, virtio-input is a best-effort driver. It ignores what
it doesn't understand, which includes ignoring everything if the
evdev device description doesn't make sense.

Signed-off-by: Ladi Prosek <[email protected]>
2017-05-09 11:38:30 +02:00
Ladi Prosek e69266f9cc vioinput: Fix build break with WDK 10.0.15063.0
The latest Win10 WDK added some more HID usage codes to hidusage.h
which broke the build.

  vioinput\sys\Hid.h(52): error C2220: warning treated as error - no 'object' file generated
  vioinput\sys\Hid.h(52): warning C4005: 'HID_USAGE_LED_SYSTEM_SUSPEND': macro redefinition
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\hidusage.h(440): note: see previous definition of 'HID_USAGE_LED_SYSTEM_SUSPEND'

  vioinput\sys\Hid.h(59): warning C4005: 'HID_USAGE_DIGITIZER_STYLUS': macro redefinition
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\hidusage.h(571): note: see previous definition of 'HID_USAGE_DIGITIZER_STYLUS'

  vioinput\sys\Hid.h(63): warning C4005: 'HID_USAGE_SIMULATION_BRAKE': macro redefinition
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\hidusage.h(184): note: see previous definition of 'HID_USAGE_SIMULATION_BRAKE'

  vioinput\sys\Hid.h(64): warning C4005: 'HID_USAGE_SIMULATION_STEERING': macro redefinition
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\hidusage.h(187): note: see previous definition of 'HID_USAGE_SIMULATION_STEERING'
  Build FAILED.

This commit fixes it by surrounding the affected macros with ifdefs.

Signed-off-by: Ladi Prosek <[email protected]>
2017-05-02 06:35:55 +02:00
Ladi Prosek 2d16d1cf5b vioinput: Fix INF verification errors
The INF verification test in Win10 HLK 1703 started treating some
of the verification warnings as errors:

  Section [sourcedisksfiles] is defined multiple times.
  Empty DDInstall section will not install any drivers.

This commit fixes it by merging [sourcedisksfiles] sections into
one and adding a [CopyFiles_Child] section.

Signed-off-by: Ladi Prosek <[email protected]>
2017-05-02 06:35:55 +02:00
Sameeh Jubran ad7f6562c9 Add missing invokes to va_end macro
According to documentation the va_end macro should be invoked before
the function returns whenever va_start has been invoked from that
function.

This commit fixes errors reported by cppcheck tool.

Error sample:
[kvm-guest-drivers-windows/Balloon/sys/utils.c:60]: (error) va_list 'list'
was opened but not closed by va_end().

Signed-off-by: Sameeh Jubran <[email protected]>
2017-03-27 16:20:25 +03:00
Vadim Rozenfeld 87ef07e2fb Bug 1303510 - Change the copyright on all the Windows drivers to "2017" in virtio-win-prewhql build
(cherry-picked from commit a3a92176c31bb5e297f7919e02a652d1580f8b8d)
Signed-off-by: Ladi Prosek <[email protected]>
2017-03-23 10:04:55 +01:00
Ladi Prosek 5b139549fb Move {RHEL,VZ}_COPYRIGHT_STARTING_YEAR out of driver props files
Defines a new CopyrightStrings property which is then used in
vendor specific files to compose copyright strings. This way
a new vendor FOO will define their copyright string policy in
Driver.FOO.props
foo.ver
etc.

without touching driver props files.

Keeping vendor specific properties in their separate files makes
introducing a new vendor a purely additive process, without the
need to edit existing files. The vendor may even keep their files
"downstream only" if they choose so.

Signed-off-by: Ladi Prosek <[email protected]>
2017-03-16 15:33:10 +01:00
Alexey V. Kostyushko 4cd8cddf7f all: added support for multiple vendors (c) years
this patch sets COPYRIGHT_STARTING_YEAR in all .props

Signed-off-by: Alexey V. Kostyushko <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
2017-03-16 15:25:21 +01:00
Alexey V. Kostyushko 8e1cdc6b3a added support for multiple vendors
This patch removes all packone PostBuildEvent and stores packages in
Install directory as earlier.

Signed-off-by: Alexey V. Kostyushko <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
2017-03-16 15:25:21 +01:00
Alexey V. Kostyushko 8dc05d8805 vioinput: support for multiple vendors
Driver.c - #includes vendor.check.h for logging
vioinput.inx - replace rhel vendor specific with INX_ that will be
               substituted by tools
vioinput.rc - simplified and use common schema from tools
vioinput.props - enables features
vioinput.vcxproj - import props, import tools targets

same for hidpassthrough

Signed-off-by: Alexey V. Kostyushko <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
2017-03-16 15:25:21 +01:00
Ladi Prosek a2943d499b vioinput: Switch from filter to bus/child architecture
The canonical KMDF HID driver uses mshidkmdf.sys (or its equivalent
viohidkmdf.sys) as the FDO for the device and the actual KMDF driver
as its lower filter to work around PnP KMDF limitations. This works,
except for the case where the same device, in terms of USB or PCI or
any other bus location, may expose different HID collections every time
it's plugged in. Because the instance path of the HID PDO (like for
example "HID-compliant mouse") is constructed only from the instance
path of the parent - likely just by replacing the bus ID with "HID" -
the system will reuse pre-existing devnodes, even if the HID collection
and the report descriptor are completely different and a keyboard,
for example, should be created instead of a mouse.

It's not hard to run into this issue with the vioinput driver. E.g.
switching from
-device virtio-mouse-pci
to
-device virtio-keyboard-pci
for the same PCI slot will result in the system loading the mouse HID
driver and the keyboard not working.

This commit works around it by making the KMDF driver a bus driver
which enumerates one and only child PDO, functionally driven by
viohidkmdf.sys. IOCTL IRPs are forwarded from viohidkmdf to vioinput
and processed just like before. The key difference is that vioinput
now generates the instance ID of the child, thus having the ability
to alter the instance path depending on the shape of the input device.
Specifically, vioinput computes a simple hash out of the HID report
descriptor and uses it as the child instance ID.

The child device is hidden from Device Manager so as not to confuse
users. It's not meant to be manipulated except through its parent.

Signed-off-by: Ladi Prosek <[email protected]>
2017-03-10 11:12:00 +01:00
Ladi Prosek 731a9a4b4f vioinput: Use viohidkmdf.sys instead of mshidkmdf.sys
This commit makes the hidpassthrough project part of the build
and makes vioinput install and use it instead of mshidkmdf.sys.

The primary reason for building our own HID KMDF shim is the
requirement to certify vioinput on server core Windows where the
in-box component is missing. A nice side-effect is that the driver
may be built for older Windows as well, although that may not be
of much use.
2017-02-12 20:57:20 +11:00
flying-122 3c6c329c9b virtio-input : fix : missing key when inputing combination keys
When HidQueue's ExecutionLevel= WdfExecutionLevelPassive and WdfIoQueueRetrieveNextRequest is called in IRQL=
 DISPATCH ,so WdfRequestForwardToIoQueue(in hid.c EvtIoDeviceControl)can not be called timely for inserting request to HIdQueue.
2017-02-09 22:06:51 +11:00
Ladi Prosek 3426183a72 vioinput: Reset device context on HW release
HW prepare/release may be called repeatedly, for example on
resource rebalancing. The uNumOfClasses device context field
was not being reset so the second invocation of HW release
attempted to touch already released input classes.
This fixes BZ #1388775.
2016-11-01 12:30:35 +11:00
Ladi Prosek dfc1286738 vioinput: Delete vioinput.vcxproj.user
The file contains user preferences which are not meant to be checked
in the repo.
2016-10-21 20:52:01 +11:00
Ladi Prosek aefcf3bdfc vioinput: Switch over to Tools/build.bat
This commit switches over to the one shared build script.
buildAll.bat now by default performs an incremental build.
2016-10-21 20:52:01 +11:00
Ladi Prosek 97fd8a45a0 Eliminate _MAJORVERSION_, _MINORVERSION_, _NT_TARGET_MIN
The three environment variables were just defined to be equal to
_BUILD_MAJOR_VERSION_, _BUILD_MINOR_VERSION_, and _RHEL_RELEASE_VERSION_,
respectively, adding no value.

This commit removes them and replaces all occurrences with the source
variables as mentioned above.
2016-10-14 21:12:06 +11:00
Ladi Prosek 60beffa0f5 vioinput: Refactor sys/packOne.bat into a post-build step
This commit reworks the packOne.bat script into a post-build step
invoked from VS/MSBuild as opposed to something that needs to be
run after the build finishes. It is part of a longer-term plan to
have VS/MSBuild drive the build for better error propagation,
incremental build support, and more.

A couple of hard-coded paths are also removed from packOne.bat.
2016-10-14 21:12:06 +11:00
Ladi Prosek a31ef68bab Suppress pack errors in balloon, vioserial, vioinput
A few harmless errors are printed when building balloon,
vioserial, and vioinput. This commit fixes two issues:

* Win10 drivers don't ship with WDF coninstallers so
  WdfCoInstaller*.dll should not be copied over to Install.

* The Install directory may be empty or not exist, which
  is worth checking before running del on its content.
2016-09-13 14:10:36 +10:00
Ladi Prosek 592de4222e Unify buildAll.bat behavior
Some of the buildAll files were capable of building only
one selected target, some were not. The command line options
required to do that also varied (e.g. Vista vs. Wlh).

This commit makes all buildAll behave the same way. Run
without any arguments, the script will build the driver for
all targets. To build only one target, the script accepts
two arguments, OS version and platform. For example:

buildAll Wlh 32
buildAll Win10 64
2016-09-06 16:34:32 +10:00
Ladi Prosek b525baf28f Move common v140_xp toolset settings to Driver.Common.props
It takes a specially crafted set of both compiler and linker
options to build a kernel mode driver for a downlevel platform
using the legacy DDK and Visual Studio 2015. The new common
props file is a good place for these options/props.
2016-09-06 16:34:32 +10:00
Ladi Prosek 77fee92995 Move the definition of InfArch to Driver.Common.props
The new common props file is a good place for properties shared
by all drivers.
2016-09-06 16:34:32 +10:00
Ladi Prosek 3db3518fc0 vioinput: Eliminate 2012-defines.h
This commit eliminates 2012-defines.h which was being generated
during build. The required version macros are now defined in
Driver.Common.props included from the project.
2016-09-06 16:34:32 +10:00
Ladi Prosek df9f26eed1 virtiolib: Remove unused VirtIOWdfInitialize parameter
The parameter is not used.
2016-08-31 21:46:17 +10:00
Ladi Prosek 80cc66f5c9 virtiolib: Drop run-time queue name support
It is hard to imagine a situation when seeing the queue name as
a string in the debugger would be of any particular use. There is
a simple and unique mapping from queue indices to queue names for
each virtio device.

This commit deletes the name field from queue data structures
along with all the supporting code.
2016-07-17 20:51:12 +10:00
Ladi Prosek 87ac5d73f4 virtiolib: Clean up feature test/enable/disable helpers
This commit renames VirtIOIsFeatureEnabled, VirtIOFeatureEnable,
and VirtIOFeatureDisable to virtio_is_feature_enabled,
virtio_feature_enable, and virtio_feature_disable, respectively.
A few redundant implementations are eliminated as well to keep
the logic in one place.
2016-07-17 20:50:46 +10:00
Ladi Prosek c3440bc925 virtiolib: Stop including virtio_config.h
There's no reason why some of the functionality should be declared
in a separate header that all drivers need to include. This commit
adds a few virtio_ wrappers to completely abstract away the config
callbacks.
2016-07-17 20:50:13 +10:00
Vadim Rozenfeld 62a837f37f disable test-signing 2016-07-17 20:30:35 +10:00