Paul Durrant [Thu, 19 May 2016 11:28:04 +0000 (12:28 +0100)]
Avoid lock contention between receiving CPUs
The single PutList/GetList for cached NET_BUFFER_LIST structures is
currently a point of contention. This patch gets rid of the contention
by keeping per-CPU GetLists.
To access the definition of HVM_MAX_VCPUS, the hvm_info_table.h header
needs to be pulled in the from the Xen source base. This patch therefore
adds the infrastructure for pulling in Xen headers.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 4 Mar 2016 11:10:33 +0000 (11:10 +0000)]
Clear stolen linkage on device removal
Commit 04c391d9 "Replace copying network settings with identity stealing" to
XENVIF changed the way that network settings are preserved when replacing
an emulated NIC with a PV network device. This change means that both the
emulated NIC and PV device have the same binding to the Windows network
stack. Thus, if we do not destroy that binding prior to uninstallation of
the PV network driver, the stack will be torn down by the network class
uninstall code rather than left in place for the emulated NIC to use after
reboot.
This patch hence adds code to the XENNET co-installer to remove stolen
linkage information from the registry in the pre-remove phase.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 30 Mar 2016 11:01:26 +0000 (12:01 +0100)]
BootFlags should be a parameter, not a subkey
A misplaced comma in the INF file means that BootFlags is being created as
a subkey under the service key with a default DWORD value, rather than a
DWORD value with the name 'BootFlags'.
This patch moves the comma and fixes the problem.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 24 Feb 2016 10:35:12 +0000 (10:35 +0000)]
Fix a typo that causes 'low resources' to erroneously kick in
This patch fixes a typo which caused XENNET to operate in a 'low resources'
situation most of the time. This was almost certainly causing performance
issues and, oddly, caused the NDISTest 6.5 OffloadChecksum test to fail...
but only on Windows 8.0.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 1 Feb 2016 15:45:14 +0000 (15:45 +0000)]
Fix a warning in the NDISTest 6.0 2c_OidsNdisRequest test
The format of the response to the OID_GEN_VENDOR_DRIVER_VERSION request was
incorrect, and also the OID_GEN_DRIVER_VERSION response has been lying since
the change to NDIS 6.1.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 1 Feb 2016 11:06:03 +0000 (11:06 +0000)]
Fix NDISTest 6.5 OffloadLSO test
There are more structure size issues lurking that cause this logo test to
fail. This patch fixes those, others that were found along the way and also
makes sure that any attempt to set IPsecV2 offload parameters fails (since
it is not supported).
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 28 Jan 2016 17:59:26 +0000 (17:59 +0000)]
Use a locally defined StringPrintf
Use of the _snprintf_s symbol fails on Windows 10, where it appears not to
be exported from ntdll. So, for portability's sake it is more robust to
implement a StringPrintf function locally.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 28 Jan 2016 09:57:24 +0000 (09:57 +0000)]
Stash a pointer to _snprintf_s in the ADAPTER structure
It is problematic if we don't, as on resume from suspend we need to
re-acquire the function pointer and this seems to lead to a BSOD, despite
there being no documentation to suggest that use of the aux_klib functions
at DISPATCH_LEVEL is disallowed.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 27 Jan 2016 14:52:57 +0000 (14:52 +0000)]
Stop using RtlStringCbPrintfA()
It appears that linking an NDIS driver with any ntstrsafe function (when
building with VS2012 and the 8.0 WDK at least) has the side effect of
requiring use of DbgPrint(). Whilst this may not sound like a problem, it
is. This is because the NDISTest 6.0 1c_KernelCalls test insists that any
use of DbgPrint is illegal and so it's impossible to logo an NDIS driver
using ntstrsafe functions.
This patch works around the issue by dynamically linking (at run-time) to
the ntdll _snprintf_s function as a replacement for calls to
RtlStringCbPrintfA(). This entails importing the dynamic linking code from
XENVIF since MmGetSystemRoutineAddress() doesn't seem to work for that
symbol.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 26 Jan 2016 11:34:47 +0000 (11:34 +0000)]
Fix multiple completion vulnerability in transmit code
My previous patch 7c3365d5 "Make transmitter robust against a possible
completion race" did not fix the problem. There is still the possibility
that a NET_BUFFER_LIST containing multiple NET_BUFFERs could lead to
multiple completions if the underlying transmit completes quickly (or indeed
synchrnously). This is because a reference is taken before sending each
NET_BUFFER but, if that transmission completes immediately the reference is
dropped back to zero (leading to the NET_BUFFER_LIST being completed) before
the reference is taken for the next NET_BUFFER.
This patch therefore takes an extra reference before sending any NET_BUFFERs
and then drops it when there are no more NET_BUFFERs to send. This ensures
that the reference count on the NET_BUFFER_LIST can only fall to zero once
the whole thing has been processed.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 19 Jan 2016 11:21:28 +0000 (11:21 +0000)]
Make transmitter robust against a possible completion race
It's possible that a transmission invoked on one CPU may complete on another
before the transmission invocation as finished. Therefore, once we have queued
a NET_BUFFER for transmission we should not use it's metadata again (including
the 'next' pointer).
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 19 Jan 2016 09:31:45 +0000 (09:31 +0000)]
Remove header/data split support
During logo testing it became apparent that:
a) This is predicated on support VLAN ID, which is not something we really
want in a PV driver (since the backend network may actually be a VLAN).
b) Turning on Viridian flags causes NDIS to stop enabling header/data split.
(There's a call to NdisGetHypervisorInfo() in NdisMSetHDSplitAttributes()).
Issue a) makes it undesirable to implement and b) makes it pretty much
pointless having the code around. Hence this patch removes it.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 18 Jan 2016 17:44:01 +0000 (17:44 +0000)]
Fix various structure sizes
NDIS defines 'sizeof' values for various attribute/parameter structures
which are documented for use with different versions of NDIS. This patch
makes sure we are using these defined values in appropriate places.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 10 Dec 2015 11:28:17 +0000 (11:28 +0000)]
Re-synchronize util.h with XENBUS and use __toupper()
A recent patch introduced __tolower() and __toupper() into util.h as
replacements for tolower() and toupper() respectively as the latter do
a hidden conversion to Unicode which make then unsafe at any IRQL other
than PASSIVE_LEVEL.
This patch imports util.h from XENBUS and fixes other code to be compatible.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 8 Dec 2015 15:06:51 +0000 (15:06 +0000)]
Don't get XENBUS_SUSPEND callback registration on AdapterCount
Instances will not necessarily come and go in order so we can't know that
the last instance to go will be the one the registered the callback.
Instead register a callback for every instance and just use AdapterCount to
decide which instance writes distribution information to xenstore.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 4 Dec 2015 12:22:08 +0000 (12:22 +0000)]
Move to XENVIF VIF interface version 4
This means we can remove a lot of complexity and crucially we no longer
need to use the XENBUS_CACHE interface, which means we can avoid the race
introduced by commit 026aa32c "Make sure XENBUS interfaces are released
when going into S4".
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 3 Dec 2015 12:55:31 +0000 (12:55 +0000)]
Make sure XENBUS interfaces are released when going into S4
Because a transition into and out of S4 means a new domain is built, it's
crucial that all XENBUS interfaces are released (so that things like
event channels, grant tables and the xenstore ring get re-constructed).
This patch fixes code paths where this was not being done. It also adds
some more logging during AdapterEnable/Disable and when moving between
D0 and D3.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 22 Oct 2015 14:50:58 +0000 (15:50 +0100)]
Add a registry override to veto driver installations
There are certain cases where a local installer package may wish to
prevent Windows Update installations of drivers. This can be achieved by
having the co-installer check for a registry value and fail it's pre-install
phase if the value is present.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 28 Jul 2015 16:27:04 +0000 (17:27 +0100)]
Add header/data split support
Now that XENNET is using NDIS 6.1, implement header/data split. See
NDIS documentation for more details. This requires using version 3 of the
VIF interface from XENVIF to support the requirements for data MDL
backfill.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 8 Sep 2015 16:20:57 +0000 (17:20 +0100)]
Parameterize vendor prefix and PCI device id
The XenServer PV vendor prefix ('XS') and PCI device (C000) are still
hard-coded into the XENNET package. These need to be stripped out and
replaced by values that can be customized at build time. This patch does
that.
The patch also reverts to building version.h and customizing xennet.inf
directly in build.py.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 24 Mar 2015 12:53:30 +0000 (12:53 +0000)]
Co-installer RequestReboot() invocation changes
Stop requesting reboot on uninstall of XENNET. If an admin removes the
network driver then there is no particular need to request a reboot.
However, make sure that we only remove the unplug key if the last instance
of XENNET is being removed.
On installation of XENNET, use the XENVIF 'NeedReboot' flag to determine
whether to request reboot.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 24 Mar 2015 13:14:19 +0000 (13:14 +0000)]
Revert previous commit
This patch reverts the previous commit which attempted to make XENNET
aware of multiple processor groups. The changes don't seem to work on NDIS
drivers and lead to corruption of the receiver GetLists.
A different approach is needed.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 20 Mar 2015 13:19:16 +0000 (13:19 +0000)]
Make XENNET processor group aware
Processor groups have been around for a long time in Windows and
contnuing to ignore them becomes ever more painful when trying to
pass the HCK multiple processor group device test. This patch, therefore,
modifies all the code that uses the non-group-aware kernel calls to use
the newer group aware calls.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 13 Mar 2015 13:41:42 +0000 (13:41 +0000)]
Add back useful information logging that was removed
It is useful to know when various offloads are enabled or disabled. That
information used to be logged but the logging macro was removed for some
reason when the multi-queue patches were added. This patch adds that
logging back in.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 13 Mar 2015 12:23:48 +0000 (12:23 +0000)]
OID handling improvements
The query OID code contains several mistakes in setting BytesNeeded and
BytesWritten. This patch re-factors the code slightly to fix those
mistakes and also adds warnings is the stack tries to query or set an OID
that we do not handle.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 13 Mar 2015 12:19:37 +0000 (12:19 +0000)]
Fix NDISTest PacketFilters test
The PacketFilters test fails because it has apparently discovered a whole
load of invalid filters. This, as it turns out, is not because of any bug
in the query OID code but rather in the set OID code. The code as it stands
returns success even for setting an invalid filter, and this is why the
test believes those filters are enabled.
This patch stops ignoring the resturn code of AdapterSetPacketFilter and
hence fixes the test.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 12 Mar 2015 10:22:41 +0000 (10:22 +0000)]
Fix CHANGE macro
The CHANGE(x, y) macro in adapter.c is supposed to evaluate to 0 if x and
y are identical, otherwise it is supposed to assign y to x and evaluate
to 1. The definition is incorrect though, and in the latter case the
assignment is done but the macro still evaluates to 0. This patch fixes
the problem.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Thu, 5 Mar 2015 15:47:51 +0000 (15:47 +0000)]
64bit OIDs: 4-byte results are a success
When buffer is >= 8-bytes, return a 8-byte buffer,
when buffer is >= 4-bytes, return a 4-byte buffer,
else, indicate 8-bytes required and indicate failure
Owen Smith [Mon, 19 Jan 2015 16:22:11 +0000 (16:22 +0000)]
NDIS6.0 1c_64bitOIDs / 1c_IOCTLCoverage
Some QUERY OIDs should return truncated results when 4 byte buffers are
passed for 8 byte values. Avoid corner cases where the OID would succeed,
but not copy data due to wrong buffer sizes.
Paul Durrant [Tue, 7 Oct 2014 09:23:48 +0000 (10:23 +0100)]
Handle lack of IPv6 registry keys in co-installer
The co-installer attempts to copy IPv6 address information from the any
relevant emulated device to the PV device during installation, but will fail
if no IPv6 address information is present. This is not an error condition and
so the co-installer should simply skip this copying operation if no address
information is found.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Michael Brown [Wed, 17 Sep 2014 01:26:35 +0000 (02:26 +0100)]
Mark xennet.sys as boot-critical to simplify offline installation
Explicitly mark the xennet driver as boot-critical using the
"BootCritical=1" directive. This causes dism.exe to reflect the
driver when performing an offline installation, thereby making it
available on the next boot (which may be an iSCSI boot, requiring a
functioning network).
This avoids the need to hack the registry to manually install the
driver (by creating the HKLM\CurrentControlSet\Services\xennet key and
corresponding entries in the CriticalDeviceDatabase).
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
Paul Durrant [Thu, 14 Aug 2014 13:56:59 +0000 (14:56 +0100)]
Update branding
Remove the use of the 'XenServer' product name except where it is
still appropriate.
Remove use of 'Citrix' from all places except source file
copyrights.
Allow company and product name to be set at build time.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 16 Jul 2014 12:16:43 +0000 (13:16 +0100)]
Implement new API version scheme
This patch changes the way APIs work in an incompatible way. (See README.md
for details).
The patch also includes a *lot* of code tidying and movement and as such
is not really suitable for review as a patch; the resulting code should
itself be reviewed.
Given the scale of the change, the major version number has been revised to
8 and other version numbers reset to zero.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 23 Dec 2013 15:50:41 +0000 (15:50 +0000)]
Find alias hardware key rather then stopping with the software key
The DeviceInstanceID value stored in the software key appears to be
specific to newer versions of Windows so we cannot rely upon it. Instead
find the hardware key by reverse mapping via the Driver value - which is
used directly by the PnP subsystem and so should be safe to rely upon.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 30 Aug 2013 08:36:56 +0000 (09:36 +0100)]
Basic functionality.
New device binding. Header file changes. Test siging. Co-installer is
basically NUL at the moment. Need to add back in all the settings copying
code, etc.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>