]> xenbits.xensource.com Git - xen.git/log
xen.git
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>
10 years agoxen: arm: add minimum exception level argument to trap handler helpers
Ian Campbell [Mon, 30 Mar 2015 12:10:14 +0000 (13:10 +0100)]
xen: arm: add minimum exception level argument to trap handler helpers

Removes a load of boiler plate.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Add and use r/o+raz and w/o+wi helpers
Ian Campbell [Mon, 30 Mar 2015 12:03:43 +0000 (13:03 +0100)]
xen: arm: Add and use r/o+raz and w/o+wi helpers

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: provide and use a handle_raz_wi helper
Ian Campbell [Mon, 30 Mar 2015 11:33:49 +0000 (12:33 +0100)]
xen: arm: provide and use a handle_raz_wi helper

Reduces the use of goto in the trap handlers to none.

Some explicitly 32-bit types become register_t here, but that's OK, on
32-bit they are 32-bit already and on 64-bit it is fine/harmless to
set the larger register, a 32-bit guest won't see the top half in any
case.

Per section B1.2.1 (ARMv8 DDI0487 A.d) writes to wN registers are zero
extended, so there is no risk of leaking the top half here.

Unlike the previous code the advancing of PC is handled within the
helper, rather than after the end of the switch as before. So return
as the handler is called.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: call inject_undef_exception directly
Ian Campbell [Mon, 30 Mar 2015 11:23:45 +0000 (12:23 +0100)]
xen: arm: call inject_undef_exception directly

Reducing the amount of goto maze considerably.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: Fix handling of ICC_{SGI1R,SGI0R,ASGI1R}_EL1
Ian Campbell [Mon, 30 Mar 2015 11:18:08 +0000 (12:18 +0100)]
xen: arm: Fix handling of ICC_{SGI1R,SGI0R,ASGI1R}_EL1

Having injected an undefined instruction we don't want to also advance
pc. So return.

The ICC_{SGI0R,ASGI1R}_EL1 case was previously missing a break, so
would have fallen through to the default case and injected a second
undef, corrupting SPSR_EL1 and ELR_EL1 for the guest.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agoxen: arm: constify union hsr and struct hsr_* where possible.
Ian Campbell [Mon, 30 Mar 2015 11:16:41 +0000 (12:16 +0100)]
xen: arm: constify union hsr and struct hsr_* where possible.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
10 years agox86: reduce struct paging_domain size
David Vrabel [Fri, 8 May 2015 10:21:17 +0000 (12:21 +0200)]
x86: reduce struct paging_domain size

Pack struct paging_domain to reduce it by 8 bytes.  Thus reducing the
size of struct domain by 8 bytes.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
10 years agox86: simplify a few macros / inline functions
Jan Beulich [Fri, 8 May 2015 09:07:42 +0000 (11:07 +0200)]
x86: simplify a few macros / inline functions

Drop pointless casts and write_atomic()'s bogus and unused "return
value".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86: add the RTC io space to the blocked access list
Roger Pau Monné [Fri, 8 May 2015 09:06:56 +0000 (11:06 +0200)]
x86: add the RTC io space to the blocked access list

Previously this was done ad-hoc in admin_io_okay.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
10 years agox86/pvh: use a custom IO bitmap for PVH hardware domains
Roger Pau Monné [Fri, 8 May 2015 09:05:29 +0000 (11:05 +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>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agosysctl: add sysctl interface for querying PCI topology
Boris Ostrovsky [Fri, 8 May 2015 09:02:41 +0000 (11:02 +0200)]
sysctl: add sysctl interface for querying PCI topology

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agoMAINTAINERS: update arinc653_sched maintainers
Robert VanVossen [Fri, 8 May 2015 09:02:16 +0000 (11:02 +0200)]
MAINTAINERS: update arinc653_sched maintainers

Removed Nathan Studer and added Josh Whitehead.

Signed-off-by: Robert VanVossen <robert.vanvossen@dornerworks.com>
Acked-by: Nathan Studer <nate.studer@gmail.com>
10 years agoarm: provide arch_fetch_and_add()
David Vrabel [Fri, 8 May 2015 08:59:44 +0000 (10:59 +0200)]
arm: provide arch_fetch_and_add()

arch_fetch_and_add() atomically adds a value and returns the previous
value.

This generic arm implementation uses the GCC __sync_fetch_and_add()
builtin.  This builtin resulted in suitable inlined asm for GCC 4.8.3
(arm64) and GCC 4.6.3 (arm32).

This is needed to implement ticket locks.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agox86: provide arch_fetch_and_add()
David Vrabel [Fri, 8 May 2015 08:59:26 +0000 (10:59 +0200)]
x86: provide arch_fetch_and_add()

arch_fetch_and_add() atomically adds a value and returns the previous
value.

This is needed to implement ticket locks.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
10 years agocpupool: assigning a CPU to a pool can fail
Dario Faggioli [Thu, 7 May 2015 13:15:53 +0000 (15:15 +0200)]
cpupool: assigning a CPU to a pool can fail

which means such an event must be handled at the call sites
of cpupool_assign_cpu_locked(), and the error, if occurring,
properly propagated.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
10 years agoalways print offending CPU on bringup/teardown failure
Dario Faggioli [Thu, 7 May 2015 13:15:24 +0000 (15:15 +0200)]
always print offending CPU on bringup/teardown failure

In fact, before this change, if bringing up or tearing down a
CPU fails with -EBUSY, we BUG_ON() and never get to see what
CPU caused the problem.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
10 years agox86/hvm: use white-lists for HVM param guest accessibility checks
Paul Durrant [Thu, 7 May 2015 13:08:43 +0000 (15:08 +0200)]
x86/hvm: use white-lists for HVM param guest accessibility checks

There are actually very few HVM parameters that a guest needs to read
and even fewer that a guest needs to write. Use white-lists to specify
those parameters and also ensre that, by default, newly introduced
parameters are not accessible.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/hvm: introduce functions for HVMOP_get/set_param allowance checks
Paul Durrant [Thu, 7 May 2015 13:07:57 +0000 (15:07 +0200)]
x86/hvm: introduce functions for HVMOP_get/set_param allowance checks

Some parameters can only (validly) be set once. Some should not be set
by a guest for its own domain, and others must not be set since they
require the domain to be paused. Consolidate these checks, along with
the XSM check, in a new hvm_allow_set_param() function for clarity.

Also, introduce hvm_allow_get_param() for similar reasons.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/hvm: give HVMOP_set_param and HVMOP_get_param their own functions
Paul Durrant [Thu, 7 May 2015 13:06:25 +0000 (15:06 +0200)]
x86/hvm: give HVMOP_set_param and HVMOP_get_param their own functions

The level of switch nesting in those ops is getting unreadable. Giving
them their own functions does introduce some code duplication in the
the pre-op checks but the overall result is easier to follow.

This patch is code movement (including style fixes). There is no
functional change.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/apic: refactor error_interrupt
Tiejun Chen [Wed, 6 May 2015 12:28:04 +0000 (14:28 +0200)]
x86/apic: refactor error_interrupt

Just make this readable while debugging.

Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86: allow 64-bit PV guest kernels to suppress user mode exposure of M2P
Jan Beulich [Tue, 5 May 2015 16:01:33 +0000 (18:01 +0200)]
x86: allow 64-bit PV guest kernels to suppress user mode exposure of M2P

Xen L4 entries being uniformly installed into any L4 table and 64-bit
PV kernels running in ring 3 means that user mode was able to see the
read-only M2P presented by Xen to the guests. While apparently not
really representing an exploitable information leak, this still very
certainly was never meant to be that way.

Building on the fact that these guests already have separate kernel and
user mode page tables we can allow guest kernels to tell Xen that they
don't want user mode to see this table. We can't, however, do this by
default: There is no ABI requirement that kernel and user mode page
tables be separate. Therefore introduce a new VM-assist flag allowing
the guest to control respective hypervisor behavior:
- when not set, L4 tables get created with the respective slot blank,
  and whenever the L4 table gets used as a kernel one the missing
  mapping gets inserted,
- when set, L4 tables get created with the respective slot initialized
  as before, and whenever the L4 table gets used as a user one the
  mapping gets zapped.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
10 years agodomctl: don't truncate XEN_DOMCTL_max_mem requests
Jan Beulich [Tue, 5 May 2015 16:00:03 +0000 (18:00 +0200)]
domctl: don't truncate XEN_DOMCTL_max_mem requests

Instead saturate the value if the input can't be represented in the
respective struct domain field.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
10 years agoxen/arm64: Use virtual address when setting up early_printk fixmap
Chen Baozi [Tue, 7 Apr 2015 11:24:44 +0000 (19:24 +0800)]
xen/arm64: Use virtual address when setting up early_printk fixmap

We have already switched to the boot pagetable when reaching the point
of early_printk fixmap setup. Thus t is no longer necessary to
calculate physical address of xen_fixmap.

Signed-off-by: Chen Baozi <baozich@gmail.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- fixed commit message typos ]

10 years agoxen/arm: p2m: Restrict preemption check in apply_p2m_changes
Julien Grall [Tue, 5 May 2015 15:02:09 +0000 (16:02 +0100)]
xen/arm: p2m: Restrict preemption check in apply_p2m_changes

The commit 569fb6c "xen/arm: Data abort exception (R/W) mem_access
events" makes apply_p2m_changes to call hypercall_preempt_check for any
operation rather than for relinquish.

The function hypercall_preempt_check call local_events_need_delivery
which rely on the current VCPU is not an idle VCPU.
Although, during DOM0 building the current VCPU is an idle one. This
would make Xen crash with the following stack trace:

(XEN) CPU0: Unexpected Trap: Data Abort
[...]
(XEN) Xen call trace:
(XEN)    [<00256ef4>] apply_p2m_changes+0x210/0x1190 (PC)
(XEN)    [<002506b4>] gic_events_need_delivery+0x5c/0x13c (LR)
(XEN)    [<002580ec>] map_mmio_regions+0x64/0x74
(XEN)    [<00251958>] gicv2v_setup+0xf8/0x150
(XEN)    [<00250964>] gicv_setup+0x20/0x30
(XEN)    [<0024cb3c>] arch_domain_create+0x170/0x244
(XEN)    [<00207df0>] domain_create+0x2ac/0x4d8
(XEN)    [<0028e3d0>] start_xen+0xcbc/0xee4
(XEN)    [<00200540>] paging+0x94/0xd8
(XEN)
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) CPU0: Unexpected Trap: Data Abort
(XEN)
(XEN) ****************************************

hypercall_preempt_check is expecting to be call only when the current
VCPU belong to a real domain (see x86 behavior).

As the bug prevents Xen booting on some platform, fix it by only check
preemption when the current VCPU is an idle one for now. We could
improve it later.

Reported-by: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: Julien Grall <julien.grall@citrix.com>
CC: Tamas K Lengyel <tklengyel@sec.in.tum.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools/libxc: Migration v2 compatibility for unmodified libxl
Andrew Cooper [Thu, 2 Apr 2015 10:33:58 +0000 (11:33 +0100)]
tools/libxc: Migration v2 compatibility for unmodified libxl

These changes cause migration v2 to behave similarly enough to legacy
migration to function for HVM guests under an unmodified xl/libxl.

The migration v2 work for libxl will fix the layering issues with the
toolstack and qemu records, at which point this patch will be unneeded.

It is however included here for people wishing to experiment with migration v2
ahead of the libxl work.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agodocs: libxc migration stream specification
David Vrabel [Tue, 3 Jun 2014 13:48:12 +0000 (14:48 +0100)]
docs: libxc migration stream specification

Add the specification for a new migration stream format.  The document
includes all the details but to summarize:

The existing (legacy) format is dependant on the word size of the
toolstack.  This prevents domains from migrating from hosts running
32-bit toolstacks to hosts running 64-bit toolstacks (and vice-versa).

The legacy format lacks any version information making it difficult to
extend in compatible way.

The new format has a header (the image header) with version information,
a domain header with basic information of the domain and a stream of
records for the image data.

The format will be used for future domain types (such as on ARM).

The specification is pandoc format (an extended markdown format) and the
documentation build system is extended to support pandoc format documents.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: common restore code
Andrew Cooper [Tue, 17 Feb 2015 18:20:23 +0000 (18:20 +0000)]
tools/libxc: common restore code

Restore a domain from the new format.  This reads and validates the domain and
image header and loads the guest memory from the PAGE_DATA records, populating
the p2m as it does so.

This provides the xc_domain_restore2() function as an alternative to the
existing xc_domain_restore().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: common save code
Andrew Cooper [Sun, 8 Jun 2014 02:03:29 +0000 (03:03 +0100)]
tools/libxc: common save code

Save a domain, calling domain type specific function at the appropriate
points.  This implements the xc_domain_save2() API function which is
equivalent to the existing xc_domain_save().

This writes the image and domain headers, and writes all the PAGE_DATA records
using a "live" process.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: x86 HVM restore code
Andrew Cooper [Sat, 7 Jun 2014 20:17:51 +0000 (21:17 +0100)]
tools/libxc: x86 HVM restore code

Restore the x86 HVM specific parts of a domain.  This is the HVM_CONTEXT and
HVM_PARAMS records.

There is no need for any page localisation.

This also includes writing the trailing qemu save record to a file because
this is what libxc currently does.  This is intended to be moved into libxl
proper in the future.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: x86 HVM save code
Andrew Cooper [Sat, 7 Jun 2014 20:17:33 +0000 (21:17 +0100)]
tools/libxc: x86 HVM save code

Save the x86 HVM specific parts of the domain.  This is considerably simpler
than an x86 PV domain.  Only the HVM_CONTEXT and HVM_PARAMS records are
needed.

There is no need for any page normalisation.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: x86 PV restore code
Andrew Cooper [Sat, 7 Jun 2014 20:17:09 +0000 (21:17 +0100)]
tools/libxc: x86 PV restore code

Restore the x86 PV specific parts.  The X86_PV_INFO, the P2M_FRAMES,
SHARED_INFO, and VCPU context records.

The localise_page callback is called from the common PAGE_DATA code to convert
PFNs in page tables to MFNs.

Page tables are pinned and the guest's P2M is updated when the stream is
complete.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: x86 PV save code
Andrew Cooper [Sat, 7 Jun 2014 20:17:02 +0000 (21:17 +0100)]
tools/libxc: x86 PV save code

Save the x86 PV specific parts of a domain.  This is the X86_PV_INFO record,
the P2M_FRAMES, the X86_PV_SHARED_INFO, the three different VCPU context
records, and the MSR records.

The normalise_page callback used by the common code when writing the PAGE_DATA
records, converts MFNs in page tables to PFNs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: x86 PV common code
Andrew Cooper [Sat, 7 Jun 2014 20:16:33 +0000 (21:16 +0100)]
tools/libxc: x86 PV common code

Add functions common to save and restore of x86 PV guests.  This includes
functions for dealing with the P2M and M2P and the VCPU context.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: x86 common code
Andrew Cooper [Sat, 7 Jun 2014 20:32:07 +0000 (21:32 +0100)]
tools/libxc: x86 common code

Save/restore records common to all x86 domain types (HVM, PV).

This is only the TSC_INFO record.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools/libxc: generic common code
Andrew Cooper [Sun, 8 Jun 2014 02:05:40 +0000 (03:05 +0100)]
tools/libxc: generic common code

Add the context structure used to keep state during the save/restore
process.

Define the set of architecture or domain type specific operations with a
set of callbacks (save_ops, and restore_ops).

Add common functions for writing records.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: C implementation of stream format
Andrew Cooper [Sat, 15 Mar 2014 20:18:45 +0000 (20:18 +0000)]
tools/libxc: C implementation of stream format

Provide the C structures matching the binary (wire) format of the new
stream format.  All header/record fields are naturally aligned and
explicit padding fields are used to ensure the correct layout (i.e.,
there is no need for any non-standard structure packing pragma or
attribute).

Provide some helper functions for converting types to string for
diagnostic purposes.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: Migration v2 framework
Andrew Cooper [Sat, 15 Mar 2014 18:50:31 +0000 (18:50 +0000)]
tools/libxc: Migration v2 framework

For testing purposes, the environmental variable "XG_MIGRATION_V2" allows the
two save/restore codepaths to coexist, and have a runtime switch.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agolibxc/progress: Extend the progress interface
Andrew Cooper [Thu, 24 Jul 2014 12:05:27 +0000 (13:05 +0100)]
libxc/progress: Extend the progress interface

Progress information is logged via a different logger to regular libxc log
messages, and currently can only express a range.  However, not everything
which needs reporting as progress comes with a range.  Extend the interface to
allow reporting of a single statement.

The programming interface now looks like:
  xc_set_progress_prefix()
    set the prefix string to be used
  xc_report_progress_single()
    report a single action
  xc_report_progress_step()
    report $X of $Y

The new programming interface is implemented in a compatible way with the
existing caller interface (by reporting a single action as "0 of 0").

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agotools/libxc: Implement writev_exact() in the same style as write_exact()
Andrew Cooper [Tue, 1 Jul 2014 18:10:35 +0000 (19:10 +0100)]
tools/libxc: Implement writev_exact() in the same style as write_exact()

This implementation of writev_exact() will cope with an iovcnt greater than
IOV_MAX because glibc will actually let this work anyway, and it is very
useful not to have to work about this in the caller of writev_exact().  The
caller is still required to ensure that the sum of iov_len's doesn't overflow
a ssize_t.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
10 years agoxen: arm: X-Gene Storm check GIC DIST address for EOI quirk
Pranavkumar Sawargaonkar [Wed, 29 Apr 2015 09:38:27 +0000 (15:08 +0530)]
xen: arm: X-Gene Storm check GIC DIST address for EOI quirk

In old X-Gene Storm firmware and DT, secure mode addresses have been
mentioned in GICv2 node. In this case maintenance interrupt is used
instead of EOI HW method.

This patch checks the GIC Distributor Base Address to enable EOI quirk
for old firmware.

Ref:
http://lists.xen.org/archives/html/xen-devel/2014-07/msg01263.html

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Tested-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: p2m: Add an ASSERT to check that p2m lock is taken in __p2m_lookup
Julien Grall [Mon, 27 Apr 2015 14:58:33 +0000 (15:58 +0100)]
xen/arm: p2m: Add an ASSERT to check that p2m lock is taken in __p2m_lookup

__p2m_lookup should be called with the p2m lock taken. Add an ASSERT in
order to catch wrong caller in debug build.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl: convert strings and ints to xenbus_state
Olaf Hering [Fri, 24 Apr 2015 09:07:14 +0000 (09:07 +0000)]
libxl: convert strings and ints to xenbus_state

Convert all plain ints and strings which are used for xenbus "state"
files to xenbus_state. This makes it easier to find code which deals
with backend/frontend state changes.

Convert usage of libxl__sprintf to GCSPRINTF.

No change in behaviour is expected by this change, beside a small
increase of runtime memory usage in places that used a string constant.

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>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools/libxc: Set HVM_PARAM_CONSOLE_EVTCHN during restore
Boris Ostrovsky [Thu, 23 Apr 2015 02:49:18 +0000 (22:49 -0400)]
tools/libxc: Set HVM_PARAM_CONSOLE_EVTCHN during restore

When resuming, the guest needs to check whether the port has changed. HVM
guests use this parameter to get the port number.

(We can't always use xenstore where this value is also written: for example
on Linux the console is resumed very early, before the store is up).

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>
10 years agop2m/ept: enable PML in p2m-ept for log-dirty
Kai Huang [Mon, 4 May 2015 10:19:25 +0000 (12:19 +0200)]
p2m/ept: enable PML in p2m-ept for log-dirty

This patch firstly enables EPT A/D bits if PML is used, as PML depends on EPT
A/D bits to work. A bit is set for all present p2m types in middle and leaf EPT
entries, and D bit is set for all writable types in EPT leaf entry, except for
log-dirty type with PML.

With PML, for 4K pages, instead of setting EPT entry to read-only, we just need
to clear D bit in order to log that GFN. For superpages, we still need to set it
to read-only as we need to split superpage to 4K pages in EPT violation.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agolog-dirty: refine common code to support PML
Kai Huang [Mon, 4 May 2015 10:18:51 +0000 (12:18 +0200)]
log-dirty: refine common code to support PML

Using PML, it's possible there are dirty GPAs logged in vcpus' PML buffers
when userspace peek/clear dirty pages, therefore we need to flush them befor
reporting dirty pages to userspace. This applies to both video ram tracking and
paging_log_dirty_op.

This patch adds new p2m layer functions to enable/disable PML and flush PML
buffers. The new functions are named to be generic to cover potential futher
PML-like features for other platforms.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
10 years agovmx: disable PML in vmx_vcpu_destroy
Kai Huang [Mon, 4 May 2015 10:17:43 +0000 (12:17 +0200)]
vmx: disable PML in vmx_vcpu_destroy

It's possible domain still remains in log-dirty mode when it is about to be
destroyed, in which case we should manually disable PML for it.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agovmx: handle PML enabling in vmx_vcpu_initialise
Kai Huang [Mon, 4 May 2015 10:17:10 +0000 (12:17 +0200)]
vmx: handle PML enabling in vmx_vcpu_initialise

It's possible domain has already been in log-dirty mode when creating vcpu, in
which case we should enable PML for this vcpu if PML has been enabled for the
domain.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agovmx: handle PML buffer full VMEXIT
Kai Huang [Mon, 4 May 2015 10:15:49 +0000 (12:15 +0200)]
vmx: handle PML buffer full VMEXIT

We need to flush PML buffer when it's full.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agovmx: add help functions to support PML
Kai Huang [Mon, 4 May 2015 10:15:07 +0000 (12:15 +0200)]
vmx: add help functions to support PML

This patch adds help functions to enable/disable PML, and flush PML buffer for
single vcpu and particular domain for further use.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agovmx: add new data structure member to support PML
Kai Huang [Mon, 4 May 2015 10:14:15 +0000 (12:14 +0200)]
vmx: add new data structure member to support PML

A new 4K page pointer is added to arch_vmx_struct as PML buffer for vcpu. And a
new 'status' field is added to vmx_domain to indicate whether PML is enabled for
the domain or not.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agovmx: add PML definition and feature detection
Kai Huang [Mon, 4 May 2015 10:12:11 +0000 (12:12 +0200)]
vmx: add PML definition and feature detection

The patch adds PML definition and feature detection. Note PML won't be detected
if PML is disabled from boot parameter. PML is also disabled in construct_vmcs,
as it will only be enabled when domain is switched to log dirty mode.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agolog-dirty: add new paging_mark_gfn_dirty
Kai Huang [Mon, 4 May 2015 10:10:41 +0000 (12:10 +0200)]
log-dirty: add new paging_mark_gfn_dirty

PML logs GPA in PML buffer. Original paging_mark_dirty takes MFN as parameter
but it gets guest pfn internally and use guest pfn to as index for looking up
radix log-dirty tree. In flushing PML buffer, calling paging_mark_dirty directly
introduces redundant p2m lookups (gfn->mfn->gfn), therefore we introduce
paging_mark_gfn_dirty which is bulk of paging_mark_dirty but takes guest pfn as
parameter, and in flushing PML buffer we call paging_mark_gfn_dirty directly.
Original paging_mark_dirty then simply is a wrapper of paging_mark_gfn_dirty.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Acked-by: Tim Deegan <tim@xen.org>
10 years agovmx: add new boot parameter to control PML enabling
Kai Huang [Mon, 4 May 2015 10:09:03 +0000 (12:09 +0200)]
vmx: add new boot parameter to control PML enabling

A top level EPT parameter "ept=<options>" and a sub boolean "opt_pml_enabled"
are added to control PML. Other booleans can be further added for any other EPT
related features.

The document description for the new parameter is also added.

Signed-off-by: Kai Huang <kai.huang@linux.intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agotest_x86_emulate: extend EFLAGS check of CMPXCHG test
Eugene Korenevsky [Mon, 4 May 2015 09:56:21 +0000 (11:56 +0200)]
test_x86_emulate: extend EFLAGS check of CMPXCHG test

CMPXCHG: in the case of inequality of the rAX and the operand,
need to check CF, PF, AF, SF and OF flags as well.

This adjustment covers the fix of incorrect comparison during
CMPXCHG emulation.

Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
10 years agox86_emulate: fix EFLAGS setting of CMPXCHG emulation
Eugene Korenevsky [Mon, 4 May 2015 09:55:41 +0000 (11:55 +0200)]
x86_emulate: fix EFLAGS setting of CMPXCHG emulation

CMPXCHG sets CF, PF, AF, SF, and OF flags according to the results of the
comparison the rAX with the operand of the instruction.
rAX must be the first argument of the comparison (a minuend), the operand
must be the second one (a subtrahend).

Due to improper order of comparison arguments, CF, PF, AF, SF and OF flags were
set incorrectly in the case of inequality. Need to swap them.

Signed-off-by: Eugene Korenevsky <ekorenevsky@gmail.com>
10 years agox86: improve psr scheduling code
Chao Peng [Mon, 4 May 2015 09:54:39 +0000 (11:54 +0200)]
x86: improve psr scheduling code

Switching RMID from previous vcpu to next vcpu only needs to write
MSR_IA32_PSR_ASSOC once. Write it with the value of next vcpu is enough,
no need to write '0' first. Idle domain has RMID set to 0 and because MSR
is already updated lazily, so just switch it as it does.

Also move the initialization of per-CPU variable which used for lazy
update from context switch to CPU starting.

Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
10 years agolibxlu: don't crash on empty lists
Jan Beulich [Fri, 24 Apr 2015 10:15:15 +0000 (12:15 +0200)]
libxlu: don't crash on empty lists

Prior to 1a09c5113a ("libxlu: rework internal representation of
setting") empty lists in config files did get accepted. Restore that
behavior.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agox86/hvm: implicitly disable an ioreq server when it is destroyed
Paul Durrant [Fri, 24 Apr 2015 10:14:23 +0000 (12:14 +0200)]
x86/hvm: implicitly disable an ioreq server when it is destroyed

Currently, unless a (non-default) ioreq server is explicitly disabled before
being destroyed, its gmfns will not be placed back into the p2m but still
released back into the ioreq_gmfn mask. This is somewhat counter-intuitive
and easily remedied by this small patch.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/hvm: actually release ioreq server pages
Paul Durrant [Fri, 24 Apr 2015 10:13:48 +0000 (12:13 +0200)]
x86/hvm: actually release ioreq server pages

hvm_free_ioreq_gmfn has the sense of the ioreq_gmfn mask inverted; it
needs to set a bit to release the gmfn, not clear it.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
10 years agouse 'Hardware domain' instead of 'Domain 0' in hwdom_shutdown()
Vitaly Kuznetsov [Fri, 24 Apr 2015 10:07:00 +0000 (12:07 +0200)]
use 'Hardware domain' instead of 'Domain 0' in hwdom_shutdown()

hwdom_shutdown() operates with hardware domains, use the proper wording.
Eliminate pointless braces from switch cases.

Use hardware_domain->domain_id instead of hardware_domid to print the actual
domain ID as in some cases it can differ (e.g. Dom0 dies before the actual HW
domain got created, kexec for the HW domain is being performed,...).

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>