x86: drop unused Transmeta definitions

Signed-off-by: Jan Beulich <jbeulich@suse.com>
x86/pvh: disallow PHYSDEVOP_pirq_eoi_gmfn_v2/v1

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

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
x86: fix determination of bit count for struct domain allocations

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

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
sysctl: annotate struct pm_cx_stat's pc[]/cc[]

Suggested-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xsm: Reduce compiler command line clutter

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

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
evtchn: optimize XSM ssid field

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

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

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
x86: enforce preemption in HVM_set_mem_access / p2m_set_mem_access()

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

This is XSA-89.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
xsm: flask: Remove unused function avc_sidcmp

Fix compilation with Clang 3.5:

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

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
xsm: flask: ss: remove unused function determine_oocontext

This function is not used neither exported.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
xsm: flask: flask_disable is only used internally

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
common: sched_sedf: Remove unused functions

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

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

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
credit2: Some functions are only used internally

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

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
x86: identify which vcpu's CR4 is being badly modified

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

After this change, the error looks more like:

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

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/xsm: Don't use multiboot by default to initialize XSM

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

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

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Keir Fraser <keir@xen.org>
xen/xsm: Add xsm_core_init function

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

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
xen/xsm: Add support for device tree

This patch adds a new module "xen,xsm-policy" to allow the user to load the XSM
policy when Xen is booting.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: Add support for XSM

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
libxc: domain restore: fold redundant variables

"vcpuextstate_size" being non-zero fully expresses "vcpuextstate" being
true - drop the latter.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Avoid said the /dev/xvd* is already defined after

open a vhd file failed

For example:
[root@dom0_134_103 ~]# xm block-attach 0
tap2:tapdisk:vhd:/root/liyi***.vhd /dev/xvdz  w
Error: ('create', '-avhd:/root/liyi***.vhd') failed (512  )
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]
Create a new virtual block device.

[root@dom0_134_103 ~]# xm block-attach 0
tap2:tapdisk:vhd:/root/liyi.vhd /dev/xvdz  w
Error: The device "/dev/xvdz" is already defined
Usage: xm block-attach <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]

Create a new virtual block device.

Signed-off-by: Yi Li <peteryili@tencent.com>
Acked-by: Matt Wilson <msw@amazon.com>
tools/xend: move assert to exception block

The two assert in restore trigger sometimes after hundreds of
migrations. If they trigger the destination host will not destroy the
newly created, yet empty guest. After a second migration attempt to this
host there will be two guets with the same name and uuid. This situation
is poorly handled by the xm tools.
With this change the empty guest will be destroyed.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Matt Wilson <msw@amazon.com>