]> xenbits.xensource.com Git - xen.git/log
xen.git
13 years agosvm: Do not intercept RDTSC(P) when TSC scaling is supported by hardware
Boris Ostrovsky [Wed, 25 Apr 2012 12:53:14 +0000 (13:53 +0100)]
svm: Do not intercept RDTSC(P) when TSC scaling is supported by hardware

When running in TSC_MODE_ALWAYS_EMULATE mode on processors that
support TSC scaling we don't need to intercept RDTSC/RDTSCP
instructions.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Acked-by: Wei Huang <wei.huang2@amd.com>
Tested-by: Wei Huang <wei.huang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoMerge
Ian Jackson [Wed, 25 Apr 2012 11:00:08 +0000 (12:00 +0100)]
Merge

13 years agolibxl, configure: print a warning if flex/bison are needed
Roger Pau Monne [Wed, 25 Apr 2012 10:44:09 +0000 (11:44 +0100)]
libxl, configure: print a warning if flex/bison are needed

This patch adds better support for both Flex and Bison, which might
be needed to compile libxl. Now configure script sets BISON and FLEX
Makefile vars if bison and flex are found, but doesn't complain if
they are not found.

Also, added some Makefile soccery to print a warning message if
Bison or Flex are needed but not found.

[ Improved the warning message slightly. -iwj ]

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: set domain scheduling parameters while creating the domU
Dieter Bloms [Wed, 25 Apr 2012 10:38:26 +0000 (11:38 +0100)]
libxl: set domain scheduling parameters while creating the domU

the domain specific scheduling parameters like cpu_weight, cap, slice, ...
will be set during creating the domain, so this parameters can be defined
in the domain config file

[ Improved the documentation wording slightly. -iwj ]

Signed-off-by: Dieter Bloms <dieter@bloms.de>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86-64: Fix memory hotplug epfn upper limit test for updating the compat M2P table
Malcolm Crossley [Wed, 25 Apr 2012 10:35:56 +0000 (12:35 +0200)]
x86-64: Fix memory hotplug epfn upper limit test for updating the compat M2P table

The epfn is being compared to (RDWR_COMPAT_MPT_VIRT_END -
RDWR_COMPAT_MPT_VIRT_START) without a 2 bit shift, resulting in the
epfn being compared to the size of the RDWR_COMPAT_MPT table in bytes
instead of the maximum page frame number that the RDWR_COMPAT_MPT
table can map.

Signed-off-by: Malcolm Crossley <malcolm.crossley@citrix.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agolibxl: use libxl_domain_config_init and not memset 0
Ian Campbell [Wed, 25 Apr 2012 10:35:42 +0000 (11:35 +0100)]
libxl: use libxl_domain_config_init and not memset 0

I missed a couple of memsets in 25237:31489be80c51, we need to use
libxl_domain_config_init everywhere and not memset since not all fields are
initialised to zero now (the type field in particular). This fixes an abort
with "xl list <dom>" for a specific domain due to assert(type == -1) in
libxl_domain_build_info_init_type().

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools/firmware: pass PYTHON as an env var to sub-makes in this subtree
Christoph Egger [Wed, 25 Apr 2012 10:21:25 +0000 (11:21 +0100)]
tools/firmware: pass PYTHON as an env var to sub-makes in this subtree

This fixes the Seabios build on platforms where just "python" is not
correct, which includes NetBSD.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: passthrough: avoid passing through devices not owned by pciback
Xudong Hao [Wed, 25 Apr 2012 10:18:45 +0000 (11:18 +0100)]
libxl: passthrough: avoid passing through devices not owned by pciback

This patch makes sure the passthrough device belongs to pciback before
allow them passthrough to the guest.  There are still many other
checks missing.

xm terminates the guest startup process when this type of condition is
found.  This patch just allows the guest to continue to boot but with
no device passthrough.

Signed-off-by: Allen Kay <allen.m.kay@intel.com>
Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxc: Document the sharing interface
Andres Lagar-Cavilla [Tue, 24 Apr 2012 18:06:42 +0000 (19:06 +0100)]
libxc: Document the sharing interface

(also make note about AMD support's experimental status)

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86/mem_sharing: Clean up debugging calls
Andres Lagar-Cavilla [Tue, 24 Apr 2012 18:05:08 +0000 (19:05 +0100)]
x86/mem_sharing: Clean up debugging calls

- Remove debug_mfn from the user-space interface
- Clean up errno codes

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: provide libxl_domain_config_init.
Ian Campbell [Wed, 4 Apr 2012 09:51:11 +0000 (10:51 +0100)]
libxl: provide libxl_domain_config_init.

Currently this struct is too complicated for the IDL to represent (arrays) so
for now implement by hand.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
13 years ago[v2] xl: Don't require a config file for cpupools
George Dunlap [Tue, 24 Apr 2012 17:51:56 +0000 (18:51 +0100)]
[v2] xl: Don't require a config file for cpupools

Since the key information can be fairly simply put on the command-line,
there's no need to require an actual config file.

Also improve the help to cross-reference the xlcpupool.cfg manpage.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxl, cpupools: Create empty pool if no cpus are specified
George Dunlap [Tue, 24 Apr 2012 17:51:56 +0000 (18:51 +0100)]
xl, cpupools: Create empty pool if no cpus are specified

Currently, if "xl cpupool-create" is called with no cpus configured,
xl will choose a cpu at random from the list of unassigned cpus, and
if no unassigned cpus are available, it will fail.

This seems to me to be a poor interface.  For one, it makes it impossible
to create an empty cpupool using the xl command-line, except by creating
a pool and then removing the cpus from it.  For two, I don't think assigning
a random cpu is a feature; it's not unreasonable for the user to specify
which cpus to add to which pools.

This patch changes the behavior of "xl cpupool-create" to create an empty
pool if no cpus are specified.  I believe this interface to be more expected
and more script-friendly.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: make most libxl_FOO_path() functions internal.
Ian Campbell [Thu, 12 Apr 2012 08:12:58 +0000 (09:12 +0100)]
libxl: make most libxl_FOO_path() functions internal.

Only libxl_xen_config_dir_path and libxl_lock_dir_path are used outside the
library. Also bindir, sbindir, sharedir and xenpagingdir appeared to be
completely unused so nuke them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoautoconf: use python-config when present, if not switch to distuti
Roger Pau Monne [Tue, 24 Apr 2012 17:42:24 +0000 (18:42 +0100)]
autoconf: use python-config when present, if not switch to distuti

Use python-config utility when possible, and if it is not present switch to
distutils.

Should fix the bug reported by Olaf Hering on SuSE.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: mark internal functions hidden
Ian Campbell [Tue, 24 Apr 2012 17:40:15 +0000 (18:40 +0100)]
libxl: mark internal functions hidden

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 agotools: Fix FPU save area definition in xen-hvmctx
Tim Deegan [Tue, 24 Apr 2012 17:39:18 +0000 (18:39 +0100)]
tools: Fix FPU save area definition in xen-hvmctx

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools/build: fix distclean
Roger Pau Monne [Tue, 24 Apr 2012 17:20:07 +0000 (18:20 +0100)]
tools/build: fix distclean

distclean removed config/Tools.mk which was needed by tools/Rules.mk, thus
preventing distclean from running properly in the tools directory. This patch
only enforces config/Tools.mk presence when not performing a clean/distclean
target

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools: xen-access: Check return values and clean up on errors during init
Aravindh Puthiyaparambil [Tue, 24 Apr 2012 17:17:51 +0000 (18:17 +0100)]
tools: xen-access: Check return values and clean up on errors during init

Check the return values of the libxc mem_access calls.  Free allocated
structures (platform_info, domain_info) on errors during
initialization and exit.  Unbind VIRQ, close event channel and
connection to Xen on errors during initialization

Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools/blktap: fix build error w/o MEMSHR
Christoph Egger [Tue, 24 Apr 2012 17:16:30 +0000 (18:16 +0100)]
tools/blktap: fix build error w/o MEMSHR

Do not include memshr.h when MEMSHR is not defined.
Fixes build error when MEMSHR is disabled.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: fix rtc_timeoffset setting
Lin Ming [Tue, 24 Apr 2012 16:45:45 +0000 (17:45 +0100)]
libxl: fix rtc_timeoffset setting

libxl__domain_build_info_setdefault may be called several times,
so rtc_timeoffset can't be setted in it.

Move rtc_timeoffset setting logic to libxl__build_pre.

Reported-by: Teck Choon Giam <giamteckchoon@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Lin Ming <mlin@ss.pku.edu.cn>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---
 tools/libxl/libxl_create.c |    9 ---------
 tools/libxl/libxl_dom.c    |   17 +++++++++++++++--
 2 files changed, 15 insertions(+), 11 deletions(-)

13 years agolibxl: Remove libxl_tmem_destroy and associated xl command
Ian Campbell [Mon, 16 Apr 2012 15:00:47 +0000 (16:00 +0100)]
libxl: Remove libxl_tmem_destroy and associated xl command

Dan Magenheimer explains in <4c2f7fca-dda2-4598-aaab-3a6a3fe532cd@default>:

I think the tmem_destroy functionality pre-dates the
existence of tmem "freeable" memory* and was a way for
a toolset to force the hypervisor to free up the hypervisor
memory used by some or all ephemeral tmem pools.  Once the
tmem allocation/free process was directly linked into
alloc_heap_pages() in the hypervisor (see call to
tmem_relinquish_pages()), this forcing function was
no longer needed.

So, bottom line, I *think* it can be ripped out, or at least
for now removed from the definition of the stable xl API/UI.
The libxl.c routine libxl_tmem_destroy() could also be
removed if you like, but I guess I'd prefer to leave the
lower level droppings in xc.c and in the hypervisor in case
I am misremembering.

Accordingly remove this interface from libxl and xl but don't touch libxc or
the hypervisor.

This is the only libxl_tmem_* function which might potentially have required
conversion to be asynchronous and which therefore might have been a potential
API stability concern.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>
13 years agoautoconf: add ovmf, rombios and seabios and configure options
Roger Pau Monne [Tue, 24 Apr 2012 16:28:37 +0000 (17:28 +0100)]
autoconf: add ovmf, rombios and seabios and configure options

Move this hardcoded options from Config.mk to config/Tools.mk and add the
appropiate configure options.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxl: add "check-xl-vif-parse" test script
Mathieu Gagne [Tue, 24 Apr 2012 16:12:22 +0000 (17:12 +0100)]
xl: add "check-xl-vif-parse" test script

This test script runs "xl -N network-attach 0 <foobar>" against various
rate syntax and checks that the output is as expected.

[ Added entries to .hgignore and .gitignore for tools/libxl/tmp.* -iwj ]

Signed-off-by: Mathieu Gagne <mgagne@iweb.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxl: add support for vif rate limiting
Mathieu Gagne [Tue, 24 Apr 2012 16:09:22 +0000 (17:09 +0100)]
xl: add support for vif rate limiting

The `rate` keyword specifies the rate at which the outgoing traffic
will be limited to. The default if this keyword is not specified
is unlimited.

The `rate` keyword supports an optional replenishment interval
parameter for specifying the granularity of credit replenishment.
It determines the frequency at which the vif transmission credit
is replenished. The default interval is 50ms.

For example:

        'rate=10Mb/s'
        'rate=250KB/s'
        'rate=1MB/s@20ms'

Signed-off-by: Mathieu Gagne <mgagne@iweb.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: use qemu-xen with PV guests by default
Stefano Stabellini [Tue, 24 Apr 2012 14:48:50 +0000 (15:48 +0100)]
libxl: use qemu-xen with PV guests by default

qemu-xen offers better disk performances than qemu-xen-traditional
because it supports Linux native AIO: use it for PV guests if it is
available.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxc: Replace alloca() with mmap() for large array sizes
Aravindh Puthiyaparambil [Tue, 24 Apr 2012 13:31:36 +0000 (14:31 +0100)]
libxc: Replace alloca() with mmap() for large array sizes

Replace alloca() with mmap() for array sizes greater than a page in
xc_linux_osdep.c.

When mapping in large amounts of pages (in the GB range) from a guest
in to Dom0 using xc_map_foreign_bulk(), a segfault occurs in the libxc
client application. This is because the pfn array in
linux_privcmd_map_foreign_bulk() is being allocated using alloca() and
the subsequent memcpy causes the stack to blow. This patch replaces
the alloca() with mmap() for pfn array sizes greater than a page.

Fix an error print with the correct function name.

Do the same for the map array in linux_gnttab_grant_map()

Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoMakefile: Some updates to uninstall
Fabio Fantoni [Mon, 23 Apr 2012 08:26:55 +0000 (10:26 +0200)]
Makefile: Some updates to uninstall

Signed-off-by: Fabio Fantoni <fabio.fantoni@heliman.it>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
13 years agox86: restore vcpu_destroy_pagetables() call on HVM domain teardown.
Tim Deegan [Fri, 20 Apr 2012 08:49:06 +0000 (09:49 +0100)]
x86: restore vcpu_destroy_pagetables() call on HVM domain teardown.

HVM vcpus that are using shadow pagetables have valid guest_table fields,
which need to be tidied up on domain teardown.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Tim Deegan <tim@xen.org>
13 years agovmx: Allow software (user defined) interrupts to be injected in to the guest
Aravindh Puthiyaparambil [Fri, 20 Apr 2012 08:43:46 +0000 (09:43 +0100)]
vmx: Allow software (user defined) interrupts to be injected in to the guest

If xc_hvm_inject_trap() is called on a software (user defined)
interrupt, it causes the guest to crash with a vmentry failure. The
following patch fixes this issue.

Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoClean up convoluted hvm_inject_exception() logic.
Keir Fraser [Fri, 20 Apr 2012 08:33:35 +0000 (09:33 +0100)]
Clean up convoluted hvm_inject_exception() logic.

Signed-off-by: Keir Fraser <keir@xen.org>
13 years agox86/mm: fix parens in mm lock level check
Tim Deegan [Thu, 19 Apr 2012 14:30:44 +0000 (15:30 +0100)]
x86/mm: fix parens in mm lock level check

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86/mm: BUG() rather than panic() on mm lock order violations
Tim Deegan [Wed, 18 Apr 2012 15:43:13 +0000 (16:43 +0100)]
x86/mm: BUG() rather than panic() on mm lock order violations

That gives us a backtrace showing where the bad lock happens.

Reported-by: Andres Lagar-Cavilla <andres@lagarcavilla.org
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86/mm/shadow: enclose an OOS function in the proper conditional ifdef
Andres Lagar-Cavilla [Wed, 18 Apr 2012 15:49:55 +0000 (16:49 +0100)]
x86/mm/shadow: enclose an OOS function in the proper conditional ifdef

Otherwise compilation fails if the feature is disabled.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-By: Gianluca Guida <gianluca.guida@citrix.com>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86/mm/sharing: Clean ups for relinquishing shared pages on destroy
Andres Lagar-Cavilla [Wed, 18 Apr 2012 12:38:47 +0000 (13:38 +0100)]
x86/mm/sharing: Clean ups for relinquishing shared pages on destroy

When a domain is destroyed, its pages are freed in relinquish_resources in a
preemptible mode, in the context of a synchronous domctl.

P2m entries pointing to shared pages are, however, released during p2m cleanup
in an RCU callback, and in non-preemptible mode.

This is an O(n) operation for a very large n, which may include actually
freeing shared pages for which the domain is the last holder.

To improve responsiveness, move this operation to the preemtible portion of
domain destruction, during the synchronous domain_kill hypercall. And remove
the bulk of the work from the RCU callback.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agomem_access: fix setting default mem_access type
Aravindh Puthiyaparambil [Wed, 18 Apr 2012 12:38:47 +0000 (13:38 +0100)]
mem_access: fix setting default mem_access type

When xc_hvm_set_mem_access(xch, domain_id, default_access, ~0ull, 0)
is called, first_pfn=~0ull is a hint to HVMOP_set_mem_access as to
what the default mem_access type is for the domain. This call was
failing because it was gated by the memory range check in the
HVMOP_set_mem_access case statement in do_hvm_op(). The following
patch fixes this issue.

Signed-off-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
---
 xen/arch/x86/hvm/hvm.c |  5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

13 years agox86/mm: Fix locking on hap enable failure
Andres Lagar-Cavilla [Wed, 18 Apr 2012 12:38:47 +0000 (13:38 +0100)]
x86/mm: Fix locking on hap enable failure

If enabling hap fails due to out of memory, the locking on the clean up path is
broken.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86/mem_event: Fix foreign domain flag in grab_slot
Andres Lagar-Cavilla [Wed, 18 Apr 2012 12:38:47 +0000 (13:38 +0100)]
x86/mem_event: Fix foreign domain flag in grab_slot

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxl: xl network-attach -N (dry run) option
Mathieu Gagne [Tue, 17 Apr 2012 18:13:52 +0000 (19:13 +0100)]
xl: xl network-attach -N (dry run) option

Add dryrun for testing and debugging purposes.

Signed-off-by: Mathieu Gagne <mgagne@iweb.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
13 years agoxl: cleanup indentation
Mathieu Gagne [Tue, 17 Apr 2012 18:13:19 +0000 (19:13 +0100)]
xl: cleanup indentation

Signed-off-by: Mathieu Gagne <mgagne@iweb.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
13 years agolibxl: Query VNC listening port through QMP
Anthony PERARD [Tue, 17 Apr 2012 17:22:49 +0000 (18:22 +0100)]
libxl: Query VNC listening port through QMP

Currently `xl vncviewer $dom` does not work because the VNC port is not
registered in xenstore when using qemu-upstream. This patch attempted to fix
this.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoMerge
Ian Jackson [Tue, 17 Apr 2012 17:19:12 +0000 (18:19 +0100)]
Merge

13 years agotools/libvchan: Remove unwanted debugging code
Olaf Hering [Tue, 17 Apr 2012 17:18:49 +0000 (18:18 +0100)]
tools/libvchan: Remove unwanted debugging code

-O2 -Wall -Werror triggers these warnings:

io.c: In function 'do_send':
io.c:196: warning: ignoring return value of 'writev', declared with attribute warn_unused_result
io.c: In function 'do_recv':
io.c:287: warning: ignoring return value of 'writev', declared with attribute warn_unused_result

writev to -1 will always fail, silence the warning by removing the offending
(disabled) debug code.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86-64: fix updating of UREGS_rip when converting sysenter to #GP
Jan Beulich [Tue, 17 Apr 2012 15:17:05 +0000 (17:17 +0200)]
x86-64: fix updating of UREGS_rip when converting sysenter to #GP

(I spotted this copy-and-paste mistake only when backporting c/s
25200:80f4113be500 to 4.1 and 4.0.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86: suppress warning messages on IO-APIC-less systems
Jan Beulich [Tue, 17 Apr 2012 13:37:05 +0000 (15:37 +0200)]
x86: suppress warning messages on IO-APIC-less systems

Each call to mp_register_gsi() so far produced two warnings (about not
being able to find the corresponding IO-APIC pin).

However, we should use the provided information for setting the ELCR
correctly (we might want to even do this when there is an IO-APIC, if
was absolutely certain that all machines really have this register
[and specifically not some other device at the two I/O ports in
question]). It is in any case questionable that we allow Dom0 to set
this register - it could particularly be the interrupt of a plug-in
serial port card that might not work due to this. The problem is that
all Dom0 kernels to date do so, hence we can't simply #GP on such an
access (which would be the result if we disallowed access to the port
as we should have done from the beginning).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/IO-APIC: adjust an otherwise pretty useless message
Jan Beulich [Tue, 17 Apr 2012 13:36:34 +0000 (15:36 +0200)]
x86/IO-APIC: adjust an otherwise pretty useless message

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/ioapic: Add register level checks to detect bogus io-apic entries
Suresh Siddha [Tue, 17 Apr 2012 13:35:39 +0000 (15:35 +0200)]
x86/ioapic: Add register level checks to detect bogus io-apic entries

With the recent changes to clear_IO_APIC_pin() which tries to
clear remoteIRR bit explicitly, some of the users started to see
"Unable to reset IRR for apic .." messages.

Close look shows that these are related to bogus IO-APIC entries
which returns all 1s for their io-apic registers. And the
above mentioned error messages are benign. But kernel should
have ignored such io-apic's in the first place.

Check if register 0, 1, 2 of the listed io-apic are all 1s and
ignore such io-apic.

[original Linux patch:]
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
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-64: fix #GP generation in assembly code
Jan Beulich [Tue, 17 Apr 2012 13:33:53 +0000 (15:33 +0200)]
x86-64: fix #GP generation in assembly code

When guest use of sysenter (64-bit PV guest) or syscall (32-bit PV
guest) gets converted into a GP fault (due to no callback having got
registered), we must
- honor the GP fault handler's request the keep enabled or mask event
  delivery
- not allow TBF_EXCEPTION to remain set past the generation of the
  (guest) exception in the vCPU's trap_bounce.flags, as that would
  otherwise allow for the next exception occurring in guest mode,
  should it happen to get handled in Xen itself, to nevertheless get
  bounced to the guest kernel.

Also, just like compat mode syscall handling already did, native mode
sysenter handling should, when converting to #GP, subtract 2 from the
RIP present in the frame so that the guest's GP fault handler would
see the fault pointing to the offending instruction instead of past it.

Finally, since those exception generating code blocks needed to be
modified anyway, convert them to make use of UNLIKELY_{START,END}().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agognttab: remove pointless NULL check
Jan Beulich [Tue, 17 Apr 2012 13:05:05 +0000 (15:05 +0200)]
gnttab: remove pointless NULL check

Domains in the domain hash (and hence locatable via the usual lookup
functions) can't have a NULL grant table pointer; no other function
performs such a check, so remove it from gnttab_prepare_for_transfer()
for consistency.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agoxsm/flask: clean up auditing output
Daniel De Graaf [Tue, 17 Apr 2012 07:31:07 +0000 (08:31 +0100)]
xsm/flask: clean up auditing output

The audit data for normal MMU updates was incorrectly using the RANGE
type which presented the data badly in audit messages; add a MEMORY
type for this showing the correct names for the fields. This patch
also shows the target domain in event channel mapping checks to make
debugging those denials easier.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
13 years agofix build error when enabling lock profile
Yang Zhang [Tue, 17 Apr 2012 07:30:27 +0000 (08:30 +0100)]
fix build error when enabling lock profile

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoFix save/restore of guest PAT table in HAP paging mode.
Gianluca Guida [Tue, 17 Apr 2012 07:29:26 +0000 (08:29 +0100)]
Fix save/restore of guest PAT table in HAP paging mode.

HAP paging mode guests use direct MSR read/write into the VMCS/VMCB
for the guest PAT table, while the current save/restore code was
accessing only the pat_cr field in hvm_vcpu, used when intercepting
the MSR mostly in shadow mode (the Intel scenario is a bit more
complicated).  This patch fixes this issue creating a new couple of
hvm_funcs, get/set_guest_pat, that access the right PAT table based on
the paging mode and guest configuration.

Signed-off-by: Gianluca Guida <gianluca.guida@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Keir Fraser <keir@xen.org>
13 years agox86/cpuidle: do not flush cache unless entering C3
Wei Wang [Mon, 16 Apr 2012 11:05:28 +0000 (13:05 +0200)]
x86/cpuidle: do not flush cache unless entering C3

Nor is there a need to disable bus master arbitration in that case.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Modified-by: Zhang, Yang Z <yang.z.zhang@intel.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agotools: Revert c/s 25150:b490ef93bad7 tools/libfsimage: include Rules.mk first
George Dunlap [Fri, 13 Apr 2012 16:13:01 +0000 (17:13 +0100)]
tools: Revert c/s 25150:b490ef93bad7 tools/libfsimage: include Rules.mk first

tools/libfsimage/Rules.mk relies on having certain variables set already; if
they're not set, the definitions dont' work right.  The result was a bunch
of empty files and pygrub failing with an uninformative error message.

It's likely that this didn't cause anyone problems becasue changing the
Makefiles didn't cause a re-build; building from a fresh repo results in
completely empty filesystem plugin binaries.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxen: Fix failure paths for xentrace
George Dunlap [Thu, 12 Apr 2012 13:01:27 +0000 (14:01 +0100)]
xen: Fix failure paths for xentrace

Problems this addresses:
* After the allocation of t_info fails, the path the code takes tries
to free t_info.  Jump past that part instead.
* The failure code assumes that unused data is zero; but the structure
is never initialized.  Zero the structure before using it.
* The t_info pages are shared with dom0 before we know that the whole
operation will succeed, and not un-shared afterwards.  Don't share the
pages until we know the whole thing will succeed.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agotools/blktap2: fix 'make clean'
Tim Deegan [Thu, 5 Apr 2012 10:24:26 +0000 (11:24 +0100)]
tools/blktap2: fix 'make clean'

Signed-off-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
13 years agox86: fix delta calculation in TSC deadline timer emulation
David Vrabel [Wed, 11 Apr 2012 15:49:45 +0000 (16:49 +0100)]
x86: fix delta calculation in TSC deadline timer emulation

In the virtual LAPIC, correct the delta calculation when emulating the
TSC deadline timer.

Without this fix, XenServer (which is based on Xen 4.1) does not work
when running as an HVM guest.  dom0 fails to boot because its timer
interrupts are very delayed (by several minutes in some cases).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agolibxl: provide STATE_AO_GC
Ian Jackson [Wed, 11 Apr 2012 13:14:18 +0000 (14:14 +0100)]
libxl: provide STATE_AO_GC

Provide a convenience macro for use in ao callback functions, and
document that it should be used.

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 agolibxl: Protect fds with CLOEXEC even with forking threads
Ian Jackson [Wed, 11 Apr 2012 13:14:18 +0000 (14:14 +0100)]
libxl: Protect fds with CLOEXEC even with forking threads

We introduce a new "carefd" concept, which relates to fds that we care
about not being inherited by long-lived children.

As yet we do not use this anywhere in libxl.  Until all locations in
libxl which make such fds are converted, libxl__postfork may not work
entirely properly.  If these locations do not use O_CLOEXEC (or use
calls for which there is no O_CLOEXEC) then multithreaded programs may
not work properly.

This introduces a new API call libxl_postfork_child_noexec which must
be called by applications which make long-running non-execing
children.  Add the appropriate call to xl's postfork function.

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 agolibxl: libxl_event.c:beforepoll_internal, REQUIRE_FDS
Ian Jackson [Wed, 11 Apr 2012 13:14:17 +0000 (14:14 +0100)]
libxl: libxl_event.c:beforepoll_internal, REQUIRE_FDS

Introduce definition and use of a new function-local macro REQUIRE_FDS
to avoid repeatedly spelling out which fds we are interested in.

We are going to introduce a new fd for the SIGCHLD self-pipe.

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 agolibxl: abolish libxl_ctx_postfork
Ian Jackson [Wed, 11 Apr 2012 13:14:17 +0000 (14:14 +0100)]
libxl: abolish libxl_ctx_postfork

libxl's task has become too complicated (particularly in the presence
of both forking and multithreading) to support reuse of the same
libxl_ctx after fork.

So abolish libxl_ctx_fork.  xl instead simply initialises a new
libxl_ctx.

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 agolibxl: include <_libxl_paths.h> in libxl_internal.h
Ian Jackson [Wed, 11 Apr 2012 13:14:16 +0000 (14:14 +0100)]
libxl: include <_libxl_paths.h> in libxl_internal.h

Ie, we permit general code in libxl direct access to the manifest
constants such as XEN_RUN_DIR.  This simplifies their use in (eg)
format strings.

This might be controversial because it will make it difficult to make
any of these runtime-configurable later without changing lots of use
sites.  But I don't think it's likely we'll want to do that.

For the moment, leave existing call sites of all the functions in
libxl_paths.c unchanged.  The simplified use arrangements can be used
in new code and when we update call sites for other reasons.

Also correct the dependencies in the Makefile so that _libxl_paths.h
is generated before anything that uses libxl_internal.h.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years agolibxl: Provide libxl_string_list_length
Ian Jackson [Wed, 11 Apr 2012 13:14:15 +0000 (14:14 +0100)]
libxl: Provide libxl_string_list_length

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 agolibxl: include <ctype.h> and introduce CTYPE helper macro
Ian Jackson [Wed, 11 Apr 2012 13:14:15 +0000 (14:14 +0100)]
libxl: include <ctype.h> and introduce CTYPE helper macro

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 agolibxl: Introduce some convenience macros
Ian Jackson [Wed, 11 Apr 2012 13:14:14 +0000 (14:14 +0100)]
libxl: Introduce some convenience macros

We introduce:
   <type> *GCNEW(<type> *var);
   <type> *GCNEW_ARRAY(<type> *var, ssize_t nmemb);
   <type> *GCREALLOC_ARRAY(<type> *var, size_t nmemb);
   char *GCSPRINTF(const char *fmt, ...);
   void LOG(<xtl_level_suffix>, const char *fmt, ...);
   void LOGE(<xtl_level_suffix>, const char *fmt, ...);
   void LOGEV(<xtl_level_suffix>, int errnoval, const char *fmt, ...);
all of which expect, in the calling context,
   libxl__gc *gc;

Most of these will find callers in subsequent patches.  The exceptions
are the orthogonally necessary LOGE and LOGEV, and GCREALLOC_ARRAY.

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 agolibxl: Make libxl__zalloc et al tolerate a NULL gc
Ian Jackson [Wed, 11 Apr 2012 13:14:14 +0000 (14:14 +0100)]
libxl: Make libxl__zalloc et al tolerate a NULL gc

Arrange that if we pass NULL as a gc, we simply don't register the
pointer.  This instantly gives us non-gc'ing but error-checking
versions of malloc, realloc, vasprintf, etc.

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 agolibxl: Crash (more sensibly) on malloc failure
Ian Jackson [Wed, 11 Apr 2012 13:14:13 +0000 (14:14 +0100)]
libxl: Crash (more sensibly) on malloc failure

Formally change the libxl memory allocation failure policy to "crash".

Previously we had a very uneven approach; much code assumed that
libxl__sprintf (for example) would never return NULL, but some code
was written more carefully.

We think it is unlikely that we will be able to make the library
actually robust against allocation failure (since that would be an
awful lot of never-tested error paths) and few calling environments
will be able to cope anyway.  So, instead, adopt the alternative
approach: provide allocation functions which never return null, but
will crash the whole process instead.

Consequently,
 - New noreturn function libxl__alloc_failed which may be used for
   printing a vaguely-useful error message, rather than simply
   dereferencing a null pointer.
 - libxl__ptr_add now returns void as it crashes on failure.
 - libxl__zalloc, _calloc, _strdup, _strndup, crash on failure using
   libxl__alloc_failed.  So all the code that uses these can no longer
   dereference null on malloc failure.

While we're at it, make libxl__ptr_add use realloc rather than
emulating it with calloc and free, and make it grow the array
exponentially rather than linearly.

Things left to do:
 - Remove a lot of now-spurious error handling.
 - Remove the ERROR_NOMEM error code.

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: Use PTHREAD_CFLAGS, _LDFLAGS, _LIBS
Ian Jackson [Wed, 11 Apr 2012 13:14:13 +0000 (14:14 +0100)]
tools: Use PTHREAD_CFLAGS, _LDFLAGS, _LIBS

Replace all literal occurrences of -lpthread and -pthread in Makefiles
by references to PTHREAD_CFLAGS, PTHREAD_LDFLAGS and PTHREAD_LIBS.
These are the new variables set by configure, and currently expand to
-pthread on the compilation and link lines as is required.

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 agolibxl: Use PTHREAD_CFLAGS, LDFLAGS, LIBS
Ian Jackson [Wed, 11 Apr 2012 13:14:12 +0000 (14:14 +0100)]
libxl: Use PTHREAD_CFLAGS, LDFLAGS, LIBS

This is going to be needed for pthread_atfork.  It is a mystery why it
hasn't been needed before.

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: Correct PTHREAD options in config/StdGNU.mk
Ian Jackson [Wed, 11 Apr 2012 13:14:11 +0000 (14:14 +0100)]
tools: Correct PTHREAD options in config/StdGNU.mk

It is not correct to say -lpthread.  The correct option is -pthread,
which may have sundry other effects on code generation etc.  It needs
to be passed both to compilation and linking.

Fix the configure test to test -pthread, and plumb the resulting flag
through to PTHREAD_{CFLAGS,LDFLAGS} in Tools.mk; also substitute
PTHREAD_LIBS (although this will currently always be empty).
Remove PTHREAD_LIBS setting from StdGNU.mk.

Fix the one user (libxc) to use PTHREAD_{CFLAGS,LDFLAGS} too.

There are still some other users in tree which pass -pthread or
-lpthread by adding it as a literal to their own compiler options.
These will be fixed in a later patch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years agolibxl: Fix leak of ctx->lock
Ian Jackson [Wed, 11 Apr 2012 13:14:10 +0000 (14:14 +0100)]
libxl: Fix leak of ctx->lock

A mutex created with pthread_mutex_init, like ctx->lock, may need to
be destroyed with pthread_mutex_destroy.

Also, previously, if libxl__init_recursive_mutex failed, the nascent
ctx would be leaked.  Add some comments which will hopefully make
these kind of mistakes less likely in future.

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 agolibxl: remove poller from list in libxl__poller_get
Roger Pau Monne [Wed, 11 Apr 2012 13:14:10 +0000 (14:14 +0100)]
libxl: remove poller from list in libxl__poller_get

Remove poller from the list once it has been requested.
Fixes a double-free bug.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years agolibxl: Fix eventloop_iteration over-locking
Ian Jackson [Wed, 11 Apr 2012 13:14:09 +0000 (14:14 +0100)]
libxl: Fix eventloop_iteration over-locking

eventloop_iteration's head comment says that it must be called with
the ctx locked exactly once, and this is indeed true, and it's done
correctly at both the call sites.

However, it takes out the lock an additional time itself.  This is
wrong because it prevents the unlocks around poll from being
effective.  This would mean that a multithreaded event-loop using
program might suffer from undesired blocking, as one thread trying to
enter libxl might end up stalled by another thread waiting for a slow
event.  So remove those two lock calls.

Also add a couple of comments documenting the locking behaviour of
libxl__ao_inprogress and libxl__egc_cleanup.

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 agolibxl: fix hang due to libxl__initiate_device_remove
Ian Jackson [Wed, 11 Apr 2012 13:14:09 +0000 (14:14 +0100)]
libxl: fix hang due to libxl__initiate_device_remove

libxl__initiate_device_remove might discover that the operation was
complete, immediately (typically, if the device is already removed).

Previously, in this situation, it would return 0 to the caller but
never call libxl__ao_complete.  Fix this.  This necessitates passing
the egc in from the functions which are the ao initiators.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years agolibxl: ao: allow immediate completion
Ian Jackson [Wed, 11 Apr 2012 13:14:08 +0000 (14:14 +0100)]
libxl: ao: allow immediate completion

Make it possible to complete an ao during its initating function.

Previously this was not generally possible because initiators did not
have an egc.  But there is no reason why an ao initiator should not
have an egc, so make the standard macros provide one.

Change the internal documentation comments accordingly.  (This change,
which means that an initiator function may call a completion callback
directly, is already consistent with the documented external API.)

We also invent of a new state flag "constructing" which indicates
whether we are between ao__create and ao__inprogress.  This is a
slightly optimisation which allows ao_complete to not bother poking
the wakeup pipe, since the logic in ao__inprogress will not run the
event loop if the ao is complete on entry.

Also fix the wording in the libxl_internal.h comment forbidding use of
ao_how-taking functions from within libxl.  (There are sadly currently
some such functions.)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Roger Pau Monne <roger.pau@entel.upc.edu>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years ago.gitignore: Add a missing file
Ian Jackson [Wed, 11 Apr 2012 13:14:07 +0000 (14:14 +0100)]
.gitignore: Add a missing file

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 agox86: explicitly mark __initdata variables as used when building with clang.
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
x86: explicitly mark __initdata variables as used when building with clang.

This stops LLVM from replacing it with a different, auto-generated
variable as part of an optimization.  (The auto-generated variable
ends up in the normal data section.)

Remove stray __read_mostly annotations on declarations that this unmasked.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxen: define __section() and friends and use them for section annotations.
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
xen: define __section() and friends and use them for section annotations.

By itself this is just code-tidying, but it's also useful for the
following patch, which will adjust __section() for clang compiles.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86: don't use .subsection when compiling with clang
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
x86: don't use .subsection when compiling with clang

LLVM's assembler doesn't support the .subsection directive, so put
the out-of-line failure path in .fixup instead.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86: fix memset(ptr, 0, sizeof ptr).
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
x86: fix memset(ptr, 0, sizeof ptr).

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86: fix logical ANDs used to mask bitfields.
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
x86: fix logical ANDs used to mask bitfields.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86/mm: Another couple of comparisons of unsigned vars with < 0.
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
x86/mm: Another couple of comparisons of unsigned vars with < 0.

Adding the explicit (unsigned) casts in case enums ever end up signed.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxen: Add -Wno-unused-value to the clang CFLAGS
Tim Deegan [Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)]
xen: Add -Wno-unused-value to the clang CFLAGS

clang complains about a lot of functions and macros whose return value
is unused.  I started on patches to drop some functions' return values
and scatter (void)s around callers, but it was getting too messy.
Just turn off the warning instead.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxen, cpupools: Fix cpupool-move to make more consistent
George Dunlap [Tue, 10 Apr 2012 09:42:35 +0000 (10:42 +0100)]
xen, cpupools: Fix cpupool-move to make more consistent

The full order for creating new private data structures when moving
from one pool to another is now:
* Allocate all new structures
 - Allocate a new private domain structure (but don't point there yet)
 - Allocate per-vcpu data structures (but don't point there yet)
* Remove old structures
 - Remove each vcpu, freeing the associated data structure
 - Free the domain data structure
* Switch to the new structures
 - Set the domain to the new cpupool, with the new private domain
 structure
 - Set each vcpu to the respective new structure, and insert

This is in line with a (fairly reasonable) assumption in credit2 that
the private structure of the domain will be the private structure
pointed to by the per-vcpu private structure.

Also fix a bug, in which insert_vcpu was called with the *old* vcpu
ops rather than the new ones.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxen, credit2: Put the per-cpu schedule lock back to the default lock when releasing cpu
George Dunlap [Tue, 10 Apr 2012 09:41:55 +0000 (10:41 +0100)]
xen, credit2: Put the per-cpu schedule lock back to the default lock when releasing cpu

This fixes a bug that happens when you remove cpus from a credit2
cpupool.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxen: Fix schedule()'s grabbing of the schedule lock
George Dunlap [Tue, 10 Apr 2012 09:41:30 +0000 (10:41 +0100)]
xen: Fix schedule()'s grabbing of the schedule lock

Because the location of the lock can change between the time you read
it and the time you grab it, the per-cpu schedule locks need to check
after lock acquisition that the lock location hasn't changed, and
release and re-try if so.  This change was effected throughout the
source code, but one very important place was apparently missed: in
schedule() itself.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agox86/mm: Take care of domain reference for shared pages
Andres Lagar-Cavilla [Thu, 5 Apr 2012 10:06:03 +0000 (11:06 +0100)]
x86/mm: Take care of domain reference for shared pages

Making a page sharable removes it from the previous owner's list. Making it
private adds it. These actions are similar to freeing or allocating a page.
Except that they were not minding the domain reference that is taken/dropped
when the first/last page is allocated/freed.

Without fixing this, a domain might remain zombie when destroyed if all its
pages are shared.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agodomctl.h: document non-standard error codes for enabling paging/access
Olaf Hering [Tue, 3 Apr 2012 15:22:59 +0000 (17:22 +0200)]
domctl.h: document non-standard error codes for enabling paging/access

The domctl to enable paging and access returns some non-standard error
codes after failure. This can be used in the tools to print specific
error messages. xenpaging recognizes these errno values and shows them
if the init function fails.

Document the return codes in the public header file.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxenpaging: add error code to indicate iommem passthrough
Olaf Hering [Fri, 30 Mar 2012 15:09:07 +0000 (17:09 +0200)]
xenpaging: add error code to indicate iommem passthrough

Similar to the existing ENODEV and EXDEV error codes, add EMDEV to
indicate that iommu passthrough is not compatible with paging.
All error codes are just made-up return codes to give proper error
messages in the pager.

Also update the HAP related error message now that paging is enabled
also on AMD hosts.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <Ian.Jackson@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoautoconf: check for as86, ld86, bcc and iasl
Roger Pau Monne [Wed, 22 Feb 2012 16:37:50 +0000 (17:37 +0100)]
autoconf: check for as86, ld86, bcc and iasl

Check for this tools, and set the proper paths on config/Tool.mk.

Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: fixup error handling in libxl_send_trigger
Ian Campbell [Wed, 4 Apr 2012 15:10:18 +0000 (16:10 +0100)]
libxl: fixup error handling in libxl_send_trigger

xc_domain_send_trigger returns -1 and sets errno on failure so use
LIBXL__LOG_ERRNO not LIBXL__LOG_ERRNOVAL(rc).

Change the default case of the switch to set rc=-1,errno=EINVAL too.

Also we weren't actually returning the error code we'd decided on.

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 agoxl, libxl: Add per-device and global permissive config options for pci passthrough
George Dunlap [Wed, 4 Apr 2012 15:06:42 +0000 (16:06 +0100)]
xl, libxl: Add per-device and global permissive config options for pci passthrough

By default pciback only allows PV guests to write "known safe" values into
PCI config space.  But many devices require writes to other areas of config
space in order to operate properly.  One way to do that is with the "quirks"
interface, which specifies areas known safe to a particular device; the
other way is to mark a device as "permissive", which tells pciback to allow
all config space writes for that domain and device.

This adds a "permissive" flag to the libxl_pci struct and teaches libxl how
to write the appropriate value into sysfs to enable the permissive feature for
devices being passed through.  It also adds the permissive config options either
on a per-device basis, or as a global option in the xl command-line.

Because of the potential stability and security implications of enabling
permissive, the flag is left off by default.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: Move bdf parsing into libxlu
George Dunlap [Wed, 4 Apr 2012 15:06:42 +0000 (16:06 +0100)]
libxl: Move bdf parsing into libxlu

Config parsing functions do not properly belong in libxl.  Move them into
libxlu so that others can use them or not as they see fit.

No functional changes.  One side-effect was making public a private libxl
utility function which just set the elements of a structure from the  function
arguments passed in.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoPV-GRUB: add support for btrfs
Matt Wilson [Wed, 4 Apr 2012 10:09:15 +0000 (11:09 +0100)]
PV-GRUB: add support for btrfs

This patch adds btrfs support to the GRUB tree used to build PV-GRUB.
The original patch is from Gentoo:
https://bugs.gentoo.org/show_bug.cgi?id=283637

Signed-off-by: Matt Wilson <msw@amazon.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoPV-GRUB: add support for ext4
Matt Wilson [Wed, 4 Apr 2012 10:09:14 +0000 (11:09 +0100)]
PV-GRUB: add support for ext4

This patch adds support for ext4 to the GRUB tree used to build PV-GRUB.
The original patch is taken from the Fedora GRUB package in this commit:
http://pkgs.fedoraproject.org/gitweb/?p=grub.git;a=commitdiff;h=32bf414af04d377055957167aac7dedec691ef57

Signed-off-by: Matt Wilson <msw@amazon.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoPV-GRUB: Check for errors when applying patches to GRUB
Matt Wilson [Wed, 4 Apr 2012 10:09:14 +0000 (11:09 +0100)]
PV-GRUB: Check for errors when applying patches to GRUB

We want to ensure that patches apply cleanly without rejects. Bail if
patch returns a non-zero exit code.

Signed-off-by: Matt Wilson <msw@amazon.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoQEMU_TAG update
Ian Jackson [Tue, 3 Apr 2012 17:25:56 +0000 (18:25 +0100)]
QEMU_TAG update

13 years agotools/libfsimage: include Rules.mk first
Olaf Hering [Wed, 14 Mar 2012 16:53:56 +0000 (17:53 +0100)]
tools/libfsimage: include Rules.mk first

Move the inclusion of Rules.mk up so that things like CFLAGS get initialized
properly. Currently only zfs appends CFLAGS. If CFLAGS get reset by Rules.mk
the private settings are lost and compilation of zfs support fails.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
13 years agotools/blktap: reorder MEMSHR_DIR to fix CFLAGS
Olaf Hering [Wed, 14 Mar 2012 16:02:23 +0000 (17:02 +0100)]
tools/blktap: reorder MEMSHR_DIR to fix CFLAGS

In blktap2 MEMSHR_DIR is used before it is set. This removes the
required -D_GNU_SOURCE from CFLAGS, its used as option for -I
Fix this by moving memshr related flags to the place where its actually
used.
The failure is a missing O_DIRECT define.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
13 years agolibxl: Pass actual RAM amount to qemu-xen
Anthony PERARD [Tue, 3 Apr 2012 17:15:11 +0000 (18:15 +0100)]
libxl: Pass actual RAM amount to qemu-xen

QEMU upstream need to kown the amount of RAM given to a guest. This patch give
the correct value.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>