xen.git
13 years agoxen/arm: implement page reference and gnttab functions needed by grant_table.c
Stefano Stabellini [Tue, 9 Oct 2012 14:05:32 +0000 (15:05 +0100)]
xen/arm: implement page reference and gnttab functions needed by grant_table.c

The implementation is strongly "inspired" by their x86 counterparts,
except that we assume paging_mode_external and paging_mode_translate.

TODO: read_only mappings and gnttab_mark_dirty.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: implement VGCF_online
Ian Campbell [Tue, 9 Oct 2012 14:05:31 +0000 (15:05 +0100)]
arm: implement VGCF_online

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxc: add ARM support to xc_dom (PV domain building)
Ian Campbell [Tue, 9 Oct 2012 14:05:30 +0000 (15:05 +0100)]
libxc: add ARM support to xc_dom (PV domain building)

Includes ARM zImage support.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoImplement page offline recovery action for AMD
Christoph Egger [Tue, 9 Oct 2012 11:51:37 +0000 (12:51 +0100)]
Implement page offline recovery action for AMD

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agotrace: rename trace_hypercall() to __trace_hypercall_entry()
David Vrabel [Tue, 9 Oct 2012 11:46:27 +0000 (12:46 +0100)]
trace: rename trace_hypercall() to __trace_hypercall_entry()

Tracing functions that don't check tb_init_done are (by convention)
prefixed with __.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agobuild: Fix build when using -fno-inline
Andrew Cooper [Tue, 9 Oct 2012 11:41:46 +0000 (12:41 +0100)]
build: Fix build when using -fno-inline

struct task_slice.migrated is not initialised by this function, and
subsequently returned by value, leading to the error:

sched_sedf.c: In function ‘sedf_do_extra_schedule’:
sched_sedf.c:711: error: ‘ret.migrated’ may be used uninitialised in
this function

for both gcc 4.1.2 and 4.4.3 (which are the two I have easily to hand)
when combined with the -fno-inline compile option.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agolibxl: Fix cd-insert with qemu-xen.
Anthony PERARD [Tue, 9 Oct 2012 10:08:21 +0000 (11:08 +0100)]
libxl: Fix cd-insert with qemu-xen.

If qemu-xen is used as a device model, the command to insert, change or eject a
cdrom will go through QMP. XenStore is still updated even if QEMU will not read
from it.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_dm: Set an id to cdrom drives with qemuu.
Anthony PERARD [Tue, 9 Oct 2012 10:08:20 +0000 (11:08 +0100)]
libxl_dm: Set an id to cdrom drives with qemuu.

In order to eject and change a cdrom when using qemu-xen, this patch adds an id
the cdrom driver when starting the device model.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_qmp: Introduce libxl__qmp_insert_cdrom.
Anthony PERARD [Tue, 9 Oct 2012 10:08:19 +0000 (11:08 +0100)]
libxl_qmp: Introduce libxl__qmp_insert_cdrom.

This function can eject or change the CDROM for a guest that use qemu-xen as a
device-model.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: add select definition to sys/time.h when HAVE_LIBC is defined
Matthew Fioravante [Tue, 9 Oct 2012 09:39:09 +0000 (10:39 +0100)]
minios: add select definition to sys/time.h when HAVE_LIBC is defined

This patch adds the select function to sys/time.h when HAVE_LIBC is
defined, which is according to standard (see the select() manpage).
It also removes a redudant lwip include from posix/sys/select.h.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: add posix io for blkfront
Matthew Fioravante [Tue, 9 Oct 2012 09:39:08 +0000 (10:39 +0100)]
minios: add posix io for blkfront

This patch adds posix io support (read,write,lseek) to block devices
using blkfront.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agopygrub: correct typo in --args assignment
Olaf Hering [Tue, 9 Oct 2012 08:18:42 +0000 (09:18 +0100)]
pygrub: correct typo in --args assignment

If pygrub was called with --args="some thing", then this string should
be append to the kernel command line.  But the last changeset
25941:795c493fe561 contained a typo, it assigns 'args' instead of 'arg'.

Rename the local variable which holds the string from the domain config
file to avoid further confusion.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: setup fpu and sse in mini-os
Matthew Fioravante [Mon, 8 Oct 2012 13:36:31 +0000 (14:36 +0100)]
minios: setup fpu and sse in mini-os

This patch adds floating point and sse support to mini-os by
initializing the floating point unit and the see unit during
domain boot up.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: add CONFIG_XC conditional
Matthew Fioravante [Mon, 8 Oct 2012 13:36:31 +0000 (14:36 +0100)]
minios: add CONFIG_XC conditional

This patch adds a CONFIG_XC option to mini-os, to allow conditional
support for libxc for mini-os domains.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: Disable the mfn_is_ram() check, it doesn't work correctly on all systems
Matthew Fioravante [Mon, 8 Oct 2012 13:36:30 +0000 (14:36 +0100)]
minios: Disable the mfn_is_ram() check, it doesn't work correctly on all systems

This patch disables the mfn_is_ram check in mini-os. The current check
is insufficient and fails on some systems with larger than 4gb memory.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: Add endian, byteswap, and wordsize macros to mini-os
Matthew Fioravante [Mon, 8 Oct 2012 13:36:29 +0000 (14:36 +0100)]
minios: Add endian, byteswap, and wordsize macros to mini-os

This patch addes byte swapping macros and endian support to mini-os.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agominios: Add ioread/iowrite functions to mini-os
Matthew Fioravante [Mon, 8 Oct 2012 13:36:28 +0000 (14:36 +0100)]
minios: Add ioread/iowrite functions to mini-os

This patch adds iowritexx() and ioreadxx() functions for interacting
with hardware memory to mini-os. The functions are available in a header
iorw.h

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agotools/configure.ac: fill PACKAGE_TARNAME in AC_INIT
Olaf Hering [Mon, 8 Oct 2012 11:18:35 +0000 (12:18 +0100)]
tools/configure.ac: fill PACKAGE_TARNAME in AC_INIT

Upcoming changes may move DOCDIR from Config.mk to config/Tools.mk. To
preserve the currently used path, which ends with /xen, specify a value
for PACKAGE_TARNAME. Without this change the path would end with
/xen-hypervisor.

Please rerun autoconf after applying this.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agostubdom: fix parallel build by expanding CROSS_MAKE
Olaf Hering [Mon, 8 Oct 2012 11:18:34 +0000 (12:18 +0100)]
stubdom: fix parallel build by expanding CROSS_MAKE

Recently I changed my rpm xen.spec file from doing
'make -C tools -j N && make stubdom' to 'make -j N stubdom' because
stubdom depends on tools, so both get built.
The result was the failure below.

....
mkdir -p grub-x86_64
CPPFLAGS="-isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../extras/mini-os/include -D__MINIOS__ -DHAVE_LIBC -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../extras/mini-os/include/posix -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../tools/xenstore  -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../extras/mini-os/include/x86 -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../extras/mini-os/include/x86/x86_64 -U __linux__ -U __FreeBSD__ -U __sun__ -nostdinc -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../extras/mini-os/include/posix -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/cross-root-x86_64/x86_64-xen-elf/include -isystem /usr/lib64/gcc/x86_64-suse-linux/4.7/include -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/lwip-x86_64/src/include -isystem /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/lwip-x86_64/src/include/ipv4 -I/home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/include -I/home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../xen/include" CFLAGS="-mno-red-zone -O1 -fno-omit-frame-pointer  -m64 -mno-red-zone -fno-reorder-blocks -fno-asynchronous-unwind-tables -m64 -g -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable   -fno-stack-protector -fno-exceptions" make DESTDIR= -C grub OBJ_DIR=/home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/grub-x86_64
make[2]: Entering directory `/home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/grub'
make[2]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
make[2]: *** INTERNAL: readdir: Bad file descriptor
.  Stop.
make[2]: Makefile: Field 'stem' not cached: Makefile

make[2]: Leaving directory `/home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/grub'
make[1]: *** [grub] Error 2
[ -d mini-os-x86_64-xenstore ] || \
for i in $(cd /home/abuild/rpmbuild/BUILD/xen-4.2.25602/non-dbg/stubdom/../extras/mini-os ; find . -type d) ; do \
                mkdir -p mini-os-x86_64-xenstore/$i ; \
done
....

Expanding every occurrence of CROSS_MAKE avoids this error. It also has
the nice side effect of actually enabling parallel build for stubdom.
According to the GNU make documentation $(MAKE) gets its special meaning
only if it appears directly in the recipe:

http://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxend/pvscsi: update sysfs parser for Linux 3.0
Olaf Hering [Mon, 8 Oct 2012 11:18:33 +0000 (12:18 +0100)]
xend/pvscsi: update sysfs parser for Linux 3.0

The sysfs parser for /sys/bus/scsi/devices understands only the layout
of kernel version 2.6.16. This looks as follows:

/sys/bus/scsi/devices/1:0:0:0/block:sda is a symlink to /sys/block/sda/
/sys/bus/scsi/devices/1:0:0:0/scsi_generic:sg1 is a symlink to /sys/class/scsi_generic/sg1

Both directories contain a 'dev' file with the major:minor information.
This patch updates the used regex strings to match also the colon to
make it more robust against possible future changes.

In kernel version 3.0 the layout changed:
/sys/bus/scsi/devices/ contains now additional symlinks to directories
such as host1 and target1:0:0. This patch ignores these as they do not
point to the desired scsi devices. They just clutter the devices array.

The directory layout in '1:0:0:0' changed as well, the 'type:name'
notation was replaced with 'type/name' directories:

/sys/bus/scsi/devices/1:0:0:0/block/sda/
/sys/bus/scsi/devices/1:0:0:0/scsi_generic/sg1/

Both directories contain a 'dev' file with the major:minor information.
This patch adds additional code to walk the subdir to find the 'dev'
file to make sure the given subdirectory is really the kernel name.

In addition this patch makes sure devname is not None.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxend/pvscsi: fix usage of persistant device names for SCSI devices
Olaf Hering [Mon, 8 Oct 2012 11:18:32 +0000 (12:18 +0100)]
xend/pvscsi: fix usage of persistant device names for SCSI devices

Currently the callers of vscsi_get_scsidevices() do not pass a mask
string.  This will call "lsscsi -g '[]'", which causes a lsscsi syntax
error. As a result the sysfs parser _vscsi_get_scsidevices() is used.
But this parser is broken and the specified names in the config file are
not found.

Using a mask '*' if no mask was given will call lsscsi correctly and the
following config is parsed correctly:

vscsi=[
'/dev/sg3, 0:0:0:0',
'/dev/disk/by-id/wwn-0x600508b4000cf1c30000800000410000, 0:0:0:1'
]

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxend/pvscsi: fix passing of SCSI control LUNs
Olaf Hering [Mon, 8 Oct 2012 11:18:31 +0000 (12:18 +0100)]
xend/pvscsi: fix passing of SCSI control LUNs

Currently pvscsi can not pass SCSI devices that have just a scsi_generic node.
In the following example sg3 is a control LUN for the disk sdd.
But vscsi=['4:0:2:0,0:0:0:0'] does not work because the internal 'devname'
variable remains None. Later writing p-devname to xenstore fails because None
is not a valid string variable.

Since devname is used for just informational purpose use sg also as devname.

carron:~ $ lsscsi -g
[0:0:0:0]    disk    ATA      FK0032CAAZP      HPF2  /dev/sda   /dev/sg0
[4:0:0:0]    disk    HP       P2000G3 FC/iSCSI T100  /dev/sdb   /dev/sg1
[4:0:1:0]    disk    HP       P2000G3 FC/iSCSI T100  /dev/sdc   /dev/sg2
[4:0:2:0]    storage HP       HSV400           0950  -         /dev/sg3
[4:0:2:1]    disk    HP       HSV400           0950  /dev/sdd   /dev/sg4
[4:0:3:0]    storage HP       HSV400           0950  -         /dev/sg5
[4:0:3:1]    disk    HP       HSV400           0950  /dev/sde   /dev/sg6

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxenballoond.init: remove 4 from default runlevel
Olaf Hering [Mon, 8 Oct 2012 11:18:31 +0000 (12:18 +0100)]
xenballoond.init: remove 4 from default runlevel

Remove 4 from default runlevel in xenballoond.init.

Similar to what changeset 24847:0900b1c905f1 does in xencommons, remove
runlevel 4 from the other runlevel scripts. LSB defines runlevel 4 as
reserved for local use, the local sysadmin is responsible for symlink
creation in rc4.d.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agohotplug/Linux: Remove tracing (bash -x) from network-nat script
Olaf Hering [Mon, 8 Oct 2012 11:18:30 +0000 (12:18 +0100)]
hotplug/Linux: Remove tracing (bash -x) from network-nat script

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoautoconf: add -Werror to libutil.h header check
Roger Pau Monne [Mon, 8 Oct 2012 11:18:29 +0000 (12:18 +0100)]
autoconf: add -Werror to libutil.h header check

libutil.h is only needed on BSDs, but not in Linux. Debian package
libbsd-dev-0.3.0-1 installed a libutil.h overlay that contains a

Perform the libutil.h check with -Werror, so we don't include this
bogus header.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: Allow migration with qemu-xen.
Anthony PERARD [Mon, 8 Oct 2012 10:45:36 +0000 (11:45 +0100)]
libxl: Allow migration with qemu-xen.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_dom: Call the right switch logdirty for the right DM.
Anthony PERARD [Mon, 8 Oct 2012 10:45:36 +0000 (11:45 +0100)]
libxl_dom: Call the right switch logdirty for the right DM.

This patch dispatch the switch logdirty call depending on which device model
version is running.

The call to qemu-xen right now is synchronous, not like the one to
qemu-xen-traditional.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_qmp: Introduce libxl__qmp_set_global_dirty_log.
Anthony PERARD [Mon, 8 Oct 2012 10:45:35 +0000 (11:45 +0100)]
libxl_qmp: Introduce libxl__qmp_set_global_dirty_log.

This function will enable or disable the global dirty log on QEMU,
used during a migration.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_qmp: Simplify run of single QMP commands.
Anthony PERARD [Mon, 8 Oct 2012 10:45:34 +0000 (11:45 +0100)]
libxl_qmp: Simplify run of single QMP commands.

This new function connects to QEMU, sends the command and disconnects.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_qmp: Use qmp_parameters_* functions for param list of a QMP command.
Anthony PERARD [Mon, 8 Oct 2012 10:45:33 +0000 (11:45 +0100)]
libxl_qmp: Use qmp_parameters_* functions for param list of a QMP command.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_qmp: Introduces helpers to create an argument list.
Anthony PERARD [Mon, 8 Oct 2012 10:45:32 +0000 (11:45 +0100)]
libxl_qmp: Introduces helpers to create an argument list.

Those functions will be used to create a "list" of parameters that
contain more than just strings. This list is converted by qmp_send to
a string to be sent to QEMU.

Those functions will be used in the next two patches, so right now
there are not compiled.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_json: Introduce libxl__json_object_to_yajl_gen.
Anthony PERARD [Mon, 8 Oct 2012 10:45:32 +0000 (11:45 +0100)]
libxl_json: Introduce libxl__json_object_to_yajl_gen.

This function converts a libxl__json_object to yajl by calling every
yajl_gen_* function on a preallocated yajl_gen hand.

This helps to integrate a json_object into an already existing
yajl_gen tree.

This function is used in a later patch.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- renamed local variable "index" to "idx" to avoid clash with
         index(3) function, highlighted by Wshadow ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.
Anthony PERARD [Mon, 8 Oct 2012 10:45:31 +0000 (11:45 +0100)]
libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.

Those two JSON_TRUE and JSON_FALSE were types of node. But it's better
to have a unique JSON_BOOL type.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_json: Remove JSON_ERROR from enum.
Anthony PERARD [Mon, 8 Oct 2012 10:45:30 +0000 (11:45 +0100)]
libxl_json: Remove JSON_ERROR from enum.

This value from libxl__json_node_type is never used.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_json: Export json_object related function.
Anthony PERARD [Mon, 8 Oct 2012 10:45:29 +0000 (11:45 +0100)]
libxl_json: Export json_object related function.

Export libxl__json_object_alloc and libxl__json_object_append_to to
use them in a later patch.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: Add a comment about NOGC usage with flexarray
Anthony PERARD [Mon, 8 Oct 2012 10:45:29 +0000 (11:45 +0100)]
libxl: Add a comment about NOGC usage with flexarray

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxl/libxl: add iomem support
Matthew Fioravante [Fri, 5 Oct 2012 14:12:04 +0000 (15:12 +0100)]
xl/libxl: add iomem support

This patch adds a new option for xen config files for
directly mapping hardware io memory into a vm.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl_json: Use libxl alloc function.
Anthony PERARD [Fri, 5 Oct 2012 13:34:30 +0000 (14:34 +0100)]
libxl_json: Use libxl alloc function.

This patch makes use of the libxl allocation API and the GC and removes the
check for allocation failure.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: Have flexarray using the GC
Anthony PERARD [Fri, 5 Oct 2012 13:34:30 +0000 (14:34 +0100)]
libxl: Have flexarray using the GC

This patch makes the flexarray function libxl__gc aware.

It also updates every function that use a flexarray to pass the gc and removes
every memory allocation check and free.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: Move gc_is_real to libxl_internal.h.
Anthony PERARD [Fri, 5 Oct 2012 13:34:29 +0000 (14:34 +0100)]
libxl: Move gc_is_real to libxl_internal.h.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl/qemu-xen: use cache=writeback for IDE and SCSI
Stefano Stabellini [Fri, 5 Oct 2012 13:34:28 +0000 (14:34 +0100)]
libxl/qemu-xen: use cache=writeback for IDE and SCSI

Change caching mode from writethrough to writeback for upstream QEMU.

After a lengthy discussion, we came up with the conclusion that
WRITEBACK is OK for IDE.
See: http://marc.info/?l=xen-devel&m=133311527009773

Given that the same reasons apply to SCSI as well, change to writeback
for SCSI too.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: make devid a type so it is initialized properly
Matthew Fioravante [Fri, 5 Oct 2012 13:34:27 +0000 (14:34 +0100)]
libxl: make devid a type so it is initialized properly

Previously device ids in libxl were treated as integers meaning they
were being initialized to 0, which is a valid device id. This patch
makes devid its own type in libxl and initializes it to -1, an invalid
value.

This fixes a bug where if you try to do a xl DEV-attach multiple
time it will continuously try to reattach device 0 instead of
generating a new device id.

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agox86/MCE: implement recoverscan for AMD
Christoph Egger [Fri, 5 Oct 2012 12:32:02 +0000 (14:32 +0200)]
x86/MCE: implement recoverscan for AMD

Implement recoverable_scan() for AMD.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: add sanity check and comments for vMCE injection
Liu, Jinsong [Fri, 5 Oct 2012 12:30:21 +0000 (14:30 +0200)]
x86: add sanity check and comments for vMCE injection

Add sanity check for input vcpu so that malicious value would not
return 0. Add comments since vcpu=-1 (broadcast) is some implicit to
code reader.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Suggested-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agofix inclusion style in public/domctl.h
Jan Beulich [Thu, 4 Oct 2012 15:11:25 +0000 (17:11 +0200)]
fix inclusion style in public/domctl.h

Public headers should include one another only via self-relative
include directives (violated by 25955:07d0d5b3a005).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/nested-svm: Update the paging mode on VMRUN and VMEXIT emulation.
Tim Deegan [Thu, 4 Oct 2012 13:20:50 +0000 (14:20 +0100)]
x86/nested-svm: Update the paging mode on VMRUN and VMEXIT emulation.

This allows Xen to walk the l1 hypervisor's shadow pagetable
correctly.  Not needed for hap-on-hap guests because they are handled
at lookup time.  Problem found with 64bit Win7 and 32bit XPMode where Win7
switches forth and back between long mode and PAE legacy pagetables.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
[Adjusted to update in all cases where the l1 vmm uses shadows]
Signed-off-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoVT-d: make remap_entry_to_msi_msg() return consistent message
Jan Beulich [Thu, 4 Oct 2012 07:28:25 +0000 (09:28 +0200)]
VT-d: make remap_entry_to_msi_msg() return consistent message

During debugging of another problem I found that in x2APIC mode, the
destination field of the low address value wasn't passed back
correctly. While this is benign in most cases (as the value isn't being
used anywhere), it can be confusing (and misguiding) when printing the
value read or when comparing it to the one previously passed into the
inverse function.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: consolidate frame state manipulation functions
Jan Beulich [Thu, 4 Oct 2012 07:05:24 +0000 (09:05 +0200)]
x86: consolidate frame state manipulation functions

Rather than doing this in multiple places, have a single central
function (decode_register()) to be used by all other code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: get the MWAIT idle driver in sync with the ACPI one
Jan Beulich [Thu, 4 Oct 2012 07:03:06 +0000 (09:03 +0200)]
x86: get the MWAIT idle driver in sync with the ACPI one

.. with respect to behavior when there is no HPET broadcast support
(for using the PIT broadcast instead, it requires explicitly enabling
CPU idle management).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agoMAINTAINERS: Move and fix up VTPM entry
Keir Fraser [Wed, 3 Oct 2012 11:59:30 +0000 (12:59 +0100)]
MAINTAINERS: Move and fix up VTPM entry

Signed-off-by: Keir Fraser <keir@xen.org>
13 years agoMAINTAINERS: Matthew Fioravante now maintains VTPM
Matthew Fioravante [Wed, 3 Oct 2012 10:13:54 +0000 (11:13 +0100)]
MAINTAINERS: Matthew Fioravante now maintains VTPM

Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Committed-by: Keir Fraser <keir@xen.org>
13 years agotrace: trace hypercalls inside a multicall
David Vrabel [Wed, 3 Oct 2012 10:11:35 +0000 (11:11 +0100)]
trace: trace hypercalls inside a multicall

Add a trace record for every hypercall inside a multicall.  These use
a new event ID (with a different sub-class ) so they may be filtered
out if only the calls into hypervisor are of interest.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agotrace: improve usefulness of hypercall trace record
David Vrabel [Wed, 3 Oct 2012 10:11:06 +0000 (11:11 +0100)]
trace: improve usefulness of hypercall trace record

Trace hypercalls using a more useful trace record format.

The EIP field is removed (it was always somewhere in the hypercall
page) and include selected hypercall arguments (e.g., the number of
calls in a multicall, and the number of PTE updates in an mmu_update
etc.).  12 bits in the first extra word are used to indicate which
arguments are present in the record and what size they are (32 or
64-bit).

This is an incompatible record format so a new event ID is used so
tools can distinguish between the two formats.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agotrace: allow for different sub-classes of TRC_PV_* tracepoints
David Vrabel [Wed, 3 Oct 2012 10:10:33 +0000 (11:10 +0100)]
trace: allow for different sub-classes of TRC_PV_* tracepoints

We want to add additional sub-classes for TRC_PV tracepoints and to be
able to only capture these new sub-classes.  This cannot currently be
done as the existing tracepoints all use a sub-class of 0xf.

So, redefine the PV events to use a new sub-class.  All the current
tracepoints are tracing entry points to the hypervisor so the
sub-class is named TRC_PV_ENTRY.

This change does not affect xenalyze as that only looks at the main
class and the event number and does not use the sub-class field.

Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agox86/Intel: add further support for Ivy Bridge CPU models
Jan Beulich [Tue, 2 Oct 2012 10:14:00 +0000 (12:14 +0200)]
x86/Intel: add further support for Ivy Bridge CPU models

And some initial Haswell ones at once.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: "Nakajima, Jun" <jun.nakajima@intel.com>
13 years agoRegister Linux PV-on-HVM drivers product number.
Paul Durrant [Mon, 1 Oct 2012 19:06:31 +0000 (20:06 +0100)]
Register Linux PV-on-HVM drivers product number.

This is already in use despite never being registereed.
See XEN_IOPORT_LINUX_PRODNUM in include/xen/platform_pci.h

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoAdd a new pvdrivers header to serve as the register of product numbers.
Paul Durrant [Mon, 1 Oct 2012 19:05:33 +0000 (20:05 +0100)]
Add a new pvdrivers header to serve as the register of product numbers.

These product numbers are used by the QEMU blacklisting protocol in
traditional QEMU and are currently coded directly into the xenstore.c
source module. Since there are now multiple QEMUs this information
should be pulled into a public header to avoid duplication/conflict.
hvm-emulated-unplug.markdown has also been adjusted to reference the
new header.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxen: Remove sched_credit_default_yield option
George Dunlap [Mon, 1 Oct 2012 19:03:19 +0000 (20:03 +0100)]
xen: Remove sched_credit_default_yield option

The sched_credit_default_yield option was added when the behavior of
"SCHEDOP_yield" was changed in 4.1, to allow any users who had
problems to revert to the old behavior.  The new behavior has been in
Xen.org xen since 4.1, and in XenServer even longer, and there is no
evidence of anyone having trouble with it.  Remove the option.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxen/console: introduce a 'w' debug-key that dumps the console ring
Matt Wilson [Mon, 1 Oct 2012 19:02:45 +0000 (20:02 +0100)]
xen/console: introduce a 'w' debug-key that dumps the console ring

This patch adds a new 'w' debug-key, chosen from the limited remaining
keys only due to its proximity to 'q', that dumps the console ring to
configured console devices. It's useful to for tracking down how an
unresponsive system got into a broken state via serial console.

Signed-off-by: Matt Wilson <msw@amazon.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agohvmloader: Add 64 bits big bar support
Xiantao Zhang [Mon, 1 Oct 2012 19:01:55 +0000 (20:01 +0100)]
hvmloader: Add 64 bits big bar support

Currently it is assumed PCI device BAR access < 4G memory. If there is
such a device whose BAR size is larger than 4G, it must access > 4G
memory address.  This patch enable the 64bits big BAR support on
hvmloader.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agodocs: initial documentation for xenstore paths
Ian Campbell [Mon, 1 Oct 2012 16:54:11 +0000 (17:54 +0100)]
docs: initial documentation for xenstore paths

This is based upon my inspection of a system with a single PV domain
and a single HVM domain running and is therefore very incomplete.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agodocs: Document scheduler-related Xen command-line options
George Dunlap [Mon, 1 Oct 2012 16:49:01 +0000 (17:49 +0100)]
docs: Document scheduler-related Xen command-line options

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86: replace literal numbers
Jan Beulich [Fri, 28 Sep 2012 08:59:41 +0000 (10:59 +0200)]
x86: replace literal numbers

In various cases, 256 was being used instead of NR_VECTORS or a derived
ARRAY_SIZE() expression. In one case (guest_has_trap_callback()), a
wrong (unrelated) constant was used instead of NR_VECTORS.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agoRevert 25960:6bf8b882df8f (x86: default-disable MWAIT-based idle driver ...)
Jan Beulich [Fri, 28 Sep 2012 07:36:32 +0000 (09:36 +0200)]
Revert 25960:6bf8b882df8f (x86: default-disable MWAIT-based idle driver ...)

The problem this was working around should be resolved with c/s
25961:6a5812129094 (x86/HPET: don't disable interrupt delivery right
after setting it up).

13 years agox86/ucode: fix Intel case of resume handling on boot CPU
Jan Beulich [Fri, 28 Sep 2012 07:28:11 +0000 (09:28 +0200)]
x86/ucode: fix Intel case of resume handling on boot CPU

Checking the stored version doesn't tell us anything about the need to
apply the update (during resume, what is stored doesn't necessarily
match what is loaded).

Note that the check can be removed altogether because once switched to
use what was read from the CPU (uci->cpu_sig.rev, as used in the
subsequent pr_debug()), it would become redundant with the checks that
lead to microcode_update_match() returning the indication that an
update should be applied.

Note further that this was not an issue on APs since they start with
uci->mc.mc_intel being NULL.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Ben Guthro <ben@guthro.net>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: remove further code applicable to 32-bit CPUs only
Jan Beulich [Fri, 28 Sep 2012 07:26:46 +0000 (09:26 +0200)]
x86: remove further code applicable to 32-bit CPUs only

On the AMD side, anything prior to family 0xf can now be ignored, as
well as very low model numbers of family 6 on the Intel side.

Apart from that, there were several made up CPU features that turned
out entirely unused throughout the tree.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/HPET: don't needlessly set up channels for broadcast
Jan Beulich [Fri, 28 Sep 2012 07:25:42 +0000 (09:25 +0200)]
x86/HPET: don't needlessly set up channels for broadcast

When there are more FSB delivery capable HPET channels than CPU cores
(or threads), we can simply use a dedicated channel per CPU. This
avoids wasting the resources to handle the excess channels (including
the pointless triggering of the respective interrupt on each
wraparound) as well as the ping-pong of the interrupts' affinities
(when getting assigned to different CPUs).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/IRQ: fix valid-old-vector checks in __assign_irq_vector()
Jan Beulich [Fri, 28 Sep 2012 07:23:34 +0000 (09:23 +0200)]
x86/IRQ: fix valid-old-vector checks in __assign_irq_vector()

There are two greater-than-zero checks for the old vector retrieved,
which don't work when a negative value got stashed into the respective
arch_irq_desc field. The effect of this was that for interrupts that
are intended to get their affinity adjusted the first time before the
first interrupt occurs, the affinity change would fail, because the
original vector assignment would have caused the move_in_progress flag
to get set (which causes subsequent re-assignments to fail until it
gets cleared, which only happens from the ->ack() actor, i.e. when an
interrupt actually occurred).

This addresses a problem introduced in c/s 23816:7f357e1ef60a (by
changing IRQ_VECTOR_UNASSIGNED from 0 to -1).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/HPET: don't disable interrupt delivery right after setting it up
Jan Beulich [Fri, 28 Sep 2012 07:22:14 +0000 (09:22 +0200)]
x86/HPET: don't disable interrupt delivery right after setting it up

We shouldn't clear HPET_TN_FSB right after we (indirectly, via
request_irq()) enabled it for the channels we intend to use for
broadcasts.

This fixes a regression introduced by c/s 25103:0b0e42dc4f0a.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: default-disable MWAIT-based idle driver for CPUs without ARAT
Jan Beulich [Wed, 26 Sep 2012 15:11:39 +0000 (17:11 +0200)]
x86: default-disable MWAIT-based idle driver for CPUs without ARAT

Without ARAT, and apparently only when using HPET broadcast mode as
replacement, CPUs occasionally fail to wake up, causing the system to
(transiently) hang. Until the reason is understood, disable the driver
on such systems.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: Expose TSC adjust to HVM guest
Liu, Jinsong [Wed, 26 Sep 2012 10:14:30 +0000 (12:14 +0200)]
x86: Expose TSC adjust to HVM guest

Intel latest SDM (17.13.3) release a new MSR CPUID.7.0.EBX[1]=1
indicates TSC_ADJUST MSR 0x3b is supported.

This patch expose it to hvm guest.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: Save/restore TSC adjust during HVM guest migration
Liu, Jinsong [Wed, 26 Sep 2012 10:13:38 +0000 (12:13 +0200)]
x86: Save/restore TSC adjust during HVM guest migration

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: Implement TSC adjust feature for HVM guest
Liu, Jinsong [Wed, 26 Sep 2012 10:12:42 +0000 (12:12 +0200)]
x86: Implement TSC adjust feature for HVM guest

IA32_TSC_ADJUST MSR is maintained separately for each logical
processor. A logical processor maintains and uses the IA32_TSC_ADJUST
MSR as follows:
1). On RESET, the value of the IA32_TSC_ADJUST MSR is 0;
2). If an execution of WRMSR to the IA32_TIME_STAMP_COUNTER MSR adds
    (or subtracts) value X from the TSC, the logical processor also
    adds (or subtracts) value X from the IA32_TSC_ADJUST MSR;
3). If an execution of WRMSR to the IA32_TSC_ADJUST MSR adds (or
    subtracts) value X from that MSR, the logical processor also adds
    (or subtracts) value X from the TSC.

This patch provides tsc adjust support for hvm guest, with it guest OS
would be happy when sync tsc.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86/vMCE: Add AMD support
Christoph Egger [Wed, 26 Sep 2012 10:07:42 +0000 (12:07 +0200)]
x86/vMCE: Add AMD support

Add vMCE support for AMD. Add vmce namespace to Intel specific vMCE MSR
functions. Move vMCE prototypes from mce.h to vmce.h.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
- fix inverted return values from vmce_amd_{rd,wr}msr()
- remove bogus printk()-s from those functions

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: vMCE save and restore
Liu, Jinsong [Wed, 26 Sep 2012 10:05:55 +0000 (12:05 +0200)]
x86: vMCE save and restore

This patch provides vMCE save/restore when migration.
1. MCG_CAP is well-defined. However, considering future cap extension,
   we keep save/restore logic that Jan implement at c/s 24887;
2. MCi_CTL2 initialized by guestos when booting, so need save/restore
   otherwise guest would surprise;
3. Other MSRs do not need save/restore since they are either error-
   related and pointless to save/restore, or, unified among all vMCE
   platform;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
- fix handling of partial data in XEN_DOMCTL_set_ext_vcpucontext
- fix adjustment of xen_domctl_ext_vcpucontext

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: vMCE injection
Liu, Jinsong [Wed, 26 Sep 2012 10:05:10 +0000 (12:05 +0200)]
x86: vMCE injection

In our test for win8 guest mce, we find a bug that no matter what
SRAO/SRAR error xen inject to win8 guest, it always reboot.

The root cause is, current Xen vMCE logic inject vMCE# only to vcpu0,
this is not correct for Intel MCE (Under Intel arch, h/w generate MCE#
to all CPUs).

This patch fixes vMCE injection bug, injecting vMCE# to all vcpus on
Intel platforms.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
- increase flexibility be making new second argument of inject_vmce() a
  VCPU ID rather than just a boolean

Acked-by: Christoph Egger <Christoph.Egger@amd.com> (on just this change)
- fix condition evaluation order in inject_vmce()

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: vMCE emulation
Liu, Jinsong [Wed, 26 Sep 2012 10:04:00 +0000 (12:04 +0200)]
x86: vMCE emulation

This patch provides virtual MCE support to guest. It emulates a simple
and clean MCE MSRs interface to guest by faking caps to guest if needed
and masking caps if unnecessary:
1. Providing a well-defined MCG_CAP to guest, filter out un-necessary
   caps and provide only guest needed caps;
2. Disabling MCG_CTL to avoid model specific;
3. Sticking all 1's to MCi_CTL to guest to avoid model specific;
4. Enabling CMCI cap but never really inject to guest to prevent
   polling periodically;
5. Masking MSCOD field of MCi_STATUS to avoid model specific;
6. Keeping natural semantics by per-vcpu instead of per-domain
   variables;
7. Using bank1 and reserving bank0 to work around 'bank0 quirk' of some
   very old processors;
8. Cleaning some vMCE# injection logic which shared by Intel and AMD
   but useless under new vMCE implement;
9. Keeping compatilbe w/ old xen version which has been backported to
   SLES11 SP2, so that old vMCE would not blocked when migrate to new
   vMCE;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
- make printing consistent (and non-exploitable)
- fix return values of intel_mce_{rd,wr}msr() for out of range banks
- miscellaneous cleanup

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: check remote MMIO remap permissions
Daniel De Graaf [Wed, 26 Sep 2012 09:56:07 +0000 (11:56 +0200)]
x86: check remote MMIO remap permissions

When a domain is mapping pages from a different pg_owner domain, the
iomem_access checks are currently only applied to the pg_owner domain,
potentially allowing a domain with a more restrictive iomem_access
policy to have the pages mapped into its page tables. To catch this,
also check the owner of the page tables. The current domain does not
need to be checked because the ability to manipulate a domain's page
tables implies full access to the target domain, so checking that
domain's permission is sufficient.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: slightly improve stack trace on debug builds
Jan Beulich [Wed, 26 Sep 2012 09:53:38 +0000 (11:53 +0200)]
x86: slightly improve stack trace on debug builds

As was rather obvious from crashes recently happening in stage testing,
the debug hypervisor, in that special case, has a drawback compared to
the non-debug one: When a call through a bad pointer happens, there's
no frame, and the top level (and frequently most important for
analysis) stack entry would get skipped:

(XEN) ----[ Xen-4.3-unstable  x86_64  debug=y  Not tainted ]----
(XEN) CPU:    1
(XEN) RIP:    e008:[<0000000000000000>] ???
(XEN) RFLAGS: 0000000000010046   CONTEXT: hypervisor
(XEN) rax: 0000000000000008   rbx: 0000000000000001   rcx: 0000000000000003
(XEN) rdx: 0000003db54eb700   rsi: 7fffffffffffffff   rdi: 0000000000000001
(XEN) rbp: ffff8302357e7ee0   rsp: ffff8302357e7e58   r8:  0000000000000000
(XEN) r9:  000000000000003e   r10: ffff8302357e7f18   r11: ffff8302357e7f18
(XEN) r12: ffff8302357ee340   r13: ffff82c480263980   r14: ffff8302357ee3d0
(XEN) r15: 0000000000000001   cr0: 000000008005003b   cr4: 00000000000026f0
(XEN) cr3: 00000000bf473000   cr2: 0000000000000000
(XEN) ds: 0000   es: 0000   fs: 0000   gs: 0000   ss: 0000   cs: e008
(XEN) Xen stack trace from rsp=ffff8302357e7e58:
(XEN)    ffff82c4801a3d05 ffff8302357eca70 0000000800000020 ffff82c4802ead60
(XEN)    0000000000000001 ffff8302357e7ea0 ffff82c48016bf07 0000000000000000
(XEN)    0000000000000000 ffff8302357e7ee0 fffff830fffff830 0000000000000046
(XEN)    ffff8302357e7f18 ffff82c480263980 ffff8302357e7f18 0000000000000000
(XEN)    0000000000000000 ffff8302357e7f10 ffff82c48015c2be 8302357dc0000fff
...
(XEN) Xen call trace:
(XEN)    [<0000000000000000>] ???
(XEN)    [<ffff82c48015c2be>] idle_loop+0x6c/0x7a
(XEN)
(XEN) Pagetable walk from 0000000000000000:

Since the bad pointer is being printed anyway (as part of the register
state), replace it with the top of stack value in such a case.

With the introduction of is_active_kernel_text(), use it also at the
(few) other suitable places (I intentionally didn't replace the use in
xen/arch/arm/mm.c - while it would be functionally correct, the
dependency on system_state wouldn't be from an abstract perspective).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: clean up interrupt stub generation
Jan Beulich [Wed, 26 Sep 2012 09:52:03 +0000 (11:52 +0200)]
x86: clean up interrupt stub generation

Apart from moving some code that is only used here from the header file
to the actual source one, this also
- moves interrupt[] into .init.data,
- prevents generating (unused) stubs for vectors below
  FIRST_DYNAMIC_VECTOR, and
- shortens and sanitizes the names of the stubs.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: slightly streamline __prepare_to_wait() inline assembly
Jan Beulich [Wed, 26 Sep 2012 09:51:27 +0000 (11:51 +0200)]
x86: slightly streamline __prepare_to_wait() inline assembly

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: use compiler visible "add" instead of inline assembly "or" in get_cpu_info()
Jan Beulich [Wed, 26 Sep 2012 09:49:56 +0000 (11:49 +0200)]
x86: use compiler visible "add" instead of inline assembly "or" in get_cpu_info()

This follows the same idea as the previous patch, just that the effect
is much more visible here: With a half-way [dr]ecent gcc this reduced
.text size by over 12k for me.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: enhance rsp-relative calculations
Jan Beulich [Wed, 26 Sep 2012 09:48:21 +0000 (11:48 +0200)]
x86: enhance rsp-relative calculations

The use of "or" in GET_CPUINFO_FIELD so far wasn't ideal, as it doesn't
lend itself to folding this operation with a possibly subsequent one
(e.g. the well known mov+add=lea conversion). Split out the sub-
operations, and shorten assembly code slightly with this.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agodocs: network network diagrams for the wiki (figs)
Ian Jackson [Tue, 25 Sep 2012 17:45:04 +0000 (18:45 +0100)]
docs: network network diagrams for the wiki (figs)

Add the figs in hg as well as git.  Sorry (again)!

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agodocs: network network diagrams for the wiki (Makefile)
Ian Jackson [Tue, 25 Sep 2012 17:39:39 +0000 (18:39 +0100)]
docs: network network diagrams for the wiki (Makefile)

Add the Makefile in hg as well as git.  Sorry.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agodocs: network diagrams for the wiki
Ian Jackson [Tue, 25 Sep 2012 17:31:20 +0000 (18:31 +0100)]
docs: network diagrams for the wiki

We provide two new diagrams
  docs/figs/network-{bridge,basic}.fig
which are converted to pngs by the Makefiles and intended for
consumption by http://wiki.xen.org/wiki/Xen_Networking.

This is perhaps not the ideal location for this source code but we
don't have a better one.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools: bump SONAMEs for changes during 4.2 development cycle.
Ian Campbell [Tue, 25 Sep 2012 12:40:00 +0000 (13:40 +0100)]
tools: bump SONAMEs for changes during 4.2 development cycle.

We mostly did this as we went along, only a couple of minor number
bumps were missed http://marc.info/?l=xen-devel&m=134366054929255&w=2:
 - Bumped libxl from 1.0.0 -> 1.0.1
 - Bumped libxenstore from 3.0.1 -> 3.0.2

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxl: resume the domain on suspend failure
Bastian Blank [Tue, 25 Sep 2012 10:03:51 +0000 (11:03 +0100)]
xl: resume the domain on suspend failure

The MUST macro calls exit(3) on failure but we need to cleanup and
resume.

Signed-off-by: Bastian Blank <waldi@debian.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agopygrub: always append --args
Olaf Hering [Tue, 25 Sep 2012 10:03:51 +0000 (11:03 +0100)]
pygrub: always append --args

If a bootloader entry in menu.lst has no additional kernel command line
options listed and the domU.cfg has 'bootargs="--args=something"' the
additional arguments from the config file are not passed to the kernel.
The reason for that incorrect behaviour is that run_grub appends arg
only if the parsed config file has arguments listed.

Fix this by appending args from image section and the config file separatly.
To avoid adding to a NoneType initialize grubcfg['args'] to an empty string.
This does not change behaviour but simplifies the code which appends the
string.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agox86/S3: add cache flush on secondary CPUs before going to sleep
Ben Guthro [Tue, 25 Sep 2012 06:38:14 +0000 (08:38 +0200)]
x86/S3: add cache flush on secondary CPUs before going to sleep

Secondary CPUs, between doing their final memory writes (particularly
updating cpu_initialized) and getting a subsequent INIT, may not write
back all modified data. The INIT itself then causes those modifications
to be lost, so in the cpu_initialized case the CPU would find itself
already initialized, (intentionally) entering an infinite loop instead
of actually coming online.

Signed-off-by: Ben Guthro <ben@guthro.net>
Make acpi_dead_idle() call default_dead_idle() rather than duplicating
the logic there.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: fix MWAIT-based idle driver for CPUs without ARAT
Jan Beulich [Tue, 25 Sep 2012 06:36:33 +0000 (08:36 +0200)]
x86: fix MWAIT-based idle driver for CPUs without ARAT

lapic_timer_{on,off} need to get initialized in this case. This in turn
requires getting HPET broadcast setup to be carried out earlier (and
hence preventing double initialization there).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
13 years agox86: enable VIA CPU support
Jan Beulich [Fri, 21 Sep 2012 15:02:46 +0000 (17:02 +0200)]
x86: enable VIA CPU support

Newer VIA CPUs have both 64-bit and VMX support. Enable them to be
recognized for these purposes, at once stripping off any 32-bit CPU
only bits from the respective CPU support file, and adding 64-bit ones
found in recent Linux.

This particularly implies untying the VMX == Intel assumption in a few
places.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: eliminate code affecting only 64-bit-incapable CPUs
Jan Beulich [Fri, 21 Sep 2012 13:20:21 +0000 (15:20 +0200)]
x86: eliminate code affecting only 64-bit-incapable CPUs

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agoprintk: prefer %#x et at over 0x%x
Jan Beulich [Fri, 21 Sep 2012 12:25:12 +0000 (14:25 +0200)]
printk: prefer %#x et at over 0x%x

Performance is not an issue with printk(), so let the function do
minimally more work and instead save a byte per affected format
specifier.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: introduce MWAIT-based, ACPI-less CPU idle driver
Jan Beulich [Fri, 21 Sep 2012 11:47:18 +0000 (13:47 +0200)]
x86: introduce MWAIT-based, ACPI-less CPU idle driver

This is a port of Linux'es intel-idle driver serving the same purpose.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agocpuidle: remove unused latency_ticks member
Jan Beulich [Fri, 21 Sep 2012 11:45:08 +0000 (13:45 +0200)]
cpuidle: remove unused latency_ticks member

... and code used only for initializing it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agointroduce guest_handle_for_field()
Jan Beulich [Thu, 20 Sep 2012 11:31:19 +0000 (13:31 +0200)]
introduce guest_handle_for_field()

This helper turns a field of a GUEST_HANDLE in a GUEST_HANDLE.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
13 years agoACPI: move tables.c fully into .init.*
Jan Beulich [Thu, 20 Sep 2012 07:22:55 +0000 (09:22 +0200)]
ACPI: move tables.c fully into .init.*

The only non-init item was the space reserved for the initial tables,
but we can as well dynamically allocate that array.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: tighten checks in XEN_DOMCTL_memory_mapping handler
Jan Beulich [Thu, 20 Sep 2012 07:21:53 +0000 (09:21 +0200)]
x86: tighten checks in XEN_DOMCTL_memory_mapping handler

Properly checking the MFN implies knowing the physical address width
supported by the platform, so to obtain this consistently the
respective code gets moved out of the MTRR subdir.

Btw., the model specific workaround in that code is likely unnecessary
- I believe those CPU models don't support 64-bit mode. But I wasn't
able to formally verify this, so I preferred to retain that code for
now.

But domctl code here also was lacking other error checks (as was,
looking at it again from that angle) the XEN_DOMCTL_ioport_mapping one.
Besides adding the missing checks, printing is also added for the case
where revoking access permissions didn't work (as that may have
implications for the host operator, e.g. wanting to not pass through
affected devices to another guest until the one previously using them
did actually die).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/IO-APIC: streamline level ack/end handling
Jan Beulich [Thu, 20 Sep 2012 07:20:30 +0000 (09:20 +0200)]
x86/IO-APIC: streamline level ack/end handling

Rather than evaluating "ioapic_ack_new" on each invocation, and
considering that the two methods really have almost no code in common,
split the handlers.

While at it, also move ioapic_ack_{new,forced} into .init.data
(eliminating the single non-__init reference to the former).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>