Revert "x86/paging: make log-dirty operations preemptible"

This reverts commit 95e6d82224689fdfd967a093a4d69efc24c17e91.

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

Revert-reqeuested-by: Jan Beulich <JBeulich@suse.com>
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 ]
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>
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>
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>
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>
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>
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 d8bad9df2544291a0fdc8e4d826b16f9f5394462 (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>
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>
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>
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>
VMX: allow RTM advanced debugging to be used by guests

All that is needed here is allowing the respective DebugCtl MSR bit to
be set by the guest.

At once - even if PV guests can't currently use it due to missing
DebugCtl MSR virtualization - make the respective adjustments to
debugreg.h.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
VMX/vPMU: reduce core2_vpmu_initialise() verbosity

No need to print these messages for each vCPU, even more, no need to
print them for each domain - they all depend on CPU features that are
either there or not.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
x86/irq: process softirqs in irq keyhandlers

Large machines with lots of interrupts can trip over the Xen watchdog.

Suggested-by: Santosh Jodh <Santosh.Jodh@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Santosh Jodh <Santosh.Jodh@citrix.com>
x86/alternatives: force inline stac() and clac()

In this case, we know better than the compiler.

gcc 4.7 (Debian Wheezy) chooses to create translation-unit-local functions
(even for non-debug builds) named stac() and clac(), and calls them.

$ objdump -d xen-syms | grep -c "<stac>:"
6

$ objdump -d xen-syms | grep -o "callq  [0-9a-f]\+ <stac>" | uniq -c
      5 callq  ffff82d0801166c9 <stac>
     20 callq  ffff82d08015ef99 <stac>
      4 callq  ffff82d080165169 <stac>
      8 callq  ffff82d080188cb9 <stac>
      3 callq  ffff82d080228779 <stac>
      4 callq  ffff82d08022c5c9 <stac>

Forcing always_inline removes these functions, and replaces each of the callqs
with the expected 3byte nops.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
x86/HVM: drop memory_type_changed() call from hvm_set_guest_pat()

The commit aa9114edd added the needless function call memory_type_changed,
it is unnessary because the PAT content does not influence the result of
epte_get_entry_emt(). If it is called, the cache will be flushed excessively
and make the nested guest very slowly, just like blocked.

Signed-off-by: Li Liang <liangx.z.li@intel.com>
x86/PVH: don't set EFER_SCE for pvh guest

Just like NX is guest managed, SCE should be too. Remove setting of
the EFER_SCE for pvh guest.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
libxl: introduce libxl__multidev_prepare_with_aodev

libxl__multidev_prepare_with_aodev is similar to libxl__multidev_prepare,
but takes a libxl__ao_device as an extra argument.
libxl__multidev_prepare is now a wrapper around
libxl__multidev_prepare_with_aodev.

This new internal API will be used by the Remus device abstract layer
for handling various Remus devices.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
libxl: add support for async. function calls when using libxl__ao_device

Extend libxl__ao_device with a libxl__ev_child member, which can be
used to asynchronously execute functions that take a long time to complete.
Remus uses this functionality to execute functions that involve blocking
system calls.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
autoconf: add libnl3 dependency for Remus network buffering support

Libnl3 is required for controlling Remus network buffering.
This patch adds dependency on libnl3 (>= 3.2.8) to autoconf scripts.
It also provides the ability to configure tools without libnl3 support
i.e., without network buffering support.

When there is no network buffering support, libxl__netbuffer_enabled()
returns 0, otherwise returns 1. The callers of this api will be
introduced in the rest of the series.

NOTE: This patch changes tools/configure.ac, please rerun
      autogen.sh while applying the patch.

Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
Reviewed-by: Wen Congyang <wency@cn.fujitsu.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>