]> xenbits.xensource.com Git - people/tklengyel/xen.git/log
people/tklengyel/xen.git
9 years agotools/libxl: arm: Use an higher value for the GIC phandle
Julien Grall [Wed, 13 May 2015 18:33:39 +0000 (19:33 +0100)]
tools/libxl: arm: Use an higher value for the GIC phandle

The partial device tree may contains phandle. The Device Tree Compiler
tends to allocate the phandle from 1.

Reserve the ID 65000 for the GIC phandle. I think we can safely assume
that the partial device tree will never contain a such ID.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
9 years agotools/(lib)xl: Add partial device tree support for ARM
Julien Grall [Wed, 13 May 2015 18:33:38 +0000 (19:33 +0100)]
tools/(lib)xl: Add partial device tree support for ARM

Allow the user to pass additional nodes to the guest device tree. For
this purpose, everything in the node /passthrough from the partial
device tree will be copied into the guest device tree.

The node /aliases will be also copied to allow the user to define
aliases which can be used by the guest kernel.

A simple partial device tree will look like:

/dts-v1/;

/ {
        #address-cells = <2>;
        #size-cells = <2>;

        passthrough {
            compatible = "simple-bus";
            ranges;
            #address-cells = <2>;
            #size-cells = <2>;

            /* List of your nodes */
        }
};

Note that:
    * The interrupt-parent property will be added by the toolstack in
    the root node
    * The properties compatible, ranges, #address-cells and #size-cells
    in /passthrough are mandatory.

The helpers provided by the libfdt don't perform all the necessary
security check on a given device tree. Therefore, only trusted device
tree should be used.

Note: The partial device tree code requires the presence of libfdt
functions which have been only correctly exported in libfdt 1.4.0 and
higher. All the major distributions but Debian Wheezy are using v1.4.0
or higher. It has been decided to disable partial device tree support on
OSes where libfdt doesn't meet the requirement.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ran autogen.sh ]

9 years agotools/libxl: Check if fdt_{first,next}_subnode are present in libfdt
Julien Grall [Tue, 17 Mar 2015 17:58:14 +0000 (17:58 +0000)]
tools/libxl: Check if fdt_{first,next}_subnode are present in libfdt

The functions fdt_{first,next}_subnode may not be available because:
    * It has been introduced in 2013 => Doesn't work on Wheezy
    * The prototype exists but the functions are not exposed. Don't ask
    why...

The later has been fixed recently in the dtc repo [1]

When the functions are not available, implement our own in order to use
them in a following patch.

Note that the _hidden attribute is placed in both the prototype and the
declaration because some version of libfdt expose the prototype but not
the declaration.

[1] git://git.kernel.org/pub/scm/utils/dtc/dtc.git
    commit a4b093f7366fdb429ca1781144d3985fa50d0fbb

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ran autogen.sh ]

9 years agovmap: avoid hitting an ASSERT with vfree(NULL)
Andrew Cooper [Thu, 21 May 2015 06:57:19 +0000 (08:57 +0200)]
vmap: avoid hitting an ASSERT with vfree(NULL)

and unconditionally defer the vm_size() call, as it doesn't have a NULL
short circuit.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
9 years agox86/mm: PV GDT handling cleanup
Andrew Cooper [Thu, 21 May 2015 06:56:24 +0000 (08:56 +0200)]
x86/mm: PV GDT handling cleanup

These are a few bits of cleanup noticed when double checking the PV GDT
handling for migration v2.

 * Drop write-only 'mfn' variable in set_gdt()
 * Hoist page_get_owner() call in alloc_segdesc_page() and unify exit paths

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agopublic: clarify xen_arch_domainconfig ABI statement
Andrew Cooper [Thu, 21 May 2015 06:56:01 +0000 (08:56 +0200)]
public: clarify xen_arch_domainconfig ABI statement

This structure is used by XEN_DOMCTL_createdomain, and is liable to be
modified going forwards.  Explicitly state that it falls under the
XEN_DOMCTL_INTERFACE_VERSION.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Reviewed-by: Don Slutz <dslutz@verizon.com>
9 years agoxen: arm: remove redundant declation of arch_get_xen_caps
Ian Campbell [Wed, 20 May 2015 12:05:28 +0000 (13:05 +0100)]
xen: arm: remove redundant declation of arch_get_xen_caps

It was recently commented out, but just remove it instead.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
9 years agoarm: drop redundant declaration of arch_get_xen_caps()
Jan Beulich [Wed, 20 May 2015 11:39:39 +0000 (13:39 +0200)]
arm: drop redundant declaration of arch_get_xen_caps()

It's being declared in xen/hypercall.h, and the duplication causes a
build failure with commit 8ddb99287c.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
9 years agox86/domctl: fix getpageframeinfo* handling
Andrew Cooper [Wed, 20 May 2015 11:31:50 +0000 (13:31 +0200)]
x86/domctl: fix getpageframeinfo* handling

In tree, there is one single caller of XEN_DOMCTL_getpageframeinfo3
(xc_get_pfn_type_batch()), and no callers of the older variants.

getpageframeinfo3 and getpageframeinfo2 are compatible if the parameter
contents are considered to be unsigned long, and indeed, a compat guest
calling getpageframeinfo3 falls through into the getpageframeinfo2 handler.

However, getpageframeinfo3 and getpageframeinfo2 have different algorithms for
calculating the eventual frame type, which means that a toolstack will get
different answers depending on whether it is compat or not.

Rewrite getpageframeinfo3 such that the code block can handle both regular and
compat guests, and use the original getpageframeinfo3 algorithm for frame
time, which is more complete.

Remove getpageframeinfo2 and getpageframeinfo1, as they are unused and
obsolete.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
9 years agopci: make pci_device_detect() return bool_t
Tiejun Chen [Wed, 20 May 2015 11:31:08 +0000 (13:31 +0200)]
pci: make pci_device_detect() return bool_t

This function should better return as bool_t and
remove that pointless comment.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
9 years agox86/pvh: trap access to sensitive IO ports
Roger Pau Monné [Wed, 20 May 2015 11:27:23 +0000 (13:27 +0200)]
x86/pvh: trap access to sensitive IO ports

This is needed so Xen can properly trap 4 byte accesses to 0xcf8 in order to
keep consistency with accesses to 0xcfc.

The access to RTC ports also needs to be trapped in order to keep
consistency, this includes RTC_PORT(0) and RTC_PORT(1) (0x70 and 0x71
respectively).

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
9 years agox86/pvh: use a custom IO bitmap for PVH hardware domains
Roger Pau Monné [Wed, 20 May 2015 11:26:43 +0000 (13:26 +0200)]
x86/pvh: use a custom IO bitmap for PVH hardware domains

Since a PVH hardware domain has access to the physical hardware create a
custom more permissive IO bitmap. The permissions set on the bitmap are
populated based on the contents of the ioports rangeset.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
9 years agox86: don't unconditionally touch the hvm_domain union during domain construction
Andrew Cooper [Wed, 20 May 2015 11:25:12 +0000 (13:25 +0200)]
x86: don't unconditionally touch the hvm_domain union during domain construction

It may not be the appropriate half to touch.

Drop the superfluous mem_sharing_enabled assignment, and move the hap_enabled
assignment to a suitable conditional before it is actually needed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
9 years agomwait-idle: add support for the Airmont Core in the Cherrytrail and Braswell SOCs
Len Brown [Wed, 20 May 2015 11:24:34 +0000 (13:24 +0200)]
mwait-idle: add support for the Airmont Core in the Cherrytrail and Braswell SOCs

Support C-states for the Airmont core in the Cherrytrail and Braswell
SOCs. The states are similar to those of Silvermont in Baytrail, except
both flavors of C6 states are faster.

Signed-off-by: Len Brown <len.brown@intel.com>
[Linux commit cab07a5652d1d124b505c2b7ed21c6823295c5d7]
Signed-off-by: Jan Beulich <jbeulich@suse.com>
9 years agomwait-idle: update support for Silvermont Core in Baytrail SOC
Len Brown [Wed, 20 May 2015 11:23:49 +0000 (13:23 +0200)]
mwait-idle: update support for Silvermont Core in Baytrail SOC

On some Silvermont-Core/Baytrail-SOC systems,
C1E latency is higher than original specifications.
Although C1E is still enumerated in CPUID.MWAIT.EDX,
we delete the state from intel_idle to avoid latency impact.

Under some conditions, the latency of the C6N-BYT and C6S-BYT states
may exceed the specified values of 40 and 140 usec, respectively.
Increase those values to 300 and 500 usec; to assure
that the hardware does not violate constraints that may be set
by the Linux PM_QOS sub-system.

Also increase the C7-BYT target residency to 4.0 ms from 1.5 ms.

Signed-off-by: Len Brown <len.brown@intel.com>
[Linux commit d7ef76717322c8e2df7d4360b33faa9466cb1a0d]
Signed-off-by: Jan Beulich <jbeulich@suse.com>
9 years agomwait-idle: support additional Broadwell model
Len Brown [Wed, 20 May 2015 11:23:17 +0000 (13:23 +0200)]
mwait-idle: support additional Broadwell model

Signed-off-by: Len Brown <len.brown@intel.com>
[Linux commit bea57077e44ec9c1e6d3a3c142c8a3c0289e290d]
Signed-off-by: Jan Beulich <jbeulich@suse.com>
9 years agospinlock: fix build with older GCC
David Vrabel [Tue, 19 May 2015 13:49:22 +0000 (15:49 +0200)]
spinlock: fix build with older GCC

Older GCC versions such as 4.3 cannot have initializers for the
members of anonymous structures, so initialize .head_tail instead.

Use a SPINLOCK_TICKET_INC define so this initializer is near the
spinlock_tickets_t definition (in case the structure changes requiring
changes to the initializer).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reported-and-tested-by: Jan Beulich <jbeulich@suse.com>
9 years agox86/EFI: keep EFI runtime services top level page tables up-to-date
Jan Beulich [Tue, 19 May 2015 09:35:30 +0000 (11:35 +0200)]
x86/EFI: keep EFI runtime services top level page tables up-to-date

Updates to idle_pg_table[] need to be mirrored into the page tables
used for invoking EFI runtime services.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
9 years agoRevert "x86: rework paging_log_dirty_op to work with hvm guests"
Jan Beulich [Mon, 18 May 2015 10:34:44 +0000 (12:34 +0200)]
Revert "x86: rework paging_log_dirty_op to work with hvm guests"

This reverts commit a809eeea06d20b115d78f12e473502bcb6209844, as it
breaks PV log dirty mode handling.

9 years agox86emul: also put_fpu() on error paths
Jan Beulich [Mon, 18 May 2015 10:11:31 +0000 (12:11 +0200)]
x86emul: also put_fpu() on error paths

fail_if() and generate_exception_if() could theoretically bypass the
normal flow reaching put_fpu(), and not invoking it would leave the
fpu_exception_callback pointer in place, allowing for the callback to
be called at an unexpected time. Luckily the two
generate_exception_if()-s that would actually trigger this are
currently commented out, so this is not (yet) a (security) issue.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agoxentrace: Implement cpu mask range parsing of human values (-c).
Konrad Rzeszutek Wilk [Fri, 15 May 2015 20:12:22 +0000 (16:12 -0400)]
xentrace: Implement cpu mask range parsing of human values (-c).

Instead of just using -c 0x<some hex value> we can
also use: -c <starting cpu>-<end cpu>, -c <cpu1>,<cpu2>, or a
combination of them, or 'all' for all cpus.

This new format can include just singular CPUs: -c <cpu1>,
or ranges without an start or end (and xentrace will figure out
the values), such as: -c -<cpu2> (which will include cpu0, cpu1,
and cpu2) or -c <cpu2>- (which will include cpu2 and up to MAX_CPUS).

That should make it easier to trace the right CPU if
using this along with 'xl vcpu-list'.

The code has been lifted from the Linux kernel, see file
lib/bitmap.c, function __bitmap_parselist.

To make the old behavior and the new function work, we check
to see if the arguments have '0x' in them. If they do
we use the old style parsing (limited to 32 CPUs). If that
does not exist we use the new parsing.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
10 years agox86: rework paging_log_dirty_op to work with hvm guests
Roger Pau Monné [Fri, 15 May 2015 08:08:33 +0000 (10:08 +0200)]
x86: rework paging_log_dirty_op to work with hvm guests

When the caller of paging_log_dirty_op is a hvm guest Xen would choke when
trying to copy the dirty bitmap to the guest because the paging lock is
already held.

Fix this by independently mapping each page of the guest bitmap as needed
without the paging lock held.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
10 years agox86/hap: make hap_track_dirty_vram use non-contiguous memory for temporary map
Roger Pau Monné [Fri, 15 May 2015 08:07:50 +0000 (10:07 +0200)]
x86/hap: make hap_track_dirty_vram use non-contiguous memory for temporary map

Just like it's done for shadow_track_dirty_vram allocate the temporary
buffer using non-contiguous memory.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
10 years agox86/shadow: fix shadow_track_dirty_vram to work on hvm guests
Roger Pau Monné [Fri, 15 May 2015 08:07:20 +0000 (10:07 +0200)]
x86/shadow: fix shadow_track_dirty_vram to work on hvm guests

Modify shadow_track_dirty_vram to use a local buffer and then flush to the
guest without the paging_lock held. This is modeled after
hap_track_dirty_vram.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
10 years agointroduce a helper to allocate non-contiguous memory
Roger Pau Monné [Fri, 15 May 2015 08:06:04 +0000 (10:06 +0200)]
introduce a helper to allocate non-contiguous memory

The allocator uses independent calls to alloc_domheap_pages in order to get
the desired amount of memory and then maps all the independent physical
addresses into a contiguous virtual address space.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Tested-by: Julien Grall <julien.grall@citrix.com> (ARM)
Reviewed-by: Tim Deegan <tim@xen.org>
10 years agox86,arm: remove asm/spinlock.h from all architectures
David Vrabel [Fri, 15 May 2015 07:52:25 +0000 (09:52 +0200)]
x86,arm: remove asm/spinlock.h from all architectures

Now that all architecture use a common ticket lock implementation for
spinlocks, remove the architecture specific byte lock implementations.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agouse ticket locks for spin locks
David Vrabel [Fri, 15 May 2015 07:49:12 +0000 (09:49 +0200)]
use ticket locks for spin locks

Replace the byte locks with ticket locks.  Ticket locks are: a) fair;
and b) peform better when contented since they spin without an atomic
operation.

The lock is split into two ticket values: head and tail.  A locker
acquires a ticket by (atomically) increasing tail and using the
previous tail value.  A CPU holds the lock if its ticket == head.  The
lock is released by increasing head.

spin_lock_irq() and spin_lock_irqsave() now spin with irqs disabled
(previously, they would spin with irqs enabled if possible).  This is
required to prevent deadlocks when the irq handler tries to take the
same lock with a higher ticket.

Architectures need only provide arch_fetch_and_add() and two barriers:
arch_lock_acquire_barrier() and arch_lock_release_barrier().

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
10 years agolibxc/restore: add checkpointed flag to the restore context
Yang Hongyang [Thu, 14 May 2015 08:55:18 +0000 (16:55 +0800)]
libxc/restore: add checkpointed flag to the restore context

add checkpointed flag to the restore context.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/restore: introduce setup() and cleanup() on restore
Yang Hongyang [Thu, 14 May 2015 08:55:17 +0000 (16:55 +0800)]
libxc/restore: introduce setup() and cleanup() on restore

introduce setup() and cleanup() which subsume the
ctx->restore.ops.{setup,cleanup}() calls and also
do memory alloc/free.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/restore: split read/handle qemu info
Yang Hongyang [Thu, 14 May 2015 08:55:16 +0000 (16:55 +0800)]
libxc/restore: split read/handle qemu info

Split read/handle qemu info. The receiving of qemu info
should be done while we receive the migration stream,
handle_qemu will be called when the stream complete.
Otherwise, it will break Remus because read_record()
won't read qemu info and stream_complete will be called
at failover.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxc/restore: introduce process_record()
Yang Hongyang [Thu, 14 May 2015 08:55:15 +0000 (16:55 +0800)]
libxc/restore: introduce process_record()

Move record handle codes into a function process_record().
It will be used multiple times by Remus.
No functional change.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/save: reuse send_dirty_pages() in send_all_pages()
Yang Hongyang [Thu, 14 May 2015 08:55:14 +0000 (16:55 +0800)]
libxc/save: reuse send_dirty_pages() in send_all_pages()

introduce bitmap_set() to set the entire bitmap.
in send_all_pages(), set the entire bitmap and call send_dirty_pages().

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/save: rename send_some_pages to send_dirty_pages
Yang Hongyang [Thu, 14 May 2015 08:55:13 +0000 (16:55 +0800)]
libxc/save: rename send_some_pages to send_dirty_pages

rename send_some_pages to send_dirty_pages, no functional change.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxc/save: remove bitmap param from send_some_pages
Yang Hongyang [Thu, 14 May 2015 08:55:12 +0000 (16:55 +0800)]
libxc/save: remove bitmap param from send_some_pages

In last patch we added dirty bitmap to the save context,
we no longer need to pass this param to send_some_pages.
We can get dirty bitmap from the save context.
'entries' should stay as it is a useful sanity check.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/save: adjust the memory allocation for migration
Yang Hongyang [Thu, 14 May 2015 08:55:11 +0000 (16:55 +0800)]
libxc/save: adjust the memory allocation for migration

Move the memory allocation before the concrete live/nolive save
in order to avoid the free/alloc memory loop when using Remus.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/save: rename to_send to dirty_bitmap
Yang Hongyang [Thu, 14 May 2015 08:55:10 +0000 (16:55 +0800)]
libxc/save: rename to_send to dirty_bitmap

rename to_send to dirty_bitmap.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/save: introduce setup() and cleanup() on save
Yang Hongyang [Thu, 14 May 2015 08:55:09 +0000 (16:55 +0800)]
libxc/save: introduce setup() and cleanup() on save

introduce setup() and cleanup() which subsume the
ctx->save.ops.{setup,cleanup}() calls.
The SHADOW_OP_OFF hypercall is also included in the cleanup().

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: add a check in xc_hypercall_buffer_free_pages macro
Yang Hongyang [Thu, 14 May 2015 08:55:08 +0000 (16:55 +0800)]
tools/libxc: add a check in xc_hypercall_buffer_free_pages macro

When we use a DECLARE_HYPERCALL_BUFFER_SHADOW it defines a user
pointer '_name' and a shadow xc_hypercall_buffer_t.
When calling xc_hypercall_buffer_free_pages(_xch, _name, _nr),
the complier will report '_name' unused error, because
xc_hypercall_buffer_free_pages() is a MACRO and '_name' is
transparently converted to the hypercall buffer. it confuses
the caller because xc_hypercall_buffer_free_pages() looks
like a function and takes '_name' as an arg.
Add an if check to let the compiler think we are actually
using the argument '_name'.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
[ ijc -- some rewording of the commit message ]

10 years agotools/libxc: unused attribute in DECLARE_HYPERCALL_BUFFER_SHADOW
Yang Hongyang [Thu, 14 May 2015 08:55:07 +0000 (16:55 +0800)]
tools/libxc: unused attribute in DECLARE_HYPERCALL_BUFFER_SHADOW

There are cases where we only need to use the hypercall buffer data,
and do not use the xc_hypercall_buffer_t struct.
DECLARE_HYPERCALL_BUFFER_SHADOW defines a user pointer that can allow
us to access the hypercall buffer data but it also defines a
xc_hypercall_buffer_t that we don't use, the compiler will report arg
unused error.
Add __attribute__((unused)) before xc_hypercall_buffer_t to avoid
the compiler error.

Example cases:
In send_all_pages(), we only need to use the hypercall buffer data
which is a dirty bitmap, we set the dirty bitmap to all dirty and call
send_dirty_pages, we will not use the xc_hypercall_buffer_t and hypercall
to retrieve the dirty bitmap.
In send_some_pages(), we will also only need to use the dirty_bitmap.
the retrieve dirty bitmap hypercall are done by the caller.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/migration: Pass checkpoint information into the save algorithm.
Andrew Cooper [Thu, 14 May 2015 08:55:06 +0000 (16:55 +0800)]
libxc/migration: Pass checkpoint information into the save algorithm.

The old code checks the callbacks "postcopy & checkpoint", if the
callbacks exists, it will call them. However this is unreliable, so
add this flag to explicitly indicate a checkpointed stream in the new
code. This is backward compatible with the legacy migration just don't
know this flag and will ignore it.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Yang Hongyang <yanghy@cn.fujitsu.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
[ ijc -- added discussion of legacy compat ]

10 years agolibxc/migration: Specification update for CHECKPOINT records
Andrew Cooper [Thu, 14 May 2015 08:55:05 +0000 (16:55 +0800)]
libxc/migration: Specification update for CHECKPOINT records

Checkpointed streams need to signal the end of a consistent view of VM state,
and the start of the libxl data.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/save: Adjust stream-position callbacks for checkpointed streams
Andrew Cooper [Thu, 14 May 2015 08:55:04 +0000 (16:55 +0800)]
libxc/save: Adjust stream-position callbacks for checkpointed streams

There are some records which should only be sent once in the stream, and not
repeated for each checkpoint.  {start,end}_of_stream() become per-checkpoint,
and a new start_of_stream() is introduced.

There is no resulting change record order, but the X86_PV_INFO record is
identified as once per stream.  Currently the X86_PV_P2M_FRAMES record is as
well, but this is because of an implementation bug and can move back to being
on an as-needed basis when fixed.

In addition, a few minor adjustments of comments and layout.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Yang Hongyang <yanghy@cn.fujitsu.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/migration: Be rather stricter with illformed callers
Andrew Cooper [Thu, 14 May 2015 08:55:03 +0000 (16:55 +0800)]
libxc/migration: Be rather stricter with illformed callers

The migration code itself should be able to validly assume all mandatory
callbacks are set up.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Yang Hongyang <yanghy@cn.fujitsu.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agoxenpm: Initialize cputopo pointer
Boris Ostrovsky [Wed, 13 May 2015 17:37:35 +0000 (13:37 -0400)]
xenpm: Initialize cputopo pointer

Commit 250f0b43af1a ("libxl/libxc: Move libxl_get_cpu_topology()'s
hypercall buffer management to libxc") broke non-debug compilation:
on error path we may have uninitialized cputopo pointer.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reported-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoMerge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging
Ian Campbell [Wed, 13 May 2015 14:46:54 +0000 (15:46 +0100)]
Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging

10 years agoIOMMU/x86: avoid pages without GFN in page table creation/updating
Jan Beulich [Wed, 13 May 2015 14:35:54 +0000 (16:35 +0200)]
IOMMU/x86: avoid pages without GFN in page table creation/updating

Handing INVALID_GFN to functions like hd->platform_ops->map_page()
just can't do any good, and the ioreq server code results in such pages
being on the list of ones owned by a guest.

While - as suggested by Tim - we should use get_gfn()/put_gfn() there
to eliminate races, we really can't due to holding the domain's page
alloc lock. Ultimately arch_iommu_populate_page_table() may need to be
switched to be GFN based. Here is what Tim said in this regard:
"Ideally this loop would be iterating over all gfns in the p2m rather
 than over all owned MFNs.  As long as needs_iommu gets set first,
 such a loop could safely be paused and restarted without worrying
 about concurrent updates.  The code sould even stay in this file,
 though exposing an iterator from the p2m code would be a lot more
 efficient."

Original by Andrew Cooper <andrew.cooper3@citrix.com>, using further
suggestions from Tim Deegan <tim@xen.org>.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Yang Zhang <yang.z.zhang@intel.com>
Acked-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
10 years agolibxl: Add interface for querying hypervisor about PCI topology
Boris Ostrovsky [Mon, 11 May 2015 16:31:30 +0000 (12:31 -0400)]
libxl: Add interface for querying hypervisor about PCI topology

.. and use this new interface to display it along with CPU topology
and NUMA information when 'xl info -n' command is issued

The output will look like
...
cpu_topology           :
cpu:    core    socket     node
  0:       0        0        0
...
device topology        :
device           node
0000:00:00.0      0
0000:00:01.0      0
...

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxc: Provide set_xen_guest_handle_offset macro
Boris Ostrovsky [Mon, 11 May 2015 16:31:29 +0000 (12:31 -0400)]
libxc: Provide set_xen_guest_handle_offset macro

Add set_xen_guest_handle_offset() macro that can be used for setting
xen_guest_handle to an offset into hypercall buffer.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl/libxc: Move libxl_get_numainfo()'s hypercall buffer management to libxc
Boris Ostrovsky [Mon, 11 May 2015 16:31:28 +0000 (12:31 -0400)]
libxl/libxc: Move libxl_get_numainfo()'s hypercall buffer management to libxc

xc_numainfo() is not expected to be used on a hot path and therefore
hypercall buffer management can be pushed into libxc. This will simplify
life for callers.

Also update error logging macros.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl/libxc: Move libxl_get_cpu_topology()'s hypercall buffer management to libxc
Boris Ostrovsky [Mon, 11 May 2015 16:31:27 +0000 (12:31 -0400)]
libxl/libxc: Move libxl_get_cpu_topology()'s hypercall buffer management to libxc

xc_cputopoinfo() is not expected to be used on a hot path and therefore
hypercall buffer management can be pushed into libxc. This will simplify
life for callers.

Also update error reporting macros.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoDocument '-F' option of create subcommand.
Giuseppe Mazzotta [Tue, 12 May 2015 14:51:42 +0000 (14:51 +0000)]
Document '-F' option of create subcommand.

Other options are still missing and not part of this patch.

Signed-off-by: Giuseppe Mazzotta <g.mazzotta@iragan.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/iommu: arm: Use p2m_ipa_bits as stage2 input size
Edgar E. Iglesias [Fri, 8 May 2015 07:10:10 +0000 (17:10 +1000)]
xen/iommu: arm: Use p2m_ipa_bits as stage2 input size

The Stage2 input-size must match what the CPU uses because
the SMMU and the CPU share page-tables.

Test that the SMMU supports the P2M IPA bit size, use it if
supported or bail out if not.

Reviewed-by: Julien Grall <julien.grall@citrix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: Add p2m_ipa_bits
Edgar E. Iglesias [Fri, 8 May 2015 07:10:09 +0000 (17:10 +1000)]
xen/arm: Add p2m_ipa_bits

Export p2m_ipa_bits holding the bit size of IPAs used in p2m tables.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen/arm: Re-order iommu_setup to after setup_virt_paging
Edgar E. Iglesias [Fri, 8 May 2015 07:10:08 +0000 (17:10 +1000)]
xen/arm: Re-order iommu_setup to after setup_virt_paging

This is needed to allow the paging setup to probe for
IPA bit sizes to be used in p2m tables prior to iommu setup.

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
10 years agocpupools: avoid crashing if shutting down with free CPUs
Dario Faggioli [Wed, 13 May 2015 13:08:30 +0000 (15:08 +0200)]
cpupools: avoid crashing if shutting down with free CPUs

in fact, before this change, shutting down or suspending the
system with some CPUs not assigned to any cpupool, would
crash as follows:

  (XEN) Xen call trace:
  (XEN)    [<ffff82d080101757>] disable_nonboot_cpus+0xb5/0x138
  (XEN)    [<ffff82d0801a8824>] enter_state_helper+0xbd/0x369
  (XEN)    [<ffff82d08010614a>] continue_hypercall_tasklet_handler+0x4a/0xb1
  (XEN)    [<ffff82d0801320bd>] do_tasklet_work+0x78/0xab
  (XEN)    [<ffff82d0801323f3>] do_tasklet+0x5e/0x8a
  (XEN)    [<ffff82d080163cb6>] idle_loop+0x56/0x6b
  (XEN)
  (XEN)
  (XEN) ****************************************
  (XEN) Panic on CPU 0:
  (XEN) Xen BUG at cpu.c:191
  (XEN) ****************************************

This is because, for free CPUs, -EBUSY were being returned
when trying to tear them down, making cpu_down() unhappy.

It is certainly unpractical to forbid shutting down or
suspenging if there are unassigned CPUs, so this change
fixes the above by just avoiding returning -EBUSY for those
CPUs. If shutting off, that does not matter much anyway. If
suspending, we make sure that the CPUs remain unassigned
when resuming.

While there, take the chance to:
 - fix the doc comment of cpupool_cpu_remove() (it was
   wrong);
 - improve comments in general around and in cpupool_cpu_remove()
   and cpupool_cpu_add();
 - add a couple of ASSERT()-s for checking consistency.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Tested-by: Juergen Gross <jgross@suse.com>
10 years agoarm: provide add_sized()
David Vrabel [Wed, 13 May 2015 13:01:25 +0000 (15:01 +0200)]
arm: provide add_sized()

add_sized(ptr, inc) adds inc to the value at ptr using only the correct
size of loads and stores for the type of *ptr.  The add is /not/ atomic.

This is needed for ticket locks to ensure the increment of the head ticket
does not affect the tail ticket.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agox86: provide add_sized()
David Vrabel [Wed, 13 May 2015 13:00:58 +0000 (15:00 +0200)]
x86: provide add_sized()

add_sized(ptr, inc) adds inc to the value at ptr using only the correct
size of loads and stores for the type of *ptr.  The add is /not/ atomic.

This is needed for ticket locks to ensure the increment of the head ticket
does not affect the tail ticket.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
10 years agotools/libxc: Fix missing break from c/s b49a7517
Andrew Cooper [Fri, 8 May 2015 20:59:27 +0000 (21:59 +0100)]
tools/libxc: Fix missing break from c/s b49a7517

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Julien Grall <julien.grall@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agopvgrub: initialise p2m_size
Wei Liu [Sun, 10 May 2015 13:14:51 +0000 (14:14 +0100)]
pvgrub: initialise p2m_size

In 84083790 ("libxc: add p2m_size to xc_dom_image") a new field is
added. We should initialised this field in pvgrub as well, otherwise
xc_dom_build_image won't work properly.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/xsm: Fix x86 XSM build after commit 6ea9f04
Julien Grall [Mon, 11 May 2015 10:09:24 +0000 (11:09 +0100)]
xen/xsm: Fix x86 XSM build after commit 6ea9f04

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agox86/hvm: permit HVM_PARAM_IDENT_PT to be set more than once
Andrew Cooper [Mon, 11 May 2015 08:42:35 +0000 (10:42 +0200)]
x86/hvm: permit HVM_PARAM_IDENT_PT to be set more than once

There is no conceptual problem with setting this parameter more than once.
Checkpointed migration streams will typically set it once per checkpoint to
the same value.

The parameter is only actually needed on early-generation VT-x which lacked
the unrestricted guest capability, although it could plausibly be used on
newer VT-x with unusual execution control settings.  Short circuit the
expensive operations on non VT-x hardware.

The parameter itself must always be latched to avoid issues if the VM
eventually migrates to a host which needs to use the pagetable.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/hvm: add store and console event channel params to white-list
Paul Durrant [Mon, 11 May 2015 08:39:07 +0000 (10:39 +0200)]
x86/hvm: add store and console event channel params to white-list

My recent patch "use white-lists for HVM param guest accessibility checks"
(commit 30efda12d63ff536102ed8e580b4c09765683b44) introduced a regression
when saving and restoring Windows guests running Xen Project PV drivers.

The drivers reset the event channel ABI on resume. This has the effect of
closing the store and console local event channel ports created by the
toolstack. The drivers do not currently use the console port but they
do use the store port and thus, prior to reset, they sample the remote
domain and port and then re-bind the channel - yielding a new and possibly
different local port - after reset. They then store the new local port
value in HVM_PARAM_CONSOLE_EVTCHN. That operation now fails and may
lead to a crash, if using a debug build of the drivers, or a barely
functional connection to xentored if not.

This patch adds HVM_PARAM_STORE_EVTCHN and HVM_PARAM_CONSOLE_EVTCHN to
the guest-settable white-list since either of them can be invalidated
by an event channel ABI reset and thus the guest may indeed need to
write new values to them to make them valid again.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86: don't clear high 32 bits of RAX on sub-word guest I/O port reads
Jan Beulich [Mon, 11 May 2015 08:37:58 +0000 (10:37 +0200)]
x86: don't clear high 32 bits of RAX on sub-word guest I/O port reads

1- or 2-byte operations never alter the high halves of registers.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agoRevert "x86/pvh: use a custom IO bitmap for PVH hardware domains"
Jan Beulich [Mon, 11 May 2015 08:34:13 +0000 (10:34 +0200)]
Revert "x86/pvh: use a custom IO bitmap for PVH hardware domains"

This reverts commit e5786bae04c3ebf6b122b2d983a946ff29308781 - it
breaks the XSM build.

10 years agoxen/arm64: Avoid sending SGI when kicking secondary cpus with spin_table
Chen Baozi [Tue, 7 Apr 2015 07:33:52 +0000 (15:33 +0800)]
xen/arm64: Avoid sending SGI when kicking secondary cpus with spin_table

On arm64, either firmware or xen's smp_up_cpu gate uses WFE on secondary
cpus to stand-by when booting. Thus, using SEV is enough for the boot
cpu to kick other secondaries. Further more, the current implementation
of cpu_up_send_sgi would pass a NULL cpumask pointer to send_SGI, which
then lead a data fault on GICv3 send_SGI implementation.

Signed-off-by: Chen Baozi <baozich@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: gic: Refactor the code for creating gic node
Suravee Suthikulpanit [Thu, 23 Apr 2015 04:51:59 +0000 (23:51 -0500)]
xen/arm: gic: Refactor the code for creating gic node

Since fdt_begin_node() is called by all gicXX_make_dt_node() to create
the interrupt-controller devicetree node, this patch refactors the call
and moves it inside make_gic_node(). This also matches the fdt_end_node()
call at the end of make_gic_node().

This patch also move the call to gic_make_node() wrapper to be after all
other generic properties are setup. This allows creating sub-node inside
gic_make_node() in order to support v2m sub-node.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen: arm: slightly refactor gic DT node creation for domain 0.
Ian Campbell [Fri, 8 May 2015 11:26:57 +0000 (12:26 +0100)]
xen: arm: slightly refactor gic DT node creation for domain 0.

Although in principal #interrupt-cells can vary it must always be 3
for a GIC (and we only support GIC as a guest interrupt controller),
so putting it in common code is OK.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agotools/libxl: Create a per-arch function to map IRQ to a domain
Julien Grall [Tue, 28 Apr 2015 14:32:37 +0000 (15:32 +0100)]
tools/libxl: Create a per-arch function to map IRQ to a domain

ARM and x86 use a different hypercall to map an IRQ to a domain.

The hypercall to give IRQ permission to the domain has also been moved
to be an x86 specific function as ARM guest won't be able to manage the IRQ.
We may want to support it later.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
10 years agoxen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device
Julien Grall [Tue, 28 Apr 2015 14:32:36 +0000 (15:32 +0100)]
xen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device

A device node is described by a path. It will be used to retrieve the
node in the device tree and assign the related device to the domain.

Only non-PCI devices protected by an IOMMU can be assigned to a guest.

Also document the behavior of XEN_DOMCTL_deassign_device in the public
headers which differ between non-PCI and PCI.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
10 years agoxen/xsm: Add helpers to check permission for device tree passthrough
Julien Grall [Tue, 28 Apr 2015 14:32:35 +0000 (15:32 +0100)]
xen/xsm: Add helpers to check permission for device tree passthrough

This is a follow-up of commit 525ee49 "xsm: add device tree labeling
support" which add support for device tree labelling in flask.

Those helpers will be use latter when non-pci passthrough (i.e device
tree) will be added.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/iommu: arm: Wire iommu DOMCTL for ARM
Julien Grall [Tue, 28 Apr 2015 14:32:34 +0000 (15:32 +0100)]
xen/iommu: arm: Wire iommu DOMCTL for ARM

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/passthrough: iommu_deassign_device_dt: By default reassign device to nobody
Julien Grall [Tue, 28 Apr 2015 14:32:33 +0000 (15:32 +0100)]
xen/passthrough: iommu_deassign_device_dt: By default reassign device to nobody

Currently, when the device is deassigned from a domain, we directly reassign
to DOM0.

As the device may not have been correctly reset, this may lead to corruption or
expose some part of DOM0 memory. Also, we may have no way to reset some
platform devices.

If Xen reassigns the device to "nobody", it may receive some global/context
fault because the transaction has failed (indeed the context has been
marked invalid). Unfortunately there is no simple way to quiesce a buggy
hardware. I think we could live with that for a first version of platform
device passthrough.

DOM0 will have to issue an hypercall to assign the device to itself if it
wants to use it.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/passthrough: arm: release the DT devices assigned to a guest earlier
Julien Grall [Tue, 28 Apr 2015 14:32:32 +0000 (15:32 +0100)]
xen/passthrough: arm: release the DT devices assigned to a guest earlier

The toolstack may not have deassigned every device used by a guest.
Therefore we have to go through the device list and remove them before
asking the IOMMU drivers to release memory for this domain.

This can be done by moving the call to the release function when we
relinquish the resources. The IOMMU part will be destroyed later when
the domain is freed.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Robert VanVossen <robert.vanvossen@dornerworks.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/passthrough: Introduce iommu_construct
Julien Grall [Tue, 28 Apr 2015 14:32:31 +0000 (15:32 +0100)]
xen/passthrough: Introduce iommu_construct

This new function will correctly initialize the IOMMU page table for the
current domain.

Also use it in iommu_assign_dt_device even though the current IOMMU
implementation on ARM shares P2M with the processor.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/dts: Provide an helper to get a DT node from a path provided by a guest
Julien Grall [Tue, 28 Apr 2015 14:32:30 +0000 (15:32 +0100)]
xen/dts: Provide an helper to get a DT node from a path provided by a guest

The maximum size of the copied string has been chosen based on the value
use by XSM in similar case.

Furthermore, Linux seems to allow path up to 4096 characters. Though
this could vary from one OS to another.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen: guestcopy: Provide an helper to safely copy string from guest
Julien Grall [Tue, 28 Apr 2015 14:32:29 +0000 (15:32 +0100)]
xen: guestcopy: Provide an helper to safely copy string from guest

Flask code already provides a helper to copy a string from guest. In a later
patch, the new DT hypercalls will need a similar function.

To avoid code duplication, copy the flask helper (flask_copying_string) to
common code:
    - Rename into safe_copy_string_from_guest
    - Add comment to explain the extra +1
    - Return the buffer directly and use the macros provided by
    xen/err.h to return an error code if necessary.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
10 years agoxen/arm: Implement hypercall DOMCTL_{, un}bind_pt_pirq
Julien Grall [Tue, 28 Apr 2015 14:32:28 +0000 (15:32 +0100)]
xen/arm: Implement hypercall DOMCTL_{, un}bind_pt_pirq

On x86, an IRQ is assigned in 2 steps to an HVM guest:
    - The toolstack is calling PHYSDEVOP_map_pirq in order to create a
    guest PIRQ (IRQ bound to an event channel)
    - The emulator (QEMU) is calling DOMCTL_bind_pt_irq in order to
    bind the IRQ

On ARM, there is no concept of PIRQ as the IRQ can be assigned to a
virtual IRQ using the interrupt controller.

It's not clear if we will need 2 different hypercalls on ARM to assign
IRQ and, for now, only the toolstack will manage IRQ.

In order to avoid re-using a fixed ABI hypercall (PHYSDEVOP_*) for a
different purpose and allow us more time to figure out the right out,
only DOMCTL_{,un}bind_pt_pirq is implemented on ARM.

The DOMCTL is extended with a new type PT_IRQ_TYPE_SPI and only IRQ ==
vIRQ (i.e machine_irq == spi) is supported.

In order to keep the same XSM checks done by the 2 hypercalls on x86,
call both xsm_map_domain_irq & xsm_bind_pt_irq in the ARM implementation.

Note: The toolstack changes for routing an IRQ to a guest will be done
in a separate patch.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: Jan Beulich <jbeulich@suse.com>
10 years agoxen/arm: Release IRQ routed to a domain when it's destroying
Julien Grall [Tue, 28 Apr 2015 14:32:27 +0000 (15:32 +0100)]
xen/arm: Release IRQ routed to a domain when it's destroying

Xen has to release IRQ routed to a domain in order to reuse later.
Currently only SPIs can be routed to the guest so we only need to
browse SPIs for a specific domain.

Furthermore, a guest can crash and leave the IRQ in an incorrect state
(i.e has not been EOIed). Xen will have to reset the IRQ in order to
be able to reuse the IRQ later.

Introduce 2 new functions for release an IRQ routed to a domain:
    - release_guest_irq: upper level to retrieve the IRQ, call the GIC
    code and release the action
    - gic_remove_guest_irq: Check if we can remove the IRQ, and reset
    it if necessary

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: vgic: Add spi_to_pending
Julien Grall [Tue, 28 Apr 2015 14:32:26 +0000 (15:32 +0100)]
xen/arm: vgic: Add spi_to_pending

Introduce spi_to_pending in order retrieve the irq_pending structure for
a specific SPI.

It's not possible to re-use irq_to_pending because it's required a VCPU
and some call of the new function may during domain destruction after
the VCPUs are freed.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: Let the toolstack configure the number of SPIs
Julien Grall [Tue, 28 Apr 2015 14:32:25 +0000 (15:32 +0100)]
xen/arm: Let the toolstack configure the number of SPIs

Each domain may have a different number of IRQs depending on the devices
assigned to it.

Rather than re-using the number of IRQs used by the hardwared GIC, let
the toolstack specify the number of SPIs when the domain is created.
This will avoid wasting memory.

To calculate the number of SPIs, we take advantage of the fact that the
libxl interface can only expose 1:1 mapping and look for the largest SPI
in the list.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Wei Liu <wei.liu2@citrix.com>
10 years agotools/libxc: Properly bracket macro parameters
Andrew Cooper [Fri, 8 May 2015 12:54:34 +0000 (13:54 +0100)]
tools/libxc: Properly bracket macro parameters

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Yang Hongyang <yanghy@cn.fujitsu.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- s/quoted/bracket/ in the subject ]

10 years agolibxlu: handle NULL pointer in xlu_cfg_destroy
Olaf Hering [Thu, 7 May 2015 08:54:26 +0000 (08:54 +0000)]
libxlu: handle NULL pointer in xlu_cfg_destroy

Handle NULL pointer passed to xlu_cfg_destroy. libvirt calls it in its
libxlDriverConfigDispose function. If the XLU_Config was not initialized
yet for some reason a crash would occur on cleanup.
Avoid the crash just like libxl_ctx_free and xtl_logger_destroy do when
called from the same context.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agolibxl: remove redundant assignment of spawn-xspath
Wei Liu [Fri, 24 Apr 2015 09:03:41 +0000 (10:03 +0100)]
libxl: remove redundant assignment of spawn-xspath

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl: Add qxl vga interface support for upstream qemu
Fabio Fantoni [Wed, 29 Apr 2015 09:20:28 +0000 (11:20 +0200)]
libxl: Add qxl vga interface support for upstream qemu

Usage:
vga="qxl"

Qxl vga support many resolutions that not supported by stdvga,
mainly the 16:9 ones and other high up to 2560x1600.
With QXL you can get improved performance and smooth video also
with high resolutions and high quality.
Require their drivers installed in the domU and spice used
otherwise act as a simple stdvga.

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
Signed-off-by: Zhou Peng <zpengxen@gmail.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
10 years agolibxc/xentrace: Use xc_cpumap_t for xc_tbuf_set_cpu_mask
George Dunlap [Thu, 23 Apr 2015 13:29:40 +0000 (09:29 -0400)]
libxc/xentrace: Use xc_cpumap_t for xc_tbuf_set_cpu_mask

xentrace is the only caller at the moment.  Split the cpu and event
mask setting out into seperate functions, but leave the current limit
of 32 bits for masks passed in from the command-line.

Based on a patch from Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10 years agolibxl/cpumap: Add xc_cpumap_[setcpu, clearcpu, testcpu] to complement xc_cpumap_alloc.
Konrad Rzeszutek Wilk [Thu, 23 Apr 2015 13:29:39 +0000 (09:29 -0400)]
libxl/cpumap: Add xc_cpumap_[setcpu, clearcpu, testcpu] to complement xc_cpumap_alloc.

We export the xc_cpumap_alloc but not the bit operations.
One could include 'xc_bitops.h' but that is naughty - so instead
we just export the proper functions to do it on the xc_cpumap_t
typedef.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
----
v2: Use our own macro to make sure ARM is not affected negatively
v3: Lifted Ian's explanation.

10 years agoRevert "x86: add the RTC io space to the blocked access list"
Jan Beulich [Fri, 8 May 2015 12:12:20 +0000 (14:12 +0200)]
Revert "x86: add the RTC io space to the blocked access list"

This reverts commit 3b22924062b2648b3df83e9ebda6da52a28c1316, as it
breaks Dom0 access to CMOS/RTC.

10 years agoxen: arm: Annotate source of ICC SGI register trapping
Ian Campbell [Mon, 30 Mar 2015 16:44:52 +0000 (17:44 +0100)]
xen: arm: Annotate source of ICC SGI register trapping

I was unable to find an ARMv8 ARM reference to this, so refer to the
GIC Architecture Specification instead.

ARMv8 ARM does cover other ways of trapping these accesses via
ICH_HCR_EL2 but we don't use those and they trap additional registers
as well.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate registers trapped when CNTHCTL_EL2.EL1PCEN == 0
Ian Campbell [Mon, 30 Mar 2015 16:11:10 +0000 (17:11 +0100)]
xen: arm: Annotate registers trapped when CNTHCTL_EL2.EL1PCEN == 0

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Remove CNTPCT_EL0 trap handling.
Ian Campbell [Mon, 30 Mar 2015 16:12:28 +0000 (17:12 +0100)]
xen: arm: Remove CNTPCT_EL0 trap handling.

We set CNTHCTL_EL2.EL1PCTEN and therefore according to ARMv8 (DDI
0487A.d) D1-1510 Table D1-60 we are not trapping this.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate registers trapped by MDCR_EL2.{TPM,TPMCR}
Ian Campbell [Mon, 30 Mar 2015 15:19:32 +0000 (16:19 +0100)]
xen: arm: Annotate registers trapped by MDCR_EL2.{TPM,TPMCR}

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate registers trapped by MDCR_EL2.TDA
Ian Campbell [Mon, 30 Mar 2015 14:55:03 +0000 (15:55 +0100)]
xen: arm: Annotate registers trapped by MDCR_EL2.TDA

Gather the affected handlers in a single place per trap type.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate registers trapped by MDCR_EL2.TDOSA
Ian Campbell [Mon, 30 Mar 2015 14:37:13 +0000 (15:37 +0100)]
xen: arm: Annotate registers trapped by MDCR_EL2.TDOSA

Gather the affected handlers in a single place per trap type.

Add some HSR_SYSREG and AArch32 defines for those registers (because
I'd already typed them in when I realised I didn't need them).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate registers trapped by MDCR_EL2.TDRA
Ian Campbell [Mon, 30 Mar 2015 13:53:35 +0000 (14:53 +0100)]
xen: arm: Annotate registers trapped by MDCR_EL2.TDRA

DBGDRAR and DBGDSAR are actually two cp or sys registers each, one
32-bit and one 64-bit. The cpregs #define is suffixed "64" and
annotations are added to both handlers.

MDRAR_EL1 (arm64 version of DBGDRAR) wasn't handled, so add that here.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate the handlers for HSTR_EL2.T15
Ian Campbell [Mon, 30 Mar 2015 13:19:22 +0000 (14:19 +0100)]
xen: arm: Annotate the handlers for HSTR_EL2.T15

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate handlers for CPTR_EL2.Tx
Ian Campbell [Mon, 30 Mar 2015 13:10:46 +0000 (14:10 +0100)]
xen: arm: Annotate handlers for CPTR_EL2.Tx

Also expand on the comment when writing CPTR_EL2 to mention that most
of the bits we are setting are RES1 on arm64 anyway.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: implement handling of registers trapped by CPTR_EL2.TTA
Ian Campbell [Mon, 30 Mar 2015 13:02:49 +0000 (14:02 +0100)]
xen: arm: implement handling of registers trapped by CPTR_EL2.TTA

Add explicit handler for 64-bit CP14 accesses, with more relevant
debug message (as per other handlers) and to provide a place for a
comment.

The docs just say "All implemented trace registers." so reflect that
in the comment since there is no explicit list.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate registers trapped by HCR_EL1.TIDCP
Ian Campbell [Mon, 30 Mar 2015 12:42:52 +0000 (13:42 +0100)]
xen: arm: Annotate registers trapped by HCR_EL1.TIDCP

This traps variety of implementation defined registers, so add a note
to the default case of the respective handler.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: implement handling of ACTLR_EL1 trap
Ian Campbell [Mon, 30 Mar 2015 12:38:07 +0000 (13:38 +0100)]
xen: arm: implement handling of ACTLR_EL1 trap

While annotating ACTLR I noticed that we don't appear to handle the
64-bit version of this trap. Do so and annotate everything.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Annotate trap handler for HCR_EL2.{TWI,TWE,TSC}
Ian Campbell [Mon, 30 Mar 2015 12:26:13 +0000 (13:26 +0100)]
xen: arm: Annotate trap handler for HCR_EL2.{TWI,TWE,TSC}

Reference the bit which enables the trap and the section/page which
describes what that bit enables.

These ones are pretty trivial, included for completeness.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>