Commit Graph
29493 Commits
Author SHA1 Message Date
Jan Beulich 2d9b91f1ae VMX/vPMU: fix DebugCtl MSR handling
- writes with one of the vPMU-supported flags and some unsupported one
  set got accepted, leading to a VM entry failure
- writes with one of the vPMU-supported flags set but the Debug Store
  feature unavailable produced a #GP (other than other writes to this
  MSR with unsupported bits set)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2014-08-22 14:30:27 +02:00
Jan Beulich dfa625e15f VMX: fix DebugCtl MSR clearing
The previous shortcut was wrong, as it bypassed the necessary vmwrite:
All we really want to avoid if the guest writes zero is to add the MSR
to the host-load list.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2014-08-22 14:29:37 +02:00
Andrew Cooper 02926b1729 x86/intel: protect set_cpuidmask() against #GP faults
Virtual environments such as Xen HVM containers and VirtualBox do not
necessarily provide support for feature masking MSRs.

As their presence is detected by model numbers alone, and their use predicated
on command line parameters, use the safe() variants of {wr,rd}msr() to avoid
dying with an early #GP fault.

While playing in this function, make some further improvements.

* Rename the masking MSR names for consistency, and name the CPU models for
  the benefit of humans reading the code.
* Correct the CPU selection as specified in the flexmigration document.  All
  steppings of 0x17 and 0x1a are stated to have masking MSRs.
* Provide log messages indicating the masks applied, or lack of masking
  capabilities.
* In the case of faulting support being available and masking command line
  options specified, provide a log message indicating the lack of masking.

References:
http://www.intel.com/content/www/us/en/virtualization/virtualization-technology-flexmigration-application-note.html
http://software.intel.com/en-us/articles/intel-architecture-and-processor-identification-with-cpuid-model-and-family-numbers

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2014-08-22 14:28:12 +02:00
Fabio Fantoni dea878490c tools/hotplug/Linux/init.d: fix wrong path in xendomains init
Fixed wrong path in xendomains init that make it not working, introduced
in commit d8bad9df25 (tools/xendomains:
move to libexec and use a smaller init helper).

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-21 23:32:43 +01:00
Yang Hongyang ca0354f90a tools: libxc: fix Remus failover regression
commit: c2ba706c "tools/libxc: goto correct label on error paths" by Andrew
Cooper broke Remus in Xen 4.4 or earlier versions that has this commit
backported.

With Remus, this jump essentially discards the current incomplete checkpoint
received by the backup and restore backup from the last complete checkpoint.
This is required for Remus to work and this does not break live migration.  It
has been around since Xen 4.0.

CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Acked-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-21 23:29:18 +01:00
Julien Grall fe47fa7139 xen/arm: mark do_unexpected_trap as noreturn
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-21 23:27:19 +01:00
Wei Liu cad883eff9 libxl: don't print out function name in log twice
The LOG macro already prints out function names. No need to explictly
use "__func__" in log message.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-21 23:23:29 +01:00
Olaf Hering bbc6fa96ed tools: remove duplicate -Wall from CFLAGS
CFLAGS+=-Wall is already provided by Config.mk
WARN_FLAGS is not used.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-21 23:12:39 +01:00
Olaf Hering 3363fc1204 tools: remove duplicate -g from CFLAGS
CFLAGS+=-g is already provided by Config.mk.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-21 23:12:27 +01:00
Parth Dixit 4da570a4de xen/arm : emulation of arm's PSCI v0.2 standard
Arm based virtual machines dom0/guest will request power related functionality
from xen through PSCI interface. This patch implements version 0.2 of
PSCI standard specified by arm for 64bit and 32 bit arm machines.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- switch include n vpsci.c from asm-arm/event.h to asm/event.h ]
2014-08-21 23:03:27 +01:00
Ian Jackson 974516cc54 Revert "x86/paging: make log-dirty operations preemptible"
This reverts commit 95e6d82224.

This fix has been discovered to cause regressions.  Investigations are
ongoing.

Revert-reqeuested-by: Jan Beulich <JBeulich@suse.com>
2014-08-19 12:54:59 +01:00
Ian Campbell f2ae8bfa49 xen: arm: Correctly handle do_sysreg exception injection from 64-bit userspace
The do_sysreg case was missing a return, so it would increment PC and
inject the trap to the second instruction of the handler.

This is CVE-2014-5148 / XSA-103.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-12 15:38:01 +02:00
Ian Campbell c0020e0997 xen: arm: Handle traps from 32-bit userspace on 64-bit kernel as undef
We are not setup to handle these properly. This turns a host crash
into a trap to the guest kernel which will likely result in killing
the offending process.

This is part of CVE-2014-5147 / XSA-102.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-12 15:37:25 +02:00
Ian Campbell a986697817 xen: arm: Correctly handle exception injection from userspace on 64-bit.
Firstly we must be prepared to propagate traps from 32-bit userspace even for
64-bit guests, so wrap the existing inject_undef??_exception into
inject_undef_exception and use that when injecting an undef exception. The
various other exception cases (aborts etc) already do this.

Secondly when injecting the trap we must pick the correct exception vector
depending on whether the source of the trap was 32-bit EL0, 64-bit EL0 or EL1.

This is part of CVE-2014-5147 / XSA-102.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-12 15:36:15 +02:00
Ian Campbell fc0cafeab3 xen: arm: handle AArch32 userspace when dumping 64-bit guest state.
A 64-bit guest can still be in 32-bit mode when running userspace,
handle this case by dumping the correct 32-bit state.

Note that on ARM it is not possible to change mode without the help
of the next exception level, hence there is no way a 64-bit guest can
be running in 32-bit kernel modes.

This is part of CVE-2014-5147 / XSA-102.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-12 15:32:27 +02:00
Jan Beulich 95e6d82224 x86/paging: make log-dirty operations preemptible
Both the freeing and the inspection of the bitmap get done in (nested)
loops which - besides having a rather high iteration count in general,
albeit that would be covered by XSA-77 - have the number of non-trivial
iterations they need to perform (indirectly) controllable by both the
guest they are for and any domain controlling the guest (including the
one running qemu for it).

This is CVE-2014-5146 / XSA-97.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2014-08-12 15:30:11 +02:00
Daniel Kiper f093fcf90f x86/EFI: Add newline to the end of graphics mode error message
Error message related to graphics mode does not have new line.
So, let's fix it.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
2014-08-11 15:13:04 +02:00
Andrew Cooper bc36a12f90 x86/hap: initialise HAP logdirty function pointers once in hap_domain_init()
rather than repeatedly initialising them each time logdirty is enabled or the
vram tracking area changes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2014-08-11 15:12:20 +02:00
Julien Grall 34155c34ae domain_update_node_affinity: bail out early if no VCPUs are allocated
The commit "move domain to cpupool0 before destroying it" make Xen crashes
when a domain is destroyed with d->vcpus allocated but no VCPU initialized.

Assertion '!cpumask_empty(dom_cpumask)' failed at domain.c:452
Xen call trace:
    [<00207bd8>] domain_update_node_affinity+0x10c/0x238 (PC)
    [<00000004>] 00000004 (LR)
    [<00226870>] sched_move_domain+0x3cc/0x42c
    [<0020925c>] domain_kill+0xc8/0x178
    [<00206a0c>] do_domctl+0xaac/0x15e4
    [<002529c0>] do_trap_hypervisor+0xc5c/0xf94
    [<002559f0>] return_from_trap+0/0x4

Bail out early if there is d->VCPU is not allocated or VCPU 0 has not been
initialized.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
2014-08-11 15:11:43 +02:00
Tiejun Chen ca063d4480 x86: make struct e820map's nr_map unsigned
nr_map is used to represent the amount of e820entry in e820 so this is
never negative.

Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
2014-08-11 15:10:07 +02:00
Jan Beulich ded2100990 x86/vHPET: use rwlock instead of simple one
This namely benefits guests heavily reading the main counter, but not
touching the HPET much otherwise. Note that due to the way
hpet_get_comparator() works hpet_read() has to special cases reads from
the comparator registers and use a write lock there instead of the read
one used for all other registers.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
2014-08-11 15:00:15 +02:00
Roger Pau Monné b074b99c34 x86/HVM: expose that grant table mappings update the IOMMU
Add a new CPUID flag for leaf 4 that indicates that grant/foreign
mappings update the IOMMU accordingly.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2014-08-11 14:58:40 +02:00
Roger Pau Monné c2ba3db31e amd-iommu: disable iommu_hap_pt_share with AMD IOMMUs
According to the comment in p2m.h, AMD IOMMUs don't work correctly
with page types different than p2m_ram_rw when the p2m is shared
between HAP and IOMMU, so disable this sharing when using AMD IOMMUs.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
2014-08-11 14:57:09 +02:00
Jan Beulich 3af450fd2d x86_emulate: properly do IP updates and other side effects on success
The two MMX/SSE/AVX code blocks failed to update IP properly, and these
as well as get_reg_refix(), which "manually" updated IP so far, failed
to do the TF and RF processing needed at the end of successfully
emulated instructions.

Fix the test utility at once to check IP is properly getting updated,
and while at it macroize the respective code quite a bit, hopefully
making it easier to add further tests when the need arises.

Reported-by: Andrei LUTAS <vlutas@bitdefender.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
2014-08-08 09:34:03 +02:00
Jan Beulich bf28eecf7b pass-through: fix unbinding of MSI interrupts
Commit 568da4f8 ("pt-irq fixes and improvements") went a little too far
in its cleaning up of pt_irq_destroy_bind(): While neither of the two
lists need any maintenance, the actual unbinding still needs to be
done. Fix this and at once
- move all variables applying only to the PCI/MSI-translate cases into
  scopes where they can't be used in error,
- limit the final (optional) log message to the cases it actually
  applies and enhance it to make clear how much cleaning up was
  actually done.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
2014-08-08 09:32:58 +02:00
Paul Durrant a84938b444 x86/viridian: make logging less verbose
The use of gdprintk() adds uninteresting prefixes to the log lines, and
there's really too many lines. This patch reduces the verbosity.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
2014-08-08 09:30:49 +02:00
Jan Beulich 142f87c0dc x86/HVM: command line option adjustments
Adding actual descriptions for them, hiding the hvm_debug= one from
non-debug builds (the option was recognized but didn't take any effect
so far), and adjusting some debug level specifiers to their purpose.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
2014-08-06 18:02:41 +02:00
Jan Beulich 793e3480fc x86/APIC: command line option adjustments
Improving their documentation, and converting one option to boolean
since it has only boolean meaning.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
2014-08-06 18:01:55 +02:00
Jan Beulich f1e06bed54 x86/ACPI: command line option adjustments
Improving their documentation, and converting one option to boolean
since it has only boolean meaning.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
2014-08-06 18:00:40 +02:00
Ian Campbell cbe4f1df38 autoconf: exec_prefix should default to $prefix not $ac_default_prefix
Otherwise "./configure --prefix=/usr" still ends up with exec_prefix=/usr/local
and therefore LIBDIR, PRIVATE_PREFIX and PRIVATE_BINDIR still point to
/usr/local/foo.

This was broken in 54f28913a2 "autoconf: xen: move standard path variables to
config/Paths.mk.in" which tried to add code to expand exec_prefix earlier.

Reported-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2014-08-04 17:00:25 +01:00
Ian Campbell b15599e84f Makefile inclusion of Paths.mk should be conditional
Since it may not exist when doing e.g. "make clean". There is
existing logic in the makefiles which will raise an error if an
actual build target is invoked without having run configure.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2014-08-04 17:00:10 +01:00
Ian Campbell f65a05af14 xen: arm: Add new str* primitives from Linux v3.16-rc6.
Imports:
  0a42cb0 arm64: lib: Implement optimized string length routines
    Author: zhichang.yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  192c4d9 arm64: lib: Implement optimized string compare routines
    Author: zhichang.yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-04 16:54:34 +01:00
Ian Campbell 65e9f06606 xen: arm: update arm32 assembly primitives to Linux v3.16-rc6
bitops, cmpxchg, atomics: Import:
  c32ffce ARM: 7984/1: prefetch: add prefetchw invocations for barriered atomics
    Author: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

atomics: In addition to the above import:
  db38ee8 ARM: 7983/1: atomics: implement a better __atomic_add_unless for v6+
    Author: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

spinlocks: We have diverged from Linux, so no updates but note this in the README.

mem* and str*: Import:
  d98b90e ARM: 7990/1: asm: rename logical shift macros push pull into lspush lspull
    Author: Victor Kamensky <victor.kamensky@linaro.org>
    Suggested-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Victor Kamensky <victor.kamensky@linaro.org>
    Acked-by: Nicolas Pitre <nico@linaro.org>
    Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

  For some reason str* were mentioned under mem* in the README, fix.

libgcc: No changes, update baseline

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-04 16:53:31 +01:00
Ian Campbell a04ef51e4c xen: arm: update arm64 assembly primitives to Linux v3.16-rc6
The only really interesting changes here are the updates to mem* which update
to actually optimised versions and introduce an optimised memcmp.

bitops: No change to the bits we import. Record new baseline.

cmpxchg: Import:
  60010e5 arm64: cmpxchg: update macros to prevent warnings
    Author: Mark Hambleton <mahamble@broadcom.com>
    Signed-off-by: Mark Hambleton <mahamble@broadcom.com>
    Signed-off-by: Mark Brown <broonie@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

  e1dfda9 arm64: xchg: prevent warning if return value is unused
    Author: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

  e1dfda9 resolves the warning which previous caused us to skip 60010e508111.

  Since arm32 and arm64 now differ (as do Linux arm and arm64) here the
  existing definition in asm/system.h gets moved to asm/arm32/cmpxchg.h.
  Previously this was shadowing the arm64 one but they happened to be identical.

atomics: Import:
  8715466 arch,arm64: Convert smp_mb__*()
    Author: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Peter Zijlstra <peterz@infradead.org>

  This just drops some unused (by us) smp_mb__*_atomic_*.

spinlocks: No change. Record new baseline.

mem*: Import:
  808dbac arm64: lib: Implement optimized memcpy routine
    Author: zhichang.yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  280adc1 arm64: lib: Implement optimized memmove routine
    Author: zhichang.yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  b29a51f arm64: lib: Implement optimized memset routine
    Author: zhichang.yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  d875c9b arm64: lib: Implement optimized memcmp routine
    Author: zhichang.yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Zhichang Yuan <zhichang.yuan@linaro.org>
    Signed-off-by: Deepak Saxena <dsaxena@linaro.org>
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

  These import various routines from Linaro's Cortex Strings library.

  Added assembler.h similar to on arm32 to define the various magic symbols
  which these imported routines depend on (e.g. CPU_LE() and CPU_BE())

str*: No changes. Record new baseline.

  Correct the paths in the README.

*_page: No changes. Record new baseline.

  README previous said clear_page was unused while clear page was, which was
  backwards.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-04 16:53:12 +01:00
Luis R. Rodriguez 015330004e systemd: add xen systemd service and module files
This adds the systemd xen service / module files and integrates
support into the build system.

This goes in with AX_AVAILABLE_SYSTEMD() which will enable
systemd if development libraries have been found on your
build system. If you don't have systemd on target systems
for binaries built with systemd then the binary will not
work, you must explicitly disable systemd support if you
do not want to build systemd support.

When systemd libraries are present only systems that
have booted into systemd go through the systemd initialization,
otherwise the SysVinit is used.

These are originally based on the Fedora systemd files.

Changes made from Fedora's systemd files:

  * split sockets into two files to claim different permissions
  * Use /bin/sh -c exec to for a simple launcher implementation
  * enables systemd socket activation for C xenstored and Ocaml
    oxenstored
  * use sd_notify(), so change the service to Type=notify, because of
    this we remove the PIDFile specification as we don't care for it, and let
    systemd do its magic for us, this also means we don't have to fork
    so we use --no-fork with systemd
  * defines a modules-load.d, its original source file will be shared
    between systemd and old init systems
  * simplify service files with ConditionVirtualization=xen which uses
    the built in systemd virtualization backend detection, these
    service files will not be available to start on systems that do not
    boot with xen as a hypervisor
  * use autoconf to replace @variable@ paths for us which piggy
    backs on top of the latest autoconf changes to xen
  * removes oxenstored service file in favor of a system variable which
    controls which which xentored to use at run time, we avoid multiple
    service files this way.
  * simplifies startup to not require polling on the sockets
    as initial socket management is handled by systemd, we just
    take on the socket later once anything pokes at it, a simple nc -U
    (as root) on any of the sockets files can activate the service for example.
    Anything queued up will be sent to us once we start. Socket activation
    should in theory also let us dynamically switch between xenstores but more
    importantly we could upgrade xenstored while keeping all active
    socket communication queued up, but in order to take advantage of
    this we eventually would need to remove the requirement of not being
    able to bring down the xenstored. Even though active sockets are
    supported since most libxl communication doesn't triggger a check
    on the unix socket first administrators are encouraged to enable
    the xenstored.service to triggger an initialization of the xenstored
    upon bring up. Some systems also never use unix sockets for
    communication with the xenstored and as such active sockets will
    not be used there.
  * allow for xenstored configuration through *either* of these
    configuration files:
	- /etc/sysconfig/xenstored
	- /etc/default/xenstored
    The /etc/default/xenstored will let debian based systems do
    the same, while SUSE/OpenSUSE/Fedora/RedHat can keep on chugging
    with sysconfig. We leave these files all commented out by default
    though given that for systemd we want to encourage not using them.
  * ensures we create the run directory as most systems will likely
    be using a tmpfs for run dirs for the pid files
  * Some systems define the selinux context in the systemd Option for the
    /var/lib/xenstored tmpfs:
	Options=mode=755,context="system_u:object_r:xenstored_var_lib_t:s0"
    For the upstream version we remove that and let systems specify the
    context on their system /etc/default/xenstored or /etc/sysconfig/xenstored
    $XENSTORED_MOUNT_CTX variable, with a default to none.
  * takes advantage of the shared xendomains helper for the xendomains
    service
  * Add the new dom0 that gets kicked off for disk backend access into
    its own systemd service associated to xen

We end up with these systemd files:

General requirements:

  * proc-xen.mount
  * var-lib-xenstored.mount

xenstored:

  * xenstored.service
  * xenstored.socket
  * xenstored_ro.socket
  * xenconsoled.service
  * xen-qemu-dom0-disk-backend.service.in

Optional:

  * xendomains.service
  * xen-watchdog.service

As for integration with xen, we house keep all the systemd files
under a new directory tools/hotplug/Linux/systemd/ and will be targeted
by default when building on Linux systems if systemd development
libraries are present at build time.

The systemd files will be sanitized for meta @VARIABLES@ upon
configuration and installed upon the install target. Systems that
do not use systemd can still get systemd service unit files installed
if the build system enabled systemd support, this however does not
mandate a requirement of having systemd libraries present. Old init
scripts are always installed.

If you don't specify a prefix you will end up with the services
files under /usr/local/lib/systemd/system/ by default, and systemd
modules-load.d conf files under /usr/local/lib/modules-load.d/ which
systemd does look for (although it seems this is not documented).

Distributions are expected to provide their /usr/ prefix to end up in
the more generic location upon distribution install at
/usr/lib/systemd/system/ and /usr/lib/modules-load.d/ respectively.

Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Jan Rękorajski <baggins@pld-linux.org>
Cc: M A Young <m.a.young@durham.ac.uk>
Cc: Jacek Konieczny <jajcus@jajcus.net>
Cc: xen-devel@lists.xenproject.org
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ran autogen.sh ]
2014-08-04 14:58:24 +01:00
Luis R. Rodriguez dff4c31163 autoconf: xen: enable explicit preference option for xenstored preference
As it stands oxenstored will be used by default if ocaml tools are
found, the init system will also try to use oxenstored first if its
found otherwise the cxenstored will be used. Lets simplify the init
script and let users be explicit about the preference through configure.

This adds support to let you be explicit about the xenstored preference,
you can only use one of these two options:

./configure --with-xenstored=xenstored
./configure --with-xenstored=oxenstored

We continue with the old behaviour and default oxenstored will be used
but only if you have ocaml dependencies. Since the xenstored preference
is explicit now and since we require configure substitutions for it we
make use of the AX_XEN_EXPAND_CONFIG() helpers as otherwise substitution
for SBINDIR is not propagated from the top level configuration.

All this allows us to simplify the init script to use the configured
xenstore from the start. We update the sysconfig/default xencommons file
with the paths for the different options though, this can be used by
users to override the default xenstored, this follows the old behaviour
but we now just explicitly provide the full configured paths for users.

As before, changing the xenstore requires a reboot.

In order to help with documentation we update the README with some
details on configure usage refer to the wiki [0] [1] [2] for more elaborate
details.

Since we are now parsing an entry within Paths.mk.in on tools we let
the move the parsing of the file to be the tool's configure.

[0] http://wiki.xen.org/wiki/Xenstored
[1] http://wiki.xen.org/wiki/XenStore
[2] http://wiki.xen.org/wiki/XenStoreReference

Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ran autogen.sh ]
2014-08-04 14:58:24 +01:00
Luis R. Rodriguez fafbc2926c xencommons: move module list into a generic place
This will allow us to share the same module list with
systemd, and lets us upkeep it in one place. Document this
while at it on the top level README and expand on the wiki:

http://wiki.xen.org/wiki/Category:Host_Configuration#Kernel_modules

In order to upkeep parallelism builds be explicit about the
requirement to complete all actions before any installation
targets.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-04 14:58:23 +01:00
Roger Pau Monne 807999107b libxc: expand cpuid features exposed to PVH guests
Expand the cpuid features exposed to PVH guests, this includes
exposing PSE, PGE and 1GB pages (which will be masked by the
hypervisor if not supported by the hardware).

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-04 14:17:07 +01:00
Ian Campbell 159e504e77 xen: arm: Write to the correct PT when mapping the DTB on boot on arm64
We currently get away with this because when debug=y and earlyprintk is enabled
the previous block of (conditional) code would have set this up. Historically we
mostly got away with it even without those options because the pre paging code
would normally (at least on h/w we test) leave x4 set to the paddr of
boot_second.

This latent bug has always been present but was exposed by ca59618967 "xen:
arm: Handle 4K aligned hypervisor load address" (or one of the related patches)
since now x4 is quite likely to point to boot_third not boot_second.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-04 14:00:45 +01:00
Ian Campbell 47087e8d06 xen: arm: Correct comment in arm32 head.S
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
2014-08-04 13:58:35 +01:00
Roger Pau Monné 41220bb7d5 x86: fix cpuid reporting on PVH Dom0
dab11417d also caused some problems regarding HVM guest creation on
PVH Dom0, mainly the CR4 mask returned by hvm_cr4_guest_reserved_bits
changed from 0xfffffffffffff800 to 0xfffffffffffff893, which means HVM
guests created from a PVH Dom0 are unable to set VME, PVI, PSE or PGE
CR4 flags.

This is because cpuid on PVH guests mask PSE, PGE, PSE36 and VME
flags, so the white listing done in xc_cpuid_hvm_policy doesn't enable
those features, and the guest ends up with a very restrictive cpuid
policy.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
2014-08-04 13:46:54 +02:00
Jan Beulich fd1863847a x86/HVM: extend LAPIC shortcuts around P2M lookups
... to all internally handled MMIO regions. It is in particular the
HPET page that, e.g. on Windows Server 2012 R2, can get heavily
accessed, and hence avoiding the unnecessary lookups is rather
beneficial (in the reported case a 40+-vCPU guest would previously not
have booted at all while with hvm_hap_nested_page_fault() shortcut
alone it was able to boot up in 18 minutes [i.e. still room for
improvement]).

Note the apparently unrelated addition of a is_hvm_vcpu() check to the
__hvm_copy() code: Afaict for PVH this shortcut should never have taken
effect (since there's no LAPIC in that case).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
2014-08-04 13:46:03 +02:00
Don Slutz 4efef44f0a console: better handing of console_timestamps as a boolean_param
In order to handle all the old ways, change to use parse_bool().

Signed-off-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Restructure code to limit churn.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-04 13:45:08 +02:00
Jan Beulich a0d52bfab4 convert "no-" command line option prefix into "=no" for OPT_CUSTOM
... to allow restoring/retaining previous behavior for options getting
converted from boolean to custom. Obviously that'll work only when no
other argument was specified for the option. Command line settings of
the form "no-<name>=<value>" will now be ignored as ambiguous (rather
than being interpreted as "<name>=<value>", i.e. ignoring the "no-"
prefix).

Reported-by: Don Slutz <dslutz@verizon.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-04 13:44:36 +02:00
Jan Beulich 9143a6c55e lz4: check for underruns
While overruns are already being taken care of, underruns (resulting
from overflows in the respective "op + length" (or similar) operations
weren't.

This is CVE-2014-4611.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
2014-08-04 13:43:03 +02:00
Jan Beulich 1b7fe9a1a1 fix qemu building with older make
The $(or ...) builtin (uses introduced by commits ffbf089357 and
8962a8f951) is supported only from make 3.81 onwards, yet we claim to
only require make 3.80. Introduce a good enough fallback.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2014-08-04 13:42:34 +02:00
Aravind Gopalakrishnan 8b24b07eef x86, amd_ucode: safeguard against #GP
When HW tries to load a corrupted patch, it generates #GP
and depending on 'noreboot' parameter on grub, the system
is either stuck in a reboot loop or is hung. Use wrmsr_safe
instead of wrmsrl so that we fail to load microcode gracefully.

Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2014-08-01 16:48:30 +02:00
Aravind Gopalakrishnan 6784dd6fdc x86, amd_ucode: fix coverity issues found in cpu_request_microcode()
This patch fixes issues reported by coverity.
 - CID 1229147: dead code
 - CID 1229148: possible resource leak of mc_amd due to goto out statements.

Coverity-IDs: 1229147, 1229148
Reported-by: Andrew Cooper<andrew.cooper3@citrix.com>
Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
Reviewed-by: Andrew Cooper<andrew.cooper3@citrix.com>
2014-08-01 16:47:48 +02:00
Vitaly Kuznetsov 400b3bd642 evtchn: make EVTCHNOP_reset suitable for kexec
It would be nice to allow guests to close all event channels in
ABI-agnostic way in case of kexec/kdump. EVTCHNOP_reset looks suitable
for this purpose. However control blocks for vcpus and event array need
cleanup when FIFO ABI is being used.

With this change a guest can simply do EVTCHNOP_reset before kexec in
both 2-level and FIFO cases. It is also important to perform store/console
channel remapping after such call.

The issue can also be solved by introducing a new EVTCHNOP operation but
it seems that EVTCHNOP_reset can be reused.

[The idea was suggested by Ian Campbell, Andrew Cooper, and David Vrabel]

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
2014-08-01 16:46:40 +02:00
Feng Wu 340f8cb830 x86/hvm: always do SMAP check when updating secondary system time for guest
In this patch, we always do the SMAP check when updating secondary
system time for the guest when SMAP is enabled by it.

Signed-off-by: Feng Wu <feng.wu@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2014-08-01 16:40:39 +02:00