]> xenbits.xensource.com Git - xen.git/log
xen.git
11 years agoxen/xsm: Add xsm_core_init function
Julien Grall [Fri, 21 Mar 2014 15:22:12 +0000 (15:22 +0000)]
xen/xsm: Add xsm_core_init function

This function contains non-specific architecture code (mostly the tail of
xsm_multiboot_init). It will be used later to avoid code duplication.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agoxen/xsm: Don't use multiboot by default to initialize XSM
Julien Grall [Fri, 21 Mar 2014 15:22:11 +0000 (15:22 +0000)]
xen/xsm: Don't use multiboot by default to initialize XSM

Multiboot protocol is only used by x86. When XSM support for ARM will be
introduced, another way will be used to retrieve the policy blob.

Introduce CONFIG_MULTIBOOT to compile XSM specific multiboot code and
rename xsm_init into xsm_multiboot_init to avoid confusion.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Keir Fraser <keir@xen.org>
11 years agox86: identify which vcpu's CR4 is being badly modified
Andrew Cooper [Wed, 26 Mar 2014 14:36:13 +0000 (15:36 +0100)]
x86: identify which vcpu's CR4 is being badly modified

When the toolstack is setting vcpu state on behalf of a migrating guest, the
domain/vcpu reference from gdprintk() identifies the toolstack, not the
affected domain.

After this change, the error looks more like:

  (XEN) d0 attempted to change d6v0's CR4 flags 00002660 -> 01876000

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agocredit2: Some functions are only used internally
Julien Grall [Wed, 26 Mar 2014 14:35:15 +0000 (15:35 +0100)]
credit2: Some functions are only used internally

The list of function above are only used internally in common/sched_credit2.c
    - migrate
    - update_max_weight

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
11 years agocommon: sched_sedf: Remove unused functions
Julien Grall [Wed, 26 Mar 2014 14:34:29 +0000 (15:34 +0100)]
common: sched_sedf: Remove unused functions

Clang 3.5 will fail to compile xen/common/sched_sedf.c because some function
are not used:

sched_sedf.c:141:20: error: unused function 'extraq_add_head' [-Werror,-Wunused-function]
static inline void extraq_add_head(struct vcpu *d, int i)
                       ^
sched_sedf.c:147:20: error: unused function 'extraq_add_tail' [-Werror,-Wunused-function]
static inline void extraq_add_tail(struct vcpu *d, int i)

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
11 years agoxsm: flask: flask_disable is only used internally
Julien Grall [Wed, 26 Mar 2014 14:33:01 +0000 (15:33 +0100)]
xsm: flask: flask_disable is only used internally

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agoxsm: flask: ss: remove unused function determine_oocontext
Julien Grall [Wed, 26 Mar 2014 14:32:49 +0000 (15:32 +0100)]
xsm: flask: ss: remove unused function determine_oocontext

This function is not used neither exported.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agoxsm: flask: Remove unused function avc_sidcmp
Julien Grall [Wed, 26 Mar 2014 14:29:34 +0000 (15:29 +0100)]
xsm: flask: Remove unused function avc_sidcmp

Fix compilation with Clang 3.5:

avc.c:657:19: error: unused function 'avc_sidcmp' [-Werror,-Wunused-function]
static inline int avc_sidcmp(u32 x, u32 y)
                      ^

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agox86: enforce preemption in HVM_set_mem_access / p2m_set_mem_access()
Jan Beulich [Tue, 25 Mar 2014 14:23:57 +0000 (15:23 +0100)]
x86: enforce preemption in HVM_set_mem_access / p2m_set_mem_access()

Processing up to 4G PFNs may take almost arbitrarily long, so
preemption is needed here.

This is XSA-89.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
11 years agoevtchn: optimize XSM ssid field
Daniel De Graaf [Mon, 24 Mar 2014 09:55:26 +0000 (10:55 +0100)]
evtchn: optimize XSM ssid field

When FLASK is the only enabled implementation of the XSM hooks in Xen,
some of the abstractions required to handle multiple XSM providers are
redundant and only produce unneeded overhead.  This patch reduces the
memory overhead of enabling XSM on event channels by replacing the
untyped ssid pointer from struct evtchn with a union containing the
contents of the structure.  This avoids an additional heap allocation
for every event channel, and on 64-bit systems, reduces the size of
struct evtchn by 4 bytes.  If an out-of-tree XSM module needs the full
flexibility of the generic evtcnn ssid pointer, defining the symbol
XSM_NEED_GENERIC_EVTCHN_SSID will include a suitable pointer field.

This also cleans up the unused selinux_checkreqprot declaration left
from the Linux port.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoxsm: Reduce compiler command line clutter
Daniel De Graaf [Mon, 24 Mar 2014 09:54:27 +0000 (10:54 +0100)]
xsm: Reduce compiler command line clutter

Move the preprocessor definitions for all FLASK parameters other than
the enable flag off the compiler command line and into config.h, which
is the preferred location for such definitions.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agosysctl: annotate struct pm_cx_stat's pc[]/cc[]
Jan Beulich [Mon, 24 Mar 2014 09:49:19 +0000 (10:49 +0100)]
sysctl: annotate struct pm_cx_stat's pc[]/cc[]

Suggested-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86: fix determination of bit count for struct domain allocations
Jan Beulich [Mon, 24 Mar 2014 09:48:03 +0000 (10:48 +0100)]
x86: fix determination of bit count for struct domain allocations

We can't just add in the hole shift value, as the hole may be at or
above the 44-bit boundary. Instead we need to determine the total bit
count until reaching 32 significant (not squashed out) bits in PFN
representations.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86/pvh: disallow PHYSDEVOP_pirq_eoi_gmfn_v2/v1
Mukesh Rathor [Mon, 24 Mar 2014 08:47:59 +0000 (09:47 +0100)]
x86/pvh: disallow PHYSDEVOP_pirq_eoi_gmfn_v2/v1

A call to do_physdev_op with PHYSDEVOP_pirq_eoi_gmfn_v2/v1 will corrupt
struct hvm_domain when it writes to domain->arch.pv_domain.pirq_eoi_map.
Disallow that. Currently, such a path exists for linux dom0 pvh.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
11 years agox86: drop unused Transmeta definitions
Jan Beulich [Mon, 24 Mar 2014 08:00:56 +0000 (09:00 +0100)]
x86: drop unused Transmeta definitions

Signed-off-by: Jan Beulich <jbeulich@suse.com>
11 years agoxl: console connection: Print errno value from exec
Ian Jackson [Wed, 19 Mar 2014 14:24:22 +0000 (14:24 +0000)]
xl: console connection: Print errno value from exec

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agoxl: Remove clone-and-hack in do_daemonize
Ian Jackson [Wed, 19 Mar 2014 14:07:05 +0000 (14:07 +0000)]
xl: Remove clone-and-hack in do_daemonize

do_daemonize had open-coded handling of the results from xl_waitpid.

Instead, break out the meat of console_child_report into a new
function child_report (which returns an error code), and use it.

No functional change other than a change to the message printed if
forking the daemonic child fails.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agoxl: Abolish vncviewer_child_report
Ian Jackson [Mon, 14 Oct 2013 15:20:20 +0000 (16:20 +0100)]
xl: Abolish vncviewer_child_report

vncviewer_child_report was very similar to console_child_report.

We can abolish vncviewer_child_report by adding an xlchildnum
parameter to console_child_report.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agoxl: Introduce children[].description and xl_report_child_exitstatus
Ian Jackson [Mon, 14 Oct 2013 15:13:19 +0000 (16:13 +0100)]
xl: Introduce children[].description and xl_report_child_exitstatus

We record the descriptive string for the child in the children[]
array, and use it when reporting the exit status.

The only functional change is that the message reported for the
migration child is changed from "migration target process" to
"migration transport process".

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agoxl: remove needless error checking from calls to xl_fork
Ian Jackson [Mon, 14 Oct 2013 15:01:49 +0000 (16:01 +0100)]
xl: remove needless error checking from calls to xl_fork

xl_fork cannot fail - it exits instead.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agoPV-GRUB: fix blk access at end of disk
Samuel Thibault [Fri, 21 Mar 2014 01:56:56 +0000 (02:56 +0100)]
PV-GRUB: fix blk access at end of disk

GRUB usually always loads a whole disk track, even if that means going
beyond the end of the disk.  We thus have to gracefully return an error,
instead of letting the blkfront go panic.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools: fix --enable-xenapi typo error
Yixun Lan (dlan) [Thu, 20 Mar 2014 22:44:16 +0000 (06:44 +0800)]
tools: fix --enable-xenapi typo error

typo in tools/configure.ac cause --enable-xenapi does not works
lead to variables XML2_CONFIG, CURL_CONFIG not set

Signed-off-by: Yixun Lan (dlan) <dennis.yxun@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: domain_vgic_init: Check xzalloc_* return
Julien Grall [Thu, 20 Mar 2014 13:51:26 +0000 (13:51 +0000)]
xen/arm: domain_vgic_init: Check xzalloc_* return

The allocations for shared_irqs and pending_irqs are not checked and use
later. This may lead to a Xen segfault if the hypervisor run out of memory.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agominios (blkfront): Add more information on block error
Samuel Thibault [Thu, 20 Mar 2014 12:10:22 +0000 (13:10 +0100)]
minios (blkfront): Add more information on block error

This notably prints the offset and size of the block operation in error.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Guard correctly asm-arm/platforms/exynos5.h
Julien Grall [Wed, 19 Mar 2014 21:27:49 +0000 (21:27 +0000)]
xen/arm: Guard correctly asm-arm/platforms/exynos5.h

Fix compilation with clang 3.5:

/local/home/julien/works/arndale/xen/xen/include/asm/platforms/exynos5.h:1:9: error: '__ASM_ARM_PLATFORMS_EXYNOS5_H' is used as a header guard here, followed by #define of a different macro [-Werror,-Wheader-guard]
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/local/home/julien/works/arndale/xen/xen/include/asm/platforms/exynos5.h:2:9: note: '__ASM_ASM_PLATFORMS_EXYSNO5_H' is defined here; did you mean '__ASM_ARM_PLATFORMS_EXYNOS5_H'?
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __ASM_ARM_PLATFORMS_EXYNOS5_H

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools/xen-access: don't use libxc internals directly.
Tim Deegan [Wed, 19 Mar 2014 10:35:35 +0000 (11:35 +0100)]
tools/xen-access: don't use libxc internals directly.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Aravindh Puthiyaparambil <aravindp@cisco.com>
11 years agoxenstore: set READ_THREAD_STACKSIZE to a sane value
Roger Pau Monne [Fri, 7 Mar 2014 12:22:58 +0000 (13:22 +0100)]
xenstore: set READ_THREAD_STACKSIZE to a sane value

On FreeBSD PTHREAD_STACK_MIN is 2048 by default, which is obviously
too low. Set the default back to the previous value (16 * 1024), or if
that's too low set it to PTHREAD_STACK_MIN.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@citrix.com>
11 years agoxen/xsm: flask: Add missing header in hooks.c
Julien Grall [Mon, 17 Mar 2014 14:06:01 +0000 (14:06 +0000)]
xen/xsm: flask: Add missing header in hooks.c

nr_static_irqs and nr_irqs is defined in asm/irq.h (on both x86 and ARM).

Include directly the header in hooks.c to avoid compilation failure on ARM.

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>
11 years agoxen/xsm: flask: flask_copying_string is taking a XEN_GUEST_HANDLE as first param
Julien Grall [Mon, 17 Mar 2014 14:06:00 +0000 (14:06 +0000)]
xen/xsm: flask: flask_copying_string is taking a XEN_GUEST_HANDLE as first param

Rather than x86, on ARM XEN_GUEST_HANDLE and XEN_GUEST_HANDLE_PARAM are
not compatible. This will result to a compilation failure on ARM when XSM
will be enabled.

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>
11 years agoxen/xsm: flask: MSI is PCI specific
Julien Grall [Mon, 17 Mar 2014 14:05:59 +0000 (14:05 +0000)]
xen/xsm: flask: MSI is PCI specific

MSI is not yet support on ARM and will break the compilation when XSM_ENABLE=y.

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>
11 years agoxen/xsm: flask: Rename variable "bool" in "b"
Julien Grall [Mon, 17 Mar 2014 14:05:58 +0000 (14:05 +0000)]
xen/xsm: flask: Rename variable "bool" in "b"

On ARM, the compilation is failing with the following error:
In file included from flask_op.c:21:0:
./include/conditional.h:24:43: error: two or more data types in declaration specifiers
./include/conditional.h:25:42: error: two or more data types in declaration specifiers

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>
11 years agoxen/xsm: flask: Fix compilation when CONFIG_COMPAT=n
Julien Grall [Mon, 17 Mar 2014 14:05:57 +0000 (14:05 +0000)]
xen/xsm: flask: Fix compilation when CONFIG_COMPAT=n

The commit f7d29f7b "flask: add compat mode guest support" introduces
build breakage on ARM when XSM is enabled. It's because ARM doesn't use
compat mode.

flask_op.c:794:34: fatal error: compat/event_channel.h: No such file or directory
 #include <compat/event_channel.h>

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>
11 years agoxen/xsm: xsm_do_mca is x86 specific
Julien Grall [Mon, 17 Mar 2014 14:05:56 +0000 (14:05 +0000)]
xen/xsm: xsm_do_mca is x86 specific

xsm_do_mca is only used by x86. Only define the function for x86 to
avoid usage on ARM.

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>
11 years agoxen/xsm: xsm functions for PCI passthrough is not x86 specific
Julien Grall [Mon, 17 Mar 2014 14:05:55 +0000 (14:05 +0000)]
xen/xsm: xsm functions for PCI passthrough is not x86 specific

Protect xsm functions for PCI passthrough by HAS_PASSTHROUGH && HAS_PCI

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>
11 years agoxen/arm: next_module: Skip module if the size is 0
Julien Grall [Mon, 17 Mar 2014 14:05:54 +0000 (14:05 +0000)]
xen/arm: next_module: Skip module if the size is 0

When the the module size is 0, it means that the module was not provided by
the user. It can happen, if the user choose to boot without initrd.

In this case, both fields (start and size) are zeroed. Therefore, next_module
will return 0 every time if there is other non-zero module after this one. This
can happen when the XSM module is added.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Correctly define size_t
Julien Grall [Mon, 17 Mar 2014 14:05:53 +0000 (14:05 +0000)]
xen/arm: Correctly define size_t

Flask code use %zu to print size_t variable. On ARM, size_t always defined
to unsigned long which make ARM build failed.

Fix it by using __SIZE_TYPE__.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Remove the parameter "attrindx" in copy_from_paddr
Julien Grall [Mon, 17 Mar 2014 14:05:52 +0000 (14:05 +0000)]
xen/arm: Remove the parameter "attrindx" in copy_from_paddr

copy_from_paddr is only used with BUFFERABLE, there is some place where
DEV_SHARED was used by mistake.

The parameter "attrindx" can be safely remove and let copy_from_paddr to map
every page with BUFFERABLE attribute.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: kernel: Don't hardcode flash address
Julien Grall [Mon, 17 Mar 2014 14:05:51 +0000 (14:05 +0000)]
xen/arm: kernel: Don't hardcode flash address

Xen is loaded either by U-boot or the bootwrapper. Both of them
correctly set xen multiboot module for the kernel in the device tree.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: multidev: Clarify internal API doc comment
Ian Jackson [Wed, 15 Jan 2014 14:33:21 +0000 (14:33 +0000)]
libxl: multidev: Clarify internal API doc comment

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agoxl: Pass -v options on to migration receiver
Ian Jackson [Tue, 7 Jan 2014 18:40:05 +0000 (18:40 +0000)]
xl: Pass -v options on to migration receiver

Compute a -v option to pass to the migration receiver.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
---
v2: Use minmsglevel_default to initialise minmsglevel.

11 years agoxl: migration: pass -t to xl migrate-receive
Ian Jackson [Tue, 7 Jan 2014 18:23:04 +0000 (18:23 +0000)]
xl: migration: pass -t to xl migrate-receive

If we ourselves are using cr-based overwriting for logging to stderr,
pass -t to the migration receiver so that it knows to do the same
(since its stderr is normally the pipe from sshd).

This requires, of course, that the receiver support that option.  This
is OK from a compatibility point of view because we support migration
to newer, but not necessarily to older, versions.  (If unsupported
backwards migration is still desired the use of -s "" allows the
remote invocation rune to be overridden by a command of one's choice.)

This fixes a regression introduced in 2f80ac9c0e8f, where migration
messages from the receiver would not use of the overwriting protocol.

CC: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
11 years agoxl: New -t option ("tty") to force \r-based messages
Ian Jackson [Tue, 7 Jan 2014 18:19:18 +0000 (18:19 +0000)]
xl: New -t option ("tty") to force \r-based messages

Provide a new xl global option -t which passes
XTL_STDIOSTREAM_PROGRESS_USE_CR to xentoollog.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxentoollog: provide XTL_STDIOSTREAM_PROGRESS_USE_CR
Ian Jackson [Tue, 7 Jan 2014 18:07:30 +0000 (18:07 +0000)]
xentoollog: provide XTL_STDIOSTREAM_PROGRESS_USE_CR

Provide flags
  XTL_STDIOSTREAM_PROGRESS_USE_CR
  XTL_STDIOSTREAM_PROGRESS_NO_CR
to allow the caller to force, or disable, the use of \r-based
overwriting of progress messages.

In the implementation, rename the variable "tty" to "progress_use_cr".

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: hotplug scripts: stdin < /dev/null
Ian Jackson [Tue, 18 Mar 2014 16:37:18 +0000 (16:37 +0000)]
libxl: hotplug scripts: stdin < /dev/null

Give hotplug scripts /dev/null for stdin.  That way if they try read
anything anything (which really they shouldn't), nothing odd will
happen.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Roger Pau Monne <roger.pau@citrix.com>
CC: Vasiliy Tolstov <v.tolstov@selfip.ru>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agolibxl: hotplug scripts: stdout >& stderr
Ian Jackson [Tue, 18 Mar 2014 16:33:06 +0000 (16:33 +0000)]
libxl: hotplug scripts: stdout >& stderr

Plumb hotplug scripts' stdout to stderr.  That way if they print
anything (which really they shouldn't), it won't get mixed up with
the application's stdout.  (Eg, perhaps with an xl migration
stream...)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Vasiliy Tolstov <v.tolstov@selfip.ru>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: Make libxl_exec tolerate foofd<=2
Ian Jackson [Tue, 18 Mar 2014 17:04:36 +0000 (17:04 +0000)]
libxl: Make libxl_exec tolerate foofd<=2

Make passing 0, 1, or 2 as stdinfd, stdoutfd or stderrfd work
properly.

Also, document the meaning of the fd arguments.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Roger Pau Monne <roger.pau@citrix.com>
CC: Vasiliy Tolstov <v.tolstov@selfip.ru>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
11 years agotools/console: xenconsole tolerate tty errors
Ian Jackson [Thu, 27 Feb 2014 17:46:49 +0000 (17:46 +0000)]
tools/console: xenconsole tolerate tty errors

Since 28d386fc4341 (XSA-57), libxl writes an empty value for the
console tty node, with read-only permission for the guest, when
setting up pv console "frontends".  (The actual tty value is later set
by xenconsoled.)   Writing an empty node is not strictly necessary to
stop the frontend from writing dangerous values here, but it is a good
belt-and-braces approach.

Unfortunately this confuses xenconsole.  It reads the empty value, and
tries to open it as the tty.  xenconsole then exits.

Fix this by having xenconsole treat an empty value the same way as no
value at all.

Also, make the error opening the tty be nonfatal: we just print a
warning, but do not exit.  I think this is helpful in theoretical
situations where xenconsole is racing with libxl and/or xenconsoled.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
---
v2: Combine two conditions and move the free

11 years agotools/console: reset tty when xenconsole fails
Ian Jackson [Mon, 24 Feb 2014 15:16:19 +0000 (15:16 +0000)]
tools/console: reset tty when xenconsole fails

If xenconsole (the client program) fails, it calls err.  This would
previously neglect to reset the user's terminal to sanity.  Use atexit
to do so.

This routinely happens in Xen 4.4 RC5 with pygrub because libxl
writes the value "" to the tty xenstore key when using xenconsole.
After this patch this just results in a harmless error message.

Reported-by: M A Young <m.a.young@durham.ac.uk>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: M A Young <m.a.young@durham.ac.uk>
CC: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Fix whitespace error (reintroduce hard tab)
    Fix commit message not to claim ignorance about root cause

11 years agotools/libxl: libxl_list_domain: fix typo in error message
Julien Grall [Tue, 18 Mar 2014 20:40:49 +0000 (20:40 +0000)]
tools/libxl: libxl_list_domain: fix typo in error message

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen: arm: fixup a couple of coding style issues
Ian Campbell [Tue, 18 Mar 2014 15:53:21 +0000 (15:53 +0000)]
xen: arm: fixup a couple of coding style issues

The if in domain.c was only syntactically valid because the macro happened to
contain enclosing braces.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: avoid "PV" terminology
Ian Campbell [Tue, 18 Mar 2014 15:53:20 +0000 (15:53 +0000)]
xen: arm: avoid "PV" terminology

Xen on ARM guests are neither PV nor HVM, they are just "guests". Avoid the
incorrect use of the term pv in the guest type macros.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: make stage 2 page tables walks inner-shareable
Ian Campbell [Mon, 17 Mar 2014 17:27:40 +0000 (17:27 +0000)]
xen: arm: make stage 2 page tables walks inner-shareable

The comment was previously incorrect and indicated that these mappings were
unshared (00) when in reality the register was set for outer-shareable (01).

Clarify ORGN0/IRGN0 in the comments while at it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: use more specific barriers for read and write barriers.
Ian Campbell [Mon, 17 Mar 2014 14:53:30 +0000 (14:53 +0000)]
xen: arm: use more specific barriers for read and write barriers.

Note that 32-bit does not provide a load variant of the inner shareable
barrier, so that remains a full any-any barrier.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: weaken SMP barriers to inner shareable.
Ian Campbell [Mon, 17 Mar 2014 14:53:29 +0000 (14:53 +0000)]
xen: arm: weaken SMP barriers to inner shareable.

Since all processors are in the inner-shareable domain and we map everything
that way this is sufficient.

The non-SMP barriers remain full system. Although in principle they could
become outer shareable barriers for some hardware this would require us to
know which class a given device is. Given the small number of device drivers
in Xen itself its probably not worth worrying over, although maybe someone
will benchmark at some point.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: add scope to dsb and dmb macros
Ian Campbell [Mon, 17 Mar 2014 14:53:28 +0000 (14:53 +0000)]
xen: arm: add scope to dsb and dmb macros

Everywhere currently passes "sy"stem, so no actual change.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: Use dmb for smp barriers
Ian Campbell [Mon, 17 Mar 2014 14:53:27 +0000 (14:53 +0000)]
xen: arm: Use dmb for smp barriers

The full power of dsb is not required in this context.

Also change wmb() to be dsb() directly instead of indirectly via mb(), for
clarity.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: Use SMP barriers when that is all which is required.
Ian Campbell [Mon, 17 Mar 2014 14:53:26 +0000 (14:53 +0000)]
xen: arm: Use SMP barriers when that is all which is required.

SMP barriers can be used when all we care about is synchronising against other
processors.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: consolidate barrier definitions
Ian Campbell [Mon, 17 Mar 2014 14:53:25 +0000 (14:53 +0000)]
xen: arm: consolidate barrier definitions

These are effectively identical on both 32- and 64-bit.

The only difference is that they implicit "sy" on 32-bit becomes explicit.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoxen: arm: Only upgrade guest barriers to inner shareable.
Ian Campbell [Mon, 17 Mar 2014 14:53:24 +0000 (14:53 +0000)]
xen: arm: Only upgrade guest barriers to inner shareable.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoxen: arm: map memory as inner shareable.
Ian Campbell [Mon, 17 Mar 2014 14:53:23 +0000 (14:53 +0000)]
xen: arm: map memory as inner shareable.

The inner shareable domain contains all SMP processors, including different
clusters (e.g. big.LITTLE). Therefore this is the correct thing to use for Xen
memory mappings. The outer shareable domain is for devices on busses which are
coherent and barrier-aware (e.g. AMBA4 AXI with ACE). While the system domain
is for things behind bridges which are not.

One wrinkle is that Normal memory with attributes Inner Non-cacheable, Outer
Non-cacheable (which we call BUFFERABLE) must be mapped Outer Shareable on ARM
v7. Therefore change the prototype of mfn_to_xen_entry to take the attribute
index so we can DTRT. On ARMv8 the sharability is ignored and considered to
always be Outer Shareable.

Don't adjust the barriers, flushes etc, those remain as they were (which is
more than is now required).  I'll change those in a later patch.

Many thanks to Leif for explaining the difference between Inner- and
Outer-Shareable in words of two or less syllables, I hope I've replicated that
explanation properly above!

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agolibxc: Fix buffer length for get_suspend_file
Ian Jackson [Tue, 18 Mar 2014 13:45:25 +0000 (13:45 +0000)]
libxc: Fix buffer length for get_suspend_file

Declaring a formal parameter to have an array type doesn't result in
the parameter actually having an array type.  The type is "adjusted"
to a pointer.  (C99 6.9.1(7), 6.7.5.3.)

So the use of sizeof in xc_suspend.c:get_suspend_file was wrong.
Instead, use the #define.  Also get rid of the array size, as it is
misleading.

Newer versions of gcc warn about the erroneous code:
  xc_suspend.c:39:25: error: argument to 'sizeof' in 'snprintf' call
    is the same expression as the destination; did you mean to provide
    an explicit length? [-Werror=sizeof-pointer-memaccess]

Reported-By: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Ian Campbell <ian.campbell@citrix.com>
CC: Julien Grall <julien.grall@linaro.org>
--
v2: Actually change the declaration of buf.

11 years agox86/idle: update to include further package/core residency MSRs
Jan Beulich [Tue, 18 Mar 2014 10:52:34 +0000 (11:52 +0100)]
x86/idle: update to include further package/core residency MSRs

With the number of these growing it becomes increasingly desirable to
not repeatedly alter the sysctl interface to accommodate them. Replace
the explicit listing of numbered states by arrays, unused fields of
which will remain untouched by the hypercall.

The adjusted sysctl interface at once fixes an unrelated shortcoming
of the original one: The "nr" field, specifying the size of the
"triggers" and "residencies" arrays, has to be an input (along with
being an output), which the previous implementation didn't obey to.

Note that the bouncing direction in the libxc interface at once gets
corrected to OUT (was BOTH).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agox86: Intel CPU family update
Jan Beulich [Tue, 18 Mar 2014 10:51:43 +0000 (11:51 +0100)]
x86: Intel CPU family update

... according to revision 49 of the Intel SDM.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agoMAINTAINERS: add Kevin Tian to "INTEL(R) VT FOR X86 (VT-X)" part
Kevin Tian [Tue, 18 Mar 2014 10:51:00 +0000 (11:51 +0100)]
MAINTAINERS: add Kevin Tian to "INTEL(R) VT FOR X86 (VT-X)" part

Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agolibxl: suspend: Apply guest timeout in evtchn case
Ian Jackson [Thu, 12 Dec 2013 19:17:03 +0000 (19:17 +0000)]
libxl: suspend: Apply guest timeout in evtchn case

When negotiating guest suspend via the evtchn ("fast") protocol,
the guest may still fail to respond.

So set the timeout.  The existing error path will already properly
tear down our (event channel) wait.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: suspend: Async evtchn wait
Ian Jackson [Tue, 10 Dec 2013 17:40:49 +0000 (17:40 +0000)]
libxl: suspend: Async evtchn wait

When negotiating guest suspend via the evtchn ("fast") protocol,
abolish synchronous wait for domain suspend.

If the guest supports the event channel suspend protocol, we used to
sit in a loop in xc_await_suspend waiting (perhaps indefinitely) for
it to suspend.

Instead, use the new libxl event channel event facility.  When we see
that the event is signaled, we look at the domain to see if it has
suspended.  (In this patch we do not yet set a timeout; that will come
next.)

So the suspend operation no longer blocks with the libxl ctx lock
held, and instead returns to the event loop.  Additionally, domains
which signal the event channel themselves, or undergo other state
changes, will be handled more correctly.

We end up making a few more hypercalls.

Also, if we encounter errors setting up the suspend event channel
(which should not happen), abort the operation rather than falling
back to the xenstore protocol.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Improve commit message.

11 years agolibxl: suspend: Fix suspend wait corner cases
Ian Jackson [Fri, 6 Dec 2013 16:40:08 +0000 (16:40 +0000)]
libxl: suspend: Fix suspend wait corner cases

When we are waiting for a guest to suspend, this suspend operation
would continue to wait (until the timeout) if the guest was destroyed
or shut down for another reason, or if xc_domain_getinfolist failed.

Handle these cases correctly, as errors.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Remove unwanted error call after a new "goto err".

11 years agolibxl: suspend: Abolish usleeps in domain suspend wait
Ian Jackson [Fri, 6 Dec 2013 16:12:44 +0000 (16:12 +0000)]
libxl: suspend: Abolish usleeps in domain suspend wait

Replace the use of a loop with usleep().

Instead, use a xenstore watch and an event system timeout.  (xenstore
fires watches on @releaseDomain when a domain shuts down.)

The logic which checks for the state of the domain is unchanged, and
not ideal, but we will leave that for the next patch.

There is not intended to be any semantic change, other than to make
the algorithm properly asynchronous and the consequential waiting be
on xenstore, rather than polling.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Remove some trailing whitespace
    Improve commit message.
v3X: Do NOT use an xswait instead of separate watch and timeout.

11 years agolibxl: suspend: Async xenstore pvcontrol wait
Ian Jackson [Thu, 5 Dec 2013 18:50:55 +0000 (18:50 +0000)]
libxl: suspend: Async xenstore pvcontrol wait

When negotiating guest suspend via the xenstore pvcontrol protocol
(ie when the guest does NOT support the evtchn fast suspend protocol):

Replace the use of loops and usleep with a call to libxl__xswait.

Also, replace the xenstore transaction loop with one using
libxl__xs_transaction_start et al.

There is not intended to be any semantic change, other than to make
the algorithm properly asynchronous.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Add a comment to clarify last minute ack.
v3X: Do NOT rename "pvcontrol" xswait state struct to "guest_wait"
     (because we're NOT going to use it for the event channel based wait
     too).

11 years agolibxl: suspend: domain_suspend_callback_common xs errs
Ian Jackson [Thu, 5 Dec 2013 19:08:34 +0000 (19:08 +0000)]
libxl: suspend: domain_suspend_callback_common xs errs

In domain_suspend_callback_common, use libxl__xs_transaction_start in
a loop, rather than xs_transaction_start and a goto label.

This will improve the error handling, but have no other semantic
effect.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: suspend: New domain_suspend_pvcontrol_acked
Ian Jackson [Thu, 5 Dec 2013 18:48:21 +0000 (18:48 +0000)]
libxl: suspend: New domain_suspend_pvcontrol_acked

Factor out domain_suspend_pvcontrol_acked.

This replaces a bunch of open-coded strcmp()s and makes the code
clearer.  It also eliminates the need to check for state==NULL each
time it's read, because we can check for NULL once before the strcmp.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Improve comment re xswatch state ENOENT

11 years agolibxl: suspend: New libxl__domain_pvcontrol_xspath
Ian Jackson [Thu, 5 Dec 2013 18:27:30 +0000 (18:27 +0000)]
libxl: suspend: New libxl__domain_pvcontrol_xspath

Factor out the pv control node xenstore path calculation into
libxl__domain_pvcontrol_xspath.

This xs path calculation was open coded in
libxl__domain_pvcontrol_read and _write.  This is undesirable because
it duplicates the code and because it makes the path inaccessible to
other parts of libxl (which are soon going to want it).

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: suspend: Reorg domain_suspend_callback_common
Ian Jackson [Wed, 4 Dec 2013 14:58:10 +0000 (14:58 +0000)]
libxl: suspend: Reorg domain_suspend_callback_common

Make domain_suspend_callback_common more callback-oriented:

* Turn the functionality behind the goto labels "err" and
  "guest_suspended" into functions which can be called just before
  "return".

* Deindent the "issuing %s suspend request via XenBus control node"
  branch; it is going to be split up into various functions as the
  xenstore work becomes callback-based.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: suspend: Async domain_suspend_callback_common
Ian Jackson [Tue, 26 Nov 2013 15:28:39 +0000 (15:28 +0000)]
libxl: suspend: Async domain_suspend_callback_common

Make domain_suspend_callback_common do its work and then call
dss->callback_common_done, rather than simply returning its answer.

This is preparatory to abolishing the usleeps in this function and
replacing them with use of the event machinery.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Remove some trailing whitespace

11 years agolibxl: suspend: Async libxl__domain_suspend_callback
Ian Jackson [Mon, 4 Nov 2013 16:27:53 +0000 (16:27 +0000)]
libxl: suspend: Async libxl__domain_suspend_callback

Mark the suspend callback libxl__domain_suspend_callback as
asynchronous in the helper stub generator (libxl_save_msgs_gen.pl).
We are going to want to provide an asynchronous version of this
function to get rid of the usleeps and waiting loops in the suspend
code.

libxl__domain_suspend_common_callback, the common synchronous core,
which used to be provided directly as the callback function for the
helper machinery, becomes libxl__domain_suspend_callback_common.  It
can now take a typesafe parameter.

For now, provide two very similar asynchronous wrappers for it
(normal, and remus).  Each is a simple function which contains only
boilerplate, calls the common synchronous core, and returns the
asynchronous response.

Essentially, we have just moved (in the case of suspend callbacks) the
call site of libxl__srm_callout_sendreply.  It was in the switch
statement in the autogenerated _libxl_save_msgs_callout.c, and is now
in the handwritten libxl_dom.c.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Shriram Rajagopalan <rshriram@cs.ubc.ca>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Clarify commit message.
    Fix a misformatted CC in the commit message
    Do not introduce a whitespace error in libxl_save_msgs_gen.pl
v2: Commit message mentions usleeps, not Remus, as motivation.

11 years agolibxl: suspend: trailing ws in libxl_save_msgs_gen.pl
Ian Jackson [Tue, 11 Mar 2014 11:31:32 +0000 (11:31 +0000)]
libxl: suspend: trailing ws in libxl_save_msgs_gen.pl

libxl_save_msgs_gen.pl has some trailing whitespace.  This can make
git complain annoyingly.  Remove the trailing whitespace.

(The file also contains tabs.  Leave these as they are to avoid a big
and intrusive diff.)

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: New patch in v3 of the series.

11 years agolibxc: suspend: Fix suspend event channel locking
Ian Jackson [Wed, 11 Dec 2013 16:29:38 +0000 (16:29 +0000)]
libxc: suspend: Fix suspend event channel locking

Use fcntl F_SETLK, rather than writing our pid into a "lock" file.
That way if we crash we don't leave the lockfile lying about.  Callers
now need to keep the fd for our lockfile.  (We don't use flock because
we don't want anyone who inherits this fd across fork to end up with a
handle onto the lock.)

While we are here:
 * Move the lockfile to /var/run/xen
 * De-duplicate the calculation of the pathname
 * Compute the buffer size for the pathname so that it will definitely
   not overrun (and use the computed value everywhere)
 * Fix various error handling bugs

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
11 years agolibxc: suspend: Rename, improve xc_suspend_evtchn_init
Ian Jackson [Tue, 26 Nov 2013 16:33:30 +0000 (16:33 +0000)]
libxc: suspend: Rename, improve xc_suspend_evtchn_init

xc_suspend_evtchn_init expects to eat the first event on the xce.  If
the xce is used for any other purpose then this can break.  Document
this fact and rename the function to xc_suspend_evtchn_init_exclusive.
(I haven't checked the call sites for improper shared use of the xce.)

Provide a corresponding xc_suspend_evtchn_init_sane which doesn't try
to eat an event, and instead leaves the caller the ability to
demultiplex.

Also document that xc_await_suspend needs exclusive use of the xce.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
CC: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Drop spurious addition of #include <assert.h>

11 years agolibxl: events: Provide libxl__ev_evtchn*
Ian Jackson [Wed, 11 Dec 2013 14:06:02 +0000 (14:06 +0000)]
libxl: events: Provide libxl__ev_evtchn*

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Fix commit message not to refer to libxl_ctx_alloc's gc, done earlier
    Change type of port in evtchn_fd_callback to evtchn_port_or_error_t
    Clarify comment about use of ctx->xce.
    Fix typo in comment.

11 years agolibxl: events: Use libxl__xswait_* in spawn code
Ian Jackson [Fri, 6 Dec 2013 15:31:02 +0000 (15:31 +0000)]
libxl: events: Use libxl__xswait_* in spawn code

Replace open-coded use of ev_time and ev_xswatch with xswait.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: events: libxl__xswait* support @paths
Ian Jackson [Fri, 14 Mar 2014 17:38:38 +0000 (17:38 +0000)]
libxl: events: libxl__xswait* support @paths

Special-case paths starting with '@' in libxl__xswait.  Attempting to
read these from xenstore gives EINVAL.  Callers waiting for (say)
@releaseDomain will be checking for some condition which can be
observed other than by looking at xenstore.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: New patch in this version of the series.

11 years agolibxl: events: Provide libxl__xswait_*
Ian Jackson [Thu, 5 Dec 2013 18:49:12 +0000 (18:49 +0000)]
libxl: events: Provide libxl__xswait_*

This is an ao utility for for conveniently doing a timed wait on
xenstore.  It handles setting up and cancelling the timeout, and also
conveniently reads the key for you.

No callers yet in this patch.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Fix doc comments to refer to correct rc values

11 years agolibxl: Formally document libxl__xs_transaction
Ian Jackson [Mon, 17 Mar 2014 13:21:24 +0000 (13:21 +0000)]
libxl: Formally document libxl__xs_transaction

Provide a more formal description of the semantics of
libxl__xs_transaction_start, _commit and _abort, in addition to the
usage pattern example.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: events: const-correct *_inuse, *_isregistered
Ian Jackson [Fri, 6 Dec 2013 16:01:32 +0000 (16:01 +0000)]
libxl: events: const-correct *_inuse, *_isregistered

The comments for libxl__ev_time_isregistered and the corresponding
watch function even say that these should be const.  Make it so.

Also fix libxl__ev_child_inuse and libxl__ev_spawn_inuse.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: init: libxl__poller_init and _get take gc
Ian Jackson [Tue, 17 Dec 2013 15:20:25 +0000 (15:20 +0000)]
libxl: init: libxl__poller_init and _get take gc

Change libxl__poller_init and libxl__poller__get to take a libxl__gc*
rather than a libxl_ctx*.  The gc is not used for memory allocation
but simply to provide the standard local variable "gc" expected by the
convenience macros.  Doing this makes the error logging more
convenient.

Hence, convert the logging calls to use the LOG* convenience macros.

And consequently, change the call sites, and the function bodies to
use CTX rather than ctx.

Also convert a call to malloc() (with error check) in
libxl__poller_get, to libxl__zalloc (no error check needed).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: init: Provide a gc later in libxl_ctx_alloc
Ian Jackson [Tue, 17 Dec 2013 15:22:40 +0000 (15:22 +0000)]
libxl: init: Provide a gc later in libxl_ctx_alloc

Provide libxl__gc *gc for the second half of libxl_ctx_alloc.
(For the first half of the function, gc is in scope but set to NULL.)

This makes it possible to make gc-requiring calls.  For example, it
makes error logging more convenient.

Make use of this by changing the logging calls to use the LOG*
convenience macros.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agox86/Intel: work around Xeon 7400 series erratum AAI65
Jan Beulich [Mon, 17 Mar 2014 15:47:22 +0000 (16:47 +0100)]
x86/Intel: work around Xeon 7400 series erratum AAI65

Linux commit 40e2d7f9b5dae048789c64672bf3027fbb663ffa ("x86 idle:
Repair large-server 50-watt idle-power regression") tells us that this
applies not just to the named Xeon 7400 series, but also NHM-EX and
WSM-EX; sadly Intel's documentation is so badly searchable that I
wasn't able to locate the respective errata (and hence can't quote
their numbers here).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agoVT-d: fix RMRR handling
Jan Beulich [Mon, 17 Mar 2014 15:45:04 +0000 (16:45 +0100)]
VT-d: fix RMRR handling

Removing mapped RMRR tracking structures in dma_pte_clear_one() is
wrong for two reasons: First, these regions may cover more than a
single page. And second, multiple devices (and hence multiple devices
assigned to any particular guest) may share a single RMRR (whether
assigning such devices to distinct guests is a safe thing to do is
another question).

Therefore move the removal of the tracking structures into the
counterpart function to the one doing the insertion -
intel_iommu_remove_device(), and add a reference count to the tracking
structure.

Further, for the handling of the mappings of the respective memory
regions to be correct, RMRRs must not overlap. Add a respective check
to acpi_parse_one_rmrr().

And finally, with all of this being VT-d specific, move the cleanup
of the list as well as the structure type definition where it belongs -
in VT-d specific rather than IOMMU generic code.

Note that this doesn't address yet another issue associated with RMRR
handling: The purpose of the RMRRs as well as the way the respective
IOMMU page table mappings get inserted both suggest that these regions
would need to be marked E820_RESERVED in all (HVM?) guests' memory
maps, yet nothing like this is being done in hvmloader. (For PV guests
this would also seem to be necessary, but may conflict with PV guests
possibly assuming there to be just a single E820 entry representing all
of its RAM.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Xiantao Zhang <xiantao.zhang@intel.com>
11 years agoxen: arm: increase priority of SGIs used as IPIs
Ian Campbell [Mon, 17 Mar 2014 11:31:02 +0000 (11:31 +0000)]
xen: arm: increase priority of SGIs used as IPIs

Code such as on_selected_cpus expects/requires that an IPI can preempt a
processor which is just handling a normal interrupt. Lacking this property can
result in a deadlock between two CPUs trying to IPI each other from interrupt
context.

For the time being there is only two priorities, IRQ and IPI, although it is
also conceivable that in the future some IPIs might be higher priority than
others. This could be used to implement a better BUG() than we have now, but I
haven't tackled that yet.

Tested with a debug patch which sends a local IPI from a keyhandler, which is
run in serial interrupt context.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Cc: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com>
11 years agoxen/arm: Remove asm-arm/processor-ca{15, 7}.h headers
Julien Grall [Wed, 5 Mar 2014 04:46:26 +0000 (12:46 +0800)]
xen/arm: Remove asm-arm/processor-ca{15, 7}.h headers

Theses headers are not in the right directory and are not used anymore.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Remove processor specific setup in vcpu_initialise
Julien Grall [Wed, 5 Mar 2014 04:46:25 +0000 (12:46 +0800)]
xen/arm: Remove processor specific setup in vcpu_initialise

This patch introduces the possibility to have specific processor callbacks
that can be called in various place.

Currently VCPU initialisation code contains processor specific setup (for
Cortex A7 and Cortex A15) for the ACTRL registers. It's possible to have
processor with a different layout for this register.

Move this setup in a specific callback for ARM v7 processor.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: marc.ceeeee@gmail.com
11 years agoxen/arm64: Implement lookup_processor_type as a dummy function
Julien Grall [Wed, 5 Mar 2014 04:46:24 +0000 (12:46 +0800)]
xen/arm64: Implement lookup_processor_type as a dummy function

ARM64 implementation doesn't yet have specific code per processor.
This function will be used in a later patch.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian campbell <ian.campbell@citrix.com>
11 years agoxen/arm32: Introduce lookup_processor_type
Julien Grall [Wed, 5 Mar 2014 04:46:23 +0000 (12:46 +0800)]
xen/arm32: Introduce lookup_processor_type

Looking for a specific proc_info structure is already implemented in assembly.
Implement lookup_processor_type to avoid duplicate code between C and
assembly.

This function searches the proc_info_list structure following the processor
ID. If the search fail, it will return NULL, otherwise a pointer to this
structure for the specific processor.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm32: head.S: Remove CA15 and CA7 specific includes
Julien Grall [Wed, 5 Mar 2014 04:46:22 +0000 (12:46 +0800)]
xen/arm32: head.S: Remove CA15 and CA7 specific includes

head.S only contains generic code. It should not include headers for a
specific processor.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm32: proc-v7.S: Rename v7_init and ACTLR_V7_SMP
Julien Grall [Wed, 5 Mar 2014 04:46:21 +0000 (12:46 +0800)]
xen/arm32: proc-v7.S: Rename v7_init and ACTLR_V7_SMP

The function v7_init and the define ACTLR_V7_SMP are Cortex A15/A7
specific.

To avoid misuse when new ARMv7 processors will be supported, create one
label per processor type and rename ACTLR_V7_SMP in ACTRL_CAXX_SMP

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: arm: do not create /chosen/bootargs in DTB if no cmdline is specified
Ian Campbell [Wed, 26 Feb 2014 12:13:00 +0000 (12:13 +0000)]
libxl: arm: do not create /chosen/bootargs in DTB if no cmdline is specified

Otherwise we deference a NULL pointer.

I saw this while experimenting with libvirt on Xen on ARM, xl already checks
that the command line is non NULL and provides "" as a default.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Cc: george.dunlap@citrix.com>
11 years agoxen/arm: Clean and invalidate dcache for boot pagetables
Oleksandr Tyshchenko [Tue, 11 Mar 2014 13:19:45 +0000 (15:19 +0200)]
xen/arm: Clean and invalidate dcache for boot pagetables

We need to invalidate dcache too after zeroing boot pagetables
to avoid unpredictable behavior which may take place after
non-boot CPUs enable their caches.

So, replace clean_xen_dcache() macro by a clean_and_invalidate_xen_dcache()
for boot pagetables.

Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Introduce clean_and_invalidate_xen_dcache() macro
Oleksandr Tyshchenko [Tue, 11 Mar 2014 13:19:44 +0000 (15:19 +0200)]
xen/arm: Introduce clean_and_invalidate_xen_dcache() macro

This macro is very similar to clean_xen_dcache(), but it performs
clean and invalidate dcache.

Also modify flush_page_to_ram() to call
clean_and_invalidate_xen_dcache_va_range() function.

Signed-off-by: Oleksandr Tyshchenko <oleksandr.tyshchenko@globallogic.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools: update config.{sub,guess}
Ian Jackson [Fri, 14 Mar 2014 12:00:11 +0000 (12:00 +0000)]
tools: update config.{sub,guess}

Update to versions from Debian Wheezy's autotools-dev package (20120608.1)

Adds ARM aarch64 support.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agounlzma: fix build of stubdom unsafe decompressors
Andrew Cooper [Fri, 14 Mar 2014 12:07:38 +0000 (13:07 +0100)]
unlzma: fix build of stubdom unsafe decompressors

c/s b683d68c386 changed the packing attribute on struct lzma_header.  However,
this is 3rd library code used by stubdomains.

Revert the change to lzma_header alone to avoid needless divergence from its
source.

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>