]> xenbits.xensource.com Git - xen.git/log
xen.git
11 years agogitignore: ignore OVMF directories
Wei Liu [Mon, 21 Apr 2014 10:16:16 +0000 (11:16 +0100)]
gitignore: ignore OVMF directories

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
11 years agox86/EPT: correct double unmap_domain_page() on error path
Andrew Cooper [Tue, 22 Apr 2014 12:45:10 +0000 (14:45 +0200)]
x86/EPT: correct double unmap_domain_page() on error path

c/s 3d90d6e6 "x86/EPT: split super pages upon mismatching memory types"
accidentally introduced an error path where the epte domain page would be
unmapped twice if splitting the superpage failed.

Only unmap the page if the loop is to be continued.  When breaking from the
loop, the page will be unmapped by the subsequent code.

Coverity-ID: 1203047
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agoallow hardware domain != dom0
Daniel De Graaf [Tue, 22 Apr 2014 10:10:13 +0000 (12:10 +0200)]
allow hardware domain != dom0

This adds a hypervisor command line option "hardware_dom=" which takes a
domain ID.  When the domain with this ID is created, it will be used
as the hardware domain.

This is intended to be used when domain 0 is a dedicated stub domain for
domain building, allowing the hardware domain to be de-privileged and
act only as a driver domain.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86/hap: fix lack of newline in error message
Andrew Cooper [Tue, 22 Apr 2014 10:09:36 +0000 (12:09 +0200)]
x86/hap: fix lack of newline in error message

to avoid corrupting the following line.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <JBeulich@suse.com>
11 years agox86/HVM: use fixed TSC value when saving or restoring domain
Boris Ostrovsky [Tue, 22 Apr 2014 10:08:56 +0000 (12:08 +0200)]
x86/HVM: use fixed TSC value when saving or restoring domain

When a domain is saved each VCPU's TSC value needs to be preserved. To get it we
use hvm_get_guest_tsc(). This routine (either itself or via get_s_time() which
it may call) calculates VCPU's TSC based on current host's TSC value (by doing a
rdtscll()). Since this is performed for each VCPU separately we end up with
un-synchronized TSCs.

Similarly, during a restore each VCPU is assigned its TSC based on host's current
tick, causing virtual TSCs to diverge further.

With this, we can easily get into situation where a guest may see time going
backwards.

Instead of reading new TSC value for each VCPU when saving/restoring it we should
use the same value across all VCPUs.

Reported-by: Philippe Coquard <philippe.coquard@mpsa.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86/svm: enable TSC scaling
Boris Ostrovsky [Tue, 22 Apr 2014 10:08:06 +0000 (12:08 +0200)]
x86/svm: enable TSC scaling

TSC ratio enabling logic is inverted: we want to use it when we
are running in native tsc mode, i.e. when d->arch.vtsc is zero.

Also, since now svm_set_tsc_offset()'s calculations depend
on vtsc's value, we need to call hvm_funcs.set_tsc_offset() after
vtsc changes in tsc_set_info().

In addition, with TSC ratio enabled, svm_set_tsc_offset() will
need to do rdtsc. With that we may end up having TSCs on guest's
processors out of sync. d->arch.hvm_domain.sync_tsc which is set
by the boot processor can now be used by APs as reference TSC
value instead of host's current TSC.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86: use native RDTSC(P) execution when guest and host frequencies are the same
Boris Ostrovsky [Tue, 22 Apr 2014 10:07:37 +0000 (12:07 +0200)]
x86: use native RDTSC(P) execution when guest and host frequencies are the same

We should be able to continue using native RDTSC(P) execution on
HVM/PVH guests after migration if host and guest frequencies are
equal (this includes the case when the frequencies are made equal
by TSC scaling feature).

This also allows us to revert main part of commit 4aab59a3 (svm: Do not
intercept RDTSC(P) when TSC scaling is supported by hardware) which
was wrong: while RDTSC intercepts were disabled domain's vtsc could
still be set, leading to inconsistent view of guest's TSC.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
11 years agoACPI/ERST: fix signed/unsigned type conflicts
Jan Beulich [Tue, 22 Apr 2014 10:05:44 +0000 (12:05 +0200)]
ACPI/ERST: fix signed/unsigned type conflicts

Error checks exist in the respective code path that expect negative
values to indicate errors, yet negative values can't be communicated
through size_t. Thus ssize_t needs to be introduced (also on ARM for
consistency, even if the code in question isn't currently being used
on there).

The bug is theoretical only in so far as all the involved code is
effectively dead. Reflect this by excluding that code from non-debug
builds.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Christoph Egger <chegger@amazon.de>
11 years agox86/MSI: drop workaround for insecure Dom0 kernels
Jan Beulich [Tue, 22 Apr 2014 10:04:20 +0000 (12:04 +0200)]
x86/MSI: drop workaround for insecure Dom0 kernels

Considering that
- the workaround is expensive (iterating through the entire P2M space
  of a domain),
- the planned elimination of the expensiveness (by propagating the type
  change step by step to the individual P2M leaves) wouldn't address
  the IOMMU side of things (as for it to obey to the changed
  permissions the adjustments must be pushed down immediately through
  the entire tree)
- the proper solution (PHYSDEVOP_msix_prepare) should by now be
  implemented by all security conscious Dom0 kernels
remove the workaround, killing eventual guests that would be known to
become a security risk instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agoimplement is_hardware_domain using hardware_domain global
Daniel De Graaf [Thu, 17 Apr 2014 08:10:33 +0000 (10:10 +0200)]
implement is_hardware_domain using hardware_domain global

This requires setting the hardware_domain variable earlier in
domain_create so that functions called from it (primarily in
arch_domain_create) observe the correct results when they call
is_hardware_domain.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agopvh dom0: make xsm_map_gmfn_foreign available for x86
Mukesh Rathor [Thu, 17 Apr 2014 08:07:44 +0000 (10:07 +0200)]
pvh dom0: make xsm_map_gmfn_foreign available for x86

In this patch we make xsm_map_gmfn_foreign available for x86 also. This
is used in the next patch "pvh dom0: Add and remove foreign pages" in
function p2m_add_foreign.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agopvh dom0: introduce p2m_map_foreign
Mukesh Rathor [Thu, 17 Apr 2014 08:05:07 +0000 (10:05 +0200)]
pvh dom0: introduce p2m_map_foreign

In this patch, a new type p2m_map_foreign is introduced for pages
that toolstack on an auto translated dom0 or a control domain maps
from foreign domains that its creating or supporting during its
run time.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agopvh dom0: move some pv specific code to static functions
Mukesh Rathor [Thu, 17 Apr 2014 08:03:41 +0000 (10:03 +0200)]
pvh dom0: move some pv specific code to static functions

In this preparatory patch, some pv specific code is
carved out into static functions. No functionality change.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agoMerge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging
Ian Campbell [Wed, 16 Apr 2014 16:28:23 +0000 (17:28 +0100)]
Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging

11 years agox86: fix instruction emulator test's xgetbv constraints
Jan Beulich [Wed, 16 Apr 2014 16:18:35 +0000 (18:18 +0200)]
x86: fix instruction emulator test's xgetbv constraints

The "A" constraint, while documented up to gcc 4.5 as "The a and d
registers, as a pair (for instructions that return half the result in
one and half in the other)," never really behaved that (natural) way,
but always meant (and is now also documented so) %eax _or_ %edx (%rax
_or_ %rdx on x86-64) unless the operand was wide enough to require both
(i.e. more than 32 bits on ix86 and more than 64 bits on x86-64).

Interestingly something internal to the compiler changed between 4.4
and 4.5 to actually expose the difference - up to gcc 4.4 I was unable
to construct a case where, when only the low half of the result is
actually looked at, the result would be considered to be in %edx/%rdx
(and %eax/%rax would be treated as unmodified by the instruction).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Tested-by: Don Slutz <dslutz@verizon.com>
11 years agoxen/arm: Pass the timer "clock-frequency" to DOM0 in make_timer_node()
Suriyan Ramasami [Mon, 14 Apr 2014 08:14:00 +0000 (01:14 -0700)]
xen/arm: Pass the timer "clock-frequency" to DOM0 in make_timer_node()

If the DT representing the ARM generic timer mentions a clock-frequency,
propragate it to the DT that is built for DOM0.

This is necessary as a workaround for boards (Odroid-XU) where CNTFRQ is not
set or returns a wrong value.

Ideally CNTFRQ should be set by the boot loader. The bootloader should respect
the ARM ARM (see B.8.1.1):
    "The CNTFRQ register is UNKNOWN at reset, and therefore the counter
    frequency must written to CNTFRQ as part of the system boot process."

For the Odroid-XU the SPL BL2 code is entered in NS HYP mode which prevents
the execution of the mcr call to set CNTFRQ.

Signed-off-by: Suriyan Ramasami <suriyan.r@gmail.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools/libxc: Remove valgrind conditional sections from libxc
Andrew Cooper [Tue, 15 Apr 2014 18:18:42 +0000 (19:18 +0100)]
tools/libxc: Remove valgrind conditional sections from libxc

The ifdef sections are not enabled at all in tree, and their justification is
out of date now that Xen hypercall support exists upstream in valgrind.

This also removes a commented-out tweak to CFLAGS in the libxc Makefile which
is not being used, and becomes stale given this patch.  In the unlikely event
that any developers were using the line, the results can be more easily
achieved by tweaking APPEND_CFLAGS in the environment.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools/libxl: Improvements to libxl-save-helper when using valgrind
Andrew Cooper [Fri, 11 Apr 2014 15:46:14 +0000 (16:46 +0100)]
tools/libxl: Improvements to libxl-save-helper when using valgrind

Fix two unfree()'d allocations in libxl-save-helper, to get them out of the
way of other legitimate complaints from valgrind.

The first is easy; close the interface to libxc when done with it.

The second can be fixed by removing the complexity of creating the logging
instance.  Initialise the global 'logger' in place rather than as an
allocation, which requires changing the indirection of its use in 5 locations.

struct xentoollog_logger_tellparent and function createlogger_tellparent() are
now unused and removed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl/save-helper: Code motion of logging functions
Andrew Cooper [Fri, 11 Apr 2014 15:46:13 +0000 (16:46 +0100)]
libxl/save-helper: Code motion of logging functions

... in preparation for a subsequent functional fix

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl_types.idl: replace empty Struct with None for libxl_event
Wei Liu [Thu, 10 Apr 2014 15:20:22 +0000 (16:20 +0100)]
libxl_types.idl: replace empty Struct with None for libxl_event

Now we generate empty map for None, the empty Struct trick is not
necessary anymore.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl/gentypes.py: generate empty map for None field in keyed-union
Wei Liu [Thu, 10 Apr 2014 15:18:00 +0000 (16:18 +0100)]
libxl/gentypes.py: generate empty map for None field in keyed-union

Without this the generated JSON is malformed.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl_json: fix JSON parser debug code
Wei Liu [Thu, 10 Apr 2014 15:26:32 +0000 (16:26 +0100)]
libxl_json: fix JSON parser debug code

Two changes included:
1. implement DEBUG_GEN_ALLOC for YAJL2
2. use size_t for variable "len"

without these two fixes it fails to compile when DEBUG_ANSWER is
defined.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl/gentypes.py: don't generate JSON for private type(s)
Wei Liu [Thu, 10 Apr 2014 15:26:31 +0000 (16:26 +0100)]
libxl/gentypes.py: don't generate JSON for private type(s)

Private types are only useful inside libxl. They don't have a valid JSON
generation function by default.

Currently there's only one private type, that's libxl_ev_link. Not
skipping this field causes testidl to fail as the code generated for
this type is NULL.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm64: Correctly align VFP regs
Julien Grall [Thu, 10 Apr 2014 11:43:57 +0000 (12:43 +0100)]
xen/arm64: Correctly align VFP regs

On arm64, VFP instructions requires vfpregs to be 128-byte aligned.

By chance, the field is already correctly aligned. In the case if someone
decides to add a new field before, Xen will receive a data abort as soon as
it saves/restores VFP.

We are safe on arm32 as the only constraint is to be 32-byte aligned.

Reported-by: Chen Baozi <baozich@gmail.com>
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoRevert "xen/arm: Allocate memory for dom0 from the bottom with the 1:1 Workaround"
Ian Campbell [Fri, 4 Apr 2014 12:56:59 +0000 (13:56 +0100)]
Revert "xen/arm: Allocate memory for dom0 from the bottom with the 1:1 Workaround"

This reverts commit 6c21cb36e263de2db8716b477157a5b6cd531e1e.

The Linux = issue which this works around was fixed in v3.13 via f52bb722547f
"ARM: mm: Correct virt_to_phys patching for 64 bit physical addresses".

This is the second attempt to revert this. Now that we have fixed
allocate_memory_11 to allocate accessible memory on 32-bit this is safe to do.
This is not quite a straight revert since we need to ensure that for 32-bit
domain 0 we do not allocate dom0's memory above 4GB where the domain cannot
access it without paging (which is disabled at start of day) and LPAE (which
the kernel may not support) enabled.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
[ ijc -- dropped debug code ]

11 years agoxen: arm: probe the kernel to determine the guest type earlier
Ian Campbell [Fri, 4 Apr 2014 12:56:58 +0000 (13:56 +0100)]
xen: arm: probe the kernel to determine the guest type earlier

We need to know if the kernel is 32- or 64- bit capable sooner so that we know
what sort of domain we are building when allocating memory to it (so we can
place appropriate limits when allocating RAM to the guest). At the moment
kernel_prepare() decides this but it needs the memory to have already been
allocated.

Therefore split the probing functionality of kernel_prepare() and call it much
earlier. The remainder of kernel_prepare() deals with where to place the
kernel in RAM which can be deferred until kernel_load() so do so.

Document the input and output of kernel_probe() and _load().

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
[ ijc -- whitespace fixes ]

11 years agoxen: arm: refactor struct kernel_info
Ian Campbell [Fri, 4 Apr 2014 12:56:57 +0000 (13:56 +0100)]
xen: arm: refactor struct kernel_info

The kernel_order and kernel_image fields are ELF specific.

Also add a few comments about what things are.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agox86/HAP: also flush TLB when altering a present 1G or intermediate entry
Jan Beulich [Mon, 14 Apr 2014 13:14:47 +0000 (15:14 +0200)]
x86/HAP: also flush TLB when altering a present 1G or intermediate entry

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoMAINTAINERS: extend coverage for "THE REST"
Jan Beulich [Mon, 14 Apr 2014 13:13:33 +0000 (15:13 +0200)]
MAINTAINERS: extend coverage for "THE REST"

As agreed upon in offlist discussion among the committers, make all
committers eligible to approve changes to code not having its
maintainership covered explicitly. (For committers to make changes to
such code, generally an ack from a second committer is going to be
required.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86/nested HAP: don't BUG() on legitimate error
Jan Beulich [Mon, 14 Apr 2014 10:50:56 +0000 (12:50 +0200)]
x86/nested HAP: don't BUG() on legitimate error

p2m_set_entry() can fail without there being a bug in the code - crash
the domain rather than the host in that case.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86/p2m: error code propagation
Mukesh Rathor [Mon, 14 Apr 2014 10:47:29 +0000 (12:47 +0200)]
x86/p2m: error code propagation

Because some of the leaf p2m functions return 0 for failure and
TRUE for success, the real errno is lost. We change some of those
functions to return proper -errno. Also, any code in the immediate
vicinity that is in coding style violation is fixed up.

This patch doesn't change any functionality.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoRename "set_p2m_entry" to "p2m_set_entry"
Mukesh Rathor [Mon, 14 Apr 2014 10:44:39 +0000 (12:44 +0200)]
Rename "set_p2m_entry" to "p2m_set_entry"

This patch renames set_p2m_entry defined in arch/x86/mm/p2m.c
to p2m_set_entry which makes it consistent with other functions
from that file. It also facilitates changing the function signature
to return approriate errno for failure cases.  This patch doesn't
change any functionality.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86: rename public functions in p2m-pt.c
Mukesh Rathor [Mon, 14 Apr 2014 10:43:36 +0000 (12:43 +0200)]
x86: rename public functions in p2m-pt.c

This patch renames "public" functions in p2m-pt.c. In addition to
making them more descriptive, it also frees up "p2m_set_entry" name
to be used later.  This patch doesn't change any functionality.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86: fix up mem_access.h
Aravindh Puthiyaparambil [Mon, 14 Apr 2014 10:42:26 +0000 (12:42 +0200)]
x86: fix up mem_access.h

Fix filename in the description
Add double inclusion guard

Signed-off-by: Aravindh Puthiyaparambil <aravindp@cisco.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agotools: improve make debball
Fabio Fantoni [Fri, 11 Apr 2014 11:13:19 +0000 (13:13 +0200)]
tools: improve make debball

- Remove version from installed package name, to make "upgrades" work
- Add conffiles to manage files in /etc on package install/update/remove
- Added in description that this is a .deb for testing only

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agofurther prefetch cleanup
Jan Beulich [Fri, 11 Apr 2014 09:27:04 +0000 (11:27 +0200)]
further prefetch cleanup

- commit 630017f4 ("xen: x86 & generic: change to __builtin_prefetch()")
  removed the ARCH_HAS_PREFETCH{,W} defines, but left the
  ARCH_HAS_SPINLOCK_PREFETCH one in place
- the x86 special casing code has always been dead due to the two
  respective CONFIG_* settings not getting defined anywhere

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 agoevtchn: eliminate 64k ports limitation
Jan Beulich [Fri, 11 Apr 2014 09:25:56 +0000 (11:25 +0200)]
evtchn: eliminate 64k ports limitation

The introduction of FIFO event channels claimed to support over 100k
ports, but failed to widen a number of 16-bit variables/operations.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agolibxl: allow dom0 to be destroyed
Daniel De Graaf [Fri, 11 Apr 2014 09:22:49 +0000 (11:22 +0200)]
libxl: allow dom0 to be destroyed

When dom0 is not the hardware domain, it can be destroyed in the same
way as any other service domain.  To avoid accidental use when a domain
is not resolved, destroying domain 0 requires passing -f to xl destroy.
Since the hypervisor already prevents a domain from destroying itself,
this patch is only useful in a disaggregated environment.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agorename various functions referencing dom0
Daniel De Graaf [Fri, 11 Apr 2014 09:21:54 +0000 (11:21 +0200)]
rename various functions referencing dom0

Most of these functions actually act on the hardware domain, so change
their names to reflect this.

Command line parameters and variables based on those parameters are
excluded since those changes would be user-visible, as are any public
headers.

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 agorename dom0 to hardware_domain
Daniel De Graaf [Fri, 11 Apr 2014 09:20:55 +0000 (11:20 +0200)]
rename dom0 to hardware_domain

This should not change any functionality other than renaming the global
variable.  In a few cases (primarily the domain building code), a local
variable or argument named dom0 was created and used instead of the
global hardware_domain to clarify that the domain being used in this
case is actually domain 0.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Christoph Egger <chegger@amazon.de>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoprevent 0 from being used as a dynamic domid
Daniel De Graaf [Fri, 11 Apr 2014 09:20:08 +0000 (11:20 +0200)]
prevent 0 from being used as a dynamic domid

When the hardware domain is made distinct from dom0, it becomes possible
to shut down and destroy domain 0 while leaving the hypervisor running.
If this happens, prevent this domain ID from being considered for
allocation to a new guest.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoiommu: Move dom0 setup code to __hwdom_init
Daniel De Graaf [Fri, 11 Apr 2014 09:19:16 +0000 (11:19 +0200)]
iommu: Move dom0 setup code to __hwdom_init

When the hardware domain is split from domain 0, the initialization code
for the hardware domain cannot be in the __init section, since the
actual domain creation happens after these sections have been discarded.
Create a __hwdom_init section designator to annotate these functions,
and control it using the XSM configuration option for now (since XSM is
required to take advantage of the security benefits of disaggregation).

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 agouse domid check in is_hardware_domain
Daniel De Graaf [Fri, 11 Apr 2014 09:16:52 +0000 (11:16 +0200)]
use domid check in is_hardware_domain

Instead of checking is_privileged to determine if a domain should
control the hardware, check that the domain_id is equal to zero (which
is currently the only domain for which is_privileged is true).  This
allows other places where domain_id is checked for zero to be replaced
with is_hardware_domain.

The distinction between is_hardware_domain, is_control_domain, and
domain 0 is based on the following disaggregation model:

Domain 0 bootstraps the system.  It may remain to perform requested
builds of domains that need a minimal trust chain (i.e. vTPM domains).
Other than being built by the hypervisor, nothing is special about this
domain - although it may be useful to have is_control_domain() return
true depending on the toolstack it uses to build other domains.

The hardware domain manages devices for PCI pass-through to driver
domains or can act as a driver domain itself, depending on the desired
degree of disaggregation.  It is also the domain managing devices that
do not support pass-through: PCI configuration space access, parsing the
hardware ACPI tables and system power or machine check events.  This is
the only domain where is_hardware_domain() is true.  The return of
is_control_domain() may be false for this domain.

The control domain manages other domains, controls guest launch and
shutdown, and manages resource constraints; is_control_domain() returns
true.  The functionality guarded by is_control_domain may in the future
be adapted to use explicit hypercalls, eliminating the special treatment
of this domain.  It may be reasonable to have multiple control domains
on a multi-tenant system.

Guest domains and other service or driver domains are all treated
identically by the hypervisor; the security policy may further constrain
administrative actions on or communication between these domains.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoserial: expand the PCIe params for an Oxford two port serial cards
Konrad Rzeszutek Wilk [Thu, 10 Apr 2014 15:59:20 +0000 (17:59 +0200)]
serial: expand the PCIe params for an Oxford two port serial cards

Which of course has a different model number and sports two
serial outputs.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86/AMD: clean up pre-canned family/revision handling for CPUID masking
Jan Beulich [Thu, 10 Apr 2014 14:16:46 +0000 (16:16 +0200)]
x86/AMD: clean up pre-canned family/revision handling for CPUID masking

Make it so this is easier to extend, and move the parsing code/data
into .init.* sections.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Aravind Gopalakrishnan<aravind.gopalakrishnan@amd.com>
11 years agox86/AMD: support further feature masking MSRs
Jan Beulich [Thu, 10 Apr 2014 14:16:00 +0000 (16:16 +0200)]
x86/AMD: support further feature masking MSRs

Newer AMD CPUs also allow masking CPUID leaf 6 ECX and CPUID leaf 7
sub-leaf 0 EAX and EBX.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Aravind Gopalakrishnan<aravind.gopalakrishnan@amd.com>
11 years agox86: fix pinned cache attribute handling
Jan Beulich [Thu, 10 Apr 2014 14:07:17 +0000 (16:07 +0200)]
x86: fix pinned cache attribute handling

- make sure UC- is only used for PAT purposes (MTRRs and hence EPT
  don't have this type)
- add order input to "get", and properly handle conflict case (forcing
  an EPT page split)
- properly detect (and refuse) overlaps during "set"
- properly use RCU constructs
- support deleting ranges through a special type input to "set"
- set ignore-PAT flag in epte_get_entry_emt() when "get" succeeds
- set "get" output to ~0 (invalid) rather than 0 (UC) on error (the
  caller shouldn't be looking at it anyway)
- move struct hvm_mem_pinned_cacheattr_range from header to C file
  (used only there)

Note that the code (before and after this change) implies the GFN
ranges passed to the hypercall to be inclusive, which is in contrast
to the sole current user in qemu (all variants). It is not clear to me
at which layer (qemu, libxc, hypervisor) this would best be fixed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agox86/EPT: IOMMU snoop capability should not affect memory type selection
Jan Beulich [Thu, 10 Apr 2014 14:06:09 +0000 (16:06 +0200)]
x86/EPT: IOMMU snoop capability should not affect memory type selection

This capability solely makes a statement on cache coherency guarantees
by the IOMMU. It does specifically not imply any further guarantees
implied by certain memory types (cachability, ordering).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agox86/EPT: split super pages upon mismatching memory types
Jan Beulich [Thu, 10 Apr 2014 14:05:12 +0000 (16:05 +0200)]
x86/EPT: split super pages upon mismatching memory types

... between constituent pages. To indicate such, the page order is
being passed down to the vMTRR routines, with a negative return value
(possible only on order-non-zero pages) indicating such collisions.

Some code redundancy reduction is being done to ept_set_entry() along
the way, allowing the new handling to be centralized to a single place
there.

In order to keep ept_set_entry() fast and simple, the actual splitting
is being deferred to the EPT_MISCONFIG VM exit handler.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agox86/EPT: force re-evaluation of memory type as necessary
Jan Beulich [Thu, 10 Apr 2014 14:01:41 +0000 (16:01 +0200)]
x86/EPT: force re-evaluation of memory type as necessary

The main goal here is to drop the bogus dependency of
epte_get_entry_emt() on d->arch.hvm_domain.params[HVM_PARAM_IDENT_PT].

Any change to state influencing epte_get_entry_emt()'s decision needs
to result in re-calculation. Do this by using the EPT_MISCONFIG VM
exit, storing an invalid memory type into EPT's emt field (leaving the
IOMMU, which doesn't care about memory types, unaffected).

This is being done in a hierarchical manner to keep execution time
down: Initially only the top level directory gets invalidated this way.
Upon access, the involved intermediate page table levels get cleared
back to zero, and the leaf entry gets its field properly set. For 4k
leaves all other entries in the same directory also get processed to
amortize the cost of the extra VM exit (which halved the number of
these VM exits in my testing).

This restoring can result in spurious EPT_MISCONFIG VM exits (since
two vCPU-s may access addresses involving identical page table
structures). Rather than simply returning in such cases (and risking
that such a VM exit results from a real mis-configuration, which
would then result in an endless loop rather than killing the VM), a
per-vCPU flag is being introduced indicating when such a spurious VM
exit might validly happen - if another one occurs right after VM re-
entry, the flag would generally end up being clear, causing the VM
to be killed as before on such VM exits.

Note that putting a reserved memory type value in the EPT structures
isn't formally sanctioned by the specification. Intel isn't willing to
adjust the specification to make this or a similar use of the
EPT_MISCONFIG VM exit formally possible, but they have indicated that
us using this is low risk wrt forward compatibility.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Kevin Tian <kevin.tian@intel.com>
11 years agoChange Xen POWER MANAGEMENT maintainer email
Liu Jinsong [Thu, 10 Apr 2014 13:53:10 +0000 (15:53 +0200)]
Change Xen POWER MANAGEMENT maintainer email

... since Jinsong switched to Alibaba Corp.

Signed-off-by: Liu Jinsong <jinsong.liu@alibaba-inc.com>
11 years agoChange Xen RAS maintainer email
Liu Jinsong [Thu, 10 Apr 2014 13:52:56 +0000 (15:52 +0200)]
Change Xen RAS maintainer email

... since Jinsong switched to Alibaba Corp.

Signed-off-by: Liu Jinsong <jinsong.liu@alibaba-inc.com>
11 years agoxen: arm: rework dom0 initrd and dtb placement
Ian Campbell [Wed, 9 Apr 2014 11:51:16 +0000 (12:51 +0100)]
xen: arm: rework dom0 initrd and dtb placement

This now uses the same decision tree as libxc (which is much easier to test).

The main change is to explicitly handle the placement at 128MB or end of RAM
as two cases, rather than combining with MIN. The effect is the same but the
code is clearer.

Secondly the attempt to place the modules right after the kernel is removed,
since it is redundant with the case where placing them at the end of RAM ends
up abutting the kernel.

Also round the kernel size up to a 2MB boundary.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: use same variables as userspace in dom0 builder place_modules()
Ian Campbell [Wed, 9 Apr 2014 11:51:15 +0000 (12:51 +0100)]
xen: arm: use same variables as userspace in dom0 builder place_modules()

The placement algorithm should be effectively the same and using different
variable names makes my head hurt when I try to compare.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agotools: arm: improve placement of initial modules.
Ian Campbell [Wed, 9 Apr 2014 11:51:14 +0000 (12:51 +0100)]
tools: arm: improve placement of initial modules.

314c9815e2f5 "tools: implement initial ramdisk support for ARM." broke starting
guests with <= 128 MB ram by placing the boot modules (dtb and initrd)
immediately after the kernel in this case, running the risk of them being
overwritten. Instead place the modules at the end of RAM, as the hypervisor
does for dom0.

The hypervisor also falls back to placing things before the kernel as a last
resort before failing, so add that here too.

Tested with the Debian installer initrd and guests of 96MB, 128MB, 256MB and
1GB. All work, also tested with 64MB but the installer doesn't run with so
little RAM (but our placement of the initrd is correct).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agoxen: make sure that likely and unlikely convert the expression to a boolean
Ian Campbell [Mon, 7 Apr 2014 11:07:04 +0000 (12:07 +0100)]
xen: make sure that likely and unlikely convert the expression to a boolean

According to http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
__builtin_expect has the prototype:
    long __builtin_expect (long exp, long c)

If sizeof(exp) > sizeof(long) then this will effectively mask off the top bits
of exp, meaning that the if in "if (unlikey(x))" will see the masked version,
which might be false when true was expected, likely has the same issue.

This is mostly likely to affect x86_32 and arm32 builds.  x86_32 is not
present on 4.3 onwards and a quick grep of current staging shows that all the
existing arm32  uses of both likely and unlikely already pass a boolean. I
noticed this with an as yet unposted patch which did not have this property.

Also the defintion of likely might not have had the expected affect for cases
where a true value > 1 might be passed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Tim Deegan <tim@xen.org>
11 years agobuild: remove Linux kernel build integration.
Ian Campbell [Tue, 8 Apr 2014 15:37:58 +0000 (16:37 +0100)]
build: remove Linux kernel build integration.

We haven't shipped a XenoLinux kernel for more releases than I can remember.
We held onto these because osstest was using them but this is no longer the
case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agodocs: remove xend latex source
Ian Campbell [Wed, 9 Apr 2014 09:55:13 +0000 (10:55 +0100)]
docs: remove xend latex source

AFAICT this hasn't actually been built since 8311d176ea6ff "docs: Remove
outdated LaTex documentation".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agotools/hotplug: Remove network-*
Ian Campbell [Wed, 9 Apr 2014 09:10:53 +0000 (10:10 +0100)]
tools/hotplug: Remove network-*

From 3f2142f0b7a0d600fa8d2d06b5eacf0d52aa5bca Mon Sep 17 00:00:00 2001
From: Ian Campbell <ian.campbell@citrix.com>
Date: Fri, 4 Apr 2014 15:00:12 +0100
Subject: [PATCH v2] tools/hotplug: Remove network-*

These are a xend-ism. Since Xen 4.1 the recommened way to configure networking
has been to use the distro facilities (e.g.
http://wiki.xen.org/wiki/HostConfiguration/Networking)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agodocs: remove stray CONFIG_XENDs and configure option from docs.
Ian Campbell [Wed, 9 Apr 2014 08:26:23 +0000 (09:26 +0100)]
docs: remove stray CONFIG_XENDs and configure option from docs.

These were added by 7dbfc2f8b054 "docs: Honour --{en, dis}able-xend when
building docs" between v1 and the (eventually committed) v2 of 9e8672f1c36d
"tools: remove xend and associated python modules" and were missed when
rebasing for v2.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agolibxl_json: remove extra "break"
Wei Liu [Wed, 9 Apr 2014 13:29:13 +0000 (14:29 +0100)]
libxl_json: remove extra "break"

... otherwise JSON array elements are not freed and memory is leaked.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoMerge branch 'stable/tmem-for-4.5.v2.1' of git://xenbits.xen.org/people/konradwilk...
Jan Beulich [Wed, 9 Apr 2014 14:17:06 +0000 (16:17 +0200)]
Merge branch 'stable/tmem-for-4.5.v2.1' of git://xenbits.xen.org/people/konradwilk/xen into staging

11 years agox86/AMD: feature masking is unavailable on Fam11
Jan Beulich [Wed, 9 Apr 2014 14:13:25 +0000 (16:13 +0200)]
x86/AMD: feature masking is unavailable on Fam11

Reported-by: Aravind Gopalakrishnan<aravind.gopalakrishnan@amd.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agoxen: tmem: tmem_try_to_evict_pgp: fix a lock issue
Bob Liu [Thu, 3 Apr 2014 08:55:04 +0000 (16:55 +0800)]
xen: tmem: tmem_try_to_evict_pgp: fix a lock issue

During xen testing, below failure was triggered if dedup=0.

(XEN) Assertion '!preempt_count()' failed at preempt.c:37
(XEN) ----[ Xen-4.5-unstable  x86_64  debug=y  Not tainted ]----
(XEN) CPU:    51
(XEN) RIP:    e008:[<ffff82d08011bfef>] ASSERT_NOT_IN_ATOMIC+0x22/0x53
(XEN) RFLAGS: 0000000000010286   CONTEXT: hypervisor
(XEN) rax: ffff82d080318d20   rbx: ffff8300681ea000   rcx: 0000000000000001
(XEN) rdx: 00000033bca03300   rsi: ffff8308110da000   rdi: ffff82d080286690
(XEN) rbp: ffff83043cd0ff08   rsp: ffff83043cd0ff08   r8:  ffff8307d2beecb0
(XEN) r9:  000000000000000d   r10: 00000000deadbeef   r11: 0000000000000202
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000005
(XEN) r15: 0000000000000001   cr0: 0000000080050033   cr4: 00000000001526f0
(XEN) cr3: 000000005246d000   cr2: ffff880106123418
(XEN) ds: 0000   es: 0000   fs: 0000   gs: 0000   ss: e010   cs: e008
(XEN) Xen stack trace from rsp=ffff83043cd0ff08:
(XEN)    00007cfbc32f00c7 ffff82d0802258f0 ffff880106123418 ffffea0006156e80
(XEN)    ffff8800d0ab5368 00007faff4c83000 ffff8801bdea33e8 0000000000000002
(XEN)    0000000000000202 00000000deadbeef 0000000000000000 00000000000c3565
(XEN)    fffffffffffffff4 ffffffff810014ca ffffffff81de1000 000000000000c356
(XEN)    00000000deadbeef 0001010000000000 ffffffff810014ca 000000000000e033
(XEN)    0000000000000202 ffff8801bdea3360 000000000000e02b 000000000000beef
(XEN)    000000000000beef 000000000000beef 000000000000beef 0000000000000033
(XEN)    ffff8300681ea000 00000033bca03300 0000000000000000
(XEN) Xen call trace:
(XEN)    [<ffff82d08011bfef>] ASSERT_NOT_IN_ATOMIC+0x22/0x53
(XEN)    [<ffff82d0802258f0>] test_all_events+0x6/0x30

The root cause is there is an wronng
'write_unlock(&pcd_tree_rwlocks[firstbyte])' in function
tmem_try_to_evict_pgp().

Nobody will lock &pcd_tree_rwlocks if dedup=0, but the write_unlock() will be
executed anyway. This was introduced by a git commit
38c433d0c711406778aba1ae183a195da98656f0 ("tmem: add page deduplication with
optional compression or trailing-zero-elimination")

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: remove useless parameter from client and pool flush
Bob Liu [Wed, 12 Feb 2014 14:43:31 +0000 (22:43 +0800)]
tmem: remove useless parameter from client and pool flush

Parameter "destroy" in function client_flush() and pool_flush() is unneeded
because it was always set to 1.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: reorg the shared pool allocate path
Bob Liu [Tue, 28 Jan 2014 04:28:32 +0000 (12:28 +0800)]
tmem: reorg the shared pool allocate path

Reorg the code to make it more readable.
Check the return value of shared_pool_join() and drop a unneeded call to
it. Disable creating a shared & persistant pool in an advance place.

Note that one might be tempted to delay the creation of the pool even
further in the code. That however would break the behavior of the code
- that is if we ended up creating a shared pool and the
'uuid_lo == -1L && uuid_hi == -1L' logic stands  we still need to
create a pool - just not shared type.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: cleanup: refactor function tmemc_shared_pool_auth()
Bob Liu [Tue, 28 Jan 2014 04:28:31 +0000 (12:28 +0800)]
tmem: cleanup: refactor function tmemc_shared_pool_auth()

Make function tmemc_shared_pool_auth() more readable.

Note that the previous check for free being set the first time
'(free == -1)' in the loop is now removed. That is OK because
when we set free the first time ('free = i;') we follow it
immediately with a break to get out of the loop.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: remove unneeded parameters from obj destroy path
Bob Liu [Tue, 28 Jan 2014 04:28:28 +0000 (12:28 +0800)]
tmem: remove unneeded parameters from obj destroy path

Parameters "selective" and "no_rebalance" are meaningless in obj
destroy path, this patch remove them. No place uses
no_rebalance=1. In the obj_destroy path we always call it with
no_balance=0.

Note that this will now free it only if:

   obj->last_client == cli_id

Which is OK - even if we allocate a non-shared pool we set by
default the obj->last_client to TMEM_CLI_ID_NULL so even if
the pool is never used, the pool_flush will take care of removing
those.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: fix the return value of tmemc_set_var()
Bob Liu [Tue, 28 Jan 2014 04:28:30 +0000 (12:28 +0800)]
tmem: fix the return value of tmemc_set_var()

tmemc_set_var() calls tmemc_set_var_one() but without taking its return value,
this patch fix this issue.
Also rename tmemc_set_var_one() to __tmemc_set_var().

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: cleanup: drop global_pool_list
Bob Liu [Tue, 28 Jan 2014 04:28:29 +0000 (12:28 +0800)]
tmem: cleanup: drop global_pool_list

No need to maintain a global pool list, nobody use it.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: drop oneline function client_freeze()
Bob Liu [Tue, 28 Jan 2014 04:28:27 +0000 (12:28 +0800)]
tmem: drop oneline function client_freeze()

Function client_freeze() only set client->frozen = freeze, the caller can do
this work directly.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: cleanup the pgp free path
Bob Liu [Wed, 12 Feb 2014 14:43:24 +0000 (22:43 +0800)]
tmem: cleanup the pgp free path

There are several functions related with pgp free, but their relationships are
not clear enough for understanding. This patch made some cleanup by remove
pgp_delist() and pgp_free_from_inv_list().

The call trace is simple now:
pgp_delist_free()
    > pgp_free()
        > __pgp_free()

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: cleanup: remove unneed parameter from pgp_free()
Bob Liu [Wed, 12 Feb 2014 14:43:23 +0000 (22:43 +0800)]
tmem: cleanup: remove unneed parameter from pgp_free()

The only difference of the "from_delete" parameter in pgp_free() is one line
ASSERT(), this patch moves it the caller to make code more clean.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: cleanup: remove unneed parameter from pgp_delist()
Bob Liu [Tue, 28 Jan 2014 04:28:24 +0000 (12:28 +0800)]
tmem: cleanup: remove unneed parameter from pgp_delist()

The parameter "eph_lock" is only needed for function tmem_evict(). Embeded the
delist code into tmem_evict() directly so as to drop the eph_lock parameter. By
this change, the eph list lock can also be released a bit earier.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[v2: A fix for an assertion of 'client->eph_count >= 0' was rolled in]

11 years agotmem: bugfix in obj allocate path
Bob Liu [Tue, 28 Jan 2014 04:28:23 +0000 (12:28 +0800)]
tmem: bugfix in obj allocate path

There is a potential bug in the obj allocate path. When there are parallel
callers allocate a obj and insert it to pool->obj_rb_root, an unexpected
obj might be returned (both callers use the same oid).

Caller A:                            Caller B:

obj_find(oidp) == NULL               obj_find(oidp) == NULL

write_lock(&pool->pool_rwlock)
obj_new():
    objA = tmem_malloc()
    obj_rb_insert(objA)
wirte_unlock()
                                     write_lock(&pool->pool_rwlock)
                                     obj_new():
                                        objB = tmem_malloc()
                                        obj_rb_insert(objB)
                                     write_unlock()

Continue write data to objA
But in future obj_find(), objB
will always be returned.

The route cause is the allocate path didn't check the return value of
obj_rb_insert(). This patch fix it and replace obj_new() with better name
obj_alloc().

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agox86: move PIRQ EOI map fields to arch_domain
Roger Pau Monné [Wed, 9 Apr 2014 10:18:10 +0000 (12:18 +0200)]
x86: move PIRQ EOI map fields to arch_domain

This is done so PVH guests can use PHYSDEVOP_pirq_eoi_gmfn_v{1/2}.
Update users of this fields, to reflect that this has been moved and
it is now also available to other kind of guests.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Move auto_unmask ahead of the other two fields, to reduce padding.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
11 years agoxentrace: add TRC_HVM_EMUL
Don Slutz [Wed, 9 Apr 2014 10:16:00 +0000 (12:16 +0200)]
xentrace: add TRC_HVM_EMUL

This add a set of trace events that track the setup of various
emulated devices related to timers in domU.

This set is hpet, pit (i8253, i8254), rtc (MC146818), apic (lapic),
and pic (i8259).  The pmtimer is not traced since it does not have a
changeable rate.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
11 years agox86/HVM: add emacs local variables to a couple of files
Don Slutz [Wed, 9 Apr 2014 10:15:35 +0000 (12:15 +0200)]
x86/HVM: add emacs local variables to a couple of files

This is per CODING_STYLE.

Signed-off-by: Don Slutz <dslutz@verizon.com>
11 years agoxen/arm32: __cmpxchg_mb should be marked always_inline
Julien Grall [Thu, 3 Apr 2014 17:09:10 +0000 (18:09 +0100)]
xen/arm32: __cmpxchg_mb should be marked always_inline

Currently __cmpxchg_mb is only marked inline. The compiler can decide to not
inline this function. In this case, the call to __cmpxchg will be inlined
but not optimised. This will result linking failure because of __bad_cmpxchg.

Caught by clang 3.5.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoMerge branch 'xend-delete-v2' of git://xenbits.xen.org/people/ianc/xen into staging
Ian Campbell [Tue, 8 Apr 2014 14:49:52 +0000 (15:49 +0100)]
Merge branch 'xend-delete-v2' of git://xenbits.xen.org/people/ianc/xen into staging

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agotools: implement initial ramdisk support for ARM.
Ian Campbell [Fri, 4 Apr 2014 13:28:45 +0000 (14:28 +0100)]
tools: implement initial ramdisk support for ARM.

The ramdisk is passed to the kernel as a property in the chosen node of the
device tree. This is somewhat tricky since in order to place the ramdisk and
dtb in ram we first need to know the size of the dtb. So we initially create a
DTB with placeholders for the ramdisk and finalise the value (which doesn't
change the size) once we know where everything is.

Rename libxl__arch_domain_configure to xl__arch_domain_init_hw_description to
better reflect its use and to be consistent with the new
libxl__arch_domain_finalise_hw_description.

The common xc_dom_build_image() function did not support explicit placement of
the ramdisk, instead passing 0 to xc_dom_alloc_segment, meaning "pick
somewhere". This change instead passes ramdisk_seg.vstart. If nothing has set
vstart then it will be zero because the entire dom struct is zeroed on
allocation in xc_dom_allocate(). Therefore there is no change to the behaviour
on x86. This is also consistent with how other segments (kernel, dtb) are
handled.

Furthermore if the ramdisk has been explicitly placed then xc_dom_build_image()
assumes that it is not to be decompressed (since that would muck up the sizings
used on placement).

With all that I'm able to boot a domain using the current Debian Jessie armhf
installer initrd and have it complete successfully.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
[ ijc -- s/itherwise/otherwise and dropped bogus emacs magic change ]

11 years agolibxc: X86: expose RDSEED, ADX, and PREFETCHW to pv/hvm
Liu Jinsong [Thu, 13 Feb 2014 13:05:01 +0000 (21:05 +0800)]
libxc: X86: expose RDSEED, ADX, and PREFETCHW to pv/hvm

Intel recently released some new features, including RDSEED, ADX, and
PREFETCHW.  This patch exposes these new features to pv and hvm.

Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: Set guest parameters from config file during a restore
Boris Ostrovsky [Tue, 1 Apr 2014 15:53:57 +0000 (11:53 -0400)]
libxl: Set guest parameters from config file during a restore

Guest's configuration parameters (e.g. timer_mode) are used by the hypervisor
during runtime. We should therefore set them during restore.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Remove GIC definitions in asm-arm/config.h
Julien Grall [Wed, 2 Apr 2014 14:13:36 +0000 (15:13 +0100)]
xen/arm: Remove GIC definitions in asm-arm/config.h

The GIC is not used anymore in assembly code.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotmem: cleanup: drop unneeded client/pool initialization
Bob Liu [Tue, 28 Jan 2014 04:28:22 +0000 (12:28 +0800)]
tmem: cleanup: drop unneeded client/pool initialization

Using xzalloc to alloc client and pool, so some extra initialization
are dropped.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: remove pageshift from struct tmem_pool
Bob Liu [Tue, 28 Jan 2014 04:28:20 +0000 (12:28 +0800)]
tmem: remove pageshift from struct tmem_pool

Pagesize is always the same as PAGE_SIZE in tmem, so remove pageshift from
struct tmem_pool and use POOL_PAGESHIFT and PAGE_SIZE directly.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: refactor function do_tmem_op()
Bob Liu [Wed, 12 Feb 2014 14:43:19 +0000 (22:43 +0800)]
tmem: refactor function do_tmem_op()

Refactor function do_tmem_op() to make it more readable.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[v2: Fixed up tab vs spaces, also removed dead code and added gulped code]

11 years agoatomic: use static inlines instead of macros
Andrew Cooper [Tue, 8 Apr 2014 10:39:23 +0000 (12:39 +0200)]
atomic: use static inlines instead of macros

This is some coverity-inspired tidying.

Coverity has some grief analysing the call sites of atomic_read().  This is
believed to be a bug in Coverity itself when expanding the nested macros, but
there is no legitimate reason for it to be a macro in the first place.

This patch changes {,_}atomic_{read,set}() from being macros to being static
inline functions, thus gaining some type safety.

One issue which is not immediately obvious is that the non-atomic variants take
their atomic_t at a different level of indirection to the atomic variants.

This is not suitable for _atomic_set() (when used to initialise an atomic_t)
which is converted to take its parameter as a pointer.  One callsite of
_atomic_set() is updated, while the other two callsites are updated to
ATOMIC_INIT().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan<tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
[For the arm bits:]
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotmem: remove dumb check in do_tmem_destroy_pool
Julien Grall [Fri, 4 Apr 2014 09:13:32 +0000 (11:13 +0200)]
tmem: remove dumb check in do_tmem_destroy_pool

do_tmem_destroy_pool is checking if pools == NULL. But, pools is a fixed
array.

Clang 3.5 will fail to compile xen/common/tmem.c with the following error:
tmem.c:1848:18: error: comparison of array 'client->pools' equal to a null
pointer is always false [-Werror,-Wtautological-pointer-compare]
    if ( client->pools == NULL )

Coverity-ID:1055632

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: propagate ENOMEM result in error handling
Matthew Daley [Fri, 4 Apr 2014 09:08:24 +0000 (11:08 +0200)]
tmem: propagate ENOMEM result in error handling

...otherwise if pcd_associate fails due to out-of-memory, the caller of
do_tmem_put will think the call was successful.

While at it, fix up the style issue.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Reviewed-by: Bob Liu <bob.liu@oracle.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agotmem: Some functions are only used internally
Julien Grall [Fri, 4 Apr 2014 09:07:04 +0000 (11:07 +0200)]
tmem: Some functions are only used internally

The list of function above are only used internally in common/tmem:
    - oid_compare
    - oid_set_invalid
    - oid_hash

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agoxenctx: Fix print_ctx_32on64's print_special call.
Don Slutz [Thu, 3 Apr 2014 19:07:09 +0000 (15:07 -0400)]
xenctx: Fix print_ctx_32on64's print_special call.

print_special() uses the width argument to both select output format
and array size.  So by passing 4 it expects an array of uint32_t.
But an array of uint64_t is passed.

So copy and mask the registers to 32 bits.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add 16 bit output
Don Slutz [Thu, 3 Apr 2014 19:07:08 +0000 (15:07 -0400)]
xenctx: Add 16 bit output

This output happens on !guest_protected_mode.  The cpu is in 16 bit
mode in this case.

For example:

$ xenctx 4
cs:eip: f000:0000d61b
flags: 00000002 nz
ss:esp: 0000:00001fee
eax: 0000ffc2   ebx: 00000049   ecx: 00000049   edx: ffffffff
esi: 00000000   edi: 00000010   ebp: 00001ff0
 ds:     e000    es:     0040    fs:     0000    gs:     0000
Code (instr addr 000fd61b)
04 67 66 8b 70 08 67 66 8b 68 0c 67 66 8b 58 10 67 66 8b 50 14 <67> 66 8b 48 18 67 8e 40 02 67 ff

Stack:
 8e30 0000 0246 812f 0000 0206 80e7 0080 0080

$ xenctx 4 -d 0x00001fee -m 0x00001fee -l 1
Memory (address 1fee):
 8e30 0000 0246 812f 0000 0206 80e7 0080 0080 c2c2 c2c2 c2c2 c2c2 c2c2 c2c2 c2c2

Stack:
 8e30 0000 0246 812f 0000 0206 80e7 0080 0080

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Fix handling of !guest_protected_mode
Don Slutz [Thu, 3 Apr 2014 19:07:07 +0000 (15:07 -0400)]
xenctx: Fix handling of !guest_protected_mode

Start with adding the code to the 64 bit path that the 32 bit path
has.

Next disable the "Stack Trace" or "Call Trace".

Finally allow stack dump.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add output of vcpu value and state for --all-vcpus
Don Slutz [Thu, 3 Apr 2014 19:07:06 +0000 (15:07 -0400)]
xenctx: Add output of vcpu value and state for --all-vcpus

This makes it easier to know which vcpu the registers belong to and
when not all vcpus are online, which vcpu it is.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add conversion of more registers to symbols
Don Slutz [Thu, 3 Apr 2014 19:07:05 +0000 (15:07 -0400)]
xenctx: Add conversion of more registers to symbols

For example can change:
 gs: 0000 @ ffffffff803ac000/0000000000000000
to
 gs: 0000 @ ffffffff803ac000/0000000000000000 boot_cpu_pda/

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: change is_kernel_text() into kernel_addr().
Don Slutz [Thu, 3 Apr 2014 19:07:04 +0000 (15:07 -0400)]
xenctx: change is_kernel_text() into kernel_addr().

A new enum has been added to allow the caller to determine if this
kernel address is a text or data address.  This is currenlty not
used, but will be in the next patch.

Add both _end and __bss_stop as kernel_end.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add -d (--dump-as-stack) <daddr> option to dump memory at daddr as a stack.
Don Slutz [Thu, 3 Apr 2014 19:07:03 +0000 (15:07 -0400)]
xenctx: Add -d (--dump-as-stack) <daddr> option to dump memory at daddr as a stack.

Also switch from read_stack_word to read_mem_word since the provided
address may not be aligned.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified.
Don Slutz [Thu, 3 Apr 2014 19:07:02 +0000 (15:07 -0400)]
xenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified.

To do this correctly the program name must be remembered since argv
is adjusted at the end of option parsing.

Switch all uses of argv[0] to prog.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add -m (--memory) <maddr> option to dump memory at maddr.
Don Slutz [Thu, 3 Apr 2014 19:07:01 +0000 (15:07 -0400)]
xenctx: Add -m (--memory) <maddr> option to dump memory at maddr.

Currently not supported on ARM.

New routine read_mem_word() will correctly read a word that crosses
a page boundary.  It will not fault if the 2nd page can not be
mapped.

Moved xenctx because guest_word_t is not defined where it was.

Here is an example:

Memory (address ffffffff803ddf90):
 ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800
 0000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c
 00000000ffffffff 0000000000000000 0000000000000000 0000000000200000
 0000000000000000 0000000000000000 0000000000000000 00cf9b000000ffff
 00af9b000000ffff 00cf93000000ffff 00cffb000000ffff 00cff3000000ffff

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>