]> xenbits.xensource.com Git - xen.git/log
xen.git
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>
11 years agoxenctx: Add output of stack address to Call and Stack Trace.
Don Slutz [Thu, 3 Apr 2014 19:07:00 +0000 (15:07 -0400)]
xenctx: Add output of stack address to Call and Stack Trace.

Here is an example:

Call Trace:
                   [<ffffffff8006b2b0>] default_idle+0x29 <--
ffffffff803ddf90:  [<ffffffff80048d19>] cpu_idle+0x95
ffffffff803ddfa0:  [<ffffffff803e7801>] start_kernel+0x220
ffffffff803ddfc0:  [<ffffffff803e722f>] x86_64_start_kernel+0x22f

and

Stack Trace:
                 * [<ffffffff8006b2b0>] default_idle+0x29 <--
ffffffff803ddf90:  [<ffffffff80048d19>] cpu_idle+0x95
ffffffff803ddf98:    0000000000200800
ffffffff803ddfa0:  [<ffffffff803e7801>] start_kernel+0x220
ffffffff803ddfa8:    0000000000086800
ffffffff803ddfb0:    0000000000000000
ffffffff803ddfb8:    ffffffff80430720
ffffffff803ddfc0:  [<ffffffff803e722f>] x86_64_start_kernel+0x22f
ffffffff803ddfc8:    80008e000010019c
ffffffff803ddfd0:    00000000ffffffff
ffffffff803ddfd8:    0000000000000000
ffffffff803ddfe0:    0000000000000000
ffffffff803ddfe8:    0000000000200000
ffffffff803ddff0:    0000000000000000
ffffffff803ddff8:    0000000000000000

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: More info on failed to map page.
Don Slutz [Thu, 3 Apr 2014 19:06:59 +0000 (15:06 -0400)]
xenctx: More info on failed to map page.

Also output an extra new line since we may be in the middle of output.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
11 years agoxenctx: Change print_symbol to do the space before.
Don Slutz [Thu, 3 Apr 2014 19:06:58 +0000 (15:06 -0400)]
xenctx: Change print_symbol to do the space before.

This stops the output of an extra space at the end of the line.

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
11 years agoxenctx: Add command line option -t (--tag-stack-dump)
Don Slutz [Thu, 3 Apr 2014 19:06:57 +0000 (15:06 -0400)]
xenctx: Add command line option -t (--tag-stack-dump)

If specified, add stack address to dump.

This is not the default because the result exceeds 80 characters per line.

Here is an example:

Stack:
ffffffff803ddf90ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800
ffffffff803ddfb00000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c
ffffffff803ddfd000000000ffffffff 0000000000000000 0000000000000000 0000000000200000
ffffffff803ddff00000000000000000 0000000000000000

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add command line option -D (--decode-as-ascii)
Don Slutz [Thu, 3 Apr 2014 19:06:56 +0000 (15:06 -0400)]
xenctx: Add command line option -D (--decode-as-ascii)

If specified, output ascii version of stack also.

This is not the default because the result exceeds 80 characters per line.

Here is an example:

Stack:
 ffffffff80048d19 0000000000200800 ffffffff803e7801 0000000000086800  .......... ......x>......h......
 0000000000000000 ffffffff80430720 ffffffff803e722f 80008e000010019c  ........ .C...../r>.............
 00000000ffffffff 0000000000000000 0000000000000000 0000000000200000  .......................... .....
 0000000000000000 0000000000000000                                    ................

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add command line options -b (--bytes-per-line) and -l (--lines)
Don Slutz [Thu, 3 Apr 2014 19:06:55 +0000 (15:06 -0400)]
xenctx: Add command line options -b (--bytes-per-line) and -l (--lines)

  -b <bytes>, --bytes-per-line <bytes>
                     change the number of bytes per line output for Stack.
                     (default 32) Note: rounded to native size (4 or 8 bytes).

This option allows you to change the width of the output line.  When
used with the -D option and/or -t, the output can be adjusted with
this to less then 80 columns.

  -l <lines>, --lines <lines>
                     change the number of lines output for Stack. (default 5)
                     Can be specified as MAX.  Note: Fewer lines will be output
                     if stack limit reached.

The default value show a reasonable amount of the raw stack.  The -S
option will output all of it one line at a time.  This can be used
to select something in the middle.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Add -n (--display-stack-pages) option to output larger stack
Don Slutz [Thu, 3 Apr 2014 19:06:54 +0000 (15:06 -0400)]
xenctx: Add -n (--display-stack-pages) option to output larger stack

Important: This is the stack size (also known as stack limit) to
display, not the configured stack size.

Note: use with caution (easy to get garbage).

Below is a pictures of a downwards growing configured 3 page stack,
and where the SP currently is.  Each box is a page.

+ pages                     -n 1    -n 2    -n 3

End of Memory
       +------------------+
       |                  |
       |                  |
       |                  |
       |                  |
       |                  |
       +------------------+
...
       +------------------+
       |                  |
       |                  |
       |                  |
       |                  |
MAX+3  |                  |
       +------------------+                   *
       |                  |                   |
       |                  |                   |
       |                  |                   |
       |                  |                   |
MAX+2  |                  |                   |
       +------------------+           *       |
       |                  |           |       |
       |                  |           |       |
       |                  |           |       |
       |                  |           |       |
MAX+1  |                  |           |       |
       +------------------+   *       |       |
       |                  |   |       |       |
SP --> |                  |   *       *       *
       |                  |
       |                  |
MAX    |                  |
       +------------------+
...
       +------------------+
       |                  |
       |                  |
       |                  |
       |                  |
0      |                  |
       +------------------+

Display using "-n 3" since the used stack pages is 3.

At a different time, the SP may be in the 1st page and so "-n 3"
will display garbage.

For example:

$ xenctx -s /boot/System.map-2.6.32-279.2.1.el6.x86_64 3 1 -n 1
...
Call Trace:
                    [<ffffffff81346898>] io_serial_out+0x18 <--
ffff880032bb1310:   [<ffffffff81346f51>] serial8250_console_putchar+0x31
ffff880032bb1330:   [<ffffffff813428de>] uart_console_write+0x3e
ffff880032bb1338:   [<ffffffff8100bc0e>] apic_timer_interrupt+0xe
ffff880032bb1370:   [<ffffffff813472ad>] serial8250_console_write+0xbd
ffff880032bb13c0:   [<ffffffff8106b8f5>] __call_console_drivers+0x75
ffff880032bb13f0:   [<ffffffff8106b95a>] _call_console_drivers+0x4a
ffff880032bb1410:   [<ffffffff8106be6e>] release_console_sem+0x4e
ffff880032bb1450:   [<ffffffff8106c628>] vprintk+0x248
ffff880032bb14f0:   [<ffffffff814fd363>] printk+0x41

$ xenctx -s /boot/System.map-2.6.32-279.2.1.el6.x86_64 3 1 -n 2
...
Call Trace:
                    [<ffffffff81346898>] io_serial_out+0x18 <--
ffff880032bb1310:   [<ffffffff81346f51>] serial8250_console_putchar+0x31
ffff880032bb1330:   [<ffffffff813428de>] uart_console_write+0x3e
ffff880032bb1338:   [<ffffffff8100bc0e>] apic_timer_interrupt+0xe
ffff880032bb1370:   [<ffffffff813472ad>] serial8250_console_write+0xbd
ffff880032bb13c0:   [<ffffffff8106b8f5>] __call_console_drivers+0x75
ffff880032bb13f0:   [<ffffffff8106b95a>] _call_console_drivers+0x4a
ffff880032bb1410:   [<ffffffff8106be6e>] release_console_sem+0x4e
ffff880032bb1450:   [<ffffffff8106c628>] vprintk+0x248
ffff880032bb14f0:   [<ffffffff814fd363>] printk+0x41

$ xenctx -s /boot/System.map-2.6.32-279.2.1.el6.x86_64 3 1 -n 3
...
Call Trace:
                    [<ffffffff81346898>] io_serial_out+0x18 <--
ffff880032bb1310:   [<ffffffff81346f51>] serial8250_console_putchar+0x31
ffff880032bb1330:   [<ffffffff813428de>] uart_console_write+0x3e
ffff880032bb1338:   [<ffffffff8100bc0e>] apic_timer_interrupt+0xe
ffff880032bb1370:   [<ffffffff813472ad>] serial8250_console_write+0xbd
ffff880032bb13c0:   [<ffffffff8106b8f5>] __call_console_drivers+0x75
ffff880032bb13f0:   [<ffffffff8106b95a>] _call_console_drivers+0x4a
ffff880032bb1410:   [<ffffffff8106be6e>] release_console_sem+0x4e
ffff880032bb1450:   [<ffffffff8106c628>] vprintk+0x248
ffff880032bb14f0:   [<ffffffff814fd363>] printk+0x41
ffff880032bb3f20:   [<ffffffff8100204c>] do_one_initcall+0x3c
ffff880032bb3f50:   [<ffffffff810b0eb1>] sys_init_module+0xe1
ffff880032bb3f80:   [<ffffffff8100b0f2>] system_call_fastpath+0x16

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Clean up stack trace when hypercall_page not in symbol table
Don Slutz [Thu, 3 Apr 2014 19:06:53 +0000 (15:06 -0400)]
xenctx: Clean up stack trace when hypercall_page not in symbol table

Before:

Call Trace:
  [<ffffffff8006b2b0>] default_idle+0x29  <--
  [<ffffffff80048d19>] cpu_idle+0x95
  [<ffffffff803e7801>] start_kernel+0x220
  [<0000000000000000>] startup_64+0x80000000
  [<ffffffff803e722f>] x86_64_start_kernel+0x22f
  [<0000000000000000>] startup_64+0x80000000
  [<0000000000000000>] startup_64+0x80000000
  [<0000000000000000>] startup_64+0x80000000
  [<0000000000000000>] startup_64+0x80000000

After:

Call Trace:
  [<ffffffff8006b2b0>] default_idle+0x29  <--
  [<ffffffff80048d19>] cpu_idle+0x95
  [<ffffffff803e7801>] start_kernel+0x220
  [<ffffffff803e722f>] x86_64_start_kernel+0x22f

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
11 years agoxenctx: clean up usage output
Don Slutz [Thu, 3 Apr 2014 19:06:52 +0000 (15:06 -0400)]
xenctx: clean up usage output

Fix usage formatting to be all the same.

Fix usage display of default --kernel-start for 64 bit.

Signed-off-by: Don Slutz <dslutz@verizon.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenctx: Correct FMT_??B_WORD for arm64.
Ian Campbell [Thu, 3 Apr 2014 19:06:51 +0000 (15:06 -0400)]
xenctx: Correct FMT_??B_WORD for arm64.

These should all be unsigned long long to match various variables used
in the code, same as x86_64.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Don Slutz <dslutz@verizon.com>
11 years agoRevert "Revert "xen/arm: Allocate memory for dom0 from the bottom with the 1:1 Workar...
Ian Campbell [Thu, 3 Apr 2014 16:54:34 +0000 (17:54 +0100)]
Revert "Revert "xen/arm: Allocate memory for dom0 from the bottom with the 1:1 Workaround""

This reverts commit 1be5c1947fd52f5faaf6b678a829d47b0ec88bfd, effectively
reinstating 6c21cb36e263de2db8716b477157a5b6cd531e1e.

Without this booting dom0 on systems with >4GB of RAM is broken because the
guest gets allocated a memory range which it cannot access.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools: drop libxen
Ian Campbell [Thu, 27 Mar 2014 11:01:50 +0000 (11:01 +0000)]
tools: drop libxen

This was a C interface to a very early version of the XenAPI, it has not kept
up with developments to the API e.g. in xapi.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
11 years agotools: remove xend and associated python modules
Ian Campbell [Thu, 12 Sep 2013 09:21:25 +0000 (10:21 +0100)]
tools: remove xend and associated python modules

I've retained xen.lowlevel.{xc,xs} since they seem more widely useful. I also
kept xen.lowlevel.xl even though it is disabled by default and IMHO useless in
its current form.

I've tried to clean up the various associated bits like example configs, init
scripts, udev rules etc but no doubt I have missed something, those can easily
be cleaned up later.

I've also removed xm-test since although it could in theory be reworked to
test xl it hasn't been touched for years. If someone wants to resurrect it
then they could do so via the git history.

This has been built but not runtime tested.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
v2: Clean out some .*ignore cruft
    Remove some xm/xend docs.

11 years agoxen: arm: document what low level primitives we have imported from Linux
Ian Campbell [Wed, 26 Mar 2014 13:38:52 +0000 (13:38 +0000)]
xen: arm: document what low level primitives we have imported from Linux

As part of the recent update I had to reverse engineer what we had, which was
very tedious. Check in my notes so that I have a reference for next time.

Now the secret is to remember to update this file every time!

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: refactor xchg and cmpxchg into their own headers
Ian Campbell [Wed, 26 Mar 2014 13:38:51 +0000 (13:38 +0000)]
xen: arm: refactor xchg and cmpxchg into their own headers

Since these functions are taken from Linux this makes it easier to compare
against the Lihnux cmpxchg.h headers (which were split out from Linux's
system.h a while back).

Since these functions are from Linux the intention is to use Linux coding
style, therefore include a suitable emacs magic block.

For this reason also fix up the indentation in the 32-bit version to use hard
tabs while moving it. The 64-bit version was already correct.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm64: optimised clear_page
Ian Campbell [Wed, 19 Mar 2014 17:19:56 +0000 (17:19 +0000)]
xen: arm64: optimised clear_page

Taken from Linux v3.14-rc7.

The clear_page header now needs to be within the !__ASSEMBLY__

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm64: assembly optimised mem* and str*
Ian Campbell [Wed, 26 Mar 2014 13:38:49 +0000 (13:38 +0000)]
xen: arm64: assembly optimised mem* and str*

Taken from Linux v3.14-rc7.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm64: asm: remove redundant "cc" clobbers
Ian Campbell [Wed, 26 Mar 2014 13:38:48 +0000 (13:38 +0000)]
xen: arm64: asm: remove redundant "cc" clobbers

This resyncs atomics and cmpxchgs with Linux v3.14-rc7 by importing:
commit 95c4189689f92fba7ecf9097173404d4928c6e9b
Author: Will Deacon <will.deacon@arm.com>
Date:   Tue Feb 4 12:29:13 2014 +0000

    arm64: asm: remove redundant "cc" clobbers

    cbnz/tbnz don't update the condition flags, so remove the "cc" clobbers
    from inline asm blocks that only use these instructions to implement
    conditional branches.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm64: reinstate hard tabs in system.h cmpxchg
Ian Campbell [Wed, 26 Mar 2014 13:38:47 +0000 (13:38 +0000)]
xen: arm64: reinstate hard tabs in system.h cmpxchg

These functions are from Linux and the intention was to keep the formatting
the same to make resyncing easier.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm64: atomics: fix use of acquire + release for full barrier semantics
Ian Campbell [Wed, 26 Mar 2014 13:38:46 +0000 (13:38 +0000)]
xen: arm64: atomics: fix use of acquire + release for full barrier semantics

Xen, like Linux, expects full barrier semantics for bitops, atomics and
cmpxchgs. This issue was discovered on Linux and we get our implementation of
these from Linux so quoting Will Deacon in Linux commit 8e86f0b409a4 for the
gory details:
    Linux requires a number of atomic operations to provide full barrier
    semantics, that is no memory accesses after the operation can be
    observed before any accesses up to and including the operation in
    program order.

    On arm64, these operations have been incorrectly implemented as follows:

        // A, B, C are independent memory locations

        <Access [A]>

        // atomic_op (B)
    1:  ldaxr   x0, [B]         // Exclusive load with acquire
        <op(B)>
        stlxr   w1, x0, [B]     // Exclusive store with release
        cbnz    w1, 1b

        <Access [C]>

    The assumption here being that two half barriers are equivalent to a
    full barrier, so the only permitted ordering would be A -> B -> C
    (where B is the atomic operation involving both a load and a store).

    Unfortunately, this is not the case by the letter of the architecture
    and, in fact, the accesses to A and C are permitted to pass their
    nearest half barrier resulting in orderings such as Bl -> A -> C -> Bs
    or Bl -> C -> A -> Bs (where Bl is the load-acquire on B and Bs is the
    store-release on B). This is a clear violation of the full barrier
    requirement.

    The simple way to fix this is to implement the same algorithm as ARMv7
    using explicit barriers:

        <Access [A]>

        // atomic_op (B)
        dmb     ish             // Full barrier
    1:  ldxr    x0, [B]         // Exclusive load
        <op(B)>
        stxr    w1, x0, [B]     // Exclusive store
        cbnz    w1, 1b
        dmb     ish             // Full barrier

        <Access [C]>

    but this has the undesirable effect of introducing *two* full barrier
    instructions. A better approach is actually the following, non-intuitive
    sequence:

        <Access [A]>

        // atomic_op (B)
    1:  ldxr    x0, [B]         // Exclusive load
        <op(B)>
        stlxr   w1, x0, [B]     // Exclusive store with release
        cbnz    w1, 1b
        dmb     ish             // Full barrier

        <Access [C]>

    The simple observations here are:

      - The dmb ensures that no subsequent accesses (e.g. the access to C)
        can enter or pass the atomic sequence.

      - The dmb also ensures that no prior accesses (e.g. the access to A)
        can pass the atomic sequence.

      - Therefore, no prior access can pass a subsequent access, or
        vice-versa (i.e. A is strictly ordered before C).

      - The stlxr ensures that no prior access can pass the store component
        of the atomic operation.

    The only tricky part remaining is the ordering between the ldxr and the
    access to A, since the absence of the first dmb means that we're now
    permitting re-ordering between the ldxr and any prior accesses.

    From an (arbitrary) observer's point of view, there are two scenarios:

      1. We have observed the ldxr. This means that if we perform a store to
         [B], the ldxr will still return older data. If we can observe the
         ldxr, then we can potentially observe the permitted re-ordering
         with the access to A, which is clearly an issue when compared to
         the dmb variant of the code. Thankfully, the exclusive monitor will
         save us here since it will be cleared as a result of the store and
         the ldxr will retry. Notice that any use of a later memory
         observation to imply observation of the ldxr will also imply
         observation of the access to A, since the stlxr/dmb ensure strict
         ordering.

      2. We have not observed the ldxr. This means we can perform a store
         and influence the later ldxr. However, that doesn't actually tell
         us anything about the access to [A], so we've not lost anything
         here either when compared to the dmb variant.

    This patch implements this solution for our barriered atomic operations,
    ensuring that we satisfy the full barrier requirements where they are
    needed.

Cc: <stable@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm64: disable alignment traps
Ian Campbell [Wed, 26 Mar 2014 13:38:45 +0000 (13:38 +0000)]
xen: arm64: disable alignment traps

The mem* primitives which I am about to import from Linux in a subsequent
patch rely on the hardware handling misalignment.

The benefits of an optimised memcpy etc outweigh the downsides.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: remove atomic_clear_mask()
Ian Campbell [Wed, 26 Mar 2014 13:38:44 +0000 (13:38 +0000)]
xen: arm: remove atomic_clear_mask()

This has no users.

This brings arm32 atomic.h into sync with Linux v3.14-rc7.

arm64/atomic.h requires other patches for this to be the case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm32: add optimised strchr and strrchr routines
Ian Campbell [Wed, 26 Mar 2014 13:38:43 +0000 (13:38 +0000)]
xen: arm32: add optimised strchr and strrchr routines

Taken from Linux v3.14-rc7.

These aren't widely used enough to be critical, but we may as well have them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm32: add optimised memchr routine
Ian Campbell [Wed, 26 Mar 2014 13:38:42 +0000 (13:38 +0000)]
xen: arm32: add optimised memchr routine

This isn't used enough to be critical, but it completes the set of mem*.

Taken from Linux v3.14-rc7.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm32: resync mem* with Linux v3.14-rc7
Ian Campbell [Wed, 26 Mar 2014 13:38:41 +0000 (13:38 +0000)]
xen: arm32: resync mem* with Linux v3.14-rc7

This pulls in the following Linux commits:
commit 455bd4c430b0c0a361f38e8658a0d6cb469942b5
Author: Ivan Djelic <ivan.djelic@parrot.com>
Date:   Wed Mar 6 20:09:27 2013 +0100

    ARM: 7668/1: fix memset-related crashes caused by recent GCC (4.7.2) optimi

    Recent GCC versions (e.g. GCC-4.7.2) perform optimizations based on
    assumptions about the implementation of memset and similar functions.
    The current ARM optimized memset code does not return the value of
    its first argument, as is usually expected from standard implementations.

    For instance in the following function:

    void debug_mutex_lock_common(struct mutex *lock, struct mutex_waiter *waite
    {
        memset(waiter, MUTEX_DEBUG_INIT, sizeof(*waiter));
        waiter->magic = waiter;
        INIT_LIST_HEAD(&waiter->list);
    }

    compiled as:

    800554d0 <debug_mutex_lock_common>:
    800554d0:       e92d4008        push    {r3, lr}
    800554d4:       e1a00001        mov     r0, r1
    800554d8:       e3a02010        mov     r2, #16 ; 0x10
    800554dc:       e3a01011        mov     r1, #17 ; 0x11
    800554e0:       eb04426e        bl      80165ea0 <memset>
    800554e4:       e1a03000        mov     r3, r0
    800554e8:       e583000c        str     r0, [r3, #12]
    800554ec:       e5830000        str     r0, [r3]
    800554f0:       e5830004        str     r0, [r3, #4]
    800554f4:       e8bd8008        pop     {r3, pc}

    GCC assumes memset returns the value of pointer 'waiter' in register r0; ca
    register/memory corruptions.

    This patch fixes the return value of the assembly version of memset.
    It adds a 'mov' instruction and merges an additional load+store into
    existing load/store instructions.
    For ease of review, here is a breakdown of the patch into 4 simple steps:

    Step 1
    ======
    Perform the following substitutions:
    ip -> r8, then
    r0 -> ip,
    and insert 'mov ip, r0' as the first statement of the function.
    At this point, we have a memset() implementation returning the proper resul
    but corrupting r8 on some paths (the ones that were using ip).

    Step 2
    ======
    Make sure r8 is saved and restored when (! CALGN(1)+0) == 1:

    save r8:
    -       str     lr, [sp, #-4]!
    +       stmfd   sp!, {r8, lr}

    and restore r8 on both exit paths:
    -       ldmeqfd sp!, {pc}               @ Now <64 bytes to go.
    +       ldmeqfd sp!, {r8, pc}           @ Now <64 bytes to go.
    (...)
            tst     r2, #16
            stmneia ip!, {r1, r3, r8, lr}
    -       ldr     lr, [sp], #4
    +       ldmfd   sp!, {r8, lr}

    Step 3
    ======
    Make sure r8 is saved and restored when (! CALGN(1)+0) == 0:

    save r8:
    -       stmfd   sp!, {r4-r7, lr}
    +       stmfd   sp!, {r4-r8, lr}

    and restore r8 on both exit paths:
            bgt     3b
    -       ldmeqfd sp!, {r4-r7, pc}
    +       ldmeqfd sp!, {r4-r8, pc}
    (...)
            tst     r2, #16
            stmneia ip!, {r4-r7}
    -       ldmfd   sp!, {r4-r7, lr}
    +       ldmfd   sp!, {r4-r8, lr}

    Step 4
    ======
    Rewrite register list "r4-r7, r8" as "r4-r8".

Signed-off-by: Ivan Djelic <ivan.djelic@parrot.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
commit 418df63adac56841ef6b0f1fcf435bc64d4ed177
Author: Nicolas Pitre <nicolas.pitre@linaro.org>
Date:   Tue Mar 12 13:00:42 2013 +0100

    ARM: 7670/1: fix the memset fix

    Commit 455bd4c430b0 ("ARM: 7668/1: fix memset-related crashes caused by
    recent GCC (4.7.2) optimizations") attempted to fix a compliance issue
    with the memset return value.  However the memset itself became broken
    by that patch for misaligned pointers.

    This fixes the above by branching over the entry code from the
    misaligned fixup code to avoid reloading the original pointer.

    Also, because the function entry alignment is wrong in the Thumb mode
    compilation, that fixup code is moved to the end.

    While at it, the entry instructions are slightly reworked to help dual
    issue pipelines.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Tested-by: Alexander Holler <holler@ahsoftware.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm32: resync atomics with (almost) v3.14-rc7
Ian Campbell [Wed, 26 Mar 2014 13:38:40 +0000 (13:38 +0000)]
xen: arm32: resync atomics with (almost) v3.14-rc7

Almost because I omitting aed3a4e "ARM: 7868/1: arm/arm64: remove
atomic_clear_mask() ..." which I will apply to both arm32 and arm64
simultaneously in a later patch.

This pulls in the following Linux patches:

commit f38d999c4d16fc0fce4270374f15fbb2d8713c09
Author: Will Deacon <will.deacon@arm.com>
Date:   Thu Jul 4 11:43:18 2013 +0100

    ARM: atomics: prefetch the destination word for write prior to strex

    The cost of changing a cacheline from shared to exclusive state can be
    significant, especially when this is triggered by an exclusive store,
    since it may result in having to retry the transaction.

    This patch prefixes our atomic access implementations with pldw
    instructions (on CPUs which support them) to try and grab the line in
    exclusive state from the start. Only the barrier-less functions are
    updated, since memory barriers can limit the usefulness of prefetching
    data.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
commit 4dcc1cf7316a26e112f5c9fcca531ff98ef44700
Author: Chen Gang <gang.chen@asianux.com>
Date:   Sat Oct 26 15:07:25 2013 +0100

    ARM: 7867/1: include: asm: use 'int' instead of 'unsigned long' for 'oldval

    For atomic_cmpxchg(), the type of 'oldval' need be 'int' to match the
    type of "*ptr" (used by 'ldrex' instruction) and 'old' (used by 'teq'
    instruction).

Reviewed-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm32: replace hard tabs in atomics.h
Ian Campbell [Wed, 26 Mar 2014 13:38:39 +0000 (13:38 +0000)]
xen: arm32: replace hard tabs in atomics.h

This file is from Linux and the intention was to keep the formatting the same
to make resyncing easier. Put the hardtabs back and adjust the emacs magic to
reflect the desired use of whitespace.

Adjust the 64-bit emacs magic too.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm32: ensure cmpxchg has full barrier semantics
Ian Campbell [Wed, 26 Mar 2014 13:38:38 +0000 (13:38 +0000)]
xen: arm32: ensure cmpxchg has full barrier semantics

Unrelated reads/writes should not pass the xchg.

Provide cmpxchg_local for parity with arm64, although it appears to be unused.
It also helps make the reason for the separation of __cmpxchg_mb more
apparent.

With this our cmpxchg is in sync with Linux v3.14-rc7.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm32: resync bitops with Linux v3.14-rc7
Ian Campbell [Wed, 26 Mar 2014 13:38:37 +0000 (13:38 +0000)]
xen: arm32: resync bitops with Linux v3.14-rc7

This pulls in the following Linux commits:

commit c36ef4b1762302a493c6cb754073bded084700e2
Author: Will Deacon <will.deacon@arm.com>
Date:   Wed Nov 23 11:28:25 2011 +0100

    ARM: 7171/1: unwind: add unwind directives to bitops assembly macros

    The bitops functions (e.g. _test_and_set_bit) on ARM do not have unwind
    annotations and therefore the kernel cannot backtrace out of them on a
    fatal error (for example, NULL pointer dereference).

    This patch annotates the bitops assembly macros with UNWIND annotations
    so that we can produce a meaningful backtrace on error. Callers of the
    macros are modified to pass their function name as a macro parameter,
    enforcing that the macros are used as standalone function implementations.

Acked-by: Dave Martin <dave.martin@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
commit d779c07dd72098a7416d907494f958213b7726f3
Author: Will Deacon <will.deacon@arm.com>
Date:   Thu Jun 27 12:01:51 2013 +0100

    ARM: bitops: prefetch the destination word for write prior to strex

    The cost of changing a cacheline from shared to exclusive state can be
    significant, especially when this is triggered by an exclusive store,
    since it may result in having to retry the transaction.

    This patch prefixes our atomic bitops implementation with prefetchw,
    to try and grab the line in exclusive state from the start. The testop
    macro is left alone, since the barrier semantics limit the usefulness
    of prefetching data.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
commit b7ec699405f55667caeb46d96229d75bf33a83ad
Author: Will Deacon <will.deacon@arm.com>
Date:   Tue Nov 19 15:46:11 2013 +0100

    ARM: 7893/1: bitops: only emit .arch_extension mp if CONFIG_SMP

    Uwe reported a build failure when targetting a NOMMU platform with my
    recent prefetch changes:

      arch/arm/lib/changebit.S: Assembler messages:
      arch/arm/lib/changebit.S:15: Error: architectural extension `mp' is
                        not allowed for the current base architecture

    This is due to use of the .arch_extension mp directive immediately prior
    to an ALT_SMP(...) instruction. Whilst the ALT_SMP macro will expand to
    nothing if !CONFIG_SMP, gas will still choke on the directive.

    This patch fixes the issue by only emitting the sequence (including the
    directive) if CONFIG_SMP=y.

Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: x86 & generic: change to __builtin_prefetch()
Ian Campbell [Wed, 26 Mar 2014 13:38:36 +0000 (13:38 +0000)]
xen: x86 & generic: change to __builtin_prefetch()

Quoting Andi Kleen in Linux b483570a13be from 2007:
    gcc 3.2+ supports __builtin_prefetch, so it's possible to use it on all
    architectures. Change the generic fallback in linux/prefetch.h to use it
    instead of noping it out. gcc should do the right thing when the
    architecture doesn't support prefetching

    Undefine the x86-64 inline assembler version and use the fallback.

ARM wants to use the builtins.

Fix a pair of spelling errors, one of which was from Lucas De Marchi in the
Linux tree.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoRevert "xen/arm: Allocate memory for dom0 from the bottom with the 1:1 Workaround"
Ian Campbell [Wed, 2 Apr 2014 12:03:36 +0000 (13:03 +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".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm32: don't force the compiler to allocate a dummy register
Ian Campbell [Thu, 3 Apr 2014 08:59:43 +0000 (09:59 +0100)]
xen: arm32: don't force the compiler to allocate a dummy register

TLBIALLH, ICIALLU and BPIALL make no use of their register argument. Instead
of making the compiler allocate a dummy register just hardcode r0, there is no
need to represent this in the inline asm since the register is neither
clobbered nor used in any way.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: flush TLB on all CPUs when setting or clearing fixmaps
Ian Campbell [Thu, 3 Apr 2014 08:59:42 +0000 (09:59 +0100)]
xen: arm: flush TLB on all CPUs when setting or clearing fixmaps

These mappings are global and therefore need flushing on all processors. Add
flush_all_xen_data_tlb_range_va which accomplishes this.

Likewise when removing the early mappings

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

11 years agoxen: arm: consolidate body of flush_xen_data_tlb_range_va_local
Ian Campbell [Thu, 3 Apr 2014 08:59:41 +0000 (09:59 +0100)]
xen: arm: consolidate body of flush_xen_data_tlb_range_va_local

This is almost identical on both sub architectures.

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

11 years agoxen: arm: clarify naming of the Xen TLB flushing functions
Ian Campbell [Thu, 3 Apr 2014 08:59:40 +0000 (09:59 +0100)]
xen: arm: clarify naming of the Xen TLB flushing functions

All of the flush_xen_*_tlb functions operate on the local processor only. Add
_local to the name and update the comments to clarify.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agox86/mm: fix checks against max_mapped_pfn
Jan Beulich [Thu, 3 Apr 2014 07:47:28 +0000 (08:47 +0100)]
x86/mm: fix checks against max_mapped_pfn

This value is an inclusive one, i.e. this fixes an off-by-one in memory
sharing and an off-by-two in shadow code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
11 years agox86/HVM: fix setting mem access to default
Jan Beulich [Wed, 2 Apr 2014 08:09:33 +0000 (09:09 +0100)]
x86/HVM: fix setting mem access to default

commit 3b0bcb89 ("x86/mm/p2m: Move p2m code in HVMOP_[gs]et_mem_access
into p2m.c") introduced an off-by-one mistake forcing an input of
HVMMEM_access_default to always fail. Since related, also eliminate the
inefficient setup of an on-stack array for each function invocation.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86/HVM: fix preemption handling in do_hvm_op() (try 2)
Jan Beulich [Wed, 2 Apr 2014 08:09:00 +0000 (09:09 +0100)]
x86/HVM: fix preemption handling in do_hvm_op() (try 2)

Just like previously done for some mem-op hypercalls, undo preemption
using the interface structures (altering it in ways the caller may not
expect) and replace it by storing the continuation point in the high
bits of sub-operation argument.

This also changes the "nr" fields of struct xen_hvm_track_dirty_vram
(operation already limited to 1Gb worth of pages) and struct
xen_hvm_modified_memory to be only 32 bits wide, consistent with those
of struct xen_set_mem{type,access}. If that's not acceptable for some
reason, we'd need to shrink the HVMOP_op_bits (while still enforcing
the [then higher] limit resulting from the need to be able to encode
the continuation).

Whether (and if so how) to adjust xc_hvm_track_dirty_vram(),
xc_hvm_modified_memory(), xc_hvm_set_mem_type(), and
xc_hvm_set_mem_access() to reflect the 32-bit restriction on "nr" is
unclear: If the APIs need to remain stable, all four functions should
probably check that there was no truncation. Preferably their
parameters would be changed to uint32_t or unsigned int, though.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86/mm: Fix compile with DEBUG_TRACE_DUMP turned on
Aravindh Puthiyaparambil [Tue, 1 Apr 2014 00:32:54 +0000 (17:32 -0700)]
x86/mm: Fix compile with DEBUG_TRACE_DUMP turned on

Signed-off-by: Aravindh Puthiyaparambil <aravindp@cisco.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agocommon/domctl: some functions are only used internally
Julien Grall [Wed, 2 Apr 2014 15:46:35 +0000 (17:46 +0200)]
common/domctl: some functions are only used internally

The list of function above are only used internally in common/domctl.c.
    - bitmap_to_xenctl_bitmap
    - xenctl_bitmap_to_bitmap
    - nodemask_to_xenctl_bitmap
    - xenctl_bitmap_to_nodemask

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoMerge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging
Ian Campbell [Wed, 2 Apr 2014 13:15:56 +0000 (14:15 +0100)]
Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging

11 years agons16550: make some initialisation common
Ian Campbell [Wed, 26 Mar 2014 11:55:55 +0000 (11:55 +0000)]
ns16550: make some initialisation common

Should avoid accidents like forgetting to init lsr_mask for DT devices in the
future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Keir Fraser <keir@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agons16550: setup default lsr_mask for DT systems too
Ian Campbell [Wed, 26 Mar 2014 11:55:54 +0000 (11:55 +0000)]
ns16550: setup default lsr_mask for DT systems too

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-By: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Tested-By: Chen Baozi <baozich@gmail.com>
Cc: keir@xen.org
11 years agocrypto: rijndael: fix compilation with Clang 3.5
Julien Grall [Tue, 1 Apr 2014 16:24:43 +0000 (18:24 +0200)]
crypto: rijndael: fix compilation with Clang 3.5

Td0, Td1, Td2, Td3, Td4 are only used when NEED_RIJNDAEL is defined.

rijndael.c:383:18: error: unused variable 'Td0' [-Werror,-Wunused-const-variable]
static const u32 Td0[256] = {
                 ^
rijndael.c:449:18: error: unused variable 'Td1' [-Werror,-Wunused-const-variable]
static const u32 Td1[256] = {
                 ^
rijndael.c:515:18: error: unused variable 'Td2' [-Werror,-Wunused-const-variable]
static const u32 Td2[256] = {
                 ^
rijndael.c:581:18: error: unused variable 'Td3' [-Werror,-Wunused-const-variable]
static const u32 Td3[256] = {
                 ^
rijndael.c:647:18: error: unused variable 'Td4' [-Werror,-Wunused-const-variable]
static const u32 Td4[256] = {

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoevtchn: rearrange fields
Daniel De Graaf [Tue, 1 Apr 2014 16:22:40 +0000 (18:22 +0200)]
evtchn: rearrange fields

Event channel arrays are allocated in blocks with EVTCHNS_PER_BUCKET
elements, which must be a power of 2.  When XSM is disabled, struct
evtchn is 32 bytes including padding; however, when XSM is enabled, the
structure becomes larger and EVTCHNS_PER_BUCKET is halved.  Rearranging
some of the fields in struct evtchn allows a 4-byte XSM field to fit
within the 32-byte structure.

This rearrangement turns the xen_consumer field of struct evtchn into a
bitfield and adjusts the xen_consumers array to fit the number of
addressable elements from this value.  Since there are currently only
two users of this array, only 3 bits (7 values) are reserved.  This
field is also used rarely enough that the slight overhead from applying
a bitmask should not cause problems.

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 agofix sed usage in build rules
Jan Beulich [Tue, 1 Apr 2014 16:21:43 +0000 (18:21 +0200)]
fix sed usage in build rules

Apparently FreeBSD sed is more picky than GNU sed, wanting a semicolon
at the end of a brace enclosed statement list.

Reported-by: Roger Pau Monné<roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoinclude: fix Makefile for FreeBSD
Jan Beulich [Tue, 1 Apr 2014 16:20:58 +0000 (18:20 +0200)]
include: fix Makefile for FreeBSD

Don't use non-standard extensions:
- \t in bracket expressions
- \+ in basic regular expressions

Reported-by: Roger Pau Monné<roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné<roger.pau@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoVMX: fix PAT value seen by guest
Jan Beulich [Tue, 1 Apr 2014 14:49:18 +0000 (16:49 +0200)]
VMX: fix PAT value seen by guest

The XSA-60 fixes introduced a window during which the guest PAT gets
forced to all zeros. This shouldn't be visible to the guest. Therefore
we need to intercept PAT MSR accesses during that time period.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Liu Jinsong <jinsong.liu@intel.com>
11 years agokexec: propagate ENOMEM result in error handling
Matthew Daley [Tue, 1 Apr 2014 14:48:02 +0000 (16:48 +0200)]
kexec: propagate ENOMEM result in error handling

...otherwise if kimage_alloc_control_page fails (presumably due to
out-of-memory; see the invocation just before this one), the caller of
do_kimage_alloc will think the call was successful.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
11 years agocpupool: cpupool_unassign_cpu is only used internally
Julien Grall [Tue, 1 Apr 2014 14:44:50 +0000 (16:44 +0200)]
cpupool: cpupool_unassign_cpu is only used internally

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
11 years agopv-grub: correct sizeof usage
Matthew Daley [Sat, 29 Mar 2014 05:08:08 +0000 (18:08 +1300)]
pv-grub: correct sizeof usage

We were lucky that sizeof(frame) >= sizeof(*frame) anyway.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Replace early_{printk, panic} call to {printk, panic} call
Julien Grall [Thu, 13 Mar 2014 15:09:18 +0000 (15:09 +0000)]
xen/arm: Replace early_{printk, panic} call to {printk, panic} call

Now that the console supports earlyprintk, we can get a rid of
early_printk and early_panic calls.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/console: Add support for early printk
Julien Grall [Thu, 13 Mar 2014 15:09:17 +0000 (15:09 +0000)]
xen/console: Add support for early printk

On ARM, a function (early_printk) was introduced to output message when the
serial port is not initialized.

This solution is fragile because the developper needs to know when the serial
port is initialized, to use either early_printk or printk. Moreover some
functions (mainly in common code), only use printk. This will result to a loss
of message sometimes.

Directly call early_printk in console code when the serial port is not yet
initialized. For this purpose use serial_steal_fn.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoxen/arm: Rename EARLY_PRINTK compile option to CONFIG_EARLY_PRINTK
Julien Grall [Thu, 13 Mar 2014 15:09:16 +0000 (15:09 +0000)]
xen/arm: Rename EARLY_PRINTK compile option to CONFIG_EARLY_PRINTK

Most of common compile option start with CONFIG_. Rename EARLY_PRINTK option
to CONFIG_EARLY_PRINTK to be compliant.

This option will be used in common code (eg console) later.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: earlyprintk: export early_puts
Julien Grall [Thu, 13 Mar 2014 15:09:15 +0000 (15:09 +0000)]
xen/arm: earlyprintk: export early_puts

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Cambpell <ian.campbell@citrix.com>