]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/log
pvdrivers/win/xenbus.git
10 years agoFix event channel unmasking for two-level ABI
Paul Durrant [Fri, 27 Feb 2015 13:48:46 +0000 (13:48 +0000)]
Fix event channel unmasking for two-level ABI

The two-level ABI requires that an event is masked for the unmask
hypercall to raise the event, so the test-and-clear operation in the
guest basically means that pending events get stuck. The simple fix
is to re-mask pending events before making the hypercall. This is
unnecessary when the FIFO ABI is used, but it's safe. Hence this patch
unconditionally re-masks pending events, regardless of ABI, before
making the unmask hypercall.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRe-instate bus enumation filtering in XENFILT
Paul Durrant [Thu, 26 Feb 2015 14:23:43 +0000 (14:23 +0000)]
Re-instate bus enumation filtering in XENFILT

The filtering code was removed in commit
ff034f7ebd4010f7b502c56cb1cca6ba40a7f1aa when it was realized that
simply modifying the reported instance ID of the active device to be
constant, even if it moves location on the PCI bus was sufficient to
keep PV drivers binding. However, this does not protect against the
active device going away so you can still end up with a non-bootable VM.

This patch re-instates the code, modified to check for presence of the
active device with a wildcard instance rather than a fixed instance.

NOTE: This patch does include a change to emulated_interface.h, to allow
      a NULL instance ID to be passed to IsDevicePresent. Whilst this is
      a new semantic, it does not affect compatibility so there is no
      change to the interface version.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix SDV build
Paul Durrant [Mon, 9 Feb 2015 13:12:39 +0000 (13:12 +0000)]
Fix SDV build

SDV builds are failing with this error:

..\..\src\xenbus\fdo.c(758) : error C2220: warning treated as error - no 'object' file generated
c:\git\xenbus\src\xenbus\fdo.c(744) : warning C6246: Local declaration of 'status' hides declaration of the same name in outer scope. For additional information, see previous declaration at line '675' of 'c:\git\xenbus\src\xenbus\fdo.c'.: Lines: 675

This patch removes the erroneous declaration.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoEVTCHN FIFO ABI should keep per-vcpu queue head shadow
Paul Durrant [Tue, 3 Feb 2015 11:38:33 +0000 (11:38 +0000)]
EVTCHN FIFO ABI should keep per-vcpu queue head shadow

There is currently only one shadow head per priority which means that
polling event channels of the same priority on different CPUs can conflict,
leading to lost events. This patch fixes the problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoSystemVirtualCpuIndex() cannot use KeWaitForSingleObject()
Paul Durrant [Fri, 30 Jan 2015 17:47:20 +0000 (17:47 +0000)]
SystemVirtualCpuIndex() cannot use KeWaitForSingleObject()

The function is called at > DISPATCH_LEVEL so it cannot wait, even with a
zero timeout. Having this call there causes the system to hang.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reported-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
10 years agoRemove use of KeNumberProcessors from SHARED_INFO code
Paul Durrant [Wed, 28 Jan 2015 16:34:22 +0000 (16:34 +0000)]
Remove use of KeNumberProcessors from SHARED_INFO code

KeNumberProcessors is used in the DEBUG callback. Use
KeQueryActiveProcessorCount() instead.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoGet rid of EVTCHN Bind from the STORE code
Paul Durrant [Wed, 28 Jan 2015 16:30:25 +0000 (16:30 +0000)]
Get rid of EVTCHN Bind from the STORE code

Removing the gratuitous Bind means we don't make use of KeNumberProcessors.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove use of KeNumberProcessors from EVTCHN code
Paul Durrant [Wed, 28 Jan 2015 16:27:36 +0000 (16:27 +0000)]
Remove use of KeNumberProcessors from EVTCHN code

The crucial things are the virtual CPUs to which the ABI can steer
interrupts and the number of interrupts which the FDO code successfully
allocated. By using an intersection of these two things we can drop any
use of KeNumberProcessors.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove use of KeNumberProcessors from SYSTEM code
Paul Durrant [Wed, 28 Jan 2015 14:47:31 +0000 (14:47 +0000)]
Remove use of KeNumberProcessors from SYSTEM code

The Xen SYSTEM module queries system information, including per-cpu
information. It is therefore best to make use if processor callback
functions rather than iterating over boot-time active processors, as this
makes the code robust to processors hot-added after boot.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove use of KeNumberProcessors from SYNC code
Paul Durrant [Tue, 27 Jan 2015 18:01:57 +0000 (18:01 +0000)]
Remove use of KeNumberProcessors from SYNC code

KeNumberProcessors is obsolete so replace it with an inital call to
KeQueryActiveProcessorCount() whenever we start a capture operation.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd missing magic number checks
Paul Durrant [Tue, 27 Jan 2015 16:35:19 +0000 (16:35 +0000)]
Add missing magic number checks

We should sanity check the magic number in an event channel whenever one is
passed to an EVTCHN method or when one is recovered from a list.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRe-work EVTCHN Close
Paul Durrant [Tue, 20 Jan 2015 17:39:58 +0000 (17:39 +0000)]
Re-work EVTCHN Close

When using the FIFO ABI, the Close operation needs to be synchronized with
polling. This requires some re-structuring of the close code to defer the
actual closure of the event channel in Xen until at least one poll after
masking and starting the tear-down.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRe-work EVTCHN Trigger
Paul Durrant [Tue, 20 Jan 2015 11:40:39 +0000 (11:40 +0000)]
Re-work EVTCHN Trigger

By re-working the event channel poll callback to add pending channels to a
list and then service them, we can tidy up Trigger by forcibly appending a
channel to the same list and then scheduling a DPC on the correct cpu to
service in the list (unless an interrupt callback came along in the interim
and did the job).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUse a DPC per CPU for EVTCHN Trigger
Paul Durrant [Fri, 16 Jan 2015 15:09:40 +0000 (15:09 +0000)]
Use a DPC per CPU for EVTCHN Trigger

Using a single DPC potentially means re-afinitizing it for each use, and
this potentially means Windows could try to insert it onto multiple CPU
queues at the same time, which probably won't end well. Using a DPC per
CPU seems a lot safer.

Also add a DPC flush before we zero out data structures.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate EVTCHN to version 3
Paul Durrant [Mon, 19 Jan 2015 17:46:33 +0000 (17:46 +0000)]
Update EVTCHN to version 3

Since the Unmask method no longer returns any useful information, make it
void. This means we need to bump the interface version to 3.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoSimplify EVTCHN Unmask
Paul Durrant [Mon, 26 Jan 2015 16:10:31 +0000 (16:10 +0000)]
Simplify EVTCHN Unmask

Just use the hypercall if the event channel is pending. It's a lot safer
than trying to avoid it.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoThe EVTCHN ABI Unmask methods should simply return Pending state
Paul Durrant [Mon, 26 Jan 2015 16:03:40 +0000 (16:03 +0000)]
The EVTCHN ABI Unmask methods should simply return Pending state

The methods should not care whether the current thread is responsible for
clearing the mask.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoEagerly enable and disable interrupts
Paul Durrant [Mon, 19 Jan 2015 09:54:38 +0000 (09:54 +0000)]
Eagerly enable and disable interrupts

There's really no need to lazily enable event channel interrupts. It makes
the code simpler to enable at the end of the first acquire and disable at
the start of the last release.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoGet rid of per-channel interrupt pointer
Paul Durrant [Mon, 19 Jan 2015 16:18:05 +0000 (16:18 +0000)]
Get rid of per-channel interrupt pointer

It's kind of redundant as we have a Cpu index value. Also, remove code that
tries to ensure everything is on the right cpu even across an event channel
re-bind. Since we now always use the hypercall to handle unmasking then we
don't need to care so much.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove unnecessary helper function
Paul Durrant [Fri, 16 Jan 2015 15:00:45 +0000 (15:00 +0000)]
Remove unnecessary helper function

The __EvtchnAcquire/ReleaseInterruptLock functions are only used in one
place. Remove them and call the underlying Fdo functions directly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoEvtchnCallback() does not need to check that the channel is active
Paul Durrant [Tue, 27 Jan 2015 14:42:24 +0000 (14:42 +0000)]
EvtchnCallback() does not need to check that the channel is active

There is no interaction with the ABI that necessitates a check whether the
channel is active.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoEVTCHN Bind method should check that the channel is active
Paul Durrant [Tue, 27 Jan 2015 14:02:18 +0000 (14:02 +0000)]
EVTCHN Bind method should check that the channel is active

Any method which performs ABI operations should check whether the channel is
active.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix EvtchnOpen() error path
Paul Durrant [Tue, 20 Jan 2015 15:11:28 +0000 (15:11 +0000)]
Fix EvtchnOpen() error path

It's possible for an error in the latter stages of EvtchnOpen() to cause the
channel to be left open in Xen. Also the Mask boolean was not being cleared
which would lead to ASSERTion failures in checked builds.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix FIFO ABI Ack and Mask methods
Paul Durrant [Mon, 26 Jan 2015 15:45:04 +0000 (15:45 +0000)]
Fix FIFO ABI Ack and Mask methods

Both methods were using the wrong event word by using the port number as an
offset twice.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd missing barrier
Paul Durrant [Mon, 26 Jan 2015 15:39:54 +0000 (15:39 +0000)]
Add missing barrier

Testing an event word flag should always be preceded by a barrier (unless
using a locked operation).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix type mismatch
Paul Durrant [Mon, 26 Jan 2015 15:48:04 +0000 (15:48 +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>
10 years agoReserve some grant entries for the crash kernel
Paul Durrant [Wed, 14 Jan 2015 09:49:01 +0000 (09:49 +0000)]
Reserve some grant entries for the crash kernel

The xencrsh driver (which is loaded into the crash kernel) needs some grant
entries to write out the dump file. It is important that these entries are
guaranteed to be unused by any backend other than the one the xencrsh uses
so reserve them in the normal grant table.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMove interface subscription code into co-installer
Paul Durrant [Fri, 9 Jan 2015 15:56:59 +0000 (15:56 +0000)]
Move interface subscription code into co-installer

Interface subscription is better handled at package installation time and
therefore the co-installer is the right place for it to live.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoReflect interface versions in PDO description
Paul Durrant [Fri, 9 Jan 2015 13:42:57 +0000 (13:42 +0000)]
Reflect interface versions in PDO description

For convenience add a string containing the latest versions of all the
interfaces exported by the driver into the PDO description. This can be
seen in Device Manager as the 'Bus reported device description' detail.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMake sure INF gets re-built each time
Paul Durrant [Fri, 19 Dec 2014 15:38:08 +0000 (15:38 +0000)]
Make sure INF gets re-built each time

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMake sure version header gets re-built each time
Paul Durrant [Fri, 19 Dec 2014 11:57:58 +0000 (11:57 +0000)]
Make sure version header gets re-built each time

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMap Local APIC IDs to Processor IDs through the MADT
Paul Durrant [Thu, 18 Dec 2014 17:18:48 +0000 (17:18 +0000)]
Map Local APIC IDs to Processor IDs through the MADT

To use the FIFO EVTCHN ABI the frontend code needs to know the vcpu id of
the guest CPUs. This mapping is currently done by taking the the CPU local
APIC ID and dividing by 2. This currently works on most Xen installations
but Matt Wilson advises that this will not work on AWS.
This patch introduces code to map and parse the ACPI RSDP, XSDT and MADT
(APIC) tables such that the local APIC substructures present in the latter
can be used to map local APIC ID to processor ID (which is identical to
vcpu id).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Cc: Matt Wilson <msw@linux.com>
10 years agoRemove extraneous parameter
Paul Durrant [Tue, 16 Dec 2014 14:40:43 +0000 (14:40 +0000)]
Remove extraneous parameter

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix free-at-wrong-IRQL bug
Paul Durrant [Tue, 16 Dec 2014 11:07:00 +0000 (11:07 +0000)]
Fix free-at-wrong-IRQL bug

The hash table code introduced for the FIFO EVTCHN ABI work tries to free
memory at HIGH IRQL. This causes a bugcheck when verifier is turned on. This
patch re-orders the unlock (which drops IRQL back to DISPATCH) and the free.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix 0xD6 bugcheck found with verifier
Paul Durrant [Mon, 15 Dec 2014 14:07:20 +0000 (14:07 +0000)]
Fix 0xD6 bugcheck found with verifier

PdoAddRevision() reads beyond the end of an allocation when copying the old
revision table to the new one. This is becaause it is incorrectly using the
Count stack variable rather then the Count field in the Pdo structure. This
patch fixes the problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRevert script pollution that was accidentally pushed
Paul Durrant [Wed, 10 Dec 2014 16:21:15 +0000 (16:21 +0000)]
Revert script pollution that was accidentally pushed

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd missing function type
Paul Durrant [Wed, 10 Dec 2014 16:10:04 +0000 (16:10 +0000)]
Add missing function type

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd registry setting for removable capability of PDOs
Owen Smith [Fri, 28 Nov 2014 13:36:34 +0000 (13:36 +0000)]
Add registry setting for removable capability of PDOs

Setting "Removable" to 0 under the key
HKLM/System/CurrentControlSet/services/XENBUS/Parameters/<PDO-Name>
will disable the PDOs removable and surprise removable capability.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix some SDV issues
Paul Durrant [Fri, 28 Nov 2014 17:36:27 +0000 (17:36 +0000)]
Fix some SDV issues

Fix issues where variables were redefined inside a code block (by getting
rid of those variables)

Suggested-by: Owen Smith <owen.smith@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAvoid making hypercalls in the SyncWorker DPC
Paul Durrant [Thu, 20 Nov 2014 15:56:32 +0000 (15:56 +0000)]
Avoid making hypercalls in the SyncWorker DPC

The code has to run with interrupts disabled on all CPUs apart from 0 to
corale them across a suspend/resume. Making hypercalls from within that
code is thus incompatible with re-populating the hypercall table on resume
since it transpites then Xen writes each byte in the page to 0xcc (int 3)
before actually setting up the hypercall thunks. The only hypercall that the
code was actually making was a SCHEDOP_yield and this is trivially replaced
by an _mm_pause intrinsic which calls through to SCHEDOP_yield in the
VMEXIT handler.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix ASSERTion failure in EVTCHN Close
Paul Durrant [Wed, 12 Nov 2014 15:02:46 +0000 (15:02 +0000)]
Fix ASSERTion failure in EVTCHN Close

The EVTCHN Channel structure contains a BOOLEAN Mask field that specifies
whether the Channel is aut0-masked on event upcall. The Close method was
failing to zero then and then falling over a later assertion that the
Channel structure had been zeroed out.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUse EVTCHNOP_unmask to unmask in some cases
Paul Durrant [Tue, 11 Nov 2014 13:33:48 +0000 (13:33 +0000)]
Use EVTCHNOP_unmask to unmask in some cases

If the EVTCHN Unmask method is called in context of the event channel
upcall, or on a CPU to which the event is not bound then use the unmask
hypercall. In the former case not doing this may lead to priorty
inversion once setting event channel priorities is enabled. In the latter
case not doing it again stops a lower priority event handler trigger from
blocking a higher priority event injection.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUse per-CPU event channel upcalls if available
Paul Durrant [Thu, 6 Nov 2014 12:44:26 +0000 (12:44 +0000)]
Use per-CPU event channel upcalls if available

A recent patch to Xen introduced a new HVM op to set a per-vcpu event
channel upcall. This patch adds code to make use of the latched interrupts
allocated by the FDO code to enable per-vcpu upcalls and adds an extra
EvtchnBind operation to a new v2 EVTCHN interface so that events can be
steered to a specified CPU.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate Xen headers to master (4.5-rc0 + HVMOP_set_evtchn_upcall_vector)
Paul Durrant [Thu, 6 Nov 2014 10:38:44 +0000 (10:38 +0000)]
Update Xen headers to master (4.5-rc0 + HVMOP_set_evtchn_upcall_vector)

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRe-work interrupt code in FDO
Paul Durrant [Thu, 6 Nov 2014 10:30:58 +0000 (10:30 +0000)]
Re-work interrupt code in FDO

This patch adds code to the FDO handler to acquire extra message signaled
(i.e. edge triggered) interrupt vectors that can be used for per-CPU event
channel upcalls (with extra support in Xen).
The existing callback via is also limited to upcall on CPU 0 meaning the
interrupt callback in the EVTCHN code can pass the current CPU value through
to the ABI.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRe-populate hypercall page on resume from suspend/hibernate
Paul Durrant [Wed, 5 Nov 2014 18:00:12 +0000 (18:00 +0000)]
Re-populate hypercall page on resume from suspend/hibernate

Doing this has the side effect of latching the shared info page width,
which is currently done when the callback via is set. When we move to a
per-cpu event channel upcall then this side effect will be lost, so
doing this makes sure that the shared info is still of the correct width.

Additionally in this patch the reporting of the Xen version is improved
by using the XENVER hypercalls to get major, minor and extra version
informattion. As part of that change, more headers have been copied in
from Xen.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove needless checks on ParametersKey validity
Paul Durrant [Fri, 7 Nov 2014 12:40:16 +0000 (12:40 +0000)]
Remove needless checks on ParametersKey validity

It used to be the case that XENBUS would tolerate a lack of Parameters key
in its Service key but that has not been true for some time, so remove
validity checks that are no longer needed.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd registry override for EVTCHN ABI
Paul Durrant [Fri, 7 Nov 2014 10:56:32 +0000 (10:56 +0000)]
Add registry override for EVTCHN ABI

Add a registry parameter DWORD:UseEvtchnFifoAbi than can be set to zero
to prevent use of the FIFO ABI or non-zero to allow it. The default value is
non-zero.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate EVTCHN FIFO ABI
Paul Durrant [Fri, 7 Nov 2014 15:03:44 +0000 (15:03 +0000)]
Update EVTCHN FIFO ABI

This patch is in response to review comments by David Vrabel.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd support for the FIFO event channel ABI
Paul Durrant [Wed, 5 Nov 2014 17:38:32 +0000 (17:38 +0000)]
Add support for the FIFO event channel ABI

If it is available then the fifo ABI will be used. If it is not then the
two-level ABI will be used instead.
The ABI is released and re-acquired across suspend/resume so this should
allow moving between hosts with different capabilities.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate Xen headers to RELEASE-4.4.1
Paul Durrant [Wed, 5 Nov 2014 17:21:53 +0000 (17:21 +0000)]
Update Xen headers to RELEASE-4.4.1

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix type mis-definition in EVTCHN interface
Paul Durrant [Wed, 5 Nov 2014 17:07:16 +0000 (17:07 +0000)]
Fix type mis-definition in EVTCHN interface

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoSeparate event channel ABI from core evtchn interface code
Paul Durrant [Wed, 5 Nov 2014 17:04:16 +0000 (17:04 +0000)]
Separate event channel ABI from core evtchn interface code

The event channel ABI now known as two-level is implemented using the
domain shared info. Use of the SHARED_INFO interface is therefore baked
into the EVTCHN interface.
Xen has recently acquired a new event channel ABI called fifo, which
improves on both scalability and performance as compared to two-level.
Hence this patch separates the ABI code from the core EVTCHN interface
code so that a subsequent patch can add support for the fifo ABI on
capable versions of Xen.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMake auto-masking a generic event channel property
Paul Durrant [Wed, 5 Nov 2014 16:31:03 +0000 (16:31 +0000)]
Make auto-masking a generic event channel property

Keeping the Mask boolean in the per-type event channel parameters makes the
code needlessly complex in several places. Just make it a generic property.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUse a hash table for event channel lookup
Paul Durrant [Wed, 5 Nov 2014 15:50:10 +0000 (15:50 +0000)]
Use a hash table for event channel lookup

Rather than using a large array for mapping port values to channel
structures, use a hash table. This means we no longer need to code a
hard port number limit into the EVTCHN implementation.

Because the hash table implementation manages its own locking, we also no
longer need to make such liberal use of the interrupt lock in the EVTCHN
implementation and can use the spinlock instead.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoSeparate checking upcall_pending in shared info from EvtchnPoll
Paul Durrant [Tue, 28 Oct 2014 10:23:25 +0000 (10:23 +0000)]
Separate checking upcall_pending in shared info from EvtchnPoll

The current EvtchnPoll routine in in the shared info code is tied to
the two level event channel ABI, wheras checking upcall_pending is ABI
independent. Hence the check should be separated into its own method.

This patch therefore introduces version 2 of the SHARED_INFO interface,
which has a new EvtchnUpcallPending method. Version 1 is still
supported by having its EvtchnPoll variant call EvtchnUpcallPending
method internally.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUse InterlockedBitTestAnd[Set|Reset] in SHARED_INFO
Paul Durrant [Tue, 28 Oct 2014 09:13:44 +0000 (09:13 +0000)]
Use InterlockedBitTestAnd[Set|Reset] in SHARED_INFO

Rather then using InterlockedCompareAndExchange to set and clear bits
in the SHARED_INFO event channel masks, use
InterlockedBitTestAnd[Set|Reset] as these will resolve to instrinsics
when available.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix bug in EVTCHN interrupt enabling
Paul Durrant [Thu, 6 Nov 2014 12:53:23 +0000 (12:53 +0000)]
Fix bug in EVTCHN interrupt enabling

The code in EvtchnOpen attempts to enable interrupts on demand when new
channels are added to a list. However there is a bug in the logic that
means interrupts will not be enabled until the second channel is opened.
This patch fixes the bug.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoWhitespace fix
Paul Durrant [Wed, 5 Nov 2014 17:08:13 +0000 (17:08 +0000)]
Whitespace fix

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix heap corruption in co-installer
Paul Durrant [Tue, 7 Oct 2014 14:55:49 +0000 (15:55 +0100)]
Fix heap corruption in co-installer

The co-installer was corrupting its heap by trying to free a pointer after
incrementing it from its original value.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd missing acquisition of the UNPLUG interface
Paul Durrant [Mon, 6 Oct 2014 16:37:16 +0000 (17:37 +0100)]
Add missing acquisition of the UNPLUG interface

Commit cba6dad2df306885dfc65908f14ce6e2d8a86211 changed the way that
emulated devices are unplugged. It used to be that XENFILT waited until it
detected the presence of the 'active' device that XENBUS bound to before
deciding whether to unplug, but that commit simply made sure that the
'active' device always appears unless something has drastically changed in
the VM configuration. Unfortunately, in making that change, the code that
acquired the initial reference to the unplug interface - and thereby caused
emulated devices to be unplugged - was lost. This patch adds in the missing
acquisition.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoReduce spam from build.py
Paul Durrant [Thu, 25 Sep 2014 14:08:41 +0000 (15:08 +0100)]
Reduce spam from build.py

We don't the verbose prints when deciding whether we're using vs2012 or 2013.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoDon't use universal_newlines=True in subprocess.Popen()
Paul Durrant [Thu, 25 Sep 2014 14:06:31 +0000 (15:06 +0100)]
Don't use universal_newlines=True in subprocess.Popen()

For some versions of python this appears to cause corruption of the
output byte string by forcibly decoding with the wrong encoding.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate active device's instance id at point of PDO filter creation
Paul Durrant [Fri, 5 Sep 2014 16:58:51 +0000 (17:58 +0100)]
Update active device's instance id at point of PDO filter creation

It's tidier to have xenfilt simply return its own versions of device and
instance id when it intercepts IRP_MN_QUERY_ID. The override of the instance
id can be done and logged once when the PDO filter device object is created.
This patch does that, and also replaces the rather vacuuous Name field in
the filter device object extensions with DeviceID and InstanceID fields.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoImprove the generated documentation
Paul Durrant [Thu, 4 Sep 2014 15:21:46 +0000 (16:21 +0100)]
Improve the generated documentation

Create a frontpage and interfaces group, and then make sure the
interface data structures are included in the group.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate README and INSTALL and add a separate BUILD
Paul Durrant [Thu, 4 Sep 2014 14:23:39 +0000 (15:23 +0100)]
Update README and INSTALL and add a separate BUILD

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoSquash changes in active platform device instance id
Paul Durrant [Wed, 3 Sep 2014 16:23:41 +0000 (17:23 +0100)]
Squash changes in active platform device instance id

If the instance id of the platform device changes then Windows will need
to rebind the xenbus driver. This means that if the system disk is hanging
off a child of xenbus then we get a 0x7B BSOD before the rebind (which is
done in user space) can occur.
This patch makes sure that the instance id of the platform device remains
invariant after initial driver installation.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoAdd support for Visual Studio 2013 & WDK 8.1
Ben Chalmers [Fri, 15 Aug 2014 14:47:14 +0000 (15:47 +0100)]
Add support for Visual Studio 2013 & WDK 8.1

Signed-off-by: Ben Chalmers <ben.chalmers@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRevise API versioning text in README.md
Paul Durrant [Thu, 14 Aug 2014 14:19:35 +0000 (15:19 +0100)]
Revise API versioning text in README.md

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove another erroneous XenServer reference
Paul Durrant [Thu, 14 Aug 2014 10:30:09 +0000 (11:30 +0100)]
Remove another erroneous XenServer reference

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoFix copyrights in RC files
Paul Durrant [Thu, 14 Aug 2014 09:45:00 +0000 (10:45 +0100)]
Fix copyrights in RC files

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoUpdate branding
Paul Durrant [Wed, 13 Aug 2014 14:26:15 +0000 (15:26 +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>
10 years agoImplement new API version scheme
Paul Durrant [Thu, 24 Jul 2014 08:01:23 +0000 (09:01 +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>
10 years agoFix assertion failure
Paul Durrant [Tue, 29 Jul 2014 14:30:08 +0000 (15:30 +0100)]
Fix assertion failure

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years ago[CA-137823] Use interlocked calls when expanding grant tables.
Owen Smith [Thu, 12 Jun 2014 10:43:15 +0000 (11:43 +0100)]
[CA-137823] Use interlocked calls when expanding grant tables.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
10 years agoReplace DPC per cache with single DPC for all caches.
Owen Smith [Fri, 6 Jun 2014 09:21:13 +0000 (10:21 +0100)]
Replace DPC per cache with single DPC for all caches.
Iterate through list of caches during DPC

Signed-off-by: Owen Smith <owen.smith@citrix.com>
10 years agoMerge pull request #30 from pauldu/gnttab
Owen Smith [Mon, 2 Jun 2014 13:10:56 +0000 (14:10 +0100)]
Merge pull request #30 from pauldu/gnttab

Updated GNTTAB interface

10 years agoModify GNTTAB interface to support caches
Paul Durrant [Fri, 30 May 2014 08:54:38 +0000 (09:54 +0100)]
Modify GNTTAB interface to support caches

Remove the Get/Set methods and replace with CreateCache/DestroyCache methods.
The PermitForeignAccess method the uses a cache to allocate an entry as it
requires. Also, as we're not only using grant table v1, we can get rid of
the idea of different types of permit and drop the use of varargs.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRemove much code duplication involved in interface query
Paul Durrant [Thu, 29 May 2014 13:24:50 +0000 (14:24 +0100)]
Remove much code duplication involved in interface query

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoExport CACHE interface to child drivers
Paul Durrant [Thu, 29 May 2014 12:51:54 +0000 (13:51 +0100)]
Export CACHE interface to child drivers

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoIntroduce the CACHE interface
Paul Durrant [Thu, 29 May 2014 12:38:33 +0000 (13:38 +0100)]
Introduce the CACHE interface

Morph the existing cache code into a first class interface and make GNTTAB
the first client.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoRename Pool* to Cache*
Paul Durrant [Thu, 29 May 2014 09:50:58 +0000 (10:50 +0100)]
Rename Pool* to Cache*

No functional change. Just largely mechanical textual substitution.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMerge pull request #28 from pauldu/ca-136429
Paul Durrant [Wed, 28 May 2014 12:40:07 +0000 (13:40 +0100)]
Merge pull request #28 from pauldu/ca-136429

Tighten up rangeset auditing and add separate counts for items and range...

10 years agoTighten up rangeset auditing and add separate counts for items and ranges
Paul Durrant [Wed, 28 May 2014 12:29:51 +0000 (13:29 +0100)]
Tighten up rangeset auditing and add separate counts for items and ranges

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMerge pull request #27 from OwenSmith/master
Paul Durrant [Wed, 28 May 2014 12:28:09 +0000 (13:28 +0100)]
Merge pull request #27 from OwenSmith/master

Fix 0xC4 BSOD from Pool code.

10 years agoFix 0xC4 BSOD from Pool code.
Owen Smith [Wed, 28 May 2014 10:40:45 +0000 (11:40 +0100)]
Fix 0xC4 BSOD from Pool code.
__PoolTrimShared would not trim any pool allocations

Signed-off-by: Owen Smith <owen.smith@citrix.com>
10 years agoIt's not necessarily safe to access interfaces when device is not in D0
Paul Durrant [Fri, 23 May 2014 15:10:12 +0000 (16:10 +0100)]
It's not necessarily safe to access interfaces when device is not in D0

The Scan, Suspend and Balloon threads should not try to access interfaces
such as STORE when the device is not in D0 as the interfaces are not there
if the system is at S4 or higher.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoMerge pull request #26 from pauldu/ca-135281
Ben Chalmers [Wed, 21 May 2014 15:53:15 +0000 (16:53 +0100)]
Merge pull request #26 from pauldu/ca-135281

CA-135281

Approved-By: Ben.Chalmers@citrix.com
10 years agoMerge pull request #25 from pauldu/master
Ben Chalmers [Wed, 21 May 2014 15:48:25 +0000 (16:48 +0100)]
Merge pull request #25 from pauldu/master

Add a minimum reservation feature to the pool code and use it in GNTTAB

Approved-By: Ben.Chalmers@citrix.com
10 years agoMake ballooning and suspending mutually exclusive operations
Paul Durrant [Wed, 21 May 2014 08:45:29 +0000 (09:45 +0100)]
Make ballooning and suspending mutually exclusive operations

10 years agoMerge branch 'master' of github.com:xenserver/win-xenbus
Paul Durrant [Wed, 21 May 2014 08:45:29 +0000 (09:45 +0100)]
Merge branch 'master' of github.com:xenserver/win-xenbus

11 years agoAdd a minimum reservation feature to the pool code and use it in GNTTAB
Paul Durrant [Thu, 1 May 2014 14:24:23 +0000 (15:24 +0100)]
Add a minimum reservation feature to the pool code and use it in GNTTAB

The grant table reservation is set to 32.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
11 years agoMerge pull request #24 from pauldu/master
Ben Chalmers [Thu, 1 May 2014 08:26:59 +0000 (09:26 +0100)]
Merge pull request #24 from pauldu/master

Re-try AuxKlibQueryModuleInformation() if buffer was too small

Approved-By: Ben Chalmers <Ben.Chalmers@citrix.com>
11 years agoRe-try AuxKlibQueryModuleInformation() if buffer was too small
Paul Durrant [Thu, 1 May 2014 08:21:51 +0000 (09:21 +0100)]
Re-try AuxKlibQueryModuleInformation() if buffer was too small

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
11 years agoMerge pull request #23 from pauldu/ca-134511
Paul Durrant [Wed, 30 Apr 2014 11:32:03 +0000 (12:32 +0100)]
Merge pull request #23 from pauldu/ca-134511

CA-134511

11 years agoAdd magic number and bounds checking...
Paul Durrant [Wed, 30 Apr 2014 11:06:24 +0000 (12:06 +0100)]
Add magic number and bounds checking...

... for event channel and grant table descriptors.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
11 years agoFix RangeSet cursor problem
Paul Durrant [Wed, 30 Apr 2014 10:47:01 +0000 (11:47 +0100)]
Fix RangeSet cursor problem

When the last or first range in the set is removed then the cursor may end
up pointing back at the anchor point. This confused RangeSetPop() so we
need to make sure that the cursor wraps round when this happens, such that
the only valid reason for the cursor to ever point at the anchor is when
the set goes empty.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
11 years agoMerge pull request #22 from pauldu/fist
Ben Chalmers [Tue, 29 Apr 2014 15:56:59 +0000 (16:56 +0100)]
Merge pull request #22 from pauldu/fist

FIST

Approved-By: Ben Chalmers <Ben.Chalmers@citrix.com>
11 years agoMerge branch 'master' of github.com:xenserver/win-xenbus
Paul Durrant [Tue, 29 Apr 2014 14:50:18 +0000 (15:50 +0100)]
Merge branch 'master' of github.com:xenserver/win-xenbus

11 years agoAdd FIST capability for pools
Paul Durrant [Tue, 29 Apr 2014 14:46:17 +0000 (15:46 +0100)]
Add FIST capability for pools

By setting xenstore parameters 'fist/pool/<name>/defer' to X and
'fist/pool/<name>/probability' to Y you can now cause failures of PoolGet()
such that it will fail with probability Y% after X initial invocations.
The name of the grant table pool has been set to 'gnttab' to make typing it
in more convenients, and some debug-keys output has been added to give
the PoolGet() failure count.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>