libxl: Hold the atfork lock while closing carefd

This avoids the process being forked while a carefd is recorded in the
list but the actual fd has been closed.  If that happened, a
subsequent libxl_postfork_child_noexec would attempt to close the fd
again.  If we are lucky that results in a harmless warning; but if we
are unlucky the fd number has been reused and we close an unrelated
fd.

This race has not been observed anywhere as far as we are aware.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
libxl: Fix carefd lock leak in save callout

If libxl_pipe fails we leave the carefd locked, which translates to
the atfork lock remaining held.  This would probably cause the process
to deadlock shortly afterwards.

Of course libxl_pipe is very unlikely to fail unless things are
already going very badly.  This bug has not been observed anywhere as
far as we are aware.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging
libxl: fix memory leak in libxl__strndup()

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
libxl: simplify libxl__dirname()

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xcutils: xc_save: avoid allocing local constant string

cmd_str doesn't need to be allocated.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxc: fix errno handling for HVM in xc_domain_save

The previous patch (dda0b77d "tools/libxc: pass errno to callers of
xc_domain_save") did not jump to the proper label if the domU is HVM.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reviewed-by: Olaf Hering <olaf@aepfle.de>
tools/mfndump: Avoid unintentional NULL dereference

If we failed to open an xc interface, using xch to log an error will end in
tears.  Print to stderr instead, as we are bailing immediately later.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Coverity-id: 1191885
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Dario Faggioli <dario.faggioli@citrix.com>
libxl: Add none to vga parameter

Usage:
  vga="none"

Make possible to not have an emulated vga on hvm domUs.

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Tested-by: Paul Durrant <paul.durrant@citrix.com>
functional cleanup for __attribute__((packed)) changes

This is to separate the functional changes from the noop consistency changes.

* Pack struct cper_mce_record rather than creating a structure named __packed
* Remove unreferenced struct xgt_desc
* Use two u16's rather than two u32 16-bit bitfields

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>

Also drop now pointless (and always having been bogus) pack pragmas.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
common: shuffle use of __attribute__((packed))

This introduced a formal define in compiler.h, and is otherwise manual
shuffling of __attribute__((packed)) statements to __packed at the head of the
structure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
x86: shuffle use of __attribute__((packed))

This is almost all manual shuffling of __attribute__((packed)) statements to
__packed at the head of the structure.

The only different change is in tboot.h, removing some now-redundant ifdefs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
arm: shuffle use of __attribute__((packed))

This is all mechanical shuffling.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
x86_emulate: Shuffle use of __attribute__((packed))

Also include #defines for the test code to allow compilation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
x86/tboot: Use an integer_param for "tboot="

rather than using a string param and manually parsing it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
docs/vtpm: explain dom0 physical TPM access caveats

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
unlzma: fix build of stubdom unsafe decompressors

c/s b683d68c386 changed the packing attribute on struct lzma_header.  However,
this is 3rd library code used by stubdomains.

Revert the change to lzma_header alone to avoid needless divergence from its
source.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools: update config.{sub,guess}

Update to versions from Debian Wheezy's autotools-dev package (20120608.1)

Adds ARM aarch64 support.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen/arm: Introduce clean_and_invalidate_xen_dcache() macro

This macro is very similar to clean_xen_dcache(), but it performs
clean and invalidate dcache.

Also modify flush_page_to_ram() to call
clean_and_invalidate_xen_dcache_va_range() function.

Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: Clean and invalidate dcache for boot pagetables

We need to invalidate dcache too after zeroing boot pagetables
to avoid unpredictable behavior which may take place after
non-boot CPUs enable their caches.

So, replace clean_xen_dcache() macro by a clean_and_invalidate_xen_dcache()
for boot pagetables.

Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>