Paul Durrant [Tue, 9 Aug 2016 13:01:19 +0000 (14:01 +0100)]
Use new monitor request key
The monitor service now uses a request key in registry under HKLM/SOFTWARE.
This patch modifies __DriverRequestReboot() to use the new key, which is
now set as a parameter by the INF file.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Mon, 8 Aug 2016 12:03:25 +0000 (13:03 +0100)]
Re-work identity stealing code
The change introduced by patch 04c391d9 "Replace copying network
settings with identity stealing" had a flaw...
If a PV device that aliases an emulated device is installed then it
will only steal linkage if that emulated device is operational at the
time. This works on initial driver install, but not if the PV network
device driver is removed and then re-installed without an interim
reboot (which would make the emulated device operational). Instead,
after re-installation, the PV device has a brand new stack binding and
thus any network settings changes that were previously made are
apparently lost.
To fix this problem, this patch breaks the process of stealing the
emulated device's stack binding into two phases:
1) Discovery: When the PV device driver is installed, if an aliasing
emulated device is operational, a DWORD value called "VIF" is
created under the emulated devices software key. The value is set
to the PV device instance.
2) Theft: When the PV device is being brought online, the registry is
checked to see if any network device has a software key containing
a "VIF" value that patches the PV device instance.
If such an entry is found then the stack binding is stolen from
that device. Since the "VIF" value is in the *emulated* device's
software key, it will not be removed if the PV device driver is
removed and re-installed and so the problem described above will
not occur.
Because this patch avoids stealing the emulated device's stack bindings
if it is actually operational (i.e. we're in phase 1) this results in the
class installer building a new set of stack bindings for the PV device
during initial installation.
These are then restored any time a PV device with a stolen stack binding
is offlined. So, when a PV device is offline there is no evidence that
any stack binding has been stolen and hence, during driver removal, there
is no risk of an emulated device's stack binding being torn down.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 28 Jul 2016 09:04:44 +0000 (10:04 +0100)]
Make sure the NICS unplug count does not run away
In a tight loop of network attach/detach it's possible for a mismatch in
the number of unplug requests and revocations to occur, leading to a
run-away unplug count.
This patch adjusts the location of the requests and revocations to make
sure this does not happen.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 28 Jul 2016 09:00:51 +0000 (10:00 +0100)]
Make sure we don't end up with duplicate PDOs
In a tight loop of network attach/detach it's possible to end up with
duplicate PDOs because, as soon as a PDO gets set to 'missing' a new one
with the same name can be created. This leads to races in accessing the
vif areas in xenstore and things can get very confused.
This patch makes sure that a new PDO cannot be created until a previous
incarnation is in the 'deleted' state, which means there will definitely
be no conflict in interactions with xenstore.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 27 Jul 2016 12:33:56 +0000 (13:33 +0100)]
Fix locking and teardown bugs in controller frontend
If the backend does not implement the control ring then the frontend will
eventually deadlock. Also, by inspection, the teardown code does not
release interfaces if the control ring was not present.
This patch fixes both issues.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 18 May 2016 15:23:51 +0000 (16:23 +0100)]
Avoid transmitting on the wrong CPU
The transmit and receive rings have DPCs and event channels affinitized
to a particular CPU. Thus, when XENNET queues a new packet at the
transmit side, make sure the packet is prepared and posted from the
CPU to which the DPC and event channel are bound to avoid lock contention.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Re-introduce mistakenly dropped frontend state logic...
...from commit c9b6e56e "Cope with unexpected initial backend states" to
handle a backend that is already connected (for cases where Windows is
booted via iSCSI).
Signed-off-by: Eytan Heidingsfeld <eytanh@gmail.com> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 7 Jan 2016 15:06:48 +0000 (15:06 +0000)]
Send transmit side hash value to the backend
Backends capable of supporting packet hashing on the guest receive side
are also capable of accepting hash values in an extra info fragment on
the guest transmit side. This patch adds code to construct and send the
extra info fragment if the packet metadata contains hash information and
the backend is able to process it.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 20 Nov 2015 16:56:49 +0000 (16:56 +0000)]
Add frontend code for the new netif control ring
My recent patches to Xen's netif.h specify a control ring that can be
used by a frontend driver to configure packet hashing and steering in
a backend.
This patch adds the necessary code to XENVIF to drive this new ring,
however the rest of the code to link this up to new VIF interface
functionality (so that it may be used by XENNET) is deferred to a
subsequent patch.
This patch also pulls in an updated EVTCHN interface from XENBUS and
corrects the PDO binding.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
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, 2 Mar 2016 16:35:47 +0000 (16:35 +0000)]
Replace copying network settings with identity stealing
It is becoming increasingly hard to find all the places in the registry
that Windows uses to stash network settings and copy them from the
emulated NIC to the new PV device when it is first installed.
So, rather than fighting a losing battle, steal the identity of emulated
devices instead, The identity information is essentially contained in two
values stored in the 'software'registry key of a NIC (under Control/Class/
<NET GUID>): NetCfgInstanceId and the NET_LUID, made up of *IfType and
NetLuidIndex. By copying these values and the contents of the Linkage subkey
we can effectively impersonate the emulated NIC once it is unplugged after
reboot.
This patch amends the settings code accordingly and also does some tidying
in pdo.c and registry.c.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 30 Mar 2016 10:58:58 +0000 (11:58 +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, 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 [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 [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 [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 [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 [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 [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>