]> xenbits.xensource.com Git - xen.git/log
xen.git
8 years agopython: drop tp_getattr implementation
Marek Marczykowski-Górecki [Thu, 23 Feb 2017 10:48:22 +0000 (11:48 +0100)]
python: drop tp_getattr implementation

tp_getattr method of type object is deprecated already in Python2 and
gone in Python3. Default implementation does the same as this custom one.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agopython: check return value of PyErr_NewException
Marek Marczykowski-Górecki [Thu, 23 Feb 2017 10:48:21 +0000 (11:48 +0100)]
python: check return value of PyErr_NewException

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxendevicemodel: Add headers.chk to .gitignore
Ian Jackson [Thu, 23 Feb 2017 12:09:47 +0000 (12:09 +0000)]
tools/libxendevicemodel: Add headers.chk to .gitignore

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
8 years agotools/libxendevicemodel: add a call to restrict the handle
Paul Durrant [Fri, 10 Feb 2017 14:34:15 +0000 (14:34 +0000)]
tools/libxendevicemodel: add a call to restrict the handle

My recent patch [1] to the Linux privcmd module introduced a mechanism
to restrict an open file handle to subsequently only accept operations for
a specified domain.

This patch extends the libxendevicemodel API and make use of the
mechanism in the Linux-specific code to restrict operations on the
interface handle.

[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>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agotools/libxendevicemodel: introduce a Linux-specific implementation
Paul Durrant [Wed, 15 Feb 2017 15:22:29 +0000 (15:22 +0000)]
tools/libxendevicemodel: introduce a Linux-specific implementation

My recent patch [1] to the Linux privcmd module introduced a dedicated
mechanism for making dm_op hypercalls.

This patch adds the necessary code to libxendevicemodel to take
advantage of that mechanism if it is implemented in the tools domain
kernel.

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

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agotools/libxendevicemodel: extract functions and add a compat layer
Paul Durrant [Wed, 15 Feb 2017 14:44:16 +0000 (14:44 +0000)]
tools/libxendevicemodel: extract functions and add a compat layer

This patch extracts all functions resulting in a dm_op hypercall from
libxenctrl and moves them into libxendevicemodel. It also adds a compat
layer into libxenctrl, which can be selected by defining
XC_WANT_COMPAT_DEVICEMODEL_API to 1 before including xenctrl.h.

With this patch the core of libxendevicemodel still uses libxencall to
issue the dm_op hypercalls, but this is done by calling through code that
can be modified on a per-OS basis. A subsequent patch will add a Linux-
specific variant.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxendevicemodel: introduce the new library
Paul Durrant [Wed, 15 Feb 2017 13:54:25 +0000 (13:54 +0000)]
tools/libxendevicemodel: introduce the new library

The new xendevicemodel library is intended to be used by all Xen device
models such that the only hypercall that use will be the dm_op hypercall
added by commit 524a98c2.

This patch adds the boilerplate for the new library, with only open() and
close() entry points, and calls to those from libxenctrl in preparation
for the compat layer added by a subsequent patch.

[ Also: update MINIOS_UPSTREAM_REVISION and QEMU_TRADITIONAL_REVISION
  to the commits with the corresponding changes to those other trees
  - Ian Jackson ]

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agodoc: fix typo in bios_path_override
Olaf Hering [Wed, 22 Feb 2017 16:35:20 +0000 (16:35 +0000)]
doc: fix typo in bios_path_override

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxenstore: correct test for opened logfile in reopen_log()
Juergen Gross [Wed, 22 Feb 2017 15:28:45 +0000 (16:28 +0100)]
xenstore: correct test for opened logfile in reopen_log()

As 0 is a valid file descriptor testing a descriptor to be valid
should be done via >= 0 instead of > 0.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoQEMU_TAG update
Ian Jackson [Wed, 22 Feb 2017 16:25:42 +0000 (16:25 +0000)]
QEMU_TAG update

8 years agotools/libxenctrl: fix error check after opening libxenforeignmemory
Paul Durrant [Wed, 22 Feb 2017 13:27:34 +0000 (13:27 +0000)]
tools/libxenctrl: fix error check after opening libxenforeignmemory

Checking the value of xch->xcall is clearly incorrect. The code should be
checking xch->fmem (i.e. the return of the previously called function).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agox86/mm: Swap mfn_valid() to use mfn_t
Andrew Cooper [Wed, 18 Jan 2017 15:05:24 +0000 (15:05 +0000)]
x86/mm: Swap mfn_valid() to use mfn_t

Replace one opencoded mfn_eq() and some coding style issues on altered lines.
Swap __mfn_valid() to being bool, although it can't be updated to take mfn_t
because of include dependencies.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@arm.com>
8 years agox86: add multiboot2 protocol support for EFI platforms
Daniel Kiper [Wed, 22 Feb 2017 13:38:54 +0000 (14:38 +0100)]
x86: add multiboot2 protocol support for EFI platforms

This way Xen can be loaded on EFI platforms using GRUB2 and
other boot loaders which support multiboot2 protocol.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agoefi: create new early memory allocator
Daniel Kiper [Wed, 22 Feb 2017 13:38:06 +0000 (14:38 +0100)]
efi: create new early memory allocator

There is a problem with place_string() which is used as early memory
allocator. It gets memory chunks starting from start symbol and goes
down. Sadly this does not work when Xen is loaded using multiboot2
protocol because then the start lives on 1 MiB address and we should
not allocate a memory from below of it. So, I tried to use mem_lower
address calculated by GRUB2. However, this solution works only on some
machines. There are machines in the wild (e.g. Dell PowerEdge R820)
which uses first ~640 KiB for boot services code or data... :-(((
Hence, we need new memory allocator for Xen EFI boot code which is
quite simple and generic and could be used by place_string() and
efi_arch_allocate_mmap_buffer(). I think about following solutions:

1) We could use native EFI allocation functions (e.g. AllocatePool()
   or AllocatePages()) to get memory chunk. However, later (somewhere
   in __start_xen()) we must copy its contents to safe place or reserve
   it in e820 memory map and map it in Xen virtual address space. This
   means that the code referring to Xen command line, loaded modules and
   EFI memory map, mostly in __start_xen(), will be further complicated
   and diverge from legacy BIOS cases. Additionally, both former things
   have to be placed below 4 GiB because their addresses are stored in
   multiboot_info_t structure which has 32-bit relevant members.

2) We may allocate memory area statically somewhere in Xen code which
   could be used as memory pool for early dynamic allocations. Looks
   quite simple. Additionally, it would not depend on EFI at all and
   could be used on legacy BIOS platforms if we need it. However, we
   must carefully choose size of this pool. We do not want increase Xen
   binary size too much and waste too much memory but also we must fit
   at least memory map on x86 EFI platforms. As I saw on small machine,
   e.g. IBM System x3550 M2 with 8 GiB RAM, memory map may contain more
   than 200 entries. Every entry on x86-64 platform is 40 bytes in size.
   So, it means that we need more than 8 KiB for EFI memory map only.
   Additionally, if we use this memory pool for Xen and modules command
   line storage (it would be used when xen.efi is executed as EFI application)
   then we should add, I think, about 1 KiB. In this case, to be on safe
   side, we should assume at least 64 KiB pool for early memory allocations.
   Which is about 4 times of our earlier calculations. However, during
   discussion on Xen-devel Jan Beulich suggested that just in case we should
   use 1 MiB memory pool like it is in original place_string() implementation.
   So, let's use 1 MiB as it was proposed. If we think that we should not
   waste unallocated memory in the pool on running system then we can mark
   this region as __initdata and move all required data to dynamically
   allocated places somewhere in __start_xen().

2a) We could put memory pool into .bss.page_aligned section. Then allocate
    memory chunks starting from the lowest address. After init phase we can
    free unused portion of the memory pool as in case of .init.text or .init.data
    sections. This way we do not need to allocate any space in image file and
    freeing of unused area in the memory pool is very simple.

Now #2a solution is implemented because it is quite simple and requires
limited number of changes, especially in __start_xen().

New allocator is quite generic and can be used on ARM platforms too.
Though it is not enabled on ARM yet due to lack of some prereq.
List of them is placed before ebmalloc code.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
Tested-by: Doug Goldstein <cardoe@cardoe.com>
8 years agoefi: build xen.gz with EFI code
Daniel Kiper [Wed, 22 Feb 2017 13:36:56 +0000 (14:36 +0100)]
efi: build xen.gz with EFI code

Build xen.gz with EFI code. We need this to support multiboot2
protocol on EFI platforms.

If we wish to load non-ELF file using multiboot (v1) or multiboot2 then
it must contain "linear" (or "flat") representation of code and data.
This is requirement of both boot protocols. Currently, PE file contains
many sections which are not "linear" (one after another without any holes)
or even do not have representation in a file (e.g. BSS). From EFI point
of view everything is OK and works. However, this file layout cannot be
properly interpreted by multiboot protocols family. In theory there is
a chance that we could build proper PE file (from multiboot protocols POV)
using current build system. However, it means that xen.efi further diverge
from Xen ELF file (in terms of contents and build method). On the other
hand ELF has all needed properties. So, it means that this is good starting
point for further development. Additionally, I think that this is also good
starting point for further xen.efi code and build optimizations. It looks
that there is a chance that finally we can generate xen.efi directly from
Xen ELF using just simple objcopy or other tool. This way we will have one
Xen binary which can be loaded by three boot protocols: EFI native loader,
multiboot (v1) and multiboot2.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
8 years agox86: add multiboot2 protocol support
Daniel Kiper [Wed, 22 Feb 2017 13:35:05 +0000 (14:35 +0100)]
x86: add multiboot2 protocol support

Add multiboot2 protocol support. Alter min memory limit handling as we
now may not find it from either multiboot (v1) or multiboot2.

This way we are laying the foundation for EFI + GRUB2 + Xen development.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Doug Goldstein <cardoe@cardoe.com>
8 years agoMAINTAINERS: update VT-d maintainers
Kevin Tian [Wed, 22 Feb 2017 11:37:22 +0000 (12:37 +0100)]
MAINTAINERS: update VT-d maintainers

Feng just left Intel.  So remove him from the list.

Signed-off-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/VMX: sanitize VM86 TSS handling
Jan Beulich [Wed, 22 Feb 2017 11:36:36 +0000 (12:36 +0100)]
x86/VMX: sanitize VM86 TSS handling

The present way of setting this up is flawed: Leaving the I/O bitmap
pointer at zero means that the interrupt redirection bitmap lives
outside (ahead of) the allocated space of the TSS. Similarly setting a
TSS limit of 255 when only 128 bytes get allocated means that 128 extra
bytes may be accessed by the CPU during I/O port access processing.

Introduce a new HVM param to set the allocated size of the TSS, and
have the hypervisor actually take care of setting namely the I/O bitmap
pointer. Both this and the segment limit now take the allocated size
into account.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoMAINTAINERS: drop Jinsong Liu
Jan Beulich [Wed, 22 Feb 2017 11:35:58 +0000 (12:35 +0100)]
MAINTAINERS: drop Jinsong Liu

Mails to his listed address are bouncing.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/emul: Support CPUID faulting via a speculative MSR read
Andrew Cooper [Wed, 2 Nov 2016 15:50:23 +0000 (15:50 +0000)]
x86/emul: Support CPUID faulting via a speculative MSR read

This removes the need for every cpuid() emulation hook to individually support
CPUID faulting.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/emul: Introduce common msr_val for emulation
Andrew Cooper [Wed, 2 Nov 2016 15:50:23 +0000 (15:50 +0000)]
x86/emul: Introduce common msr_val for emulation

Use it consistently in place of local tsc_aux, msr_content and val
declarations, and replace opencoded uses of X86EMUL_OKAY.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hvm: Don't raise #GP behind the emulators back for MSR accesses
Andrew Cooper [Wed, 2 Nov 2016 14:36:49 +0000 (14:36 +0000)]
x86/hvm: Don't raise #GP behind the emulators back for MSR accesses

The current hvm_msr_{read,write}_intercept() infrastructure calls
hvm_inject_hw_exception() directly to latch a fault, and returns
X86EMUL_EXCEPTION to its caller.

This behaviour is problematic for the hvmemul_{read,write}_msr() paths, as the
fault is raised behind the back of the x86 emulator.

Alter the behaviour so hvm_msr_{read,write}_intercept() simply returns
X86EMUL_EXCEPTION, leaving the callers to actually inject the #GP fault.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
8 years agox86/vmx: Drop vmx_msr_state infrastructure
Andrew Cooper [Sun, 18 Dec 2016 14:56:28 +0000 (14:56 +0000)]
x86/vmx: Drop vmx_msr_state infrastructure

To avoid leaking host MSR state into guests, guest LSTAR, STAR and
SYSCALL_MASK state is unconditionally loaded when switching into guest
context.

Attempting to dirty-track the state is pointless; host state is always
restoring upon exit from guest context, meaning that guest state is always
considered dirty.

Drop struct vmx_msr_state, enum VMX_INDEX_MSR_* and msr_index[].  The guests
MSR values are stored plainly in arch_vmx_struct, in the same way as shadow_gs
and cstar are.  vmx_restore_guest_msrs() and long_mode_do_msr_write() ensure
that the hardware MSR values are always up-to-date.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/vmx: Remove vmx_save_host_msrs() and host_msr_state
Andrew Cooper [Sun, 18 Dec 2016 14:56:28 +0000 (14:56 +0000)]
x86/vmx: Remove vmx_save_host_msrs() and host_msr_state

A pcpu's LSTAR, STAR and SYSCALL_MASK MSRs are unconditionally switched when
moving in and out of HVM vcpu context.  Two of these values are compile time
constants, and the third is directly available in an existing per-cpu
variable.

There is no need to save host state in vmx_cpu_up() into a different per-cpu
structure, so drop all the infrastructure.  vmx_restore_host_msrs() is
simplified to 3 plain WRMSR instructions.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/setup: Intoduce XEN_MSR_STAR
Andrew Cooper [Sun, 18 Dec 2016 14:56:28 +0000 (14:56 +0000)]
x86/setup: Intoduce XEN_MSR_STAR

Xen's choice of the MSR_STAR value is constant across all pcpus.  Introduce a
new define and use it to avoid the opencoding in subarch_percpu_traps_init()
and restore_rest_processor_state().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/vmx: Don't leak host syscall MSR state into HVM guests
Andrew Cooper [Sun, 18 Dec 2016 14:20:49 +0000 (14:20 +0000)]
x86/vmx: Don't leak host syscall MSR state into HVM guests

hvm_hw_cpu->msr_flags is in fact the VMX dirty bitmap of MSRs needing to be
restored when switching into guest context.  It should never have been part of
the migration state to start with, and Xen must not make any decisions based
on the value seen during restore.

Identify it as obsolete in the header files, consistently save it as zero and
ignore it on restore.

The MSRs must be considered dirty during VMCS creation to cause the proper
defaults of 0 to be visible to the guest.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/shadow: Correct guest behaviour when creating PTEs above maxphysaddr
Andrew Cooper [Mon, 4 Jul 2016 08:40:34 +0000 (09:40 +0100)]
x86/shadow: Correct guest behaviour when creating PTEs above maxphysaddr

XSA-173 (c/s 8b1764833) introduces gfn_bits, and an upper limit which might be
lower than the real maxphysaddr, to avoid overflowing the superpage shadow
backpointer.

However, plenty of hardware has a physical address width less that 44 bits,
and the code added in shadow_domain_init() is a straight assignment.  This
causes gfn_bits to be increased beyond the physical address width on most
Intel consumer hardware (typically a width of 39, which is the number reported
to the guest via CPUID).

If the guest intentionally creates a PTE referencing a physical address
between 39 and 44 bits, the result should be #PF[RSVD] for using the virtual
address.  However, the shadow code accepts the PTE, shadows it, and the
virtual address works normally.

Introduce paging_max_paddr_bits() to calculate the largest guest physical
address supportable by the paging infrastructure, and update
recalculate_cpuid_policy() to take this into account when clamping the guests
cpuid_policy to reality.

There is an existing gfn_valid() in guest_pt.h but it is unused in the
codebase.  Repurpose it to perform a guest-specific maxphysaddr check, which
replaces the users of gfn_bits.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Tim Deegan <tim@xen.org>
8 years agolowmemd: fix comparison in cleanup
Norbert Manthey [Fri, 17 Feb 2017 10:47:46 +0000 (11:47 +0100)]
lowmemd: fix comparison in cleanup

The variable virq_port of type uint32_t was compared to being greater than
-1. This check always results in false for unsigned data types, resulting
in never cleaning up the memory. Furthermore, the initialization with a
negative variable for an unsigned type has been fixed.

Signed-off-by: Norbert Manthey <nmanthey@amazon.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxc: don't pass uninitialized data to do_dm_op()
Jan Beulich [Mon, 20 Feb 2017 16:53:27 +0000 (16:53 +0000)]
libxc: don't pass uninitialized data to do_dm_op()

do_dm_op() expects (void *, size_t) pairs, but with nr being uint32_t
the type of the expression of xc_hvm_track_dirty_vram()'s last argument
to the function is only a 32 bits one. Neither C nor the ABI require
the compiler to promote the type beyond int.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxl: refactor do_domain_create()
Zhang Chen [Fri, 17 Feb 2017 02:18:25 +0000 (10:18 +0800)]
tools/libxl: refactor do_domain_create()

We use params->colo_proxy_script to make do_domain_create()
doesn't take "colo_proxy_script" anymore.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agox86emul/test: avoid race in link farm rune
Wei Liu [Mon, 20 Feb 2017 14:37:37 +0000 (14:37 +0000)]
x86emul/test: avoid race in link farm rune

Several `ln -sf` can race with each other.  Provide dedicated targets
for soft-linking directories.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agofuzz/x86emul: avoid race in link farm rune
Wei Liu [Mon, 20 Feb 2017 14:37:36 +0000 (14:37 +0000)]
fuzz/x86emul: avoid race in link farm rune

Several `ln -sf` can race with each other and cause error like:

14:43:56 00:07:06 O: ln: cannot remove 'asm': No such file or directory

Provide dedicated targets for soft-linking directories.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agolibxc/x86: PV guests should see leaf 0xa on Intel
Boris Ostrovsky [Fri, 17 Feb 2017 17:40:12 +0000 (12:40 -0500)]
libxc/x86: PV guests should see leaf 0xa on Intel

PV guests support VPMU and therefore leaf 0xa can be exposed
to them.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxen/arm: Set nr_cpu_ids to available number of cpus
Vijaya Kumar K [Mon, 1 Feb 2016 09:26:13 +0000 (14:56 +0530)]
xen/arm: Set nr_cpu_ids to available number of cpus

nr_cpu_ids for arm platforms is incorrectly set to NR_CPUS
irrespective of the number of cpus supported by platform.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agobuild: enable no-parentheses in clang
Roger Pau Monné [Fri, 17 Feb 2017 15:10:28 +0000 (16:10 +0100)]
build: enable no-parentheses in clang

And fix the following errors reported:

traps.c:2014:25: error: equality comparison with extraneous parentheses
      [-Werror,-Wparentheses-equality]
        else if ( (port == RTC_PORT(0)) )
                   ~~~~~^~~~~~~~~~~~~~
traps.c:2014:25: note: remove extraneous parentheses around the comparison to silence this warning
        else if ( (port == RTC_PORT(0)) )
                  ~     ^             ~
traps.c:2014:25: note: use '=' to turn this equality comparison into an assignment
        else if ( (port == RTC_PORT(0)) )
                        ^~
                        =
traps.c:2083:25: error: equality comparison with extraneous parentheses
      [-Werror,-Wparentheses-equality]
        else if ( (port == RTC_PORT(0)) )
                   ~~~~~^~~~~~~~~~~~~~

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agobuild: enable unused value checks for clang
Roger Pau Monné [Fri, 17 Feb 2017 15:10:00 +0000 (16:10 +0100)]
build: enable unused value checks for clang

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agobuild/printf: fix incorrect format specifiers
Roger Pau Monné [Fri, 17 Feb 2017 15:09:38 +0000 (16:09 +0100)]
build/printf: fix incorrect format specifiers

The following incorrect format specifiers and incorrect number of parameters
passed to printf like functions are reported by clang:

mce.c:601:18: error: data argument not used by format string [-Werror,-Wformat-extra-args]
                 smp_processor_id());
                 ^

xenpm.c:102:23: error: data argument not used by format string [-Werror,-Wformat-extra-args]
                what, argv[argc > 1]);
                      ^

libxl_internal.c:25:69: error: data argument not used by format string
      [-Werror,-Wformat-extra-args]
    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L);
                                                                    ^
libxl_internal.c:24:17: note: expanded from macro 'L'
          func, (unsigned long)nmemb, (unsigned long)size
                ^
libxl_internal.c:26:21: error: data argument not used by format string
      [-Werror,-Wformat-extra-args]
    fprintf(stderr, L);
                    ^
libxl_internal.c:24:17: note: expanded from macro 'L'
          func, (unsigned long)nmemb, (unsigned long)size
                ^

This patch contains the fixes for them and enables -Wformat for clang.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agogrants: print grant number and handle in hex format
Roger Pau Monné [Fri, 17 Feb 2017 15:09:03 +0000 (16:09 +0100)]
grants: print grant number and handle in hex format

Due to the large number of grants in use it seems more useful to print the
grant references and handlers in hex format rather than decimal.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/vmx: fix compilation after 997382
Roger Pau Monné [Fri, 17 Feb 2017 15:08:37 +0000 (16:08 +0100)]
x86/vmx: fix compilation after 997382

997382 introduced the following errors:

intr.c:342:46: error: address of array 'vlapic->regs->data' will always evaluate to 'true'
      [-Werror,-Wpointer-bool-conversion]
                if ( vlapic && vlapic->regs->data )
                            ~~ ~~~~~~~~~~~~~~^~~~
intr.c:352:42: error: address of array 'pi_desc->pir' will always evaluate to 'true'
      [-Werror,-Wpointer-bool-conversion]
                if ( pi_desc && pi_desc->pir )
                             ~~ ~~~~~~~~~^~~
Both of those checks are done against static arrays, which doesn't seem to make
much sense, so just remove them.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoconsole: avoid wrapping of console pointers
Jan Beulich [Fri, 17 Feb 2017 14:59:15 +0000 (15:59 +0100)]
console: avoid wrapping of console pointers

We particularly want/need to avoid accessing data outside (ahead of)
the ring buffer. Also latch both pointers into local variable to
avoid different steps of the calculation being done with different
values.

Reported-by: Quan Luo <a4651386@163.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/vmce: include domain/vcpu id in debug messages
Haozhong Zhang [Fri, 17 Feb 2017 14:56:46 +0000 (15:56 +0100)]
x86/vmce: include domain/vcpu id in debug messages

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mce: remove unnecessary braces around intel_get_extended_msrs()
Haozhong Zhang [Fri, 17 Feb 2017 14:56:25 +0000 (15:56 +0100)]
x86/mce: remove unnecessary braces around intel_get_extended_msrs()

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mce: remove declarations of non-existing functions in mce.h
Haozhong Zhang [Fri, 17 Feb 2017 14:55:47 +0000 (15:55 +0100)]
x86/mce: remove declarations of non-existing functions in mce.h

Remove declarations of functions
    intel_mcheck_timer()
    mce_intel_feature_init()
    mce_cap_init()
    x86_mcinfo_getptr()
whose definitions had been removed long time ago.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mce: fix indentation style in xen-mca.h and mce.h
Haozhong Zhang [Fri, 17 Feb 2017 14:55:17 +0000 (15:55 +0100)]
x86/mce: fix indentation style in xen-mca.h and mce.h

Replace tab indentation by whitespace.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/mm: fix memory hotplug error cleanup
Norbert Manthey [Fri, 17 Feb 2017 14:51:37 +0000 (15:51 +0100)]
x86/mm: fix memory hotplug error cleanup

During destroying the m2p mapping, the loop variable was always incremented
by one, as the current version used a compare operator on the left hand side,
which always evaluated to true, i.e.

i += 1UL < (L2_PAGETABLE_SHIFT - 2)

The fix increments the value of the variable by the actual page size by
using the shift operator instead.

Signed-off-by: Norbert Manthey <nmanthey@amazon.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: package up context switch hook pointers
Jan Beulich [Fri, 17 Feb 2017 14:51:03 +0000 (15:51 +0100)]
x86: package up context switch hook pointers

They're all solely dependent on guest type, so we don't need to repeat
all the same three pointers in every vCPU control structure. Instead use
static const structures, and store pointers to them in the domain
control structure.

Since touching it anyway, take the opportunity and expand
schedule_tail() in the only two places invoking it, allowing the macro
to be dropped.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
8 years agoVMX: fix VMCS race on context-switch paths
Jan Beulich [Fri, 17 Feb 2017 14:49:56 +0000 (15:49 +0100)]
VMX: fix VMCS race on context-switch paths

When __context_switch() is being bypassed during original context
switch handling, the vCPU "owning" the VMCS partially loses control of
it: It will appear non-running to remote CPUs, and hence their attempt
to pause the owning vCPU will have no effect on it (as it already
looks to be paused). At the same time the "owning" CPU will re-enable
interrupts eventually (the lastest when entering the idle loop) and
hence becomes subject to IPIs from other CPUs requesting access to the
VMCS. As a result, when __context_switch() finally gets run, the CPU
may no longer have the VMCS loaded, and hence any accesses to it would
fail. Hence we may need to re-load the VMCS in vmx_ctxt_switch_from().

For consistency use the new function also in vmx_do_resume(), to
avoid leaving an open-coded incarnation of it around.

Reported-by: Kevin Mayer <Kevin.Mayer@gdata.de>
Reported-by: Anshul Makkar <anshul.makkar@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Tested-by: Sergey Dyasli <sergey.dyasli@citrix.com>
8 years agocommon/vcpu: Fix unintended breakage from cleanup
Andrew Cooper [Fri, 17 Feb 2017 11:53:44 +0000 (11:53 +0000)]
common/vcpu: Fix unintended breakage from cleanup

c/s 3044a2a "common/vcpu: Switch v->vcpu_info_mfn to mfn_t" was intended to be
no functional change.

Unfortunately, because vcpu_info_reset() clobbers v->vcpu_info_mfn, the change
ended up calling put_page_and_type() on MFN_INVALID.

Reintroduce the local variable, and leave a comment behind.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agogitignore: ignore asm soft link in fuzz and x86emul test
Wei Liu [Thu, 16 Feb 2017 18:56:51 +0000 (18:56 +0000)]
gitignore: ignore asm soft link in fuzz and x86emul test

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agoarm: read/write rank->vcpu atomically
Stefano Stabellini [Sat, 11 Feb 2017 02:05:22 +0000 (18:05 -0800)]
arm: read/write rank->vcpu atomically

We don't need a lock in vgic_get_target_vcpu anymore, solving the
following lock inversion bug: the rank lock should be taken first, then
the vgic lock. However, gic_update_one_lr is called with the vgic lock
held, and it calls vgic_get_target_vcpu, which tries to obtain the rank
lock.

Coverity-ID: 1381855
Coverity-ID: 1381853

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agox86emul: catch exceptions occurring in stubs
Jan Beulich [Thu, 16 Feb 2017 17:11:42 +0000 (18:11 +0100)]
x86emul: catch exceptions occurring in stubs

Before adding more use of stubs cloned from decoded guest insns, guard
ourselves against mistakes there: Should an exception (with the
noteworthy exception of #PF) occur inside the stub, forward it to the
guest.

Since the exception fixup table entry can't encode the address of the
faulting insn itself, attach it to the return address instead. This at
once provides a convenient place to hand the exception information
back: The return address is being overwritten by it before branching to
the recovery code.

Take the opportunity and (finally!) add symbol resolution to the
respective log messages (the new one is intentionally not being coded
that way, as it covers stub addresses only, which don't have symbols
associated).

Also take the opportunity and make search_one_extable() static again.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: add "w" flag to .init.data section definition
Daniel Kiper [Thu, 16 Feb 2017 17:10:04 +0000 (18:10 +0100)]
x86: add "w" flag to .init.data section definition

init.data section is clearly writable, so, add "w" flag to its
definition in xen/arch/x86/boot/x86_64.S.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/hypercall: Move hypercall continuation logic
Andrew Cooper [Wed, 15 Feb 2017 19:15:41 +0000 (19:15 +0000)]
x86/hypercall: Move hypercall continuation logic

The newly-repurposed arch/x86/hypercall.c is a more appropriate place for the
hypercall continuation logic to live.

This is purely code motion.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hypercall: Split out PV hypercall infrastructure
Andrew Cooper [Mon, 13 Feb 2017 11:49:33 +0000 (11:49 +0000)]
x86/hypercall: Split out PV hypercall infrastructure

Repurpose arch/x86/hypercall.c to be common x86 hypercall infrastructure, and
move the PV specific routines to arch/x86/pv/hypercall.c

This is purely code motion.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hypercall: Make the HVM hcall_64bit boolean common
Andrew Cooper [Tue, 14 Feb 2017 18:21:22 +0000 (18:21 +0000)]
x86/hypercall: Make the HVM hcall_64bit boolean common

HVM guests currently make use of arch.hvm_vcpu.hcall_64bit to track the ABI of
the hypercall in use.

The rest of Xen deals in terms of the comat ABI or not, so rename the boolean
and make it common, guared by CONFIG_COMPAT to avoid bloat if a compat ABI is
not wanted/needed.

Set hcall_compat uniformly for PV guests as well as HVM guests.  This removes
the remaining piece of guest-type-specific knowledge from
hypercall_create_continuation(), allowing it to operate only in terms of the
hypercall ABI in use.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoxen/multicall: Use the common hcall_preempted boolean
Andrew Cooper [Tue, 14 Feb 2017 18:06:59 +0000 (18:06 +0000)]
xen/multicall: Use the common hcall_preempted boolean

The now-common hcall_preempted boolean is perfectly usable for multicalls.
Remove the multicall-specific preemption mechanism.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agoarm/hypercall: Use the common hcall_preempted boolean
Andrew Cooper [Tue, 14 Feb 2017 17:56:33 +0000 (17:56 +0000)]
arm/hypercall: Use the common hcall_preempted boolean

With hcall_preempted having just been made common, ARM can use use it to
simplify its hypercall handling.

This simplifies the continuation logic and removes the risk of accidentally
skipping multiple instructions.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agox86/hypercall: Make the HVM hcall_preempted boolean common
Andrew Cooper [Tue, 14 Feb 2017 17:02:04 +0000 (17:02 +0000)]
x86/hypercall: Make the HVM hcall_preempted boolean common

HVM guests currently make use of arch.hvm_vcpu.hcall_preempted to track
hypercall preemption in struct vcpu.  Move this boolean to being common at the
top level of struct vcpu, which will allow it to be reused elsewhere.

Alter the PV preemption logic to use this boolean.  This simplifies the code
by removing guest-type-specific knowledge, and removes the risk of accidently
skipping backwards or forwards multiple times and corrupting %rip.

In pv_hypercall() the old_rip bodge can be removed, and parameter clobbering
can happen based on a more obvious condition.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agocommon/vcpu: Switch v->vcpu_info_mfn to mfn_t
Andrew Cooper [Wed, 15 Feb 2017 17:32:30 +0000 (17:32 +0000)]
common/vcpu: Switch v->vcpu_info_mfn to mfn_t

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoxen/sched.h Whitespace and bool cleanup
Andrew Cooper [Wed, 15 Feb 2017 17:30:48 +0000 (17:30 +0000)]
xen/sched.h Whitespace and bool cleanup

Extend the Maptrack comment to point at the Grant table subsystem.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoxen/include: Include xen/kconfig.h automatically
Andrew Cooper [Wed, 15 Feb 2017 18:04:58 +0000 (18:04 +0000)]
xen/include: Include xen/kconfig.h automatically

generated/autoconf.h is already included automatically so CONFIG_* defines are
available.  However, the companion macros such as IS_ENABLED() are not
included.

Include them uniformly everywhere.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
8 years agoxen/include: Remove explicit asm/config.h includes
Andrew Cooper [Wed, 15 Feb 2017 17:48:47 +0000 (17:48 +0000)]
xen/include: Remove explicit asm/config.h includes

xen/config.h includes asm/config.h, and is included automatically via CFLAGS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
8 years agoxen/include: Remove explicit xen/config.h includes
Andrew Cooper [Wed, 15 Feb 2017 17:45:47 +0000 (17:45 +0000)]
xen/include: Remove explicit xen/config.h includes

This file is included automatically via CFLAGS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agotools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY
George Dunlap [Wed, 15 Feb 2017 17:08:11 +0000 (17:08 +0000)]
tools/libxl: Introduce LIBXL_CPUPOOL_POOLID_ANY

Callers to libxl_cpupool_create() can either request a specific pool
id, or request that Xen do it for them.  But at the moment, the
"automatic" selection is indicated by using a magic value, 0.  This is
undesirable both because it doesn't obviously have meaning, but also
because '0' is a valid cpupool (albeit one which at the moment can't
be changed).

Introduce a constant, LIBXL_CPUPOOL_POOLID_ANY, to indicate this
instead.  Still accept '0' as meaning "ANY" for backwards
compatibility.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ wei: removed two trailing spaces ]
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/libxc: Introduce XC_CPUPOOL_POOLID_ANY
George Dunlap [Wed, 15 Feb 2017 17:08:10 +0000 (17:08 +0000)]
tools/libxc: Introduce XC_CPUPOOL_POOLID_ANY

Callers to xc_cpupool_create() can either request a specific pool id,
or request that Xen do it for them.  But at the moment, the
"automatic" selection is indicated by using a magic value, 0.  This is
undesirable both because it doesn't obviously have meaning, but also
because '0' is a valid cpupool (albeit one which at the moment can't
be changed).

Introduce a constant, XC_CPUPOOL_POOLID_ANY, to indicate this instead.
Have it be the default for the python bindings.

Manually translate it, even though it's the same underlying value,
because we don't yet have a relaible way of enforcing that these
values are the same.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxl: correct xenstore entry for empty cdrom
Juergen Gross [Wed, 15 Feb 2017 11:11:12 +0000 (12:11 +0100)]
libxl: correct xenstore entry for empty cdrom

Specifying an empty cdrom device will result in a Xenstore entry

params = aio:(null)

as the physical device path isn't existing. This lets a domain booted
via OVMF hang as OVMF is checking for "aio:" only in order to detect
the empty cdrom case.

Use an empty string for the physical device path in this case. As a
cdrom device for HVM is always backed by qdisk we only need to cover this
backend.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoxen/arm: Print whether Xen is booting using ACPI or DT
Julien Grall [Fri, 3 Feb 2017 19:18:52 +0000 (19:18 +0000)]
xen/arm: Print whether Xen is booting using ACPI or DT

Make it easier to figure out whether Xen is booting using ACPI or DT by
printing a message on the console.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: acpi: Rework acpi_boot_table_init error paths
Julien Grall [Fri, 3 Feb 2017 19:18:48 +0000 (19:18 +0000)]
xen/arm: acpi: Rework acpi_boot_table_init error paths

There are multiple path disable ACPI on error. Consolidate in a single
place, this will help in a follow-up patch to add more code on the error
path.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: acpi: Handle correctly detection of GICv2 on GICv3
Julien Grall [Fri, 3 Feb 2017 19:18:45 +0000 (19:18 +0000)]
xen/arm: acpi: Handle correctly detection of GICv2 on GICv3

When the GICv3 is not GICv2 compatible, the associated field in the MADT
will be zeroed. However, the rest of the code expects the variable to
be set to INVALID_PADDR.

This will result to false detection of GICv2 and give I/O access to page
0 for the hardware domain.

Thankfully, it will fail because the size of GICV has not been set.

Fix the detection by converting 0 to INVALID_PADDR for the GICC and
GICV base. At the same time only set the size of each region when the
base address is not 0.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: Remove the makefile target xen.axf
Julien Grall [Fri, 3 Feb 2017 19:21:13 +0000 (19:21 +0000)]
xen/arm: Remove the makefile target xen.axf

Since commit 4557c22 "xen: arm: rewrite start of day page table and cpu
bring up", Xen requires to be launched in NS HYP/EL2.

xen.axf is generated in order to directly boot Xen on ARM models (e.g
Foundation). However they usually start in secure mode, which mean Xen
cannot boot.

The way forward to boot Xen on models is using either EFI or
bootwrapper [1].

[1] https://git.kernel.org/cgit/linux/kernel/git/mark/boot-wrapper-aarch64.git/

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: Remove build option CONFIG_LOAD_ADDRESS
Julien Grall [Fri, 3 Feb 2017 19:20:46 +0000 (19:20 +0000)]
xen/arm: Remove build option CONFIG_LOAD_ADDRESS

The build option CONFIG_LOAD_ADDRESS is defined but never plumbed
through.

Signed-off-by: Julien Grall <julien.gralL@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agodocs: remove odt variant of XENV
Olaf Hering [Tue, 14 Feb 2017 16:15:27 +0000 (17:15 +0100)]
docs: remove odt variant of XENV

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agodocs: remove odt variant of STAO
Olaf Hering [Tue, 14 Feb 2017 16:14:52 +0000 (17:14 +0100)]
docs: remove odt variant of STAO

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agodocs: convert XENV from odt to fodt
Olaf Hering [Tue, 14 Feb 2017 16:12:58 +0000 (17:12 +0100)]
docs: convert XENV from odt to fodt

Fixes c33b5f013d ("Add XENV to docs/misc")

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agodocs: convert STAO from odt to fodt
Olaf Hering [Tue, 14 Feb 2017 16:12:01 +0000 (17:12 +0100)]
docs: convert STAO from odt to fodt

Fixes 140b31a8de ("Add STAO spec to docs/misc")

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agox86/asm: Use ASM_FLAG_OUT() to simplify atomic and bitop stubs
Andrew Cooper [Thu, 9 Feb 2017 17:08:44 +0000 (17:08 +0000)]
x86/asm: Use ASM_FLAG_OUT() to simplify atomic and bitop stubs

bitops.h cannot include asm_defns.h, because the static inlines in cpumasks.h
result in forward declarations of the bitops.h contents.  Move ASM_FLAG_OUT()
to a new asm/compiler.h to compensate.

While making changes, switch bool_t to bool and use named asm parameters.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoxen/p2m: Fix p2m_flush_table for non-nested cases
George Dunlap [Wed, 15 Feb 2017 17:13:22 +0000 (17:13 +0000)]
xen/p2m: Fix p2m_flush_table for non-nested cases

Commit 71bb7304e7a7a35ea6df4b0cedebc35028e4c159 added flushing of
nested p2m tables whenever the host p2m table changed.  Unfortunately
in the process, it added a filter to p2m_flush_table() function so
that the p2m would only be flushed if it was being used as a nested
p2m.  This meant that the p2m was not being flushed at all for altp2m
callers.

Only check np2m_base if p2m_class for nested p2m's.

NB that this is not a security issue: The only time this codepath is
called is in cases where either nestedp2m or altp2m is enabled, and
neither of them are in security support.

Reported-by: Matt Leinhos <matt@starlab.io>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Tested-by: Tamas K Lengyel <tamas@tklengyel.com>
8 years agoxen: credit2: improve comments' style and definition of CSFLAG-s
Dario Faggioli [Wed, 15 Feb 2017 15:47:29 +0000 (15:47 +0000)]
xen: credit2: improve comments' style and definition of CSFLAG-s

Most of the comments describing the meaning of the
vCPU flags used by the scheduler miss the 'wings' (or
have other minor style issues).

Also, use 1U (instead of 1) as the base of shiftings.

No functional change intended.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
8 years agoxen: credit2: clear bit instead of skip step in runq_tickle()
Dario Faggioli [Wed, 15 Feb 2017 15:47:29 +0000 (15:47 +0000)]
xen: credit2: clear bit instead of skip step in runq_tickle()

Since we are doing cpumask manipulation already, clear a bit
in the mask at once. Doing that will save us an if, later in
the code.

No functional change intended.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
8 years agoxen: sched: harmonize debug dump output among schedulers.
Dario Faggioli [Wed, 15 Feb 2017 15:47:29 +0000 (15:47 +0000)]
xen: sched: harmonize debug dump output among schedulers.

Information we currently print for idle vCPUs is
rather useless. Credit2 already stopped showing that,
do the same for Credit and RTDS.

Also, define a new CPU status dump hook, which is
not defined by those schedulers which already dump
such info in other ways (e.g., Credit2, which does
that while dumping runqueue information).

This also means that, still in Credit2, we can keep
the runqueue and pCPU info closer together.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Meng Xu <mengxu@cis.upenn.edu>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
8 years agoxen/kbdif: add multi-touch support
Oleksandr Andrushchenko [Wed, 8 Feb 2017 07:38:18 +0000 (09:38 +0200)]
xen/kbdif: add multi-touch support

Multi-touch fields re-use the page that is used by the other features
which means that you can interleave multi-touch, motion, and key
events.

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
8 years agoxen/kbdif: Update protocol description
Oleksandr Andrushchenko [Tue, 7 Feb 2017 17:38:41 +0000 (12:38 -0500)]
xen/kbdif: Update protocol description

The patch clarifies the protocol that is used by the PV keyboard
drivers.

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
8 years agoMAINTAINERS: Add myself as the public API "Czar"
Konrad Rzeszutek Wilk [Fri, 18 Nov 2016 16:18:24 +0000 (11:18 -0500)]
MAINTAINERS: Add myself as the public API "Czar"

That way we have one person who can: a) poke other maintainers
or pull them in with new drivers are introduced, b) we have
one maintainer who can shepherd the patches along instead of
depending on the REST maintainers which may be busy with
other responsibilities.

Acked-by: Ian Jackson <ian.jackson@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
8 years agoIOMMU: always call teardown callback
Oleksandr Tyshchenko [Wed, 15 Feb 2017 12:20:01 +0000 (12:20 +0000)]
IOMMU: always call teardown callback

There is a possible scenario when (d)->need_iommu remains unset
during guest domain execution. For example, when no devices
were assigned to it. Taking into account that teardown callback
is not called when (d)->need_iommu is unset we might have unreleased
resourses after destroying domain.

So, always call teardown callback to roll back actions
that were performed in init callback.

This is XSA-207.

Signed-off-by: Oleksandr Tyshchenko <olekstysh@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Julien Grall <julien.grall@arm.com>
8 years agoconfigure: disable bash check for FreeBSD
Roger Pau Monne [Mon, 13 Feb 2017 15:47:38 +0000 (15:47 +0000)]
configure: disable bash check for FreeBSD

Bash it's not used on FreeBSD.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ wei: rerun autogen.sh ]

8 years agox86/hvm: Improve physdev_op hypercall dispatching
Andrew Cooper [Mon, 13 Feb 2017 11:49:30 +0000 (11:49 +0000)]
x86/hvm: Improve physdev_op hypercall dispatching

hvm_physdev_op() and hvm_physdev_op_compat32() are almost identical, but there
is no need to have two functions instantiated at the end of different function
pointers.

Combine the two into a single hvm_physdev_op() and dispatch to
{do,compat}_physdev_op() based on the hcall_64bit setting.

This also fixes an inconsistency where 64bit PVH hardware domains were
permitted access to extra physdev ops, but 32bit domains weren't.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hvm: Improve grant_table_op hypercall dispatching
Andrew Cooper [Mon, 13 Feb 2017 11:49:29 +0000 (11:49 +0000)]
x86/hvm: Improve grant_table_op hypercall dispatching

hvm_grant_table_op() and hvm_grant_table_op_compat32() are almost identical,
but there is no need to have two functions instantiated at the end of
different function pointers.

Combine the two into a single hvm_grant_table_op() (folding
grant_table_op_is_allowed() into is now-single caller) and dispatch to
{do,compat}_grant_table_op() based on the hcall_64bit setting.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hvm: Improve memory_op hypercall dispatching
Andrew Cooper [Mon, 13 Feb 2017 11:49:24 +0000 (11:49 +0000)]
x86/hvm: Improve memory_op hypercall dispatching

hvm_memory_op() and hvm_memory_op_compat32() are almost identical, but there
is no need to have two functions instantiated at the end of different function
pointers.

Combine the two into single hvm_memory_op() which dispatches to
{do,compat}_memory_op() based on the hcall_64bit setting.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hvm: Split the hypercall dispatching infrastructure out of hvm.c
Andrew Cooper [Fri, 3 Feb 2017 16:21:22 +0000 (16:21 +0000)]
x86/hvm: Split the hypercall dispatching infrastructure out of hvm.c

Into a new hypercall.c.  This is purely code motion.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hvm: Rework HVM_HCALL_invalidate handling
Andrew Cooper [Fri, 3 Feb 2017 16:21:22 +0000 (16:21 +0000)]
x86/hvm: Rework HVM_HCALL_invalidate handling

Sending an invalidation to the device model is an internal detail of
completing the hypercall; callers should not need to be responsible for it.
Drop HVM_HCALL_invalidate entirely and call send_invalidate_req() when
appropriate.

This makes the function boolean in nature, although the existing
HVM_HCALL_{completed,preempted} constants are kept to aid code clarity.  While
updating the return type, drop _do from the name, as it is redundant.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/vvmx: correctly emulate VMREAD
Sergey Dyasli [Mon, 13 Feb 2017 14:21:10 +0000 (14:21 +0000)]
x86/vvmx: correctly emulate VMREAD

There is an issue with the original __vmread() in nested vmx mode:
emulation of a guest's VMREAD with invalid arguments leads to BUG().

Fix this by using vmread_safe() and reporting any kind of VMfail back
to the guest.

A new safe versions of get_vvmcs() macro and related functions are
introduced because of new function signatures and lots of existing
users.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/vvmx: correctly emulate VMWRITE
Sergey Dyasli [Mon, 13 Feb 2017 14:21:09 +0000 (14:21 +0000)]
x86/vvmx: correctly emulate VMWRITE

There is an issue with the original __vmwrite() in nested vmx mode:
emulation of a guest's VMWRITE with invalid arguments leads to BUG().

Fix this by using vmwrite_safe() and reporting any kind of VMfail back
to the guest.

A new safe versions of set_vvmcs() macro and related functions are
introduced because of new function signatures and lots of existing
users.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86/vmx: introduce VMX_INSN_SUCCEED
Sergey Dyasli [Mon, 13 Feb 2017 14:21:08 +0000 (14:21 +0000)]
x86/vmx: introduce VMX_INSN_SUCCEED

The new value corresponds to VMsucceed status of VMX instructions.
This will replace usage of literal zeroes in related functions.

Update vmfail(), vmread_safe() and vmwrite_safe().

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
8 years agox86emul: flatten twobyte_table[]
Jan Beulich [Mon, 13 Feb 2017 14:26:19 +0000 (15:26 +0100)]
x86emul: flatten twobyte_table[]

... in the hope of making it more readable, and in preparation of
adding a second field to the structure.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: adjust which files need vpmu.h
Boris Ostrovsky [Mon, 13 Feb 2017 14:23:58 +0000 (15:23 +0100)]
x86: adjust which files need vpmu.h

asm-x86/vmcs.h doesn't need it while asm-x86/domain.h does.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/PVHv2: fix dom0_max_vcpus so it's capped to HVM_MAX_VCPUS for PVHv2 Dom0
Roger Pau Monné [Mon, 13 Feb 2017 14:23:34 +0000 (15:23 +0100)]
x86/PVHv2: fix dom0_max_vcpus so it's capped to HVM_MAX_VCPUS for PVHv2 Dom0

PVHv2 Dom0 is limited to 128 vCPUs, as are all HVM guests at the moment. Fix
dom0_max_vcpus so it takes this limitation into account.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: split Dom0 build into PV and PVHv2
Roger Pau Monné [Mon, 13 Feb 2017 14:22:01 +0000 (15:22 +0100)]
x86: split Dom0 build into PV and PVHv2

Split the Dom0 builder into two different functions, one for PV (and classic
PVH), and another one for PVHv2. Introduce a new command line parameter called
'dom0' that can be used to request the creation of a PVHv2 Dom0 by setting the
'hvm' sub-option. A panic has also been added if a user tries to use dom0=hvm
until all the code is in place, then the panic will be removed.

While there mark the dom0_shadow option that was used by PV Dom0 as deprecated,
it was lacking documentation and was not functional. Point users towards
dom0=shadow instead.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/time: tsc_check_writability() may need to be run a second time
Jan Beulich [Mon, 13 Feb 2017 14:21:24 +0000 (15:21 +0100)]
x86/time: tsc_check_writability() may need to be run a second time

While we shouldn't remove its current invocation, we need to re-run it
for the case that the X86_FEATURE_TSC_RELIABLE feature flag has been
cleared, in order to avoid using the TSC rendezvous function in case
the TSC can't be written.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
8 years agox86emul: always init mmval
Jan Beulich [Mon, 13 Feb 2017 14:20:55 +0000 (15:20 +0100)]
x86emul: always init mmval

... to avoid buggy read/write sizes becoming info leaks.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoy86/vmx: dump PIR and vIRR before ASSERT()
Chao Gao [Mon, 13 Feb 2017 14:19:42 +0000 (15:19 +0100)]
y86/vmx: dump PIR and vIRR before ASSERT()

Commit c7bdecae42 ("x86/apicv: fix RTC periodic timer and apicv issue") has
added a assertion that intack.vector is the highest priority vector. But
according to the osstest, the assertion failed sometimes. More discussion can
be found in the thread
(https://lists.xenproject.org/archives/html/xen-devel/2017-01/msg01019.html).

The assertion failure is hard to reproduce. In order to root cause issue, this
patch is to add logs to dump PIR and vIRR when failure takes place. It should
be reverted once the root cause is found.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>