libxl: Remove a duplicate calculation of be_path

Coverity-ID: 1238177
CC: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Reviewed-by: Don Slutz <dslutz@verizon.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: Use REG_RANK_INDEX macro

Use REG_RANK_INDEX macro to compute index to access
vgic ipriority[] and itargets[] for a given irq.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: Restricted access to IFSR32_EL2 and FPEXC32_EL2

IFSR32_EL1 and FPEXC32_EL1 registers are accessible in
aarch64 mode only if aarch32 mode is support in EL1.
So allow access to these registers only for 32-bit domains.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arm: remove check for generic timer support for arm64

Information about support for generic support is available in
IDR_PFR1 register in ARMv7. Where as this information is not
available in ARMv8 that supports only aarch64 bit mode.
ARMv8 being always supports generic timer, this check is not
required.

For platforms that support only aarch64 mode, IDR_PFR1 is
not implemented

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
docs: add PVH specification

Introduce a document that describes the interfaces used on PVH. This
document has been designed from a guest OS point of view (i.e.: what a guest
needs to do in order to support PVH).

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Mukesh Rathor <mukesh.rathor@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
MAINTAINERS: Add Wei Liu as toolstack co-maintainer.

The three existing maintainers are not really able to keep up with
the flow and Wei is one of the top tools contributors (according to
"git shortlog -s -n -p RELEASE-4.4.0..origin/staging tools" and my
own impressions).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Fix QEMU cross-compile build

Introduce the per-arch IOEMU_CPU_ARCH variable.
Always pass --configure=IOEMU_CPU_ARCH to QEMU's configure script.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- dropped redundant comments ]
flask/policy: use naming convention xenpolicy-$(XEN_FULLVERSION)

Daniel suggested we use xenpolicy-$(XEN_FULLVERSION) as flask policy
naming convention.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
x86/EFI: fix freeing of uninitialized pointer

The only valid response from the LocateHandle() call is EFI_BUFFER_TOO_SMALL,
so exit if we get anything else.  We pass a 0 size/NULL pointer buffer, so the
only other returns we will get is an error.  Return right away as there is
nothing to do.  Also return if there is an error allocating the buffer, as the
previous code path also allowed for an undefined pointer to be freed.

Signed-off-by: Roy Franz <roy.franz@linaro.org>

Re-structure the change.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging
x86/p2m: typo fix for spelling ambiguous

Signed-off-by: Tamas K Lengyel <tklengyel@sec.in.tum.de>
Acked-by: Tim Deegan <tim@xen.org>
libbxl: add support for pvscsi, iteration 1

Add support for vscsi= in domU.cfg, add new xl commands scsi-attach,
scsi-list, scsi-detach. The syntax follows what xend understood.

pvscsi provides a dom0 SCSI device as-is to a domU. The backend and
frontend drivers can be found in xen-linux, or its forward-ported
variants. This patch was tested with an openSUSE dom0 and a SLES12
guest. Any openSUSE/SLE11/SLE12 dom0/domU combination will work.

The domU.cfg syntax is "vscsi=[ 'pdev,vdev[,option]' ]". pdev is the
dom0 device in either /dev/$device or HOST:CHANNEL:TARGET:LUN notation.
vdev is the domU device in HOST:CHANNEL:TARGET:LUN notation.

xl scsi-attach will attach a SCSI device at runtime.
xl scsi-detach will remove a SCSI drivce at runtime.
xl scsi-list lists SCSI devices for a list of domains.

The backend driver uses a single_host:many_devices notation to manage
domU devices. The xenstore layout looks like this:

/local/domain/0/backend/vscsi/<domid>/<vhost>/feature-host = "0"
/local/domain/0/backend/vscsi/<domid>/<vhost>/frontend = "/local/domain/<domid>/device/vscsi/0"
/local/domain/0/backend/vscsi/<domid>/<vhost>/frontend-id = "<domid>"
/local/domain/0/backend/vscsi/<domid>/<vhost>/online = "1"
/local/domain/0/backend/vscsi/<domid>/<vhost>/state = "4"
/local/domain/0/backend/vscsi/<domid>/<vhost>/vscsi-devs/dev-0/p-dev = "8:0:2:1"
/local/domain/0/backend/vscsi/<domid>/<vhost>/vscsi-devs/dev-0/state = "4"
/local/domain/0/backend/vscsi/<domid>/<vhost>/vscsi-devs/dev-0/v-dev = "0:0:0:0"
/local/domain/0/backend/vscsi/<domid>/<vhost>/vscsi-devs/dev-1/p-dev = "8:0:2:2"
/local/domain/0/backend/vscsi/<domid>/<vhost>/vscsi-devs/dev-1/state = "4"
/local/domain/0/backend/vscsi/<domid>/<vhost>/vscsi-devs/dev-1/v-dev = "0:0:1:0"

/local/domain/<domid>/device/vscsi/<vhost>/backend = "/local/domain/0/backend/vscsi/<domid>/<vhost>"
/local/domain/<domid>/device/vscsi/<vhost>/backend-id = "0"
/local/domain/<domid>/device/vscsi/<vhost>/event-channel = "20"
/local/domain/<domid>/device/vscsi/<vhost>/ring-ref = "43"
/local/domain/<domid>/device/vscsi/<vhost>/state = "4"
/local/domain/<domid>/device/vscsi/<vhost>/vscsi-devs/dev-0/state = "4"
/local/domain/<domid>/device/vscsi/<vhost>/vscsi-devs/dev-1/state = "4"

This is a challenge for libxl because libxl currently handles only
single_host:single_device in its device helper functions.  Due to this
limitation in libxl, scsi-detach will remove the whole virtual scsi host
with all its virtual devices, instead of just the requested single
virtual device.  scsi-attach can cope with this limitation because it
could write the required files directly into xenstore to attach yet
another virtual scsi device to an existing virtual scsi host. However,
this functionality is currently not implemented.

To support the pdev notation '/dev/$device' it is required to parse
sysfs to translate the path to HST:CHN:TGT:LUN notation. In its current
variant /sys/dev/ is used, which is available since at least Linux 3.0.
Support for dom0 kernels which lack this interface will be added later.

This is a draft patch to get it out of the door, to get help with
solving the libxl limitation above, and of course for public code review.
In this first iteration:
 - the domU.cfg parser for vscsi=[] is functional.
 - xl scsi-list will print output similar to its xm counter part.
 - xl scsi-detach will remove entire scsi hosts, unlike its xm counter part.
 - xl scsi-attach is not yet implemented.
 - coding style may be way off in some parts of the new code.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Ondrej Holecek <oholecek@suse.com>
pvscsi: scsi-detach, scsi-attach

Signed-off-by: Olaf Hering <olaf@aepfle.de>