]> xenbits.xensource.com Git - people/royger/xen.git/log
people/royger/xen.git
8 years agox86: support larger memory map from EFI master gitlab/master
Juergen Gross [Fri, 24 Mar 2017 13:19:47 +0000 (14:19 +0100)]
x86: support larger memory map from EFI

Use a larger e820 map buffer for non-BIOS memory map sources. This
requires to have different defines for the maximum number of E820 map
entries for the raw BIOS buffer and the later used struct e820map.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: use trampoline e820 buffer for BIOS interface only
Juergen Gross [Fri, 24 Mar 2017 13:19:24 +0000 (14:19 +0100)]
x86: use trampoline e820 buffer for BIOS interface only

Instead of using the E820 raw buffer for BIOS, EFI and multiboot based
memory map information use it for the BIOS interface only. This will
enable us to support more E820 entries than the limited trampoline
located buffer can.

Add a new raw e820 table for common purpose and copy the BIOS buffer
to it. Doing the copying in assembly avoids the need to export the
symbols for the BIOS E820 buffer and number of entries.

Signed-off-by: Juergen Gross <jgross@suse.com>
[jb: eliminate an unneeded local variable]
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: split boot trampoline into permanent and temporary part
Juergen Gross [Fri, 24 Mar 2017 13:18:54 +0000 (14:18 +0100)]
x86: split boot trampoline into permanent and temporary part

The hypervisor needs a trampoline in low memory for early boot and
later for bringing up cpus and during wakeup from suspend. Today this
trampoline is kept completely even if most of it isn't needed later.

Split the trampoline into a permanent part and a temporary part needed
at early boot only. Introduce a new entry at the boundary.

Reduce the stack for wakeup code in order for the permanent
trampoline to fit in a single page. 4k of stack seems excessive, about
3k should be more than enough.

Add an ASSERT() to the linker script to ensure the wakeup stack is
always at least 3k.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mm: fix the check in get_pg_owner
Wei Liu [Fri, 24 Mar 2017 11:34:01 +0000 (11:34 +0000)]
x86/mm: fix the check in get_pg_owner

PVH (both v1 and v2) guest is actually an translated guest. It should be
able to manipulate page table for other domains when acting as Dom0.

The removal of PVHv1 deleted the special case for PVH guest but didn't
add a check for HVM guest.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agodocs: update HVM emulated unplug protocol to cover NVMe disks
Paul Durrant [Fri, 24 Mar 2017 11:00:13 +0000 (11:00 +0000)]
docs: update HVM emulated unplug protocol to cover NVMe disks

Recent discussions on xen-devel have highlighted that to properly
support displacing emulated NVMe disks with PV equivalents will need
updates to PV frontends. Therefore it is important that, if an emulated
NVMe disk is exposed to a guest with an existing PV storage frontend,
that frontend does not inadvertently cause unplug of that emulated
disk when unplugging IDE or SCSI disks.

This patch defines a new bit in the mask used to instruct QEMU to unplug
emulated devices which will instruct QEMU to unplug NVMe disks and limits
the semantics of the existing 'all' disk-unplug bit to only IDE and/or SCSI
disks.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
8 years agoConfig.mk: update OVMF changeset
Anthony PERARD [Thu, 23 Mar 2017 17:10:09 +0000 (17:10 +0000)]
Config.mk: update OVMF changeset

This new changeset contain a fix to build with GCC 6.3.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxen/Makefile: remove all temporary files for every architecture
Luca Miccio [Thu, 23 Mar 2017 01:31:37 +0000 (02:31 +0100)]
xen/Makefile: remove all temporary files for every architecture

Execute the clean target for both arm and x86 architecture.

When trying to build Xen for a different architecture in the same
tree, the command make clean will only remove temporary files for
the host architecture.
This will lead a compilation error when trying to build ARM64 and
ARM32 Xen in the same tree.
(See also: https://lists.xenproject.org/archives/html/xen-devel/2016-11/msg02176.html)

Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxenforeignmemory: add a call to restrict the handle
Paul Durrant [Wed, 22 Mar 2017 11:25:25 +0000 (11:25 +0000)]
tools/libxenforeignmemory: add a call to restrict the handle

Commit 8ef5f344d061 "tools/libxendevicemodel: add a call to restrict the
handle" added a function to the devicemodel interface to restrict
operations through the API to a specific domain, where a capable under-
lying privcmd driver exists.

This patch adds similar functionality to the xenforeignmemory API. This
will be necessary (as much as xendevicemodel restriction) for limiting
the scope of device models to specific domains.

NOTE: My patch to the linux kernel [1] added the appropriate checks to
      the foreign memory ioctls.

[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=4610d240

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoarm/mm: remove unused p2m_refcount in page_info
Wei Liu [Thu, 23 Mar 2017 16:06:28 +0000 (16:06 +0000)]
arm/mm: remove unused p2m_refcount in page_info

The code which used that field has been deleted. Found by code
inspection.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agox86/shadow: Drop VALID_GFN()
Andrew Cooper [Wed, 1 Mar 2017 18:01:51 +0000 (18:01 +0000)]
x86/shadow: Drop VALID_GFN()

There is only one single user of VALID_GFN().  Inline the macro to remove the
added layer of indirection in sh_gva_to_gfn()

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
8 years agox86/pagewalk: Use pointer syntax for pfec parameter
Andrew Cooper [Thu, 2 Mar 2017 14:35:50 +0000 (14:35 +0000)]
x86/pagewalk: Use pointer syntax for pfec parameter

It is a pointer, not an array.

No functional change.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
8 years agox86/cpuid: Sort cpu_has_* predicates by feature number
Andrew Cooper [Tue, 14 Mar 2017 15:32:38 +0000 (15:32 +0000)]
x86/cpuid: Sort cpu_has_* predicates by feature number

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/viridian: annotate intentional fallthrough
Andrew Cooper [Thu, 23 Mar 2017 14:53:37 +0000 (15:53 +0100)]
x86/viridian: annotate intentional fallthrough

This stops Coverity complaining.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoarch: drop ALIGN_STR
Jan Beulich [Thu, 23 Mar 2017 14:53:02 +0000 (15:53 +0100)]
arch: drop ALIGN_STR

... as being unused and having been unusable: It was clearly intended
for use in asm(), yet was placed inside __ASSEMBLY__ conditionals.

Also drop __ALIGN{,_STR} - there's no need to have a second flavor of
these constructs with no difference in behavior.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agox86/viridian: implement the crash MSRs
Paul Durrant [Thu, 23 Mar 2017 14:52:08 +0000 (15:52 +0100)]
x86/viridian: implement the crash MSRs

Section 2.4.4 of the Hypervisor Top Level Functional Specification states
that enabling bit 10 in EDX of CPUID leaf 3 advertises to Windows a set
of MSRs into which it can write crash information.

This patch advertises that bit and implements the MSRs such that Xen can
log the information if a Windows guest crashes.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agox86/viridian: make the threshold for HvNotifyLongSpinWait tunable
Paul Durrant [Thu, 23 Mar 2017 14:51:45 +0000 (15:51 +0100)]
x86/viridian: make the threshold for HvNotifyLongSpinWait tunable

The current threshold before the guest issues the hypercall is, and always
has been, hard-coded to 2047. It is not clear where this number came
from so, to at least allow for ease of experimentation, this patch makes
the threshold tunable via the Xen command line.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/viridian: don't put Xen version information in CPUID leaf 2
Paul Durrant [Thu, 23 Mar 2017 14:51:14 +0000 (15:51 +0100)]
x86/viridian: don't put Xen version information in CPUID leaf 2

The Hypervisor Top Level Functional Specification v5.0a states in section
2.5:

"The hypervisor version information is encoded in leaf 0x40000002. Two
version numbers are provided: the main version and the service version.
The main version includes a major and minor version number and a build
number. These correspond to Microsoft Windows release numbers."

It also goes on to advise clients (i.e. guest versions of Windows) to use
the following algorithm to determine compatibility with the hypervisor
enlightenments:

if <your-main-version> greater than <hypervisor-main-version>
{
your version is compatible
}
else if <your-main-version> equal to <hypervisor-main-version> and
 <your-service-version> greater than or equal to <hypervisor-service-version>
{
your version is compatible
}
else
{
your version is NOT compatible
}

So, clearly putting Xen hypervisor version information in that leaf is
spurious, but we probably get away with it because Xen's major version
is lower than the major version of Windows in which Hyper-V first
appeared (Server 2008).

This patch changes the leaf to use the kernel major and minor
versions, and build number from Windows Server 2008 (64-bit) by default.
These default values can be overriden from the Xen command line using new
'viridian-version' parameter.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agolibxl: use libxl__xs_read_checked() instead or raw xs_read() in do_domain_soft_reset()
Vitaly Kuznetsov [Wed, 22 Mar 2017 13:59:45 +0000 (14:59 +0100)]
libxl: use libxl__xs_read_checked() instead or raw xs_read() in do_domain_soft_reset()

Replace raw xs_read() calls with libxl__xs_read_checked() and bail on error.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxl: preserve console tty across soft reset
Vitaly Kuznetsov [Wed, 22 Mar 2017 13:59:44 +0000 (14:59 +0100)]
libxl: preserve console tty across soft reset

On soft reset we remove the domain from xenstore and introduce it back to
have everything reconnected. Console, however, stays attached (as xenconsoled
checks if the domain is dying and our domain is not) but we lose the
information about tty:

before soft reset:
   console = ""
    ...
    type = "xenconsoled"
    output = "pty"
    tty = "/dev/pts/1"
    ...

after:
   console = ""
    ...
    type = "xenconsoled"
    output = "pty"
    tty = ""
    ...

The issue applies to both HVM and PVH but for HVM guests serial console
through QEMU is usually in use and for PVH we don't have it.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoCOLO-proxy: Fix argument check error
Zhang Chen [Thu, 23 Mar 2017 11:43:55 +0000 (19:43 +0800)]
COLO-proxy: Fix argument check error

Here, we should check the 'outdev' before use.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoARM: arm64: activate atomic 64-bit accessors
Andre Przywara [Thu, 16 Mar 2017 11:20:10 +0000 (11:20 +0000)]
ARM: arm64: activate atomic 64-bit accessors

For some reason (probably because there was no user before) the 64-bit
atomic access wrappers were commented out so far.
As we will need them in the next patch, active (and fix) them now.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agolibxl: don't try to rename dm save file for PVH
Vitaly Kuznetsov [Mon, 20 Mar 2017 18:03:10 +0000 (19:03 +0100)]
libxl: don't try to rename dm save file for PVH

Guests with LIBXL_DEVICE_MODEL_VERSION_NONE don't have a device model
running so there is no save file to rename.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxc: Drop dombuilder support for PV autotranslate guests
Andrew Cooper [Mon, 20 Mar 2017 16:32:10 +0000 (16:32 +0000)]
tools/libxc: Drop dombuilder support for PV autotranslate guests

c/s 4045953 "x86/paging: Enforce PG_external == PG_translate == PG_refcounts"
in the hypervisor finally prevented the construction of PV autotranslate
guests.

Remove support for such guests in the domain builder, bailing out with an
obvious "no longer supported" message, rather than a more obscure
"SHADOW_OP_ENABLED failed".

As a piece of cleanup, rename xc_dom_feature_translated() to
xc_dom_translated() to match its actual semantics.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxenstore: add missing checks for allocation failure
Juergen Gross [Mon, 20 Mar 2017 08:00:21 +0000 (09:00 +0100)]
xenstore: add missing checks for allocation failure

Add missing allocation failure checks.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxenstore: set correct error code when violating quota
Juergen Gross [Mon, 20 Mar 2017 08:00:20 +0000 (09:00 +0100)]
xenstore: set correct error code when violating quota

When the number of permitted xenstore entries for a domain is being
exceeded the operation trying to create a new entry is denied.
Unfortunately errno isn't being set in this case so the error code
returned to the client is undefined.

Set errno to ENOSPC in this case.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agox86/viridian: add warnings for unimplemented hypercalls and MSRs
Paul Durrant [Wed, 22 Mar 2017 11:04:20 +0000 (12:04 +0100)]
x86/viridian: add warnings for unimplemented hypercalls and MSRs

These warnings can be useful when Microsoft updates Windows.

In the past there have been several cases when Windows erroneously uses
hypercalls and MSRs that should be gated on CPUID flags than Xen does
not set. The usual symptom is a guest crash with little or no information
in the hypervisor log. Adding these warnings at least gives a clue as to
what might be happening in such cases.

Some versions of Windows do currently issue hypercalls that they should
not, so this patch whitelists those to avoid the warnings as the lack
of implementation is clearly proved not to be a problem to the guest.

The warnings are rate limited so a malicious guest cannot use them to
as a DoS.

NOTE: Because the MSR warnings need to be gated on range checking the
      MSR address this patch imports the up-to-date definitions of all
      the viridian MSRs from the specification.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/viridian: get rid of the magic numbers in CPUID leaves 1 and 2
Paul Durrant [Wed, 22 Mar 2017 11:03:54 +0000 (12:03 +0100)]
x86/viridian: get rid of the magic numbers in CPUID leaves 1 and 2

The numbers correspond to ASCII characters so just use appropriate
character strings directly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/viridian: fix xen-hvmcrash when vp_assist page is present
Paul Durrant [Wed, 22 Mar 2017 11:03:03 +0000 (12:03 +0100)]
x86/viridian: fix xen-hvmcrash when vp_assist page is present

Currently use of xen-hvmcrash will cause an immediate domain_crash() in
initialize_vp_assist() because it is called from viridian_load_vcpu_ctxt()
without having first cleared any previous mapping.

This patch addes a check into viridian_load_vcpu_ctxt() to avoid re-
initialization and turned the domain_crash() in initialize_vp_assist()
into an ASSERT() since neither codepath into that function should allow
it to be hit.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mm: use statically defined locking order
Ross Lagerwall [Wed, 22 Mar 2017 11:02:01 +0000 (12:02 +0100)]
x86/mm: use statically defined locking order

Instead of using a locking order based on line numbers which interacts
poorly with trying to create a live patch, statically define the locking
order.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
8 years agoQEMU_TAG update
Ian Jackson [Tue, 21 Mar 2017 18:43:44 +0000 (18:43 +0000)]
QEMU_TAG update

8 years agomisc/branching-checklist: Call mg-branch-setup in Cambridge too
Ian Jackson [Thu, 9 Mar 2017 15:15:00 +0000 (15:15 +0000)]
misc/branching-checklist: Call mg-branch-setup in Cambridge too

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
8 years agomisc/release-checklist: Split out branching-checklist.txt
Ian Jackson [Tue, 7 Mar 2017 15:18:33 +0000 (15:18 +0000)]
misc/release-checklist: Split out branching-checklist.txt

This is almost all just motion.  There is one new paragraph in
branching-checklist.txt:

+ Update both new branches according to release-checklist.txt section re
+ README etc.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
8 years agomisc/release-checklist: Remove pre-4.3 tarball target instructions
Ian Jackson [Tue, 7 Mar 2017 15:15:25 +0000 (15:15 +0000)]
misc/release-checklist: Remove pre-4.3 tarball target instructions

4.2 is well out of support and we will never need to make a release of
it again.  Delete all the stuff for making combined tarballs "by hand".

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
8 years agomisc/release-checklist: Remove clearly-obsolete stuff
Ian Jackson [Tue, 7 Mar 2017 15:11:00 +0000 (15:11 +0000)]
misc/release-checklist: Remove clearly-obsolete stuff

Remove:

 - Head comment saying not to edit here.  This came from the
   now-no-longer-master xenbits copy which I have deleted.

 - Many old (commented-out) instruction related to hg

 - Many old (commented-out) instruction related to pre-unified
   qemu trees.

 - Many old (commented-out) instruction related to ancient
   locations within Citrix.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
8 years agocommon: allow a default compiled-in command line using Kconfig
Zhongze Liu [Tue, 21 Mar 2017 14:14:21 +0000 (15:14 +0100)]
common: allow a default compiled-in command line using Kconfig

This allows downstreams to set their defaults without modifying the source code
all over the place. Also probably useful for the embedded space.
(See Also: https://xenproject.atlassian.net/browse/XEN-41)

If CMDLINE is set, it will be parsed prior to the bootloader command line.
This order of parsing implies that if any non-cumulative options are set in
both CMDLINE and the bootloader command line, only the ones in the latter will
take effect. Furthermore, if CMDLINE_OVERRIDE is set to y, the whole
bootloader command line will be ignored, which will be useful to work around
broken bootloaders. A wrapper to the original common/kernel.c:cmdline_parse()
was introduced to complete this task.

Signed-off-by: Zhongze Liu <blackskygg@gmail.com>
[jb: fix non-EXPERT build]
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agox86emul: correct FPU code/data pointers and opcode handling
Jan Beulich [Tue, 21 Mar 2017 14:13:42 +0000 (15:13 +0100)]
x86emul: correct FPU code/data pointers and opcode handling

Prevent leaking the hypervisor ones (stored by hardware during stub
execution), at once making sure the guest sees correct values there.
This piggybacks on the backout logic used to deal with write faults of
FPU insns.

Deliberately ignore the NO_FPU_SEL feature here: Honoring it would
merely mean extra code with no benefit (once we XRSTOR state, the
selector values will simply be lost anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com> [hvm/emulate.c]
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: correct handling of FPU insns faulting on memory write
Jan Beulich [Tue, 21 Mar 2017 14:12:59 +0000 (15:12 +0100)]
x86emul: correct handling of FPU insns faulting on memory write

When an FPU instruction with a memory destination fails during the
memory write, it should not affect FPU register state. Due to the way
we emulate FPU (and SIMD) instructions, we can only guarantee this by
- backing out changes to the FPU register state in such a case or
- doing a descriptor read and/or page walk up front, perhaps with the
  stubs accessing the actual memory location then.
The latter would require a significant change in how the emulator does
its guest memory accessing, so for now the former variant is being
chosen.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com> [hvm/emulate.c]
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
8 years agox86emul: centralize put_fpu() invocations
Jan Beulich [Tue, 21 Mar 2017 14:10:25 +0000 (15:10 +0100)]
x86emul: centralize put_fpu() invocations

..., splitting parts of it into check_*() macros. This is in
preparation of making ->put_fpu() do further adjustments to register
state. (Some of the check_xmm() invocations could be avoided, as in
some of the cases no insns handled there can actually raise #XM, but I
think we're better off keeping them to avoid later additions of further
insn patterns rendering the lack of the check a bug.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agotools/insn-fuzz: Support AFL's afl-clang-fast mode
Andrew Cooper [Wed, 1 Mar 2017 19:02:35 +0000 (19:02 +0000)]
tools/insn-fuzz: Support AFL's afl-clang-fast mode

AFL has an alternative llvm-base instrumentation mode, which has much lower
overhead than the traditional afl-gcc.

One extra ability is to chose exactly where the master process gets
initialised to, before being forked for testing.  This point is chosen after
the call to LLVMFuzzerInitialize(), so the stack isn't being remapped
executable for every test.

Another extra ability is to feed multiple inputs into a single test process,
to reduce the number of fork() calls required overall.  Two caveats are that if
stdin is used for data, it must be unbuffered, and if input is passed via a
command line parameter, the underlying file must be opened and closed on each
iteration.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/insn-fuzz: Make use of LLVMFuzzerInitialize()
Andrew Cooper [Wed, 1 Mar 2017 18:46:52 +0000 (18:46 +0000)]
tools/insn-fuzz: Make use of LLVMFuzzerInitialize()

libfuzz can perform one-time initialisation by calling LLVMFuzzerInitialize().
Move emul_test_init() into this, to avoid repeating it on every
LLVMFuzzerTestOneInput() call.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/insn-fuzz: Accept fuzzing input on stdin
Andrew Cooper [Thu, 2 Mar 2017 17:24:30 +0000 (17:24 +0000)]
tools/insn-fuzz: Accept fuzzing input on stdin

This is rather faster for afl-fuzz to arrange than using an explicit file
parameter.  Also update the README to recommend using a tmpfs for findings_dir
which reduces disk load and is more performant.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/insn-fuzz: Use getopt() for parsing the command line
Andrew Cooper [Thu, 2 Mar 2017 17:01:34 +0000 (17:01 +0000)]
tools/insn-fuzz: Use getopt() for parsing the command line

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/insn-fuzz: Use shorter filenames
Andrew Cooper [Wed, 1 Mar 2017 18:13:46 +0000 (18:13 +0000)]
tools/insn-fuzz: Use shorter filenames

Amongst other things, these tab complete more easily.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/fuzz: Include LLVMFuzzerTestOneInput() in the generated .a
Andrew Cooper [Wed, 1 Mar 2017 18:22:31 +0000 (18:22 +0000)]
tools/fuzz: Include LLVMFuzzerTestOneInput() in the generated .a

Otherwise they are not suitable for use with libfuzz.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/fuzz: Use $(CC) for linking the harnesses
Andrew Cooper [Thu, 2 Mar 2017 20:41:49 +0000 (20:41 +0000)]
tools/fuzz: Use $(CC) for linking the harnesses

This is necessary to make use of compiler features such as UBSAN.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/fuzz: Remove .d files in clean
Andrew Cooper [Wed, 1 Mar 2017 17:46:18 +0000 (17:46 +0000)]
tools/fuzz: Remove .d files in clean

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
8 years agoAMD-Vi: allocate root table on demand
Jan Beulich [Mon, 20 Mar 2017 16:00:34 +0000 (17:00 +0100)]
AMD-Vi: allocate root table on demand

This was my originally intended fix for the AMD side of XSA-207:
There's no need to unconditionally allocate the root table, and with
that there's then also no way to leak it when a guest has no devices
assigned.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
8 years agox86/viridian: update to version 5.0a of the specification
Paul Durrant [Mon, 20 Mar 2017 15:59:54 +0000 (16:59 +0100)]
x86/viridian: update to version 5.0a of the specification

The Hypervisor Top Level Functional Specification v5.0a has many differences
from previous versions and introduces whole new sections.

This patch:

- Updates the URL at the top of the source.
- Fixes up section references accordingly.
- Modifies the MSR naming convention in the code to match the specification.
- Rename the apic_assist page to the vp_assist page to reflect the change
  in the specification.
  (The APIC assist feature itself is inconsistently named in the
  specification so stick wth the current feature name).
- Updates the handling of CPUID leaf 3.

There is one functional change in this patch: The vp_assist page is
mapped (and completely zeroed) regardless of whether the APIC assist
feature is enabled. This reflects its new wider remit and simplifies the
code slightly.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mce: add blank lines between non-fall-through switch case blocks
Haozhong Zhang [Mon, 20 Mar 2017 15:59:16 +0000 (16:59 +0100)]
x86/mce: add blank lines between non-fall-through switch case blocks

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mce_intel: refine messages of MCA capabilities
Haozhong Zhang [Mon, 20 Mar 2017 15:58:33 +0000 (16:58 +0100)]
x86/mce_intel: refine messages of MCA capabilities

... to only print available ones.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mce: switch bool_t/1/0 to bool/true/false
Haozhong Zhang [Mon, 20 Mar 2017 15:57:29 +0000 (16:57 +0100)]
x86/mce: switch bool_t/1/0 to bool/true/false

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: remove stale PVHv1 comment from PV domain builder
Wei Liu [Mon, 20 Mar 2017 15:01:04 +0000 (15:01 +0000)]
x86: remove stale PVHv1 comment from PV domain builder

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agosched.h: remove stale PVHv1 comment
Wei Liu [Thu, 16 Mar 2017 18:38:46 +0000 (18:38 +0000)]
sched.h: remove stale PVHv1 comment

With the removal of PVHv1 this comment is wrong. Just remove it.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agodocs: update dmop.markdown
Wei Liu [Thu, 16 Mar 2017 18:30:12 +0000 (18:30 +0000)]
docs: update dmop.markdown

... to match the code after the removal of PVHv1.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: clean up header files in dom0_build.c
Wei Liu [Thu, 16 Mar 2017 17:48:00 +0000 (17:48 +0000)]
x86: clean up header files in dom0_build.c

Remove the ones that are no longer needed and sort them.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: split PVH dom0 builder to hvm/dom0_build.c
Wei Liu [Thu, 16 Mar 2017 17:43:24 +0000 (17:43 +0000)]
x86: split PVH dom0 builder to hvm/dom0_build.c

Long term we want to be able to disentangle PV and HVM code. Move
the PVH domain builder to a dedicated file.

Lift function declarations to dom0_build.h and rename them when
necessary.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: split PV dom0 builder to pv/dom0_builder.c
Wei Liu [Thu, 16 Mar 2017 16:53:20 +0000 (16:53 +0000)]
x86: split PV dom0 builder to pv/dom0_builder.c

Long term we want to be able to disentangle PV and HVM code. Move the PV
domain builder to a dedicated file.

This in turn requires exposing a few functions and variables via a new
header dom0_build.h. These functions and variables are now prefixed with
"dom0_" if they weren't already so.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: modify setup_dom0_vcpu to use dom0_cpus internally
Wei Liu [Mon, 20 Mar 2017 13:05:08 +0000 (13:05 +0000)]
x86: modify setup_dom0_vcpu to use dom0_cpus internally

We will later move dom0 builders to different directories. To avoid the
need of making dom0_cpus visible outside dom0_builder.c, modify
setup_dom0_vcpus to cycle through dom0_cpus internally instead of
relying on the callers to do that.

No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: rename domain_build.c to dom0_build.c
Wei Liu [Thu, 16 Mar 2017 16:40:53 +0000 (16:40 +0000)]
x86: rename domain_build.c to dom0_build.c

To reflect the true nature of this file. No functional change.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agolibxl/libxl_qmp.c: Update COLO query replication status API
Zhang Chen [Fri, 17 Mar 2017 08:42:32 +0000 (16:42 +0800)]
libxl/libxl_qmp.c: Update COLO query replication status API

The QEMU community has asked us to change QMP command
xen-get-replication-error to query-xen-replication-status. Modify Xen
side to use the new name.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxl/libxl_qmp.c: Update COLO do checkpoint API
Zhang Chen [Fri, 17 Mar 2017 08:42:31 +0000 (16:42 +0800)]
libxl/libxl_qmp.c: Update COLO do checkpoint API

The QEMU community has asked us to change the QMP command from
xen-do-checkpoint to xen-colo-do-checkpoint. Modify Xen side to use
the new name.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agox86/time: don't use virtual TSC if host and guest frequencies are equal
Boris Ostrovsky [Mon, 20 Mar 2017 08:27:35 +0000 (09:27 +0100)]
x86/time: don't use virtual TSC if host and guest frequencies are equal

Commit 82713ec8d2 ("x86: use native RDTSC(P) execution when guest and
host frequencies are the same") left out optimization for PV guests
when host and guest run at the same frequency.

For such a case we should be able not to use virtual TSC regardless
of whether we are runing before or after a migration (i.e. regardless
of incarnation value).

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
[jb: retain parts of the original comment]
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/EFI: avoid Xen image when looking for module/kexec position
Jan Beulich [Mon, 20 Mar 2017 08:27:12 +0000 (09:27 +0100)]
x86/EFI: avoid Xen image when looking for module/kexec position

When booting straight from EFI, we don't further try to relocate Xen.
As a result, so far we also didn't avoid the area Xen uses when looking
for a location to put modules or the kexec area. Introduce a fake
module slot to deal with that without having to fiddle with a lot of
code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/EFI: avoid IOMMU faults on [_end,__2M_rwdata_end)
Jan Beulich [Mon, 20 Mar 2017 08:25:36 +0000 (09:25 +0100)]
x86/EFI: avoid IOMMU faults on [_end,__2M_rwdata_end)

Commit c9a4a1c419 ("x86/layout: Correct Xen's idea of its own memory
layout") didn't go far enough with the conversion, causing IOMMU faults
when memory from that range was handed to a domain. We must not make
this memory available for allocation (the change is benign to xen.gz at
this point in time).

Note that the change to tboot_shutdown() is fixing another issue at
once: As it looks, the function so far skipped all memory below the Xen
image.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/EFI: avoid overrunning mb_modules[]
Jan Beulich [Fri, 17 Mar 2017 14:45:22 +0000 (15:45 +0100)]
x86/EFI: avoid overrunning mb_modules[]

Commit 436fb462ab ("x86/microcode: enable boot time (pre-Dom0)
loading") added a 4th module without providing an array slot for it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: parallelize SIMD test code building
Jan Beulich [Fri, 17 Mar 2017 08:34:38 +0000 (09:34 +0100)]
x86emul: parallelize SIMD test code building

In anticipation of further flavors (AVX, AVX-512) going to be added
(which would make the current situation even worse), facilitate
reduction of build time (and hence latency to availability of test
results) via use of make's -j option.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: correct DECLARE_ALIGNED()
Jan Beulich [Fri, 17 Mar 2017 08:33:45 +0000 (09:33 +0100)]
x86emul: correct DECLARE_ALIGNED()

Stop creating an excessively large array on the stack, by properly
taking into account the array element size when establishing its
element count (and of course also when calculating the pointer to
be actually used to access the memory).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agocredit2: remove undefined declaration of __dump_execstate()
Dario Faggioli [Fri, 17 Mar 2017 08:31:58 +0000 (09:31 +0100)]
credit2: remove undefined declaration of __dump_execstate()

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
8 years agoRevert "x86/vvmx: correct nested shadow VMCS handling"
Jan Beulich [Fri, 17 Mar 2017 08:31:19 +0000 (09:31 +0100)]
Revert "x86/vvmx: correct nested shadow VMCS handling"

This reverts commit dc05c0ceeb8609b6d60f6a117a0192e9160946b8,
causing a regression.

8 years agoRevert "x86/vvmx: add a shadow vmcs check to vmlaunch"
Jan Beulich [Fri, 17 Mar 2017 08:30:41 +0000 (09:30 +0100)]
Revert "x86/vvmx: add a shadow vmcs check to vmlaunch"

This reverts commit b22ee98c4ecc4e7c827451dee01181529df4d26c,
causing a regression.

8 years agolibxl/colo: unified exit path for colo_proxy_checkpoint
Wei Liu [Wed, 15 Mar 2017 10:50:19 +0000 (10:50 +0000)]
libxl/colo: unified exit path for colo_proxy_checkpoint

Slightly refactor the code to have only one exit path for the said
function.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
8 years agox86/PVHv2: move pvh_setup_e820 together with the other pvh functions
Roger Pau Monne [Thu, 2 Mar 2017 18:31:04 +0000 (18:31 +0000)]
x86/PVHv2: move pvh_setup_e820 together with the other pvh functions

This function is only used by PVHv2 domain build, so move it together with the
other PVH domain build functions.

Just code motion, no functional change.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: remove has_hvm_container_{domain/vcpu}
Roger Pau Monne [Fri, 3 Mar 2017 12:19:22 +0000 (12:19 +0000)]
x86: remove has_hvm_container_{domain/vcpu}

It is now useless since PVHv1 is removed and PVHv2 is a HVM domain from Xen's
point of view.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
8 years agox86: remove PVHv1 code
Roger Pau Monne [Fri, 3 Mar 2017 12:19:22 +0000 (12:19 +0000)]
x86: remove PVHv1 code

This removal applies to both the hypervisor and the toolstack side of PVHv1.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
8 years agoocaml/gen: fix ocaml type/code generator from IDL
Ian Jackson [Fri, 3 Mar 2017 12:19:21 +0000 (12:19 +0000)]
ocaml/gen: fix ocaml type/code generator from IDL

This patch adds support for union members which have their own type name.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave@recoil.org>
8 years agotools/kdd: don't use a pointer to an unaligned field.
Tim Deegan [Fri, 10 Mar 2017 10:10:57 +0000 (10:10 +0000)]
tools/kdd: don't use a pointer to an unaligned field.

The 'val' field in the packet is byte-aligned (because it is part of a
packed struct), but the pointer argument to kdd_rdmsr() has the normal
alignment constraints for a uint64_t *.  Use a local variable to make sure
the passed pointer has the correct alignment.

Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Roger Pau Monné <roger.pau@citrix.com>
8 years agotools: remove gntshr support
Juergen Gross [Wed, 15 Mar 2017 07:13:31 +0000 (08:13 +0100)]
tools: remove gntshr support

libgnttab contains the complete gntshr support, but the tools build
infrastructure contains dedicated support for gntshr _and_ gnttab.

Remove the gntshr specific flags and switch their users to gnttab
instead.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/xl/xl_parse.c: Remove blank line.
Zhang Chen [Wed, 15 Mar 2017 02:34:55 +0000 (10:34 +0800)]
tools/xl/xl_parse.c: Remove blank line.

Address Liu Wei's comments.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: include sys/sysmacros.h on Linux
Olaf Hering [Wed, 15 Mar 2017 07:01:34 +0000 (07:01 +0000)]
tools: include sys/sysmacros.h on Linux

Due to a bug in the glibc headers the macros makedev(), major() and
minor() where avaialble by including sys/types.h. This bug was
addressed in glibc-2.25 by introducing a warning when these macros are
used. Since Xen is build with -Werror this new warning cause a compile
error.

Use sys/sysmacros.h to define these three macros.

blktap2 is already Linux specific. The kernel header which was used to
get makedev() does not provided it anymore, and it was wrong to use a
kernel header anyway.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxc: Fix ARM build broken by XEN_DOMCTL_getvcpuextstate commit
Razvan Cojocaru [Wed, 15 Mar 2017 09:20:30 +0000 (11:20 +0200)]
tools/libxc: Fix ARM build broken by XEN_DOMCTL_getvcpuextstate commit

The previous "tools/libxc: Exposed XEN_DOMCTL_getvcpuextstate" broke
the ARM build (the hypercall does not have a corresponding DOMCTL
ARM struct). This patch fixes the build by returning -ENODEV for
ARM from xc_vcpu_get_extstate().

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxen/arm: p2m: Perform local TLB invalidation on vCPU migration
Julien Grall [Wed, 8 Mar 2017 18:06:02 +0000 (18:06 +0000)]
xen/arm: p2m: Perform local TLB invalidation on vCPU migration

The ARM architecture allows an OS to have per-CPU page tables, as it
guarantees that TLBs never migrate from one CPU to another.

This works fine until this is done in a guest. Consider the following
scenario:
    - vcpu-0 maps P to V
    - vpcu-1 maps P' to V

If run on the same physical CPU, vcpu-1 can hit in TLBs generated by
vcpu-0 accesses, and access the wrong physical page.

The solution to this is to keep a per-p2m map of which vCPU ran the last
on each given pCPU and invalidate local TLBs if two vPCUs from the same
VM run on the same CPU.

Unfortunately it is not possible to allocate per-cpu variable on the
fly. So for now the size of the array is NR_CPUS, this is fine because
we still have space in the structure domain. We may want to add an
helper to allocate per-cpu variable in the future.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoEFI: retrieve and expose Apple device properties
Jan Beulich [Tue, 14 Mar 2017 17:21:09 +0000 (18:21 +0100)]
EFI: retrieve and expose Apple device properties

Apple's EFI drivers supply device properties which are needed to
support Macs optimally. They contain vital information which cannot be
obtained any other way (e.g. Thunderbolt Device ROM). They're also used
to convey the current device state so that OS drivers can pick up where
EFI drivers left (e.g. GPU mode setting).

Reference: Linux commit 58c5475aba67706b31d9237808d5d3d54074e5ea (see
there for the full original commit message, only the initial part of
which is being reproduced above)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: correct {,v}{ld,st}mxcsr handling
Jan Beulich [Tue, 14 Mar 2017 17:20:27 +0000 (18:20 +0100)]
x86emul: correct {,v}{ld,st}mxcsr handling

Calls to get_fpu() were missing. Calls to put_fpu() are deliberately
not being added: Neither instruction can raise #XM, so the catch-all
_put_fpu() is just fine here.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild/clang: fix XSM dummy policy when using clang 4.0
Roger Pau Monné [Tue, 14 Mar 2017 17:19:29 +0000 (18:19 +0100)]
build/clang: fix XSM dummy policy when using clang 4.0

There seems to be some weird bug in clang 4.0 that prevents xsm_pmu_op from
working as expected, and vpmu.o ends up with a reference to
__xsm_action_mismatch_detected which makes the build fail:

[...]
ld    -melf_x86_64_fbsd  -T xen.lds -N prelink.o  \
    xen/common/symbols-dummy.o -o xen/.xen-syms.0
prelink.o: In function `xsm_default_action':
xen/include/xsm/dummy.h:80: undefined reference to `__xsm_action_mismatch_detected'
xen/xen/include/xsm/dummy.h:80: relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__xsm_action_mismatch_detected'
ld: xen/xen/.xen-syms.0: hidden symbol `__xsm_action_mismatch_detected' isn't defined

Then doing a search in the objects files:

# find xen/ -type f -name '*.o' -print0 | xargs -0 bash -c \
  'for filename; do nm "$filename" | \
  grep -q __xsm_action_mismatch_detected && echo "$filename"; done' bash
xen/arch/x86/prelink.o
xen/arch/x86/cpu/vpmu.o
xen/arch/x86/cpu/built_in.o
xen/arch/x86/built_in.o

The current patch is the only way I've found to fix this so far, by simply
moving the XSM_PRIV check into the default case in xsm_pmu_op. This also fixes
the behavior of do_xenpmu_op, which will now return -EINVAL for unknown
XENPMU_* operations, instead of -EPERM when called by a privileged domain.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
8 years agotools/libxl: correct distclean target
Juergen Gross [Tue, 14 Mar 2017 15:04:42 +0000 (16:04 +0100)]
tools/libxl: correct distclean target

Commit 3e5f1a63b53920763 ("tools: adapt xenlight.pc and xlutil.pc to
new pkg-config scheme") introduced an error for "make distclean" as
*.pc.in are deleted which are now files in git.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: correct build in directory below tools
Juergen Gross [Tue, 14 Mar 2017 15:04:41 +0000 (16:04 +0100)]
tools: correct build in directory below tools

Recent changes to create *.pc files introduced a bug when trying to
build a library from a directory below tools as PKG_CONFIG_DIR wouldn't
be set. Correct this by adding a default value to Rules.mk.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxc: Exposed XEN_DOMCTL_getvcpuextstate
Razvan Cojocaru [Tue, 14 Mar 2017 13:30:18 +0000 (15:30 +0200)]
tools/libxc: Exposed XEN_DOMCTL_getvcpuextstate

It's useful for an introspection tool to be able to inspect
XSAVE states. Xen already has a DOMCTL that can be used for this
purpose, but it had no public libxc wrapper. This patch adds
xc_vcpu_get_extstate().

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: adapt xenlight.pc and xlutil.pc to new pkg-config scheme
Juergen Gross [Tue, 14 Mar 2017 13:31:24 +0000 (14:31 +0100)]
tools: adapt xenlight.pc and xlutil.pc to new pkg-config scheme

Instead of generating the *.pc.in files at configure time use the new
pkg-config scheme for those files. Add the dependencies to other Xen
libraries as needed.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenblktapctl
Juergen Gross [Tue, 14 Mar 2017 13:31:23 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenblktapctl

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenblktapctl.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenvchan
Juergen Gross [Tue, 14 Mar 2017 13:31:22 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenvchan

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenvchan.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenstat
Juergen Gross [Tue, 14 Mar 2017 13:31:21 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenstat

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenstat.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenstore
Juergen Gross [Tue, 14 Mar 2017 13:31:20 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenstore

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenstore.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenguest, update the one for libxenctrl
Juergen Gross [Tue, 14 Mar 2017 13:31:19 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenguest, update the one for libxenctrl

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenguest.pc file.

Update the xencontrol.pc file to reflect the dependencies of libxenctrl.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxendevicemodel
Juergen Gross [Tue, 14 Mar 2017 13:31:18 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxendevicemodel

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xendevicemodel.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenforeignmemory
Juergen Gross [Tue, 14 Mar 2017 13:31:17 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenforeignmemory

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenforeignmemory.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxencall
Juergen Gross [Tue, 14 Mar 2017 13:31:16 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxencall

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xencall.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxengnttab
Juergen Gross [Tue, 14 Mar 2017 13:31:15 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxengnttab

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xengnttab.pc and a xengntshr.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxenevtchn
Juergen Gross [Tue, 14 Mar 2017 13:31:14 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxenevtchn

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xenevtchn.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: provide pkg-config file for libxentoollog
Juergen Gross [Tue, 14 Mar 2017 13:31:13 +0000 (14:31 +0100)]
tools: provide pkg-config file for libxentoollog

In order to be able to use pkg-config for obtaining linker- and
compiler-flags provide a xentoollog.pc file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools: add support for additional items in .pc files for local builds
Juergen Gross [Tue, 14 Mar 2017 13:31:12 +0000 (14:31 +0100)]
tools: add support for additional items in .pc files for local builds

Some libraries require different compiler-flags when being used in a
local build compared to a build using installed libraries.

Reflect that by supporting local cflags variables in generated
pkg-config files. The local variants will be empty in the installed
pkg-config files.

The flags for the linker in the local variants will have to specify
the search patch for the library with "-Wl,-rpath-link=", while the
flags for the installed library will be "-L".

Add needed directory patterns.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>