Paul Durrant [Fri, 6 May 2016 08:51:30 +0000 (09:51 +0100)]
Make sure transmitter DPC does not try to unmask non-existent evtchn
In the case where the backend does not support split event channels (one
for RX and one for TX) then the transmitter code in XENVIF does not open
the combined channel; it is handled by the receiver code. So, the
transmitter DPC should not make any attempt to unmask the event channel at
the end of processing.
This patch adds the necessary check for FrontendIsSplit before doing the
unmask and also removes an unnecessary check for FrontendIsSplit in the
transmitter ring enable function.
Paul Durrant [Wed, 23 Mar 2016 14:06:27 +0000 (14:06 +0000)]
Avoid ASSERTion failure on VIF plug
If the backend is not fast enough then it's possible that the frontend
code sees the backend in state Initialising rather than InitWait. This
causes an ASSERT to be hit.
This patch simply whitelists the Initialising state to avoid the problem.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 23 Mar 2016 11:50:35 +0000 (11:50 +0000)]
Prevent VIF from being incorrectly considered offline...
...one resume from suspend.
My previous reversion of 765b7a6a exposed the original reason the
reverted patch.
On resume from suspend, the backend will have been re-created by the
toolstack and hence the frontend detects it as being offline. This
causes the frontend to request ejection of the disk (thinking that
the reason for the backend going offline is because the VIF is being
unplugged).
This patch works around this problem by introducing an early suspend
callback to note that the frontend has actually gone offline, which
will prevent the ejection from being requested.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 22 Mar 2016 11:29:37 +0000 (11:29 +0000)]
Remove erroneous code to re-acquire backend path on resume
Commit 765b7a6a added code to release and re-acquire the backend
path (and domid) on resume from suspend. That code falsely
assumes that the frontend is not in a closed state at the time.
It's also not clear why it was added in the first place so
this patch removes it again, as it causes a BSOD when the
frontend is in the closed state.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 21 Jan 2016 09:23:27 +0000 (09:23 +0000)]
Dynamic multicast control
Only use the multicast control feature of the backend if it supported
"feature-dynamic-multicast-control" otherwise attempts to enable the 'all
multicast' filter level in XENVIF will have no effect and the NDISTest 6.5
MultiCast Address test will fail.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 28 Jan 2016 14:35:53 +0000 (14:35 +0000)]
Cancel pending timers when rings are disabled
No new timers can be scheduled once rings are disabled but if the rings are
both disconnected and destroyed within the next 100us then it's possible
that the DPC might hit some unitialized data so make sure pending timers
are cancelled.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 25 Jan 2016 10:24:49 +0000 (10:24 +0000)]
Add DPC watchdog avoidance to receiver and transmitter poll
Under HCK MPE testing it's possible for both receiver and transmitter
polling loops to run long enough to hit the DPC watchdog. This patch
avoids the problem by terminating the polling loops after a 'batch'
(currently 1/4 of the ring) and then checking the remaining time before the
watchdog fires. If the remaining time is still more than half the total
time then another poll is done, otherwise a timer is scheduled to complete
the work.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 22 Jan 2016 13:57:58 +0000 (13:57 +0000)]
Fix DPC accounting
The DPC count is not zeroed when the event count is zeroed leading to some
odd looking stats. Also the DPC count should really be incremented by the
DPC itself to ensure serialization.
While in the neighbourhood, the ring notify functions in transmitter and
receiver look a little superfluous; they can easily be folded directly
into the DPC if the receiver code triggers the transmmitter DPC in the case
of a combined event channel.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 19 Jan 2016 16:31:44 +0000 (16:31 +0000)]
Fix WHQL InvalidPackets test
Because the transmit code now parses packets before queueing (for the
purposes of maybe needing to hash) the operation can fail of the headers
are invalid. The WHQL test does not expect this to happen.
This patch ignores the parse failure but instead fails the packet when it
is de-queued but only if absolutely no header (i.e. even the ethernet
header) could be parsed. This seems to be enough to keep the test happy.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 15 Dec 2015 14:26:55 +0000 (14:26 +0000)]
Centralize compatibility code
This patch moves the code that maintains compatibility with older
VIF interface versions into the vif.c module, rather than having it
distributed amongst vif.c, transmitter.c and receiver.c.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 4 Jan 2016 13:09:14 +0000 (13:09 +0000)]
Update VIF interface to version 5
Unfortunately VIF interface version 4 suffers from a shutdown race with
the TransmitterQueuePacket method. If a call to this races with the Disable
method then a NULL callback function pointer can be invoked.
This patch fixes the race by having TransmitterQueuePacket return a status
code to indicate whether a packet has been queued (rather than invoking the
completion callback if it has not), but this necessitates a interface change
so the VIF interface version is also updated to 5 and a new PDO revision is
added.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 10 Dec 2015 11:17:05 +0000 (11:17 +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 [Fri, 4 Dec 2015 11:04:41 +0000 (11:04 +0000)]
Introduce VIF interface version 4
This greatly simplifies the interface with XENNET by queuing single packets
on both the transmit and receive side, negating the need for a shared packet
structures and bringing static hash calculation into XENVIF.
Crucially this also means that XENNET no longer needs to use the
XENBUS_CACHE interface which allows it to be patched to 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 [Fri, 4 Dec 2015 09:12:21 +0000 (09:12 +0000)]
Move check for split event channels into Frontend module
Reduce code duplication and efficiency a little by checking the xenstore
key once in Frontend and then providing a function with Transmitter and
Receiver can use to grab the value.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 15 Sep 2015 09:35:38 +0000 (10:35 +0100)]
Remove version 1 of the XENVIF_VIF interface
The revision has been gone from the PDO for a long time so version 1 of
the interface has been technically dead for a while. This patch cleans up
the code.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 29 Jul 2015 15:19:15 +0000 (16:19 +0100)]
Add code to set receive side backfill size
The NDIS header/data-split feature requires that the first data
MDL in a NET_BUFFER has sufficient headroom to take a copy of the
entire header MDL just in case something up the stack can't cope
with the split.
To this end NDIS specifies a 'backfill size' which must be
reserved. This patch implements support for that by copying and
adjusting the first data MDL if necessary.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 3 Dec 2015 12:23:27 +0000 (12:23 +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.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 24 Nov 2015 14:25:16 +0000 (14:25 +0000)]
Add XENBUS_STORE and XENBUS_SUSPEND interfaces to exported set
To advertise driver distribution information to xenstore XENNET needs to
make use of the XENBUS_STORE and XENBUS_SUSPEND interfaces. As XENVIF is
XENNET's parent driver, it must export them. Adding them to the exported
set also requires update of the PDO revision number.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Import updated store_interface.h from XENBUS and revised commit comment.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 12 Nov 2015 14:57:49 +0000 (14:57 +0000)]
Publish network information to xenstore using documented paths
My recent patch series to Xen added documented paths for advertising vif
hotplug capability and paths for publishing network interface information
(name, IP addresses, etc.).
This patch modifies XENVIF to make use of those new paths.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 14 Aug 2015 12:28:42 +0000 (13:28 +0100)]
Use multicast control if the backend supports it.
This required a bit of re-work in the transmitter code since using multicast
control necessitates sending dummy transmit requests with special extra
info fragments. As a knock-on I also re-worked the way the IP address table
is maintained, removing bits that were in the transmitter code into the
general frontend code.
Re-work was also required in the mac code since it is also necessary to
track addition and removal of individual multicast addresses, rather than
just handling a table update.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 22 Oct 2015 14:46:09 +0000 (15:46 +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, 15 Sep 2015 14:25:53 +0000 (15:25 +0100)]
Cope with zero-length binary values in the registry
It appears that it is legitimate for the registry to contain zero-length
binary values, so the registry access code needs to cope with them and
the settings copy code needs to allow for them too.
Reported-by: Rafal Wojdyla <omeg@invisiblethingslab.com> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 9 Sep 2015 08:26:22 +0000 (09:26 +0100)]
Parameterize vendor prefix and PCI device id
The XenServer PV vendor prefix ('XS') and PCI device (C000) are still
hard-coded into the XENVIF 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 xenvif.inf
directly in build.py.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 8 Sep 2015 13:44:17 +0000 (14:44 +0100)]
Don't treat a missing Driver key as a hard failure
When looking to see whether an incumbent child driver will patch the
PDO names created by the new version of XENVIF, ignore any cases where
we find that the Driver key referenced in the Device key is actually
missing.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 3 Sep 2015 16:41:30 +0000 (17:41 +0100)]
Avoid holding a reference to the UNLPLUG interface
If the system goes into S3 or S4 then currently the reference will still be
held. This is not problematic for this interface but it is not desirable to
hold references in this circumstance and for other interfaces it can lead
to bugchecks.
This patch adds a function, PdoRequestUnplug(), which only acquires the
interface as needed and then makes use of that.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 3 Sep 2015 09:27:09 +0000 (10:27 +0100)]
Don't NULL out fragment in pending array __TransmitterRingFakeResponses()
It is completion of the response in TransmitterRingPoll() that should NULL
out the entry in the array. Doing so causes the assertion at
transmitter.c:2111 to fire in a debug build and a page fault in a non-debug
build.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 6 Aug 2015 14:58:14 +0000 (15:58 +0100)]
Registry string value types cannot be inferred
Following a similar fix in XENBUS this patch adds an explicit Type parameter
to RegistryUpdateSzValue(). It also adds a similar parameter to
RegistryQuerySzValue() so that code querying a string value can find out
what type it is.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 5 Aug 2015 11:48:58 +0000 (12:48 +0100)]
Use prefix matching for IPv6 address copy code
...and also fix registry path and add support for similar IPv4 address
copying.
Windows puts static IP address values in some oddly named and located
registry keys. The key names are just GUIDs and the only useful part of
the values names (that allows use to find them) is that they prefix
match the interface LUID rendered as a 16 digit hex string.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 10 Jul 2015 10:56:25 +0000 (11:56 +0100)]
Lookup active network interfaces by index rather than LUID
The frontend address lookup code was failing to check whether the interface
it was querying was actually active, and also using LUID is kind of overkill
when we could just use index.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 8 Jul 2015 13:10:53 +0000 (14:10 +0100)]
Avoid PDO namespace conflicts...
...by encoding the driver major version in the upper byte of the
revision.
This clearly implies that any future change in the driver major version
will start a new PDO namespace, but that it almost certainly the correct
thing to do in that case.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 8 Jul 2015 13:02:02 +0000 (14:02 +0100)]
Update bindings
Refresh the interface headers (just suspend_interface.h in this case) and
add the XENBUS major version into the top byte of the revision, since this
is now used to avoid namespace conflicts.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 7 Jul 2015 14:21:38 +0000 (15:21 +0100)]
Add functions to backup and restore network settings
In PdoStartDevice(), if an aliasing emulated device is found in the MIB
interface table, back up its network settings to a private area under the
the PDO software key before requesting reboot.
In a later boot, if the emulated device has been unplugged, restore the
network settings from the private area to the PDO such that it will start
with the same configuration as the emulated device it has replaced.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 8 Jul 2015 10:53:42 +0000 (11:53 +0100)]
Stop synthesizing the NET_LUID
From Windows 10 the lifetime of the registry keys used to synthesize the
PDO's NET_LUID has changed. Instead of using a synthesized NET_LUID, look it
up in the MIB interface table (keyed by the permanent physical address)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 8 Jul 2015 10:16:13 +0000 (11:16 +0100)]
Move reboot request code into driver.c
It doesn't really belong in pdo.c
Also this patch adds a check in PdoStartDevice() to fail if a reboot has
already been requested. This is because Windows 10 apparently has a couple
of goes at starting the PDO even after it failed to start the first time
(because we requested a reboot).
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 7 Jul 2015 13:42:46 +0000 (14:42 +0100)]
Only open the PDO software key once
There are currently two functions where the PDO software key is opened and
closed: __PdoSetCurrentAddress() and __PdoSetLuid(). Both of these
functions are called from PdoStartDevice() so it's more efficient to open
the software key there and pass it as an argument to the aforementioned
functions.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 7 Jul 2015 13:56:17 +0000 (14:56 +0100)]
Add a type argument to the RegistryEnumerateValues() callback...
...and pass ANSI_STRINGs rather than PCHARs.
Also fix both RegistryEnumerateSubKeys() and RegistryEnumerateValues() to
not clobber their own buffer sizes when calling ZwEnumerateKey() or
ZwEnumerateValueKey() respectively.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 7 Jul 2015 10:44:53 +0000 (11:44 +0100)]
Remove use of 'Addresses' subkey
XENVIF writes the permanent address of each vif into a subkey under its
service key. This is done to allow XENNET's co-installer to copy network
settings from any emulated device that currently has that address.
As of Windows 10, this functionality cannot be provided by a co-installer
and so this subkey has become useless. Hence this patch removes its use.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 2 Jul 2015 10:31:29 +0000 (11:31 +0100)]
Remove erroneous use of transmitter DPC
If the backend does not support split event channels then the transmitter
DPC should not be used, and it contains an assertion to that effect.
The ring enable function, however, unconditionally queues the DPC leading
to an assertion failure. This patch makes sure the DPC is only queued if
the backend does indeed support split event channels.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 8 May 2015 14:40:50 +0000 (15:40 +0100)]
Release and re-acquire backend on resume
When resuming from suspend, any previously cached backend domid and path are
invalid. The frontend code should therefore release and re-acquire those
values before attempting to manipulate vif state.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 16 Apr 2015 11:45:57 +0000 (12:45 +0100)]
Re-work frontend xenbus state handling code
Any time the xenbus state transitions through XenbusStateClosed (6) then
it's possible for the toolstack to tear down the vif, regardless of whether
the state transition was initialiated by the backend going offline or the
frontend being disabled at the same time the backend happens to go offline.
It's important, therefore, that the frontend code allows for this and
always requests PDO ejection if the backend does go away (even if a new
immediately appears).
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 15 Apr 2015 15:10:08 +0000 (16:10 +0100)]
Allow PdoResume() to fail
At the moment FrontendResume() can fail, but PdoResume() cannot and hence
the error status is ignored. This is problematic because it is not safe to
call FrontendSuspend() if FrontendResume() did not complete successfully.
This patch, therefore, wires through the failure of FrontendResume() into
PdoResume() and on into FdoAddPhysicalDeviceObject().
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 1 Apr 2015 14:32:54 +0000 (15:32 +0100)]
Log a message to note that when a receiver is waiting for packets
Before the receiver object in the frontend can be shut down, the Windows
network stack must return all buffers passed up. The code therefore
waits for this to happen during the VIF Disable method. Add logging to
note that the wait is occuring as it can take a significant amount of time.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 1 Apr 2015 14:28:29 +0000 (15:28 +0100)]
Ping the transmitter backend when trying to disable
Any transmit requests which have been pushed to the backend must be
responded to before the frontend shuts down, otherwise the frontend
cannot safely tear down the shared ring structures. Whilst waiting
for the backend to respond, send events to make sure it is awake.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 24 Mar 2015 17:50:53 +0000 (17:50 +0000)]
Fix a couple of ASSERT failures
The multi-processor-group patch introduced a new statistics array in
the Frontend object. Unfortunately, whilst the array is correctly freed
on object destruction, the pointer is not NULL-ed out so the IsZeroMemory
check fails. This patch adss the ncessary lines to NULL the array pointer.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Tue, 24 Mar 2015 12:18:59 +0000 (12:18 +0000)]
Add the 'NeedReboot' flag back in
Older versions of the code used to set a 'NeedReboot' registry value if
the PDO failed to start because the corresponding emulated device was
found to be still present. The value was set directly in the service key
which is non-volatile and thus the value would persist after reboot.
This patch adds code to again set a 'NeedReboot' value, but this time it
is in a volatile 'Status' key under the service key so that it does not
persist. This value can then be used by the XENNET co-installer to
determine whether it should request a reboot during postinstall
processing.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 20 Mar 2015 12:01:47 +0000 (12:01 +0000)]
Make XENVIF 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>
This brings the headers into line with XENBUS. There's no reliance on a
post-4.5.0 change in XENVIF but the re-structuring in the headers done
after 4.5.0 does mean change is necessary and we may as well take the pain
sooner rather than later.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 13 Mar 2015 16:00:16 +0000 (16:00 +0000)]
Disambiguate transmitter packet caches
When a VM has multiple VIFs then it is not currently possible to tell
which transmitter packet cache applies to which VIF. This patch adds
the VIF path into the cache name to disambiguate.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 5 Mar 2015 09:56:38 +0000 (09:56 +0000)]
Fix memory leak
Verifier discovered a memory leak on shutdown of XENVIF. This is because
the per-ring path used for talking to multi-queue aware backends is not
freed in the case where there is only one queue. This patch simply removes
that check as it is incorrect.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 4 Mar 2015 10:04:58 +0000 (10:04 +0000)]
Fix WHQL induced BSODs
The PNP Rebalance Fail Restart Device test causes BSODs due to incorrect
PnP state assumptions about the FDO. This patch fixes these problems
allowing the test to pass.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 27 Feb 2015 17:47:04 +0000 (17:47 +0000)]
Release lower bus interface before passing removal IRP to PDO
If the PDO is surprised removed then the FDO tries to retain its
reference to the PDO's bus interface byond its destruction. This will
cause an assertion failure in checked builds of XENBUS and may cause
memory corruption.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 26 Jan 2015 16:15:24 +0000 (16:15 +0000)]
Fix type mismatch
The size of PWCHAR and the size of ULONG are the same for 32-bit
installations so this bug only affects 64-bit installations, but the
symptom is a crash on PDO destruction due to a corrupted heap.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>