Jan Beulich [Fri, 19 Nov 2010 18:39:33 +0000 (18:39 +0000)]
stubdom: allow building with read-only sources
Signed-off-by: Jan Beulich <jbeulich@novell.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Andre Przywara [Fri, 19 Nov 2010 18:15:14 +0000 (18:15 +0000)]
libxc: fix tracing (broken with hypercall buffers)
the attached patch makes Xen tracing work again, after the introduction
of the hypercall buffers broke it. Just a missing line.
Thanks to Uwe Dannowski for reporting this.
Signed-off-by: Andre Przywara <andre.przywara@amd.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Fri, 19 Nov 2010 13:45:08 +0000 (13:45 +0000)]
Introduce PHYSDEVOP_get_free_pirq
Introduce a new physdev_op called PHYSDEVOP_get_free_pirq to allow a
guest to get a free pirq number from Xen; the hypervisor would keep
that pirq free for the guest to use in a mapping.
Keir Fraser [Fri, 19 Nov 2010 13:43:24 +0000 (13:43 +0000)]
Interrupt remapping to PIRQs in HVM guests
This patch allows HVM guests to remap interrupts and MSIs into pirqs;
once the mapping is in place the guest will receive the interrupt (or
the MSI) as an event. The interrupt to be remapped can either be an
interrupt of an emulated device or an interrupt of a passthrough
device and we keep track of that.
Keir Fraser [Fri, 19 Nov 2010 13:24:00 +0000 (13:24 +0000)]
x86-64: one more adjustment for Fam10 MMCONF enabling
The BASE_VALID() macro needs adjustment to match the other changes
done to the original Linux code (which are all queued to be merged
into Linus' tree), plus per Hypertransport specification the range
0xff00000000-0xffffffffff also needs to be excluded.
Keir Fraser [Fri, 19 Nov 2010 13:21:09 +0000 (13:21 +0000)]
x86/mm: Allocate log-dirty bitmaps from shadow/HAP memory.
Move the p2m alloc and free functions back into the per-domain paging
assistance structure and allow them to be called from the log-dirty
code. This makes it less likely that log-dirty code will run out of
memory populating the log-dirty bitmap.
Keir Fraser [Thu, 18 Nov 2010 12:28:31 +0000 (12:28 +0000)]
x86 hvm: Refuse to perform __hvm_copy() work in atomic context.
Soon we will properly handle paged out memory in this function by
sleeping in hypervisor context. This will require that all callers can
sleep.
If this check is too strong, we can reduce it to only applying to
guests with paging enabled (which also currently implies only guests
using Intel EPT). However my brief testing seems to indicate it works
okay.
Keir Fraser [Thu, 18 Nov 2010 12:26:27 +0000 (12:26 +0000)]
rcu_lock(current->domain) does not need to disable preemption.
If the guest sleeps in hypervisor context, it should not be destroyed
until execution reaches a safe point (i.e., guest context). This is
not implemented yet. :-) But the next patch will rely on it, to allow
an HVM guest to execute hypercalls that indirectly invoke __hvm_copy()
within an rcu_lock_current_domain() region.
Keir Fraser [Wed, 17 Nov 2010 17:28:17 +0000 (17:28 +0000)]
x86/hvm/pmtimer: improving scalability of virtual time update
Mitigate the heavy contention on handle_pmt_io when running a HVM
configured with many cores (e.g., 32 cores). As the virtual time of a
domain must be fresh, there should be someone updating it,
periodically. But it is not necessary to let a VCPU update the virtual
time when another one has been updating it. Thus the update can be
skipped when the VCPU finds someone else is updating the virtual time.
So every time a VCPU invoke handle_pmt_io to update the current
domain's virtual time, it will first try to acquire the pmtimer lock.
If it succeeds, it will update the virtual time. Otherwise, it can
skip the update, waits for the pmtimer lock holder to finish updating
the virtual time and returns the updated time.
Signed-off-by: Xiang Song <xiangsong@fudan.edu.cn> Signed-off-by: Keir Fraser <keir@xen.org>
Keir Fraser [Mon, 15 Nov 2010 09:31:38 +0000 (09:31 +0000)]
x2apic: Remove a panic condition in enabling x2APIC
Currently Xen triggers a panic if user disables VT-d by command line
while not disable x2APIC. This requires users to specify both
"iommu=0" and "x2apic=0" to disable VT-d if the platform supports
x2APIC. It's not user friendly. This patch removes the panic
condition. That's to say, don't require user to specify "x2apic=0"
when specify "iommu=0". As long as VT-d is not enabled (disabled in
BIOS or in command line), x2APIC won't be enabled naturally (x2APIC
depends on VT-d Interrupt remapping).
Signed-off-by: Weidong Han <weidong.han@intel.com>
tools/hotplug/Linux: supply --physdev-is-bridged in iptables runes
With newer (pvops) kernels logs get flooded with this iptables
warning: physdev match: using --physdev-out in the OUTPUT, FORWARD and
POSTROUTING chains for non-bridged traffic is not supported anymore
Using the --physdev-is-bridged option prevents this.
See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=571634#10
Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Wed, 10 Nov 2010 13:58:16 +0000 (13:58 +0000)]
hvmloader: fix off-by-one-bit error when initialising PCI devices
hvmloader is responsible for - amoungst other things - initialising
the PCI device BARs prior to loading the guest BIOS. The previous
code only probed for devfn up to 128. The lower 3 bits are function
IDs so this meant that only devices in slots 0-15 were actually being
initialized.
Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com> Acked-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Ian Campbell [Tue, 9 Nov 2010 18:15:25 +0000 (18:15 +0000)]
tools: provide explicit target for refetching/resetting qemu
This patch adds an explicit update mechanism:
make tools/ioemu-dir-force-update
This isn't brilliant but is better than doing "cd tools/ioemu-remote
&& git reset --hard <sha1...>" by hand.
Note that invoking this target will destroy all working tree changes
made to qemu-xen.
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Anthony Perard [Tue, 9 Nov 2010 18:03:55 +0000 (18:03 +0000)]
firmware, qemu: Change ACPI IO values to match QEMU BIOS
As part of the QEMU/Xen merge, this patch comes to change the value of
sleep states and add some information in the PCI registers to match the
implementation of the BIOS of QEMU.
It also does a hypercall (HVM_PARAM_ACPI_IOPORTS_LOCATION) that tell the
Xen to use the new Port I/O instead of the old one.
[ Also, in this patch, update QEMU_TAG to the qemu-xen revision
with the corresponding qemu change. -iwj ]
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools: libxl: fix cpuid compilation errors for ia64
ia64 does not have cpuid. So break out cpuid-related functions into a
separate file, with stubs for ia64.
Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Tue, 9 Nov 2010 11:50:14 +0000 (11:50 +0000)]
x86: allow passing initrd to kernel without exposing it through the initial mapping
The (Dom0 only for now) kernel can indicate that it doesn't need its
initrd mapped through a newly added ELF note - it gets passed the PFN
of the initrd in this case instead of the virtual address.
Even for kernels not making use of the new feature, the initrd will
no longer get copied into the initial mapping, but the memory it lives
in will get assigned to and mapped for the guest instead.
Keir Fraser [Tue, 9 Nov 2010 11:49:49 +0000 (11:49 +0000)]
x86: do away with the boot time low-memory 1:1 mapping
By doing so, we're no longer restricted to be able to place all boot
loader modules into the low 1Gb/4Gb (32-/64-bit) of memory, nor is
there a dependency anymore on where the boot loader places the
modules.
We're also no longer restricted to copy the modules into a place below
4Gb, nor to put them all together into a single piece of memory.
Further it allows even the 32-bit Dom0 kernel to be loaded anywhere in
physical memory (except if it doesn't support PAE-above-4G).
Anthony Perard [Mon, 8 Nov 2010 17:25:54 +0000 (17:25 +0000)]
libxc: Save the HVM_PARAM_ACPI_IOPORTS_LOCATION
This will save the acpi_ioport_location hvm_param in the checkpoint file
and set the parameter in Xen at restore.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson [Mon, 8 Nov 2010 17:05:14 +0000 (17:05 +0000)]
tools: xl: more const-correctness
The implementation of xl was lacking a lot of consts on its char*s.
In this patch we improve matters. It doesn't fix everything. In
particular:
* I only changed char*s and not other structs that ought to be const.
* libxl_send_debug_keys should take a const char* but the pointer
ends up getting sent to DECLARE_HYPERCALL_BOUNCE from xc_private.h
and that won't take a const char*. I wasn't sure what to do so
I have left it.
* There is a great deal of in-place string tokenisation (both
ad-hoc, and using strtok_r). I haven't changed any of that.
* I haven't changed any of the occurrences of char **argv because of
the castless assignment incompatibility between const char** and
char **.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen84: # virsh create ./win2k8r2.xml
error: Failed to create domain from ./win2k8r2.xml
error: POST operation failed: xend_post: error from xen daemon:
(xend.err "Error creating domain: 'key'")
The PCI device config maintained by xend includes a 'key' field, which is
initialized by xm client when using that tool and traditional xen config
file. libvirt, which uses xend's sexpr-over-http interface (is that the
proper name for that interface??), does not initialize this field - and
shouldn't be expected to do so IMO. Clients should not be bothered with
xend's internal representation of a PCI device.
This patch populates the 'key' field within xend if it is uninitialized,
similar to current initialization of 'uuid' field. The 'vdevfn' field
suffers a similar problem if not (optionally) specified by user.
AFAICT, the xm client initializes 'vdevfn' to 0x100 if not specified so
I've done the same here.
Signed-off-by: Jim Fehlig <jfehlig@novell.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Mon, 8 Nov 2010 15:44:02 +0000 (15:44 +0000)]
x86: xsave save/restore support for both PV and HVM guests (version 2)
I have tested the patch in the following senarios:
1> Non-xsave platform
2> Xsave-capable platform, guest does not support xsave, xen support xsave
3> Xsave-capable platform, guest does support xsave, xen supports xsave
4> Guest (non-xsave) saved on platform without xsave, restored on a
Xsave-capable system.
All passed.
Signed-off-by: Shan Haitao <haitao.shan@intel.com> Signed-off-by: Han Weidong <weidong.han@intel.com>
Keir Fraser [Mon, 8 Nov 2010 15:32:05 +0000 (15:32 +0000)]
x86-64: more fixes for Fam10 MMCONF enabling
Unfortunately it turned out the original Linux code had more issues:
We want to place the region above 4G in any case (even if TOM2 isn't
enabled or invalid), and the base mask definition was improperly typed
(thus causing shifts by FAM10H_MMIO_CONF_BASE_SHIFT to produce other
than the intended result). Fixing this in turn allowed simplifying the
MMIO region detection code, as regions ending below TOM2 now aren't of
interest anymore.
Keir Fraser [Thu, 4 Nov 2010 16:37:29 +0000 (16:37 +0000)]
libelf: move to init text/data when built for the hypervisor
Rather than annotating each and every function and data object (and
then still missing some compiler generated ones, plus getting into
ugliness due to the code also being built from tools/libxc/), use
objcopy to rename all relevant sections.
Keir Fraser [Thu, 4 Nov 2010 16:36:37 +0000 (16:36 +0000)]
x86: clean up AMD Fam10 xenoprof IBS code
Arrange for (almost) no code to be generated for x86-32, where the
functionality is disabled anyway. Properly __init-annotate the code.
Remove some pointless bits.
Keir Fraser [Thu, 4 Nov 2010 16:35:58 +0000 (16:35 +0000)]
x86-64: enable MMCONFIG on AMD Fam10 systems even if the BIOS didn't
Code for this has been in Linux since 2.6.26, and since Xen itself
wants to use the MMCONFIG access method when possible, clone it
(fixing some rather obvious bugs in that code at once).
This patch fixes compilation errors by 22275:e95dc0eb152d:
ia64/xc_ia64_linux_save.c:797: error: too few arguments to function 'callbacks->switch_qemu_logdirty'
and applies 22285:36a317494429 to ia64.
Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Juergen Gross [Wed, 3 Nov 2010 12:10:46 +0000 (12:10 +0000)]
tools: change cpumaps to uint8_t
Cpumap types in tools (libxc and libxl) are changed to be based on bytes like
in the interface to the hypervisor.
To make handling easier the size of used cpumaps is always based on the
number of physical cpus supported by the hypervisor. This eliminates the need
to keep track of the cpumap size in external interfaces.
In libxl a macro for cycling through a cpumap is added (libxl_for_each_cpu).
Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Wed, 3 Nov 2010 08:18:51 +0000 (08:18 +0000)]
VT-d: fix device assignment failure (regression from Xen c/s 19805:2f1fa2215e60)
If the device at <secbus>:00.0 is the device the mapping operation was
initiated for, trying to map it a second time will fail, and hence
this second mapping attempt must be prevented (as was done prior to
said c/s).
While at it, simplify the code a little, too.
Signed-off-by: Jan Beulich <jbeulich@novell.com> Acked-by: Weidong Han <weidong.han@intel.com>
Keir Fraser [Tue, 2 Nov 2010 07:35:52 +0000 (07:35 +0000)]
Fix ia64 tools build
22066:eccfdeb41b80 replaced tools/libxc/ia64/aclinux.h with
xen/include/acpi/platform/aclinux.h.
Because both are incompatible, tools cannot be built on ia64.
This patch fixes compilation errors by defining identifiers at
ac_ia64_tools.h.
Primarily fix up register names in public header file for
compatibility with old unmodified versions of virtual firmware and
qemu-dm. Also fixes a bug in the read case of handle_evt_io().
Keir Fraser [Fri, 29 Oct 2010 09:40:14 +0000 (10:40 +0100)]
X86: Prefer TSC-deadline timer in Xen
The new TSC Deadline Timer offers system software a low overhead
per-logical-thread deadline timer in TSC units.
The timer is implemented via a new architectural 64-bit register,
IA32_TSC_DEADLINE_MSR. Reads and writes of this MSR occur in program
order, but are non-serializing.
The support for this feature is indicated by
CPUID.01H:ECX.TSC_Deadline[bit 24] =3D 1 as documented in the Intel
Architecture Software Developer's Manual.
The LOCAL APIC on new processors has a mode where its underlying
hardware timer can now be accessed via the non-serializing
IA32_TSC_DEADLINE_MSR in TSC tick units.
If this mode is present, prefer it over the traditional LAPIC timer
mode. KERN_DEBUG dmesg will print "TSC deadline timer enabled" when
TDT is used.
Bootparam "tdt=off" is available to revert to LAPIC timer mode.
This patch is based on original work by Len Brown for Linux kernel.
cc: Len Brown <len.brown@intel.com> Signed-off-by: Wei Gang <gang.wei@intel.com> Signed-off-by: Keir Fraser <keir@xen.org>
Keir Fraser [Fri, 29 Oct 2010 09:29:14 +0000 (10:29 +0100)]
vtd: consolidate VT-d quirks into a single file quirks.c
Consolidate VT-d quirks into a single file - quirks.c. This includes
quirks to workaround OEM BIOS issue with VT-d enabling in IGD, Cantiga
VT-d buffer flush issue, Cantiga IGD Vt-d low power related errata,
and a quirk to workaround issues related to wifi direct assignment.
Signed-off-by: Allen Kay <allen.m.kay@intel.com> Reviewed-by: Jan Beulich <JBeulich@novell.com>
Keir Fraser [Fri, 29 Oct 2010 09:20:08 +0000 (10:20 +0100)]
credit2: Fix runq_tickle to use idle, tickled masks
The previous code had a bug where, if a second vcpu woke up and ran
runq_tickle before the first vcpu had actually started running on a
tickled processor, the code would choose the same cpu to tickle, and
the result would be a "missed tickle" -- only one of the vcpus would
run, despite having idle processors.
This change:
* Keeps a mask of idle cpus
* Keeps a mask of cpus which have been tickled, but not entered
schedule yet.
The new tickle code first looks at the set of idle-but-not-tickled
cpus; if it's not empty, it tickles one.
If that doesn't work, it looks at the set of not-idle-but-not-tickled
cpus, finds the one with the lowest credit; if that's lower than the
waking vcpu, it tickles that one.
If any cpu is tickled, its bit in the tickled mask is set, and cleared
when schedule() is called.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Keir Fraser [Fri, 29 Oct 2010 09:17:07 +0000 (10:17 +0100)]
hvmloader: Configure gPXE to use serial console
Sometimes we would rather connect to an HVM's serial console than it's
VGA display. In this case we cannot see or interact with the ethernet
booting process. This is a bit annoying so let's just enable it.
Juergen Gross [Thu, 28 Oct 2010 11:22:09 +0000 (12:22 +0100)]
avoid numa placement of cpus with active cpupools
When using cpupools don't pin vcpus to numa nodes as this might
conflict with the cpupool definition.
numa placement should be handled by cpupool configuration instead.
Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Thu, 28 Oct 2010 11:19:43 +0000 (12:19 +0100)]
libxl: Fix migration of HVM guests
In the default "QemuDeviceModelRecord"-style HVM tail of the migration
protocol the size of the qemu save record is unknown at the receiver
and therefore it must read until EOF. This is not compatible with the
xl migration protocol which contains a post-migration handshake and
therefore cannot close the socket on the sending end.
What is required is an explicit length field for the save record,
which the "RemusDeviceModelState"-style HVM tail includes.
Rather than overload the "RemusDeviceModelState" name for a non-Remus
use case (on off chance that they need to diverge for some reason in
the future) introduce a third style called "DeviceModelRecord0002"
which is identical to current "RemusDeviceModelState"-style.
Hopefully the inclusion of a number here will allow easier extension
in the future without needing to come up with increasingly less
helpful names!
Also propagate errors from xc_domain_save and
libxl__domain_suspend_common to callers.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Campbell [Thu, 28 Oct 2010 11:16:48 +0000 (12:16 +0100)]
xl: support -w (wait) option in xl shutdown
improves compatibility with xm.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Patrick Colp [Thu, 28 Oct 2010 11:15:41 +0000 (12:15 +0100)]
tools: caml-stubdom: fix "red zone" bug
According to the AMD64 ABI, the 128-byte area below %rsp is reserved
for scratch space and should not be used by signal, interrupt, or
exception handlers. However, Mini-OS does not adhere to this
interface. As a result, the -mno-red-zone flag must be provided to gcc
in order to force code to be compiled without this assumption. In the
case of the c-stubdom or the ioemu stubdom, Makefile configuration and
flags are inherited from Xen, which includes this flag. However, in
the case of the ocaml stubdom, since an independent ocaml version is
pulled and compiled, with its own make system in place, this flag is
not present.
As a default optimisation (no optimisation flags specified), gcc
generates function header code that uses mov instead of push (to save
a few instructions). However, with the 128-byte scratch space
assumption in place, registers are moved onto the stack *before* %rsp
is updated. This results in cases where when a function is being
called, *after* the first mov <foo>, <offset>(%rsp) but *before* the
%rsp update, sub <bar>, %rsp, if an interrupt is fired, then the stack
will be clobbered (as Mini-OS uses the application stack for its
stack, pushing registers onto the stack on entry and popping them off
on exit).
This patch fixes this issue by passing the -mno-red-zone flag to the
ocaml configure script in the stubdom Makefile.
Signed-off-by: Patrick Colp <pjcolp@cs.ubc.ca> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Ian Jackson [Thu, 28 Oct 2010 11:05:45 +0000 (12:05 +0100)]
libxl: Fix format string abuses / vulnerabilities
There are a few places where libxl__xs_write is passed a variable
value to write to xenstore, but the semantics are that the first char*
is a format string. So use "%s".
This fixes the following errors reported by some newer compilers:
libxl.c: In function "libxl_create_cpupool":
libxl.c:3981: error: format not a string literal and no format arguments
libxl.c:3983: error: format not a string literal and no format arguments
libxl.c: In function "libxl_cpupool_movedomain":
libxl.c:4095: error: format not a string literal and no format arguments
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Gianni Tedesco [Thu, 28 Oct 2010 11:02:22 +0000 (12:02 +0100)]
libxl: fix dom0 minimum memory threshold check
libxl_set_memory_target tries to set the memory target for a given
domain to new_target_memkb. The function includes a check to make sure
that dom0's memory is not reduced below a minimal threshold ie.
LIBXL_MIN_DOM0_MEM. However, this check is performed before the
new_target_memkb variable is properly initialised - when the value is
always zero. This means that the check always fails. Fix this by moving
the test to happen after the proper initialisation of new_target_memkb.
Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Gianni Tedesco [Thu, 28 Oct 2010 10:47:26 +0000 (11:47 +0100)]
gdbsx: Makefiles: correctly generate dependencies
gdbsx hacks CFLAGS to remove optimisations for easier debugging, however
this breaks dep generation due to an early evaluation of CFLAGS and
leaves stale files called "..d" after a make clean. We could possibly
fix this by separating dep generation from the rest of CFLAGS but it
seems a little invasive. The gdbsx hackers can do their own thing during
development and testing anyway...
When trying to live migrate guest with great memory (e.g. 20 GB),
there's delay caused by destroying source copy of domain. To speed up
this process we can close socket before starting guest destroy, as
source guest is not running anymore.
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>