xen.git
11 years agox86/ACPI: allow CMOS RTC use even when ACPI says there is none
Jan Beulich [Fri, 1 Aug 2014 14:29:27 +0000 (16:29 +0200)]
x86/ACPI: allow CMOS RTC use even when ACPI says there is none

HP is setting the ACPI_FADT_NO_CMOS_RTC flag on newer systems,
regardless of whether they're being booted from UEFI. Add a command
line option to allow probing for a working RTC in that case.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agodocs: make .txt files over-writable when building from r/o sources
Jan Beulich [Fri, 1 Aug 2014 14:28:48 +0000 (16:28 +0200)]
docs: make .txt files over-writable when building from r/o sources

Otherwise an incremental build will fail to overwrite the destination
files.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agolibxl: automatic NUMA placement affects soft affinity
Dario Faggioli [Tue, 29 Jul 2014 16:07:09 +0000 (18:07 +0200)]
libxl: automatic NUMA placement affects soft affinity

vCPU soft affinity and NUMA-aware scheduling does not have
to be related. However, soft affinity is how NUMA-aware
scheduling is actually implemented, and therefore, by default,
the results of automatic NUMA placement (at VM creation time)
are also used to set the soft affinity of all the vCPUs of
the domain.

Of course, this only happens if automatic NUMA placement is
enabled and actually takes place (for instance, if the user
does not specify any hard and soft affiniy in the xl config
file).

This also takes care of the vice-versa, i.e., don't trigger
automatic placement if the config file specifies either an
hard (the check for which was already there) or a soft (the
check for which is introduced by this commit) affinity.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl/xl: make it possible to specify soft-affinity in domain config file
Dario Faggioli [Tue, 29 Jul 2014 16:06:52 +0000 (18:06 +0200)]
libxl/xl: make it possible to specify soft-affinity in domain config file

To do so, we add the vcpu_soft_affinity array to build_info, and
treat it much like vcpu_hard_affinity. The new config option is
called "cpus_soft".

Note that the vcpu_hard_affinity array, introduced in a previous
patch, and the vcpu_soft_affinity array, introduced here, share
the same LIBXL_HAVE_xxx macro, in libxl.h. That is called
LIBXL_HAVE_BUILDINFO_VCPU_AFFINITY_ARRAYS, and was introduced
together with vcpu_hard_affinity, but only inside a comment.
In this change, we uncomment, and hence properly define it.

In order to avoid having to issue separate calls to
libxl_set_vcpuaffinity() (one for hard affinity and one for soft
affinity) in libxl__build_pre(), in case the caller uses
b_info->cpumap (for the former) and b_info->vcpu_soft_affinity (for
the latter), we also set (again!) a new default for b_info->cpumap.
This allows, from this change on, to always and only deal with
b_info->vcpu_hard_affinity all around libxl internals.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxl: move the vcpu affinity parsing in a function
Dario Faggioli [Tue, 29 Jul 2014 16:06:42 +0000 (18:06 +0200)]
xl: move the vcpu affinity parsing in a function

so that such parsing code can be used for both hard and soft
affinity, the support for which is introduced in the next
change.

This is pure code motion, no functional change intended.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxl: move away from the use of cpumap for hard affinity
Dario Faggioli [Tue, 29 Jul 2014 16:06:28 +0000 (18:06 +0200)]
xl: move away from the use of cpumap for hard affinity

and start using the vcpu_hard_affinity array instead. This is done
as when, in a subsequent patch ("libxl/xl: make it possible to
specify soft-affinity in domain config file") we will become able
to deal with soft affinity, code can be shared.

This change also enables more advanced VCPU to PCPU (hard, for now)
affinity specification, in case a list is used, like:

      cpus = ["3-4", "2-6,^4"]

What it means is that VCPU 0 must be pinned to PCPU 3,4 and VCPU 1
to PCPUs 2,3,5,6 (before this change, cpus=[xx, yy] only supported
single values). Of course, the old (e.g., cpus=[2, 3]) syntax
continues to work.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxl: enable getting and setting soft affinity
Dario Faggioli [Tue, 29 Jul 2014 16:06:17 +0000 (18:06 +0200)]
xl: enable getting and setting soft affinity

Getting happens via `xl vcpu-list', which now looks like this:

 # xl vcpu-list -s
 Name       ID VCPU CPU State Time(s) Affinity (Hard / Soft)
 Domain-0   0     0  11  -b-     5.4  8-15 / all
 Domain-0   0     1  11  -b-     1.0  8-15 / all
 Domain-0   0    14  13  -b-     1.4  8-15 / all
 Domain-0   0    15   8  -b-     1.6  8-15 / all
 vm-test    3     0   4  -b-     2.5  0-12 / 0-7
 vm-test    3     1   0  -b-     3.2  0-12 / 0-7

Setting happens by specifying two pCPU masks to the `xl vcpu-pin'
command, the first one will be hard affinity, the second soft
affinity. If only one mask is specified, it is only hard affinity
that is affected. To change only soft affinity, '-' can be used
as the hard affinity mask parameter, and it will be left alone.

xl manual page is updated accordingly.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenbaked.c: Fix return handling for case of mmap failure
Don Slutz [Mon, 28 Jul 2014 16:06:02 +0000 (12:06 -0400)]
xenbaked.c: Fix return handling for case of mmap failure

mmap() returns MAP_FAILED not NULL.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl_internal.c: Fix return handling for case of mmap failure
Don Slutz [Mon, 28 Jul 2014 16:06:01 +0000 (12:06 -0400)]
libxl_internal.c: Fix return handling for case of mmap failure

mmap() returns MAP_FAILED not NULL.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoloadpolicy.c: Fix return handling for case of mmap failure
Don Slutz [Mon, 28 Jul 2014 16:06:00 +0000 (12:06 -0400)]
loadpolicy.c: Fix return handling for case of mmap failure

mmap() returns MAP_FAILED not NULL.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agox86/cpu: undo BIOS CPUID max_leaf limit before querying for features
Andrew Cooper [Tue, 29 Jul 2014 15:02:25 +0000 (17:02 +0200)]
x86/cpu: undo BIOS CPUID max_leaf limit before querying for features

If IA32_MISC_ENABLE[22] is set by the BIOS, CPUID.0.EAX will be limited to 3.
Lift this limit before considering whether to query CPUID.7[ECX=0].EBX for
features.

Without this change, dom0 is able to see this feature leaf (as the limit was
subsequently lifted), and will set features appropriately in HVM domain cpuid
policies.

The specific bug XenServer observed was the advertisement of the FSGSBASE
feature, but an inability to set CR4.FSGSBASE as Xen considered the bit to be
reserved as cpu_has_fsgsbase incorrectly evaluated as false.

This is a regression introduced by c/s 44e24f8567 "x86: don't call
generic_identify() redundantly" where the redundant call actually resampled
CPUID.7[ECX=0] properly to obtain the feature flags.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86, amd_ucode: remove needless cast
Aravind Gopalakrishnan [Tue, 29 Jul 2014 14:51:51 +0000 (16:51 +0200)]
x86, amd_ucode: remove needless cast

Missed cleaning up this cast as part of 0aacc28.
Doing that here; and we can remove 'off' variable as well,
just use *offset in it's place.

Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
11 years agolibxl: use libxl_fd_set_{cloexec,nonblock} helpers
Jan Beulich [Tue, 29 Jul 2014 14:51:26 +0000 (16:51 +0200)]
libxl: use libxl_fd_set_{cloexec,nonblock} helpers

... instead of open-coding them or not using them at all. This in
particular fixes a build (and presumably also runtime) problem on old
enough libc due to the recent introduction of a use of O_CLOEXEC. The
other two changes are only of cleanup kind.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agox86/hvm: alter hpet_init() to take a domain rather than vcpu
Andrew Cooper [Mon, 28 Jul 2014 14:55:32 +0000 (16:55 +0200)]
x86/hvm: alter hpet_init() to take a domain rather than vcpu

There is nothing vcpu-specific about hpet_init(); all it does is follow the
vcpu's domain pointer to get at the domain vhpet state.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agoannotate debugtrace_printk() with a printf compiler __attribute__
Andrew Cooper [Mon, 28 Jul 2014 14:53:35 +0000 (16:53 +0200)]
annotate debugtrace_printk() with a printf compiler __attribute__

And fix up the resulting compilation issue.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agoautoconf: xen: move standard path variables to config/Paths.mk.in
Luis R. Rodriguez [Sat, 26 Jul 2014 02:14:17 +0000 (19:14 -0700)]
autoconf: xen: move standard path variables to config/Paths.mk.in

This moves all generic path variables to a new the config/Paths.mk.in
input source file to be processed at configure time, tons of files use
these so this just share them. This also paves the way to let us
easily dynamically configure these with autoconf, for now we leave the
same presets as was present before.

This work was prompted by looking for an autoconf way to do
replacements for the hotplug global file, while at it I realized
that a few other files use the same variables and have in places
around the tree the same constructs for generating their own
files. This makes use of the old buildmakevars2file() but generalizes
the definition of the paths at configure time and spreads the
new definitions out throughout the build system.

This has no impact on building the hypervisor and extras/mini-os,
you do not need to, and are not expected to, run configure to build
those targets.

While at it lets add some documentation on the for the two files on
the source file, we can expand further details on the wiki [0].

[0] http://wiki.xen.org/wiki/Category:Host_Configuration#System_wide_xen_configuration

Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- reran autogen.sh ]

11 years agooxenstored: also fail if only 1 socket was given by systemd
Luis R. Rodriguez [Sat, 26 Jul 2014 02:14:16 +0000 (19:14 -0700)]
oxenstored: also fail if only 1 socket was given by systemd

Reported-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agocxenstored: also fail if only 1 socket was given by systemd
Luis R. Rodriguez [Sat, 26 Jul 2014 02:14:15 +0000 (19:14 -0700)]
cxenstored: also fail if only 1 socket was given by systemd

Reported-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: call vcpu_yield on WFE trap
Stefano Stabellini [Wed, 23 Jul 2014 13:37:23 +0000 (14:37 +0100)]
xen/arm: call vcpu_yield on WFE trap

No need to call vcpu_force_reschedule, is too expensive.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen: export do_yield as vcpu_yield
Stefano Stabellini [Wed, 23 Jul 2014 13:37:22 +0000 (14:37 +0100)]
xen: export do_yield as vcpu_yield

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
CC: JBeulich@suse.com
11 years agoxen: arm: Select ramdisk bootmodule early enough when building dom0
Ian Campbell [Sat, 26 Jul 2014 08:04:23 +0000 (09:04 +0100)]
xen: arm: Select ramdisk bootmodule early enough when building dom0

I thought in 0040b649d6df "xen: arm: Only lookup kernel/initrd bootmodule once
while building dom0" that I had identified place_modules as being soon enough,
but I was wrong, since write_properties wants to use it sooner.

Select the initrd boot module in kernel_probe at the same time we select the
kernel to avoid all this.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
11 years agox86/gdbsx: security audit of {,un}pausevcpu and domstatus hypercalls
Andrew Cooper [Fri, 25 Jul 2014 09:55:11 +0000 (11:55 +0200)]
x86/gdbsx: security audit of {,un}pausevcpu and domstatus hypercalls

XEN_DOMCTL_gdbsx_domstatus is already safe.  It loops at most over every vcpu
in a domain and breaks at the first vcpu with an event pending, marking it as
not-pending.

XEN_DOMCTL_gdbsx_pausevcpu had an incorrect bounds check against the vcpu id,
allowing an overflow of d->vcpu[] with an id between d->max_vcpus and
MAX_VIRT_CPUS.  It was also able to overflow a vcpus pause count by many
repeated hypercalls.

The bounds check is fixed, and vcpu_pause() has been replaced with
vcpu_pause_by_systemcontroller() which cuts out at 255 uses.

XEN_DOMCTL_gdbsx_unpausevcpu suffered from the same bounds problems as its
pause counterpart, and is fixed in exactly the same way.  Despite the
atomic_read(&v->pause_count), this code didn't successfully prevent against an
underflow of the vcpu pause count.

The vcpu_unpause() has been replaced with vcpu_pause_by_systemcontroller()
which correctly prevents against underflow.  The printk() is updated to have a
proper guest logging level, and provide more useful information in the XSM
case of one domain having debugger privileges over another.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agocommon: introduce vcpu_{,un}pause_by_systemcontroller() helpers
Andrew Cooper [Fri, 25 Jul 2014 09:54:20 +0000 (11:54 +0200)]
common: introduce vcpu_{,un}pause_by_systemcontroller() helpers

Which will be used by following patches.  Reorder the function declarations
for vcpu/domain pause/unpause to group by vcpu/domain and visually separate
them slightly.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agox86/gdbsx: invert preconditions for XEN_DOMCTL_gdbsx_{,un}pausevcpu hypercalls
Andrew Cooper [Fri, 25 Jul 2014 09:53:31 +0000 (11:53 +0200)]
x86/gdbsx: invert preconditions for XEN_DOMCTL_gdbsx_{,un}pausevcpu hypercalls

c/s 3eb1c708ab "properly reference count DOMCTL_{,un}pausedomain hypercalls"
accidentally inverted the use of d->controller_pause_count.

Revert back to how it was originally, i.e. the XEN_DOMCTL_gdbsx_{,un}pausevcpu
hypercalls are only valid for a domain already paused by the system controller.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agox86: fix ioreq-server event channel vulnerability
Paul Durrant [Fri, 25 Jul 2014 09:51:57 +0000 (11:51 +0200)]
x86: fix ioreq-server event channel vulnerability

The code in hvm_send_assist_req_to_ioreq_server() and hvm_do_resume() uses
an event channel port number taken from the page of memory shared with the
emulator. This allows an emulator to corrupt values that are then blindly
used by Xen, leading to assertion failures in some cases. Moreover, in the
case of the default ioreq server the page remains in the guest p2m so a
malicious guest could similarly corrupt those values.

This patch changes the afforementioned functions to get the event channel
port number from an internal structure and also adds an extra check to
hvm_send_assist_req_to_ioreq_server() which will crash the domain should the
guest or an emulator corrupt the port number in the shared page.

Reported-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
11 years agooxenstored: force FD_CLOEXEC with Unix.set_close_on_exec on LSB init
Luis R. Rodriguez [Thu, 17 Jul 2014 23:28:15 +0000 (16:28 -0700)]
oxenstored: force FD_CLOEXEC with Unix.set_close_on_exec on LSB init

Lets match the systemd active socket activation implementation and
ensure that FD_CLOEXEC is set by usin Unix.set_close_on_exec. David
notes oxenstored likely does not exec but there is no harm in being
careful just in case things change in the future.

Cc: David Scott <dave.scott@eu.citrix.com>
Cc: Anil Madhavapeddy <anil@recoil.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Vincent Hanquez <Vincent.Hanquez@eu.citrix.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agooxenstored: add support for systemd active sockets
Luis R. Rodriguez [Thu, 17 Jul 2014 23:28:14 +0000 (16:28 -0700)]
oxenstored: add support for systemd active sockets

This adds systemd socket activation support for the Ocaml xenstored.
Ocaml lacks systemd library support so we provide our own C helpers
as is done with other functionality lacking on Ocaml.

Active sockets enables oxenstored to be loaded only if required by a system
onto which Xen is installed on. Socket activation is handled by
systemd, once a port for a service which claims a socket is used
systemd will start the required services for it, on demand. For more
details on socket activation refer to Lennart's socket-activation
post regarding this [0].

An important difference with socket activation is that systemd will set
FD_CLOEXEC for us on the socket before giving it to us, we'll sprinkly
the Unix.set_close_on_exec for LSB init next as a separate commit.

Right now this code adds a no-op for this functionality, leaving the
enablement to be done later once systemd is properly hooked into
the build system. The socket activation is ordered in aligment with
the socket activation order passed on to systemd.

[0] http://0pointer.de/blog/projects/socket-activation2.html

Cc: David Scott <dave.scott@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Vincent Hanquez <Vincent.Hanquez@eu.citrix.com>
Acked-by: Dave Scott <Dave.Scott@citrix.com>
Acked-by: Anil Madhavapeddy <anil@recoil.org>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
11 years agocxenstored: add support for systemd active sockets
Luis R. Rodriguez [Thu, 17 Jul 2014 23:28:13 +0000 (16:28 -0700)]
cxenstored: add support for systemd active sockets

This adds systemd socket activation support for the C xenstored.
Active sockets enable xenstored to be loaded only if required by a system
onto which Xen is installed on. Socket activation is handled by
systemd, once a port for a service which claims a socket is used
systemd will start the required services for it, on demand. For more
details on socket activation refer to Lennart's socket-activation
post regarding this [0].

Right now this code adds a no-op for this functionality, leaving the
enablement to be done later once systemd is properly hooked into
the build system. The socket activation is ordered in aligment with
the socket activation order passed on to systemd.

[0] http://0pointer.de/blog/projects/socket-activation2.html

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstored: enable usage of config.h on both xenstored and oxenstored
Luis R. Rodriguez [Thu, 17 Jul 2014 23:28:12 +0000 (16:28 -0700)]
xenstored: enable usage of config.h on both xenstored and oxenstored

This will be used later for dynamic configuration paths on C code.

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
11 years agoxen: arm: document boot module compatibility based on ordering
Ian Campbell [Mon, 21 Jul 2014 12:16:31 +0000 (13:16 +0100)]
xen: arm: document boot module compatibility based on ordering

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agofix list_domain_details: check config data length=0
Chunyan Liu [Wed, 23 Jul 2014 09:42:09 +0000 (17:42 +0800)]
fix list_domain_details: check config data length=0

If domain is created through virsh, then in xl, one could see it
with 'xl list', but with 'xl list --long domU', it reports:
"Domain name must be specified."
The reason is xl config data does not exist but it still tries
to parse_config_data in current code.

Improve list_domain_details:
If len of config data is 0, just pass, do not go forward to
parse_config_data, otherwise, it will meet error like
"Domain name not specified" and exit. This error is not expected,
since if code enters list_domain_details, domain name validness
is already checked and domain does exist.

Length of config data is 0 may means: config data does not exist due
to some reason, like: domain is created by libvirt, or in destroying
domain process config data is cleared but domain fails to clean up.
No matter in which case, list_domain_details could just show empty
info, but not error like "Domain name not specified".

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agotools/xenconsoled: Log Xen boot messages at startup.
Andrew Cooper [Tue, 22 Jul 2014 16:17:16 +0000 (17:17 +0100)]
tools/xenconsoled: Log Xen boot messages at startup.

When xenconsoled starts, there will be log lines in the Xen console ring from
boot, even though VIRQ_CON_RING is not yet pending.

Add a force option to handle_hv_logs() which bypasses the event channel check,
allowing xenconsoled to drain the Xen boot messages when it starts, rather
than at the first subsequent time that VIRQ_CON_RING becomes set.

Signed-off-by: Andrew Cooper <andrew.cooper3@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>
11 years agotools/xenconsoled: Possibly perform repeated xc_readconsolering() hypercalls
Andrew Cooper [Tue, 22 Jul 2014 16:17:15 +0000 (17:17 +0100)]
tools/xenconsoled: Possibly perform repeated xc_readconsolering() hypercalls

The size of the Xen console ring is runtime configurable, so the statically
sized 16k buffer is not necessarily sufficient.  Make repeated
xc_readconsolering() hypercalls while Xen managed to completely fill the
provided buffer.

Also, change the buffer to being static to save on stack space.

Signed-off-by: Andrew Cooper <andrew.cooper3@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>
11 years agotools/xenconsoled: Newline on 'Logfile Opened' messages
Andrew Cooper [Tue, 22 Jul 2014 16:17:14 +0000 (17:17 +0100)]
tools/xenconsoled: Newline on 'Logfile Opened' messages

Signed-off-by: Andrew Cooper <andrew.cooper3@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>
11 years agolibxl IDL: the name of a KeyedUnion discriminator need not be 'type'
David Scott [Tue, 22 Jul 2014 15:05:18 +0000 (16:05 +0100)]
libxl IDL: the name of a KeyedUnion discriminator need not be 'type'

Signed-off-by: David Scott <dave.scott@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agostubdom: fix -Wextra usage in vtpm_emulator
Olaf Hering [Tue, 22 Jul 2014 07:19:17 +0000 (09:19 +0200)]
stubdom: fix -Wextra usage in vtpm_emulator

If -Wextra is appended to CFLAGS it will enable all warnings. Previous
options such as -Wno-unused-parameters have no effect anymore. As a
result compilation will fail with gcc-4.3. Newer versions of gcc will
appearently remember -Wno-* options before -Wextra.
Rearrange warning options for gcc so that -Wextra comes before other -W
options. This fixes compilation of stubdom in SLES11.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: tpm: remove usage of inline keyword
Olaf Hering [Tue, 22 Jul 2014 07:19:16 +0000 (09:19 +0200)]
mini-os: tpm: remove usage of inline keyword

Compilation fails with gcc-4.3:

tpmback.c: In function 'tpmback_resp':
tpmback.c:148: error: inlining failed in call to 'tpmdev_check_req': call is unlikely and code size would grow
tpmback.c:165: error: called from here
tpmback.c: In function 'new_tpmif':
tpmback.c:384: error: inlining failed in call to '__init_tpmif': call is unlikely and code size would grow
tpmback.c:425: error: called from here

Adjust code to use static instead of inline, it has the same effect.
Change also tpmif_req_ready and tpmif_req_finished before they start to
cause failures.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: tpm: fix array access in locality_enabled
Olaf Hering [Tue, 22 Jul 2014 07:19:15 +0000 (09:19 +0200)]
mini-os: tpm: fix array access in locality_enabled

gcc-4.3 fails to prove that array indices will remain positive. Add a
hint for the compiler and check the index value before using it.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agoxen: arm: don't release modules which aren't in RAM into the heap
Ian Campbell [Wed, 23 Jul 2014 16:45:30 +0000 (17:45 +0100)]
xen: arm: don't release modules which aren't in RAM into the heap

They might be in e.g. flash or something but more likely they could
be in a bank of RAM which we aren't handling or in RAM which the
bootloader hasn't told us about for some reason.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Cc: Fu Wei <fu.wei@linaro.org>
Cc: Roy Franz <roy.franz@linaro.org>
11 years agoxen: arm: Only lookup kernel/initrd bootmodule once while building dom0.
Ian Campbell [Mon, 21 Jul 2014 12:09:16 +0000 (13:09 +0100)]
xen: arm: Only lookup kernel/initrd bootmodule once while building dom0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: Correctly use GLOBAL/ENTRY in head.S, avoid .global
Ian Campbell [Mon, 21 Jul 2014 13:00:00 +0000 (14:00 +0100)]
xen: arm: Correctly use GLOBAL/ENTRY in head.S, avoid .global

Use ENTRY() for function entry points since it ensures correct
alignment where GLOBAL() doesn't. The exception is the initial start
label which must be at offset 0, so just use GLOBAL() to avoid the
possibility of realignment.

Since everything happens to already be aligned there should be no
difference to the actual binary. objdump agrees.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: ensure that the boot code is <4K in size
Ian Campbell [Mon, 21 Jul 2014 12:59:59 +0000 (13:59 +0100)]
xen: arm: ensure that the boot code is <4K in size

This avoids having to deal with the 1:1 boot mapping crossing a
section or page boundary.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: avoid unnecessary additional mappings in boot page tables.
Ian Campbell [Mon, 21 Jul 2014 12:59:58 +0000 (13:59 +0100)]
xen: arm: avoid unnecessary additional mappings in boot page tables.

If the identity map is created at one level then avoid creating
entries further down the boot page tables, since these will be aliases at
strange virtual address.

For example consider an arm32 system (for simplicity) with Xen loaded at
address 0x40402000. As a virtual address this corresponds to walking offsets 1,
2 and 2 at the first, second and third levels respectively.

When creating the identity map we will therefore create a 1GB super mapping at
0x40000000 for the identity map, which is the one we want to use.

However when considering the second level we will see the offset 2 and create a
2MB mapping in slot 2 of boot_second. Since boot_second is mapped in slot 0 of
boot_first this corresponds to an unwanted mapping from virtual address
0x00400000 to physical address 0x40400000.

We still do not handle the case where the load address is within the 2MB range
starting just after XEN_VIRT_START. This is not a regression but this patch
tries to provide a more useful diagnostic message. We do handle loading at
exactly XEN_VIRT_START.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: Do not use level 0 section mappings in boot page tables.
Ian Campbell [Mon, 21 Jul 2014 12:59:57 +0000 (13:59 +0100)]
xen: arm: Do not use level 0 section mappings in boot page tables.

Level 0 does not support superpage mappings, meaning that systems on where Xen
is loaded above 512GB (I'm not aware of any such systems) the 1:1 mapping on
the boot page tables is invalid.

In order to avoid this issue we need an additional first level page table
mapped by the appropriate L0 slot and containing a 1:1 superpage mapping.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: Handle 4K aligned hypervisor load address.
Ian Campbell [Mon, 21 Jul 2014 12:59:56 +0000 (13:59 +0100)]
xen: arm: Handle 4K aligned hypervisor load address.

Currently the boot page tables map Xen at XEN_VIRT_START using a 2MB section
mapping. This means that the bootloader must load Xen at a 2MB aligned address.
Unfortunately this is not the case with UEFI on the Juno platform where Xen
fails to boot. Furthermore the Linux boot protocol (which Xen claims to adhere
to) does not have this restriction, therefore this is our bug and not the
bootloader's.

Fix this by adding third level pagetables to the boot time pagetables, allowing
us to map a Xen which is aligned only to a 4K boundary. This only affects the
boot time page tables since Xen will later relocate itself to a 2MB aligned
address. Strictly speaking the non-boot processors could make use of this and
use a section mapping, but it is simpler if all processors follow the same boot
path.

Strictly speaking the Linux boot protocol doesn't even require 4K alignment
(and apparently Linux can cope with this), but so far all bootloaders appear to
provide it, so support for this is left for another day.

In order to use LPAE_ENTRIES in head.S we need to define it in an asm friendly
way.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
[ ijc -- properly format message "- FOO -\r\n" ]

11 years agoxen: arm: correct whitespace/comments and use #defines in head.S
Ian Campbell [Mon, 21 Jul 2014 12:59:55 +0000 (13:59 +0100)]
xen: arm: correct whitespace/comments and use #defines in head.S

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agolibxc: disable valgrind integration when building for minios
Ian Campbell [Mon, 21 Jul 2014 11:29:14 +0000 (12:29 +0100)]
libxc: disable valgrind integration when building for minios

The stubdom build system incorrectly picks up on the hosts
installation of Valgrind, which cannot work in a stubdom environment.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Simon Martin <furryfuttock@gmail.com>
Reviewed-by: Andrew Cooper<andrew.cooper3@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
[ ijc -- s/define/defined/ ]

11 years agodocument IOMMU related command line options
Jan Beulich [Thu, 24 Jul 2014 06:58:10 +0000 (08:58 +0200)]
document IOMMU related command line options

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agox86, amd_ucode: support multiple container files appended together
Aravind Gopalakrishnan [Wed, 23 Jul 2014 16:14:41 +0000 (18:14 +0200)]
x86, amd_ucode: support multiple container files appended together

This patch adds support for parsing through multiple AMD container
binaries concatenated together. It is a feature already present in Linux.
Link to linux patch:
http://lkml.kernel.org/r/1370463236-2115-3-git-send-email-jacob.shin@amd.com

Other changes introduced:
 - Define HDR_SIZE's explicitly for code clarity.
 - Minor cleanup: Remove extra casts in that are used in
   install_equiv_cpu_table()

Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86/kexec: fix kexec on systems which boot in x2apic mode
Andrew Cooper [Wed, 23 Jul 2014 16:08:47 +0000 (18:08 +0200)]
x86/kexec: fix kexec on systems which boot in x2apic mode

Moving straight from fully disabled to x2apic mode is an illegal state
transition, and causes an unconditional #GP fault.  Bounce through xapic mode
to avoid the fault.

In addition, avoid bouncing through the various apic modes if the mode is
already correct.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86/mem_event: prevent underflow of vcpu pause counts
Andrew Cooper [Wed, 23 Jul 2014 16:08:04 +0000 (18:08 +0200)]
x86/mem_event: prevent underflow of vcpu pause counts

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Tested-by: Aravindh Puthiyaparambil <aravindp@cisco.com>
11 years agox86/mem_event: validate the response vcpu_id before acting on it
Andrew Cooper [Wed, 23 Jul 2014 16:07:11 +0000 (18:07 +0200)]
x86/mem_event: validate the response vcpu_id before acting on it

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Tested-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
11 years agox86/mem_event: fix regression affecting CR0 memory events
Tamas K Lengyel [Wed, 23 Jul 2014 16:05:11 +0000 (18:05 +0200)]
x86/mem_event: fix regression affecting CR0 memory events

This is a patch repairing a regression in code previously functional in 4.1.x.
It appears that, during some refactoring work, call to hvm_memory_event_cr0 was lost.

This function was originally called in mov_to_cr() of vmx.c, but the commit
http://xenbits.xen.org/hg/xen-unstable.hg/rev/1276926e3795 abstracted the
original code into generic functions up a level in hvm.c, dropping the call
in the process.

The same issue affected the CR3 and CR4 events, which were fixed in patch
http://xenbits.xensource.com/hg/xen-unstable.hg/rev/7ab899e46347.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
Reviewed-by: Tim Deegan <tim@xen.org>
11 years agox86: fix pvh dom0 boot after dab11417d
Andrew Cooper [Wed, 23 Jul 2014 16:04:28 +0000 (18:04 +0200)]
x86: fix pvh dom0 boot after dab11417d

Changeset dab11417d
"x86/HVM: consolidate and sanitize CR4 guest reserved bit determination"

did not take into account the fact that dom0 does not have a cpuid policy.  As
a result, PVH dom0s would be given unexpected #GP faults on boot.

In addition to the restore case (where the toolstack has not had time to load
a cpuid policy), unconditionally exempt the hardware domain from needing a
policy.

Reported-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Roger Pau Monné <roger.pau@citrix.com>
11 years agoavoid crash when doing shutdown with active cpupools
Juergen Gross [Wed, 23 Jul 2014 16:03:19 +0000 (18:03 +0200)]
avoid crash when doing shutdown with active cpupools

When shutting down the machine while there are cpus in a cpupool other than
Pool-0 a crash is triggered due to cpupool handling rejecting offlining the
non-boot cpus in other cpupools.

It is easy to detect this case and allow offlining those cpus.

Reported-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Tested-by: Stefan Bader <stefan.bader@canonical.com>
11 years agox86: Remove USER_MAPPINGS_ARE_GLOBAL definition
Andrew Cooper [Wed, 23 Jul 2014 16:01:28 +0000 (18:01 +0200)]
x86: Remove USER_MAPPINGS_ARE_GLOBAL definition

It has been unconditionally enabled for 64bit Xen builds since 2006
  c/s 6f562e72 "[XEN][X86_64] USe GLOBAL bit to build user mappings."

Adjust the order of definitions in x86_64/page.h to put the bit definitions
for pte flags together.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agoxen: arm: update multiboot device tree bindings.
Ian Campbell [Fri, 18 Jul 2014 13:08:19 +0000 (14:08 +0100)]
xen: arm: update multiboot device tree bindings.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: support bootmodule type detection by ordering
Ian Campbell [Fri, 18 Jul 2014 13:08:18 +0000 (14:08 +0100)]
xen: arm: support bootmodule type detection by ordering

Assign modules types based on the order in which they are defined in the FDT.
This is supported only for the dom0 kernel and ramdisk when given as the first
and second modules respectively, similar to how
http://wiki.xen.org/wiki?title=Xen_ARM_with_Virtualization_Extensions/Multiboot&oldid=11824
defined the default types from the bootloader side.

This is compatible with how Xen interprets the modules with x86 multiboot and I
think simplifies things for bootloaders which now need not contain similar
guessing code if they only care about the most basic case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: store per-boot module type instead of relying on index
Ian Campbell [Fri, 18 Jul 2014 13:08:17 +0000 (14:08 +0100)]
xen: arm: store per-boot module type instead of relying on index

This is more natural and better matches how multiboot is actually supposed to
work.

As part of this we need to modify consider_modules to handle Xen not
necessarily being module zero any more. To do this we first register a module
for Xen at the original load address and then update after we have relocated.
This is also fixing a latent issue which is that get_xen_paddr() would not
consider Xen's current physical address when picking the target address which
was buggy because the relocation code cannot handle the possibility of the old
and new locations overlapping.

All callers of consider_modules now consider the full range instead of some
skipping slot 0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: move device_tree_bootargs to bootfdt.c, renaming to boot_fdt_cmdline
Ian Campbell [Fri, 18 Jul 2014 13:08:16 +0000 (14:08 +0100)]
xen: arm: move device_tree_bootargs to bootfdt.c, renaming to boot_fdt_cmdline

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: move boot time fdt parsing into separate file.
Ian Campbell [Fri, 18 Jul 2014 13:08:15 +0000 (14:08 +0100)]
xen: arm: move boot time fdt parsing into separate file.

Move the early code for walking the flattened device tree out of device_tree.c.
The intention is that eventually only the proper (i.e.  unflattened) device
tree support will live in device_tree.c.

The new home is bootfdt.c to try and better reflect the purpose of the code.
Although in theory this early code could be generic in reality it is pretty ARM
specific, so place it under xen/arch/arm until a second user wants it.

As part of the move rename device_tree_early_init to boot_fdt_info. Drop
device_tree_dump, it is unused.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoxen: arm: rename early_info structs
Ian Campbell [Fri, 18 Jul 2014 13:08:14 +0000 (14:08 +0100)]
xen: arm: rename early_info structs

There isn't really anything Device Tree specific about the early_info, we just
happen to get it from device tree (but in the future it might come e.g. from
UEFI or ACPI or something else).

Move the relevant structs out of device_tree.h and into asm/setup.h and rename to
be more neutral.

For now the code to parse the DT into the now arch specific structs remains in
common code.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
11 years agoxen: arm: prefer typesafe max()/min() over MAX()/MIN()
Ian Campbell [Fri, 18 Jul 2014 13:08:13 +0000 (14:08 +0100)]
xen: arm: prefer typesafe max()/min() over MAX()/MIN()

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: /chosen/module@N/bootargs bootprotcol node is not deprecated
Ian Campbell [Fri, 18 Jul 2014 13:08:12 +0000 (14:08 +0100)]
xen: arm: /chosen/module@N/bootargs bootprotcol node is not deprecated

When using a multiboot capable bootloader this is exactly the field which
should be used.

Replace the deprecation wording with a reference to the information on the
priority of the bootargs fields.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: implement generic multiboot compatibility strings
Ian Campbell [Fri, 18 Jul 2014 13:08:11 +0000 (14:08 +0100)]
xen: arm: implement generic multiboot compatibility strings

This causes Xen to accept the more generic names specified in
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions/Multiboot as of
2014-06-06.

These names are more generic than those proposed by Andre in
http://thread.gmane.org/gmane.linux.linaro.announce.boot/326 and those
used in earlier drafts of the /Multiboot wiki page.

This will allow bootloaders to not special case Xen (or at least to reduce
the amount which is required).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: avoid reusing incorrect mappings when walking the p2m.
Ian Campbell [Fri, 18 Jul 2014 13:33:59 +0000 (14:33 +0100)]
xen: arm: avoid reusing incorrect mappings when walking the p2m.

When we change which PT page we are mapping at a given level then we need to
invalidate any cached mappings further down the tree, otherwise we risk using
them because their offset might match but be based on a different offset
further up the table.

e.g. when remapping first then cur_first_offset and cur_second_offset (which
indicate the currently mapped second and third tables respectively) both become
invalid

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoextras/mini-os/tpmback.c: fix compilation error.
Dushyant Behl [Sun, 20 Jul 2014 20:52:59 +0000 (02:22 +0530)]
extras/mini-os/tpmback.c: fix compilation error.

This patch is with respect to the following discussion on xen-devel -
http://lists.xenproject.org/archives/html/xen-devel/2014-07/msg01991.html

The file extras/mini-os/tpmback.c was failing compilation on certain compilers
because of size mismatch between enum and int. Earlier the code used to read
value of enum using %d format, which failed compilation on some compilers:

tpmback.c: In function ‘tpmif_change_state’:
tpmback.c:350:4: error: format ‘%d’ expects argument of type ‘int *’,
but argument 3 has type ‘enum xenbus_state *’ [-Werror=format=]
    if(sscanf(value, "%d", &readst) != 1) {
    ^

Now the value is read into an actual int variable and then assigned to the
enum.

Signed-off-by:- Dushyant Behl <myselfdushyantbehl@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
[ ijc -- added the actual error to the commit log ]

11 years agoxen: arm: flush TLB after overwriting 1:1 mapping in boot page tables
Ian Campbell [Mon, 14 Jul 2014 16:39:10 +0000 (17:39 +0100)]
xen: arm: flush TLB after overwriting 1:1 mapping in boot page tables

Otherwise a stale TLB entry can shadow the fixmap/UART or DTB mapping

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: correctly handle removing a subset of a superpage mapping.
Ian Campbell [Mon, 14 Jul 2014 16:27:05 +0000 (17:27 +0100)]
xen: arm: correctly handle removing a subset of a superpage mapping.

This can be exercised for example via ballooning which will remove 4K
regions from anywhere in the address space.

Reported-by: Julien Grall <julien.grall@linaro.org>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: when ALLOCATING p2m entries maddr is meaningless
Ian Campbell [Mon, 14 Jul 2014 16:27:04 +0000 (17:27 +0100)]
xen: arm: when ALLOCATING p2m entries maddr is meaningless

The maddr differs on each loop depending on the pages which happen to get
allocated.

There is already an assertion that maddr == 0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: use physical processor ID (MPIDR) when calling psci CPU_ON
Ian Campbell [Mon, 14 Jul 2014 16:21:47 +0000 (17:21 +0100)]
xen: arm: use physical processor ID (MPIDR) when calling psci CPU_ON

Xen's logical CPU map can differ from the underlying layout.

Also add an emacs magic block to this file.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: Add Juno earlyprintk configuration
Ian Campbell [Mon, 14 Jul 2014 16:21:11 +0000 (17:21 +0100)]
xen: arm: Add Juno earlyprintk configuration

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agomini-os: use generic local_irq_enable function
Thomas Leonard [Wed, 16 Jul 2014 11:07:46 +0000 (12:07 +0100)]
mini-os: use generic local_irq_enable function

__sti is x86 specific.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: x86_64: make thread stacks 16-byte aligned
Thomas Leonard [Wed, 16 Jul 2014 11:07:41 +0000 (12:07 +0100)]
mini-os: x86_64: make thread stacks 16-byte aligned

Otherwise, passing doubles to varargs functions causes a crash.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agotools/libxc: Shuffle definitions and uses of min()/max() macros
Andrew Cooper [Wed, 16 Jul 2014 14:32:05 +0000 (15:32 +0100)]
tools/libxc: Shuffle definitions and uses of min()/max() macros

Move the typesafe min() macro from xc_dom_decompress_unsafe_xz.c to
xc_private.h, and complement it with an equivalent max() macro.

Replace current users of type unsafe MIN()/MAX() macros, and remove their
scattered definitions.

Signed-off-by: Andrew Cooper <andrew.cooper3@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>
11 years agoarch/arm: let map_mmio_regions() use start and count
Arianna Avanzini [Mon, 14 Jul 2014 00:50:24 +0000 (02:50 +0200)]
arch/arm: let map_mmio_regions() use start and count

Currently, the arguments given to the function map_mmio_regions() to
describe the memory range to be mapped are the start and end page frame
numbers of the range to be mapped. However, this could give rise to
issues due to the range being inclusive or exclusive of the end gfn
given as parameter. This commit changes the interface of the function
to accept the start gfn and the number of gfns to be mapped.
This commit also changes the interface of the function map_one_mmio(),
helper for the xgene-storm platform, which is a wrapper for the function
map_mmio_regions() and does not need its arguments to be paddr_t.

NOTE: platform-specific code has not been tested, save for the
      sunxi and the Arndale Exynos 5 platforms (see the Tested-by
      below for the latter).

Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
Acked-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Tested-by: Julien Grall <julien.grall@citrix.com>
Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Paolo Valente <paolo.valente@unimore.it>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Eric Trudeau <etrudeau@broadcom.com>
Cc: Viktor Kleinik <viktor.kleinik@globallogic.com>
[ ijc -- remove stray extra parameter in xgene-storm.c ]

11 years agoarch/arm: let map_mmio_regions() take pfn as parameters
Arianna Avanzini [Mon, 14 Jul 2014 00:50:23 +0000 (02:50 +0200)]
arch/arm: let map_mmio_regions() take pfn as parameters

Currently, the map_mmio_regions() function, defined for the ARM
architecture, has parameters with paddr_t type. This interface,
however, needs caller functions to correctly page-align addresses
given as parameters to map_mmio_regions(). This commit changes the
function's interface to accept page frame numbers as parameters.
This commit also modifies caller functions in an attempt to adapt
them to the new interface.
This commit is meant to produce the minimum indispensable needed
changes; these are also instrumental to making the interface of
map_mmio_regions() symmetric with the unmap_mmio_regions() function,
that will be introduced in one of the next commits of the series
and will feature a pfn-based interface.

NOTE: platform-specific code has not been tested, save for the
      sunxi and the Arndale Exynos 5 platforms (see the Tested-by
      below for the latter).

Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
Tested-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Paolo Valente <paolo.valente@unimore.it>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Eric Trudeau <etrudeau@broadcom.com>
Cc: Viktor Kleinik <viktor.kleinik@globallogic.com>
11 years agoxl: 'xl vncviewer' accesses port 0 by any invalid domid
Chunyan Liu [Fri, 18 Jul 2014 06:18:04 +0000 (14:18 +0800)]
xl: 'xl vncviewer' accesses port 0 by any invalid domid

Currently, with command:
  xl vncviewer invalid_domid
it always brings user to the domU using vncport 5900.
The invalid domid could be an non-existing one or Dom0.
It's better to report error in this case.

Correct libxl_vncviewer_exec:
  In existing code, when vncport is NULL, it still continues
  and will show vncport 5900. So, with 'xl vncviewer 0' it also
  wrongly shows domU using vncport 5900. Correct it to report error
  if vncport is NULL.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agomake: Make *-dir-force-update depend on *-dir-find
George Dunlap [Mon, 14 Jul 2014 16:15:24 +0000 (17:15 +0100)]
make: Make *-dir-force-update depend on *-dir-find

Make the targets depend on the "-find" targets, so that if the
subtrees are cloned if they haven't been cloned already.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agomake: Normalize config options for external trees
George Dunlap [Mon, 14 Jul 2014 16:15:23 +0000 (17:15 +0100)]
make: Normalize config options for external trees

We have four different external trees, and four different naming
conventions for specifying the URL, where they live, and what revision
to check out.

Normalize config options on the following bases:
 - QEMU_UPSTREAM
 - QEMU_TRADITIONAL
 - SEABIOS_UPSTREAM
 - OVMF_UPSTREAM

The following suffixes for all trees:
 - _URL : A remote repository to clone from
 - _REVISION : The revision to check out

And the following suffixes for the qemu trees:
 - _INTREE : The location of an inlined tree (for tarball releases)
 - _LOC : Where to actually look (either a directory or a URL)

The following parameters are still supported for backwards
compatibility:
 - CONFIG_QEMU          (=> QEMU_TRADITIONAL_LOC)
 - QEMU_REMOTE          (=> QEMU_TRADITIONAL_URL)
 - QEMU_TAG             (=> QEMU_TRADITIONAL_REVISION)
 - SEABIOS_UPSTREAM_TAG (=> SEABIOS_UPSTREAM_REVISION)

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agomake: Check tools/qemu-xen[-traditional] for qemu before downloading
George Dunlap [Mon, 14 Jul 2014 16:15:22 +0000 (17:15 +0100)]
make: Check tools/qemu-xen[-traditional] for qemu before downloading

Currently xen, qemu-xen, and qemu-xen-traditional are kept in separate
repositories, but when we release them as a tarball, qemu-xen and
qemu-xen-traditional are in-lined into the tools/ directory.

In order to make this "just work", at the moment developer doing the
release manually modifies Config.mk as part of the relase process so
that CONFIG_QEMU and QEMU_UPSTREAM_URL point into the tools/ directory
instead.

Modify Config.mk to automatically check there before trying a remote
repository.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agoxen/arm: Trap and yield on WFE instructions
Anup Patel [Wed, 16 Jul 2014 10:32:15 +0000 (16:02 +0530)]
xen/arm: Trap and yield on WFE instructions

If we have a Guest/DomU with two or more of its VCPUs running
on same host CPU then it can quite likely happen that these
VCPUs fight for same spinlock and one of them will waste CPU
cycles in WFE instruction. This patch makes WFE instruction
trap for VCPU and forces VCPU to yield its timeslice.

The KVM ARM/ARM64 also does similar thing for handling WFE
instructions. (Please refer,
https://lists.cs.columbia.edu/pipermail/kvmarm/2013-November/006259.html)

In general, this patch is more of an optimization for an
oversubscribed system having number of VCPUs more than
underlying host CPUs.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Tested-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- resolved conflict with "Adding helper function for WFI",
         nuked stray hard tab ]

11 years agoxen/arm : Adding helper function for WFI
Parth Dixit [Mon, 14 Jul 2014 13:51:53 +0000 (19:21 +0530)]
xen/arm : Adding helper function for WFI

WFI functionality is required at different places in xen.
Moving it to seperate helper function so that it is easier
to call WFI function and avoid duplication of code

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctrl: Make the headers C++ friendly
Razvan Cojocaru [Wed, 2 Jul 2014 16:30:33 +0000 (19:30 +0300)]
xenctrl: Make the headers C++ friendly

Moved an enum definition before the typedef that uses it.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools/Makefile: Build only a subset of things for rump kernels
Ian Jackson [Wed, 25 Jun 2014 11:38:35 +0000 (12:38 +0100)]
tools/Makefile: Build only a subset of things for rump kernels

Override the set of tools/ subdirectories for rump kernel builds.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agorump kernels: Handle rumpxen host in configure
Ian Jackson [Wed, 28 May 2014 16:04:52 +0000 (17:04 +0100)]
rump kernels: Handle rumpxen host in configure

Support
   ./configure --host=x86_64-rumpxen-netbsd
   ./configure --host=i386-rumpxen-netbsd

Setting --host tells configure we are cross compiling and therefore
has various automatic effects.

But in this patch we make some deliberate changes as well:
 * We disable a large number of configure tests for libraries
   etc. which don't exist.
 * We set CONFIG_RUMP in Tools.mk.
 * Hence, we automatically set XEN_OS.

(I have only tested the 32-bit build but I think the 64-bit build
should work just as well.)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
---
v3: Add comment to `fi'
v2: Mention x86_64.
    Drop an erroneous whitespace change.

11 years agobuild system: Introduce nosharedlibs variable.
Ian Jackson [Wed, 28 May 2014 16:06:02 +0000 (17:06 +0100)]
build system: Introduce nosharedlibs variable.

Introduce a new build variable "nosharedlibs".

In tools/libxc use it instead of $(stubdom).
In tools/xenstore honour it, and build static clients.

If shared libs are disabled, do not try to install or symlink them.

Set nosharedlibs when building for MiniOS or NetBSDRump.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
---
v2: Clarify deliberate INSTALL_SHLIB and SYMLINK_SHLIB breakage.

11 years agobuild system: Introduce libextension variable
Ian Jackson [Wed, 28 May 2014 16:05:19 +0000 (17:05 +0100)]
build system: Introduce libextension variable

This variable is the suffix to use for finding libraries when doing
compile-time linking.  For now we always set it to ".so" - so no
functional change.

In a forthcoming patch it may take on different values.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agobuild system: Introduce INSTALL_SHLIB and SYMLINK_SHLIB
Ian Jackson [Wed, 25 Jun 2014 09:54:38 +0000 (10:54 +0100)]
build system: Introduce INSTALL_SHLIB and SYMLINK_SHLIB

INSTALL_SHLIB is like INSTALL_PROG but used only for shared libraries.
SYMLINK_SHLIB is the ln -sf rune for shared library symlinks.

Use these in the appropriate places in tools/libxc and tools/xenstore.

No functional change right now.  In a forthcoming patch these
variables might take on different values.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstore: Make building of xenstored optional
Ian Jackson [Wed, 25 Jun 2014 09:54:54 +0000 (10:54 +0100)]
xenstore: Make building of xenstored optional

In principle it would be possible to make a rumpuser-xen-based stub
xenstored, but all the necessary pieces do not yet exist.

So provide a facility to disable compilation of xenstored, and use it
to disable it on rump kernels.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstore: rump kernels: Look for /dev/xen/xenbus
Ian Jackson [Thu, 19 Jun 2014 17:54:35 +0000 (18:54 +0100)]
xenstore: rump kernels: Look for /dev/xen/xenbus

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxc: rump kernels: Use standard xc_osdep_get_info
Ian Jackson [Wed, 28 May 2014 16:06:21 +0000 (17:06 +0100)]
libxc: rump kernels: Use standard xc_osdep_get_info

Do not try to support the dlopen-based xc indirection.

Introduce a local #define DO_DYNAMIC_OSDEP to centralise the condition.

Add comments to the #endifs.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
---
v2: Remove duplication by introducing DO_DYNAMIC_OSDEP.
    Add comments to the #endifs.

11 years agorump kernels: Start introducing new XEN_OS NetBSDRump
Ian Jackson [Wed, 28 May 2014 16:07:37 +0000 (17:07 +0100)]
rump kernels: Start introducing new XEN_OS NetBSDRump

Provide an entry in config/, and a copy of xen-sys privcmd.h.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstore: In xenstore_client, avoid stack buffer in recursive function
Ian Jackson [Fri, 20 Jun 2014 10:54:56 +0000 (11:54 +0100)]
xenstore: In xenstore_client, avoid stack buffer in recursive function

do_ls is recursive.  It had a buffer of size around 5K allocated on
the stack.  This combination is not a very good idea: some
environments (eg, Mini-OS) have limited stack sizes (eg 64K).

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstore: Use $(PTHREAD_LDFLAGS) and $(PTHREAD_LIBS) not -lpthread
Ian Jackson [Wed, 28 May 2014 16:06:50 +0000 (17:06 +0100)]
xenstore: Use $(PTHREAD_LDFLAGS) and $(PTHREAD_LIBS) not -lpthread

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: We need PTHREAD_LDFLAGS too (!)

11 years agolibxl: Fix duplicate libxl_ctx typedef.
Wen Congyang [Fri, 11 Jul 2014 03:32:33 +0000 (11:32 +0800)]
libxl: Fix duplicate libxl_ctx typedef.

commit de18e4c038306aeeca53e6e63e563036cafef162 introduces a build error with
older gcc:

In file included from xl.c:31:
libxl.h:582: error: redefinition of typedef ‘libxl_ctx’
libxl.h:348: note: previous declaration of ‘libxl_ctx’ was here

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- rewrote commit message ]

11 years agolibxl: Use proper path for 'do_flr' functionality.
Konrad Rzeszutek Wilk [Tue, 8 Jul 2014 19:00:37 +0000 (15:00 -0400)]
libxl: Use proper path for 'do_flr' functionality.

Commit f74035d3b1e827ff6ff1873e2f10feb011a8d0d2 "xl: PCI code cleanups"
introduced an regression where it changed the name from:
/sys/bus/pci/drivers/pciback/do_flr
to
libxl_sprintf(ctx, "%s/pciback/do_flr", SYSFS_PCI_DEV);

And SYSFS_PCI_DEV is "/sys/bus/pci/devices", meaning we would
do /sys/bus/pci/devices/pciback/do_flr. The proper define
should have been SYSFS_PCIBACK_DRIVER, which is what this patch does.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoinit-xenstore-domain: Add optional ramdisk argument.
James Bielman [Mon, 7 Jul 2014 21:52:24 +0000 (14:52 -0700)]
init-xenstore-domain: Add optional ramdisk argument.

- Added an optional argument to allow passing a ramdisk
  to the Xenstore domain built by init-xenstore-domain.
- This is needed for Xenstore/MAC to pass initial security
  policy.

Signed-off-by: James Bielman <jamesjb@galois.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agodocs: Tweak .gitignore
Andrew Cooper [Mon, 7 Jul 2014 10:27:33 +0000 (11:27 +0100)]
docs: Tweak .gitignore

* Remove ignores for removed docs.
* Introduce blanket ignores for the "output" directories, including txt/ which
  was previously missing.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen: arm: allocate more than one bank for 1:1 domain 0 if needed
Ian Campbell [Wed, 9 Jul 2014 12:07:46 +0000 (13:07 +0100)]
xen: arm: allocate more than one bank for 1:1 domain 0 if needed

Depending on where Xen and the initial modules were loaded into RAM we may not
be able to allocate a suitably contiguous block of memory for dom0. Especially
since the allocations made by alloc_domheap_pages are naturally aligned (e.g. a
1GB allocation must be at a 1GB boundary).

The alignment requirement in particular is a huge limitation, meaning that even
dom0_mem0=1G on a 2GB system is pretty likely to fail unless you are very
careful with your load addresses. People were also having trouble with dom0 >
128MB on the 1GB cubieboard2 when using fairly standard load addresses for
things.

This patch tries to allocate multiple banks of memory in order to try and
satisfy the entire requested domain 0 allocation. Sadly this turns out to be
pretty tricky to arrange (see the large comment in the code).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Karim Raslan <karim.allah.ahmed@gmail.com>
Acked-by: Julien Grall <julien.grall@linaro.org>