Ian Campbell [Fri, 22 Oct 2010 14:14:51 +0000 (15:14 +0100)]
python acm: use hypercall buffer interface.
I have a suspicion these routines should be using libxc rather than
reimplementing all the hypercalls again, but I don't have the
enthusiasm to fix it.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
Keir Fraser [Sun, 24 Oct 2010 12:15:06 +0000 (13:15 +0100)]
x86/kexec: fix very old regression and make compatible with modern Linux
c/s 13829 lost the (32-bit only) cpu_has_pae argument passed to the
primary kernel's stub (in the 32-bit Xen case only), and Linux
2.6.27/.30 (32-/64-bit) introduced a new argument (for KEXEC_JUMP)
which for now simply gets passed a hardcoded value.
Keir Fraser [Sun, 24 Oct 2010 12:13:04 +0000 (13:13 +0100)]
Allow max_pages to be set to less than tot_pages
The memory allocation code sometimes needs to enforce that a guest
that's been told to balloon down isn't going to expand further
(because it's still executing a previous balloon-up operation). That
means being able to set the desired max_pages even before the balloon
driver has brought tot_pages down to the right level.
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Sun, 24 Oct 2010 12:09:50 +0000 (13:09 +0100)]
cpupools: Make interface more consistent
The current cpupools code interface is a bit inconsistent. This
patch addresses this by making the interaction for each
vcpu in a pool look like this:
alloc_vdata() -- allocates and sets up vcpu data
insert_vcpu() -- the vcpu is ready to run in this pool
remove_vcpu() -- take the vcpu out of the pool
free_vdata() -- delete allocated vcpu data
(Previously, remove_vcpu and free_vdata were combined into a "destroy
vcpu", and insert_vcpu was only called for idle vcpus.)
This also addresses a bug in credit2 which was caused by a
misunderstanding of the cpupools interface.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Ian Campbell [Thu, 21 Oct 2010 17:46:32 +0000 (18:46 +0100)]
tools: cleanup domain save switch_qemu_logdirty callback
Move the function into struct save_callbacks with the others and add
the void *closure to the callback arguments.
Add and propagate an error return code from the callback.
Use this in libxl to pass the save context to
libxl__domain_suspend_common_switch_qemu_logdirty allowing us to reuse
the parent's xenstore handle, gc context etc.
Also add an apparently missing libxl__free_all to
libxl__domain_suspend_common.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Juergen Gross [Thu, 21 Oct 2010 17:36:22 +0000 (18:36 +0100)]
tools: cpupools: xl: commands and library changes
Support of cpu pools in libxl and xl:
library functions
xl cpupool-create
xl cpupool-list
xl cpupool-destroy
xl cpupool-cpu-add
xl cpupool-cpu-remove
xl cpupool-migrate
Renamed all cpu pool related names to *cpupool*
Signed-off-by: juergen.gross@ts.fujitsu.com Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Juergen Gross [Thu, 21 Oct 2010 17:32:56 +0000 (18:32 +0100)]
tools: cpupools: Support arbitrary numbers of physical cpus
To be able to support arbitrary numbers of physical cpus it was necessary to
include the size of cpumaps in the xc-interfaces for cpu pools.
These were:
definition of xc_cpupoolinfo_t
xc_cpupool_getinfo()
xc_cpupool_freeinfo()
xc_cpupool_getinfo() and xc_cpupool_freeinfo() are changed to allocate the
needed buffer and return it.
Signed-off-by: juergen.gross@ts.fujitsu.com Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Wed, 20 Oct 2010 08:56:36 +0000 (09:56 +0100)]
x86 hvm: Improve test for wait-for-SIPI state of a target VLAPIC.
This fixes a livelock in hvmloader with credit2 scheduler, whereby an
AP can be brought online, do its work, and shut itself down, before
the BSP re-emulates the VLAPIC write that sent the SIPI. BSP then ends
up in an endless re-emulation work where it sees the target vcpu is
down, therefore schedules a tasklet, which does no work because the
vcpu is already initialised. The fix is to check v->is_initialised
rather than VPF_down, before scheduling the tasklet.
Keir Fraser [Wed, 20 Oct 2010 07:41:58 +0000 (08:41 +0100)]
svm: Re-enable 2MB super paging
Bitwise OR operator has higher precedence than conditional
operator. This patch fixes the incorrect associativity and re-enables
2MB paging for AMD family 10h system.
Signed-off-by: Wei Wang <wei.wang2@amd.com> Acked-by: Wei Huang <wei.huang2@amd.com>
Keir Fraser [Wed, 20 Oct 2010 07:40:44 +0000 (08:40 +0100)]
msi: Mask out multi-function flag from PCI_HEADER_TYPE in read_pci_mem_bar()
This leads to an erroneous WARN_ON and possibly other side effects. It
seems to me that even multi-function devices ought to enjoy the
privilege of MSI-X capabilities.
Ian Campbell [Mon, 18 Oct 2010 16:40:08 +0000 (17:40 +0100)]
libxc: use generic xc_get_pfn_list on ia64
The ia64 specific xc_get_pfn_list doesn't seem any different to the
generic xc_get_pfn_list once the call to xc_ia64_get_pfn_list is
expanded so remove and just use the generic one.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Mon, 18 Oct 2010 16:39:44 +0000 (17:39 +0100)]
libxc: do not lock VCPU context in xc_ia64_pv_recv_vcpu_context
xc_ia64_pv_recv_vcpu_context does not need to lock the ctxt buffer
since it calls xc_ia64_recv_vcpu_context which calls
xc_vcpu_setcontext which takes care of any necessary bouncing.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Mon, 18 Oct 2010 16:38:15 +0000 (17:38 +0100)]
libxc: drop xc_get_max_pages
The function isn't really ia64 specific but since the result isn't
actually used in the only caller and the same info is available via
xc_domain_getinfo simply drop the function.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Mon, 18 Oct 2010 16:35:59 +0000 (17:35 +0100)]
libxc: make xc_memory_op library private
Now that all XENMEM_* callers go via an op specific function make
xc_memory_op private to libxc (and rename to do_memory_op for
consistency with other private functions).
Also change the interface to take a size parameter so that
do_memory_op knows how much memory to lock for the top-level argument,
removing some of the introspection.
[ Compatibility note: this breaks qemu-xen before 706bc8c588cb ]
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Mon, 18 Oct 2010 15:54:42 +0000 (16:54 +0100)]
libxc: wrappers for XENMEM {increase,decrease}_reservation and populate_physmap
Currently the wrappers for these hypercalls swallow partial success
and return failure to the caller.
In order to use these functions more widely instead of open-coding
uses of XENMEM_* and xc_memory_op add variants which return the actual
hypercall result.
Therefore add the following functions:
xc_domain_increase_reservation
xc_domain_decrease_reservation
xc_domain_populate_physmap
and implement the existing semantics using these new functions as
xc_domain_increase_reservation_exact
xc_domain_decrease_reservation_exact
xc_domain_populate_physmap_exact
replacing the existing xc_domain_memory_* functions.
Use these new functions to replace all open coded uses of
XENMEM_increase_reservation, XENMEM_decrease_reservation and
XENMEM_populate_physmap.
Also rename xc_domain_memory_*_pod_target to xc_domain_*_pod_target
for consistency.
Temporarily add a compatibility macro for
xc_domain_memory_populate_physmap to allow time for qemu to catch up.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Mon, 18 Oct 2010 15:43:58 +0000 (16:43 +0100)]
libxc: pass an xc_interface handle to page locking functions
Not actually used here but useful to confirm that a handle is passed
down to each location where it will be required once we switch to
hypercall buffers.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Mon, 18 Oct 2010 10:30:10 +0000 (11:30 +0100)]
x86 guest pagetable walker: check for invalid bits in pagetable
entries.
Some bits are reserved in x86 pagetable entries and must be zero; the
MMU should raise a pagefault if it sees them, with bit 3 set in the
error code. Xen's software pagetable walker hasn't been doing this,
which has been OK because no guest OSes actually have invalid bits set
except in error cases where things are already very wrong.
Xen's shadow pagetable code deliberately sets these bits as part of
the not-present-entry fast path, so if we're to support
shadow-on-shadow nested HVM, we need to start checking them.
Signed-off-by: Tim Deeegan <Tim.Deegan@citrix.com>
Ian Campbell [Wed, 13 Oct 2010 11:01:30 +0000 (12:01 +0100)]
xl: audit allocation of strings within libxl_device_*
* Remove string literals from init_*_info.
* Free any existing string values before overwriting during device
option parsing.
* Free libxl_device_console after use.
Ian Campbell [Wed, 13 Oct 2010 10:37:02 +0000 (11:37 +0100)]
xl: correct migration_domname_r
22154:ed8019e672c6 causes migration_domname_r to be initialised as
d_config.c_info.name + "--incoming" immediately after setting
d_config.c_info.name. The intention appears to have been to set it to
common_domname + "--incoming" so do so.
Stephan Peijnik [Mon, 11 Oct 2010 16:54:53 +0000 (17:54 +0100)]
Replace pyxml/xmlproc-based XML validator with lxml based one
Pyxml/xmlproc is being used in tools/xen/xm/xenapi_create.py but is
unmaintained for several years now. xmlproc is used only for validating
XML documents against a DTD file.
This patch replaces the pyxml/xmlproc based XML validation with code
based on lxml, which is actively maintained.
Keir Fraser [Mon, 11 Oct 2010 08:02:36 +0000 (09:02 +0100)]
x86-64: workaround for BIOSes wrongly enabling LAHF_LM feature indicator
This workaround is taken from Linux, and the main motivation (besides
such workarounds indeed belonging in the hypervisor rather than each
kernel) is to suppress the warnings in the Xen log each Linux guest
would cause due to the disallowed wrmsr.
Gianni Tedesco [Wed, 6 Oct 2010 16:38:15 +0000 (17:38 +0100)]
xl: Implement PCI passthrough force removal
This fixes two errors with removing PCI devices from HVM domains. The
first error is that the handling of "pci-rem" device-model command is
erroneously implemented in qemu and difficult (impossible?) to get
right.
For example, during domain shutdown there can be a race where the guest
OS unloads it's drivers and perhaps even shuts down PCI subsystem before
the pci-rem command has been received by qemu. This means that no OS is
present to write to the port which causes the dm command to be
acknowledged.
We fix this by implementing a 'force removal' option to
libxl_device_pci_remove which is always set to 1 during guest shutdown.
It can be optionally enabled on the xl command line for other occasions.
The second error is that if a guest OS doesn't respond to the SCI
interrupt and therefore the pci-rem dm command, which can happen if the
guest OS has no ACPI PCI hotplug support, then device removal bails with
an error but only AFTER removing the device from xenstore. This means
that xenstore gets in to an inconsistent state where an assigned device
also appears to be assignable.
This is fixed by moving xenstore device removal to occur only after the
device has really been removed.
Ian Campbell [Tue, 5 Oct 2010 16:51:28 +0000 (17:51 +0100)]
libxl: remove console 0 backend directory from xenstore on devices destroy
The first PV console device has an unusual frontend path for
historical reasons (/local/domain/<domid>/console rather than
/local/domain/<domid>/device/console/0).
Therefore we need to check this additional frontend path as well as
those under /local/domain/<domid>/device when tearing down all
backends or else we miss the backend for the console.
As part of this we need to ensure that the frontend directory has a
valid link to the backend, currently this link does not exist.
Fix this by adding libxl__device_frontend_path to return the correct
frontend path, accounting for the special case, and use it from
libxl__device_add_generic. Also add libxl__device_backend_path for
consistency.
This also allows console 0 setup to follow essentially the same code
path as other consoles within libxl_device_console_add, reducing the
special casing required there.
This also fixes the link from backend to frontend which until now gave
a dangling link to the normal device path instead of the exceptional
one.
Keir Fraser [Sat, 2 Oct 2010 14:05:50 +0000 (15:05 +0100)]
x86 shadow: reset up-pointers on all l3s when l3s stop being pinnable.
Walking the pinned-shadows list isn't enough: there could be an
unpinned (but still shadowed) l3 somewhere and if we later try to
unshadow it it'll have an up-pointer of PAGE_LIST_NULL:PAGE_LIST_NULL.
Keir Fraser [Sat, 2 Oct 2010 14:04:21 +0000 (15:04 +0100)]
Vt-d: fix dom0 graphics problem on Levnovo T410.
The patch is derived from a similar quirk in Linux kernel by David
Woodhouse and Adam Jackson. It checks for VT enabling bit in IGD GGC
register. If VT is not enabled correctly in the IGD, Xen does not
enable VT-d translation for IGD VT-d engine. In case where iommu boot
parameter is set to force, Xen calls panic().
Keir Fraser [Sat, 2 Oct 2010 14:03:15 +0000 (15:03 +0100)]
x86: fix boot failure (regression from pre-4.0 IRQ handling changes)
With the change to index irq_desc[] by IRQ rather than by vector, the
prior implicit change of the used flow handler when altering the IRQ
routing path to go through the 8259A didn't work anymore, and hence
on boards needing the ExtINT delivery workaround failed to boot.
Make make_8259A_irq() a real function again, thus allowing the flow
handler to be changed there.
Also eliminate the generally superfluous and (at least theoretically)
dangerous hard coded setting of the flow handler for IRQ0: Earlier
code should have set this already based on information coming from
ACPI/MPS, and non-standard systems may e.g. have this IRQ level
triggered.
Signed-off-by: Jan Beulich <jbeulich@novell.com> Tested-by: Markus Schuster <ml@markus.schuster.name>
Keir Fraser [Sat, 2 Oct 2010 14:00:05 +0000 (15:00 +0100)]
Vt-d: fix feature boot messages
Changed vt-d feature boot messages from "supported" to "enabled" since
they reflect what is currently enabled in this Xen boot - not what is
supported by VT-d hardware.
Andre Przywara [Fri, 1 Oct 2010 16:22:40 +0000 (17:22 +0100)]
xl: allow parsing of both old and new cpuid syntax
Allow parsing of both versions of the cpuid syntax, the old xm used one
and the new one for xl. This works automatically, as the parser can tell
a Python list apart from a string before processing the line.
Andre Przywara [Fri, 1 Oct 2010 16:21:01 +0000 (17:21 +0100)]
libxl: implementing legacy xm cpuid parser
To support compatibility with the xm config files, add a parser for the
old style cpuid= syntax. This uses a Python list, so it can be
distinguished from the new syntax easily.
Andre Przywara [Fri, 1 Oct 2010 16:20:41 +0000 (17:20 +0100)]
xl: implement parsing of cpuid parameter and translate to Xen interface
Parses a string enumerating cpuid flags and their behavior.
The syntax is: cpuid = "host,<flagname>=[01xks],..."
Supports:
0: clear this flag
1: set this flag
x: don't care, use the default handling
k: use the host value
s: as k, but keep stable across migrations
For multiple bit flags there have to be numbers passed (hex or dec),
like: family=0x10,model=4
Andre Przywara [Fri, 1 Oct 2010 14:42:46 +0000 (15:42 +0100)]
xl: use libxl_domain_info to get the uuid in printf_info
If there is no UUID specified in the config file, we generate one during
the _parsing_ process. Since xl list -l parses the config file again,
the UUID will be generated again in this case and the reported
version does probably not match the used one.
Fix this by retrieving the UUID from dominfo (like xl list -v does).
Tim Deegan [Fri, 1 Oct 2010 10:57:53 +0000 (11:57 +0100)]
x86 mm: free p2m pages to the shadow/hap pool.
This allows the p2m code to dynamically free and reallocate memory
rather than just freeing everything once at domain teardown.
The previous mechanism (allocating p2m pages from shadow/hap
memory but freeing them directly to the domheap) was a relic
of the original shadow2's rather complex pool code.
In the warning message issued on writes, the Xen-modified value should
be printed (and used to determine whether anything needs to be printed
at all), as the guest kernel will usually do a read-modify-write
cycle.
A question is whether Dom0 shouldn't be allowed control over some
bits, or whether some bits shouldn't be fully virtualized. I'm
particularly thinking of MSR_IA32_MISC_ENABLE_FAST_STRING, which
recent Linux kernels want to disable for CONFIG_KMEMCHECK.
While putting this together I also noticed that rdmsr_safe() failed to
initialize its output registers in the failure path, thus leading to
printing of uninitialized data in the guest WRMSR warning message.
Further, the default case value-changed check can be simplified.
While not as relevant after c/s 21894, is still seems safer to check
the CPUID level here, just like Linux does. The is particularly
relevant for the 4.0 tree (which doesn't have said c/s), but also
possibly for nested environments where writing MSR_IA32_MISC_ENABLE
may not actually take effect (Xen itself ignores such writes).
xl: Fix stack corruption caused by non-terminated call to libxl__xs_writev
Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Tested-by: Christoph Egger <Christoph.Egger@amd.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/python: do not link against blktap except on Linux
Link to libblktapctl in python setup only for platforms which build it.
This fixes a build breakage on NetBSD introduced in 330c4d9010da.
Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Tested-by: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
libxl: Introduce a maximum limit for free_mem_slack (re (dom0) ballooning)
This fixes this message:
libxl: error: libxl.c:2921:libxl_set_memory_target new target
for dom0 is below the minimum threshold
which can occur spuriously if dom0_mem is specified and xl
autoballoning is left turned on.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Tested-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
When converting a gfn to mfn, check if the page is paged-out.
If it is, request a page-in and return GNTST_eagain to the caller
to indicate a retry of the hypercall is required.
This fixes granttable errors when xenpaging is enabled in the guest.