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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Paul Durrant [Tue, 29 Apr 2014 10:03:48 +0000 (11:03 +0100)]
RangeSet fixes
- add spinlock to protect rangesets.
- add a Count value to check against empty condition in audit.
- use LONGLONG in ranges rather than ULONGLONG so that ranges can be
invalidated by setting Start > End.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Ben Chalmers [Fri, 25 Apr 2014 14:15:27 +0000 (15:15 +0100)]
[SCTX-1104] Add WindowsPEMode to xenfilt
ParentIdPrefixes are not avilable at Windows PE driver filtering time,
but we don't actually need them if we know emulated devices will be
unplugged, so, if ParentIdPrefix can't be read from the registry and
HKLM\System\CurrentControlSet\Services\xenfilt\WindowsPEMode is set to 1
then just set the prefix to be an empty string and continue
We never set WindowsPEMode anywhere except in the sample Windows PE
scripts, so non-WindowsPE environments are unaffected
Signed-off-by: Ben Chalmers <Ben.Chalmers@citrix.com>
Paul Durrant [Wed, 23 Apr 2014 09:04:59 +0000 (10:04 +0100)]
Various fixes in improvements to the XEX.SYS System module
- Improved error handling. Various errors were ignored before.
- Moved several globals inside scope of __SystemGetCpuInformation since
that's the only place they are used.
- Added a call to free memory range information. It was leaked before.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 23 Apr 2014 09:26:42 +0000 (10:26 +0100)]
Better way to ignore assertions in free builds
Disabling warnings is not a great thing to do so define an inline function
to take the assertion expression as an argument and then declare its
argument to be ignored.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Wed, 23 Apr 2014 09:00:48 +0000 (10:00 +0100)]
Fix bug in RangeSetGet()
If RangeSetGet() was invoked when the cursor just happened to be pointing at
the correct singleton range than that range was not removed and an ASSERT was
hit. This patch fixes that problem.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 11 Apr 2014 10:09:20 +0000 (11:09 +0100)]
Re-worked GNTTAB.
The new version of the interface no longer exposes raw references to clients.
They are now behind an opaque XENVIF_GNTTAB_DESCRIPTOR, analogous to the
XENVIF_EVTCHN_DESCRIPTOR which hides raw ports from clients.
The allocator is also more sophisticated. It uses a pool with per-cpu
magazines for lockless access backed by rangesets.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 1 Nov 2013 09:21:42 +0000 (10:21 +0100)]
Enable and disable callback via at source rather than
trying to keep a local disabled flag for the interrupt.
If we don't do this we can get into a interrupt storm on
startup.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 31 Oct 2013 15:37:42 +0000 (16:37 +0100)]
Enable and disable callback via at source rather than
trying to keep a local disabled flag for the interrupt.
If we don't do this we can get into a interrupt storm on
startup.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 4 Oct 2013 10:54:11 +0000 (11:54 +0100)]
Keep track of ActiveDevice rather than ActiveDeviceInstance. If we include
the instance then any change in the PCI bus can cause the PV drivers to
become inactive.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>