Commit Graph
100 Commits
Author SHA1 Message Date
Ian Campbell 7a3543df83 tools/libxc: Remove osdep indirection for privcmd
The alternative backend (a xen-api/xapi shim) is no longer around and
so this stuff is now just baggage which is getting in the way of
refactoring libxenctrl.

Nested virt probably suffices for this use case now.

This was the last component of the osdep infrastructure, so all the
dynamic loading etc stuff all falls away too.

As part of this I was forced to investigate the twisty
xc_map_foreign_* maze, which I have added to the
toolstack-library-apis doc in the hopes of doing something sensible.

NetBSD and Solaris now call xc_map_foreign_bulk_compat directly from
their xc_map_foreign_bulk, which could have been achieved by using
some ifdefs around a renamed function. This will fall out in the wash
when these functions move to their own library.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: David Scott <dave.scott@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2016-01-22 12:22:38 +00:00
Ian Campbell a71ad0fead tools: Refactor /dev/xen/gnt{dev,shr} wrappers into libxengnttab.
libxengnttab will provide a stable API and ABI for accessing the
grant table devices.

The functions are moved into the xengnt{tab,shr} namespace to make a
clean break from libxc and avoid ambiguity regarding which interfaces
are stable.

All in-tree users are updated to use the new names.

Upon request (via #define XC_WANT_COMPAT_GNTTAB_API) libxenctrl will
provide a compat API for the old names. This is used by qemu-xen for
the time being. qemu-xen-traditional is updated in lockstep.

This leaves a few grant table related functions which go via privcmd
(GNTTABOP) rather than ioctls on the /dev/xen/gnt* devices in
libxenctrl. Specifically:

  - xc_gnttab_get_version
  - xc_gnttab_map_table_v1
  - xc_gnttab_map_table_v2
  - xc_gnttab_op

These functions do not appear to be needed by qemu-dm, qemu-pv
(provision of device model to HVM guests and PV backends respectively)
or by libvchan suggesting they are not needed by non-toolstack uses of
event channels.

The new library uses a version script to ensure that only expected
symbols are exported and to version them such that ABI guarantees can
be kept in the future.

After this change libxenvchan no longer needs to link against
libxenctrl. It still needs xenctrl.h in one file for xen_mb and
friends.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ ijc -- updated MINIOS_UPSTREAM_REVISION and QEMU_TRADITIONAL_REVISION ]
2016-01-22 12:22:27 +00:00
Ian Campbell 05e88ac015 tools/libxc: Remove osdep indirection for xc_gnt{shr,tab}
The alternative backend (a xen-api/xapi shim) is no longer around and
so this stuff is now just baggage which is getting in the way of
refactoring libxenctrl.

Nested virt probably suffices for this use case now.

It is now necessary to provide explicit versions of things for
platforms which do not implement this functionality, since the osdep
dispatcher cannot fulfil this need any more. These are provided by
appropriate xc_nognt???.c files which are compiled and linked on the
appropriate platforms. In them open and close return failure and
everything else aborts, since if open fails they should never be
called.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2016-01-22 12:21:39 +00:00
Ian Campbell aae392b46c tools: Arrange to check public headers for ANSI compatiblity
Using the same rune as we use for the Xen public headers, except we do
not need stdint.h here.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2016-01-22 12:21:39 +00:00
Ian Campbell b7f76a699d tools: Refactor /dev/xen/evtchn wrappers into libxenevtchn.
libxenevtchn will provide a stable API and ABI for accessing the
evtchn device.

The functions are moved into the xenevtchn namespace to make a clean
break from libxc and avoid ambiguity regarding which interfaces are
stable.

All in-tree users are updated to use the new names.

Upon request (via #define XC_WANT_COMPAT_EVTCHN_API) libxenctrl will
provide a compat API for the old names. This is used by qemu-xen for
the time being. qemu-xen-traditional is updated in lockstep.

This leaves a few event channel related functions which go via privcmd
(EVTCHNOP) rather than ioctls on the /dev/xen/evtchn device in
libxenctrl. Specifically:

 - xc_evtchn_alloc_unbound
 - xc_evtchn_reset
 - xc_evtchn_status

Note that xc_evtchn_alloc_unbound's functionality is also provided by
xenevtchn_bind_unbound_port() (née xc_evtchn_bind_unbound_port) and is
probably redundant.

These functions do not appear to be needed by qemu-dm, qemu-pv
(provision of device model to HVM guests and PV backends respectively)
or by libvchan suggesting they are not needed by non-toolstack uses of
event channels. QEMU does use these in hw/xenpv/xen_domainbuild.c but
that is a "toolstack use".

The new library uses a version script to ensure that only expected
symbols are exported and to version them such that ABI guarantees can
be kept in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[ ijc -- updated MINIOS_UPSTREAM_REVISION and QEMU_TRADITIONAL_REVISION ]
2016-01-22 12:21:07 +00:00
Ian Campbell 97d9bc6ca6 tools/libxc: Remove osdep indirection for xc_evtchn
The alternative backend (a xen-api/xapi shim) is no longer around and
so this stuff is now just baggage which is getting in the way of
refactoring libxenctrl.

Note that the intention is to move this into a separate library
shortly.

Nested virt probably suffices for this use case now.

One incorrect instance of using xc_interface where xc_evtchn (in ocaml
stubs) is removed, this used to work because they were typedefs to the
same struct, but is no longer permitted.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2016-01-22 12:19:02 +00:00
Ian Campbell ef17887d84 docs: correct descriptions of gnttab_max_{, maptrack}_frames
gnttab_max_frames incorrectly referred to numbers of grant tab
operations and gnttab_max_maptrack_frames was confusingly worded.

Add the default for gnttab_max_frames while here (it's currently the
same on all arches since no arch uses the available arch override) and
adjust the default for gnttab_max_maptrack_frames to match the normal
form.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2016-01-19 16:24:44 +00:00
Ian Campbell 3b911d948e xen: move installed copy of xen/.config file to /boot
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2016-01-18 11:45:45 +00:00
Ian Campbell 2f3b2f4aa2 SEABIOS_UPSTREAM_REVISION Update
Track the upstream 1.9-stable branch.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
2016-01-15 10:35:06 +00:00
Ian Campbell 5d3dc86715 tools: Refactor "xentoollog" into its own library
In attempting to disaggregate libxenctrl I found that many of the
pieces were going to want access to this library, so split it out (as
it probably should always have been).

Various build adjustments are needed. In particular things which use
xtl_* themselves now need to explicity link against the library.

This has a nice side effect which is that users of libxl no longer
need to link against libxenctrl just to create a logger, which was
counter to the principal that applications using libxl shouldn't be
required to look behind the curtain. This means that xl no longer
links against libxenctrl.

The new library uses a version script to ensure that only expected
symbols are exported and to version them such that ABI guarantees can
be kept in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ ijc -- dropped QEMU_TRADITIONAL_REVISION update, this had since
         progressed to 569eac99e8dd which is after 9fad9ed28583, the
         commit needed here. ]
2016-01-05 11:45:26 +00:00
Ian Campbell b48aae50a8 stubdom: recurse into tools/include in mk-headers-$(XEN_TARGET_ARCH) rule
... rather than in the libxc rule.

This puts all the header dependencies in one place and will allow us
to avoid races when more libraries which need these headers are
introduced. I observed issues with the xen-foreign/tmp.size file
getting deleted in parallel with another process trying to use it.

The mini-os links are already created in the
mk-headers-$(XEN_TARGET_ARCH) target so the other places which do so
are redundant, in the case of polarssl and vtpmmgr indirectly through
their eventual dependency on newlib which in turn depends on
mk-headers-$(XEN_TARGET_ARCH).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: samuel.thibault@ens-lyon.org
2016-01-05 11:33:32 +00:00
Ian Campbell de858271c1 tools: allow configure time choice of libexec subdirectory.
Currently we hardcode various paths such as $libexec/xen/{bin,boot},
however some downstreams (notably Debian) would like instead to
install things into $libexec/xen-X.Y/{bin,boot} as part of allowing
multiple versions of the tools packages to be installed.

Since this currently involves patching configure its a bit fiddly,
provide a configure option for the leaf dir instead, name it
--with-libexec-leaf-dir similar to the existing
--with-sysconfig-leaf-dir.

Rather than have the determination of the full path in both configure
and config/Paths.mk.in move it into configure only. Also for
consistency move the other LIBEXEC_* to configure, even though they
are only substituted into Paths.mk.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Doug Goldstein <cardoe@cardoe.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: 805508@bugs.debian.org
[ ijc -- removed stray ` ]
2016-01-05 11:32:21 +00:00
Ian Campbell d3619c989c flask: Allow device model to raise PCI interrupts (pcilevel capability)
Allows:

(XEN) avc:  denied  { pcilevel } for domid=2 target=1 scontext=system_u:system_r:dm_dom_t tcontext=system_u:system_r:domU_t_target tclass=hvm

Which otherwise leads to the following on resume after migrate (comparing
non-XSM to XSM):

 ata2.00: configured for MWDMA2
 usb 1-2: reset full-speed USB device number 2 using uhci_hcd
+PM: restore of devices complete after 3779.268 msecs
 usb 1-2: USB disconnect, device number 2
-PM: restore of devices complete after 2342.528 msecs
 usb 1-2: new full-speed USB device number 3 using uhci_hcd
 usb 1-2: New USB device found, idVendor=0627, idProduct=0001
 usb 1-2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
 usb 1-2: Product: QEMU USB Tablet
 usb 1-2: Manufacturer: QEMU 0.10.2
 usb 1-2: SerialNumber: 1
 input: QEMU 0.10.2 QEMU USB Tablet as /devices/pci0000:00/0000:00:01.2/usb1/1-2/1-2:1.0/input/input8
 generic-usb 0003:0627:0001.0002: input,hidraw0: USB HID v0.01 Pointer [QEMU 0.10.2 QEMU USB Tablet] on usb-0000:00:01.2-2/input0
 Restarting tasks ... done.
 Setting capacity to 20480000
 Setting capacity to 20480000
+uhci_hcd 0000:00:01.2: Unlink after no-IRQ?  Controller is probably using the wrong IRQ.

And a glitch in the domU which is sufficient to disrupt the post migration
checks done by osstest.

This has been through a test run on merlot1 and resolved the migration
issues with the test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm
osstest test case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2015-12-16 09:44:45 +00:00
Ian Campbell 6285ff920d xen: arm: Drop trailing ; from DEFINE_XEN_GUEST_HANDLE
This is always present at the point of use, which with -pedantic
provokes:

error: ISO C does not allow extra ';' outside of a function [-Werror=edantic]

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2015-12-15 12:06:53 +00:00
Ian Campbell ec07125761 Revert "tools: Refactor "xentoollog" into its own library"
This reverts commit c7d3afbb44 which
broke the libvirt build, since libvirt uses xtl_* and hence needs
updating to link against the new library when necessary.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-12-10 10:21:34 +00:00
Ian Campbell c7d3afbb44 tools: Refactor "xentoollog" into its own library
In attempting to disaggregate libxenctrl I found that many of the
pieces were going to want access to this library, so split it out (as
it probably should always have been).

Various build adjustments are needed. In particular things which use
xtl_* themselves now need to explicity link against the library.

This has a nice side effect which is that users of libxl no longer
need to link against libxenctrl just to create a logger, which was
counter to the principal that applications using libxl shouldn't be
required to look behind the curtain. This means that xl no longer
links against libxenctrl.

The new library uses a version script to ensure that only expected
symbols are exported and to version them such that ABI guarantees can
be kept in the future.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ ijc -- Update QEMU_TRADITIONAL_REVISION and MINIOS_UPSTREAM_REVISION ]
2015-12-09 12:37:00 +00:00
Ian Campbell 78fb69ad93 tools/Rules.mk: Properly handle libraries with recursive dependencies.
In tree libraries which link against other in tree libraries in a way
which is opaque to their callers need special handling, specifically
correct use of -Wl,-rpath-link for the recusively used libraries.

Currently this is rather simple, but up coming changes are going to
introduce transitive dependencies more than 1 step deep.

Introduce a SHDEPS idiom to contain all the recursive deps for a
library and include those in both LDLIBS (for linking) and SHLIB (for
recursive uses).

Try and document the whole thing.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-12-09 12:36:59 +00:00
Ian Campbell b9fc6f36d5 tools/ocaml: simplify compile/link of test apps
xtl doesn't require the full LDLIBS_libxenctrl, just the -L and
xenlight.cmxa, the latter which contains LDLIBS_libxenctrl as needed.
Fixing this avoids the need to be concerned about LDLIBS_libxenctrl
becoming more than one word in the future.

Since the tests are pure ocaml (no C components) CFLAGS and
LIBS_xenlight are not required.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: David Scott <dave@recoil.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: David Scott <dave@recoil.org>
2015-12-09 12:36:53 +00:00
Ian Campbell c6dd439ade mce-test: do not include libxenguest internal headers
As far as I can tell there is no requirement for these and it builds
fine without them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-12-09 12:36:46 +00:00
Ian Campbell 9b436680f0 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-11-24 16:50:27 +00:00
Ian Campbell bb4b673ace MAINTAINERS: mini-os patches should be copied to minios-devel
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: samuel.thibault@ens-lyon.org
Cc: stefano.stabellini@eu.citrix.com
Cc: minios-devel@lists.xenproject.org
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2015-11-24 16:12:28 +00:00
Ian Campbell 969eb34abd MINIOS_UPSTREAM_REVISION Update
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-11-24 16:10:32 +00:00
Ian Campbell 032dbbae93 Config.mk: Update SEABIOS_UPSTREAM_TAG to rel-1.9.0
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-11-24 16:08:55 +00:00
Ian Campbell 827db7b263 MINIOS_UPSTREAM_REVISION Update
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-11-23 09:39:17 +00:00
Ian Campbell d07f63fa6e Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-11-16 13:38:33 +00:00
Ian Campbell 6853c9bf9f MINIOS_UPSTREAM_REVISION Update
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-11-16 11:29:45 +00:00
Ian Campbell fb31b1475f tools: pygrub: if partition table is empty, try treating as a whole disk
pygrub (in identify_disk_image()) detects a DOS style partition table
via the presence of the 0xaa55 signature at the end of the first
sector of the disk.

However this signature is also present in whole-disk configurations
when there is an MBR on the disk. Many filesystems (e.g. ext[234])
include leading padding in their on disk format specifically to enable
this.

So if we think we have a DOS partition table but do not find any
actual partition table entries we may as well try looking at it as a
whole disk image. Worst case is we probe and find there isn't anything
there.

This was reported by Sjors Gielen in Debian bug #745419. The fix was
inspired by a patch by Adi Kriegisch in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745419#27

Tested by genext2fs'ing my /boot into a new raw image (works) and
then:
   dd if=/usr/lib/grub/i386-pc/g2ldr.mbr of=img conv=notrunc bs=512 count=1

to add an MBR (with 0xaa55 signature) to it, which after this patch
also works.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: 745419-forwarded@bugs.debian.org
2015-11-16 11:01:50 +00:00
Ian Campbell f4a9a01a21 tools: migration: Use PRIpfn when printing frame numbers.
This avoids various printf formatting warnings when building on arm32.

While touching the affected lines make them consistently use %#.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
2015-11-16 11:01:13 +00:00
Ian Campbell 700772bc13 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-11-04 09:38:51 +00:00
Ian Campbell 1ef01396fd arm: handle races between relinquish_memory and free_domheap_pages
Primarily this means XENMEM_decrease_reservation from a toolstack
domain.

Unlike x86 we have no requirement right now to queue such pages onto
a separate list, if we hit this race then the other code has already
fully accepted responsibility for freeing this page and therefore
there is no more for relinquish_memory to do.

This is CVE-2015-7814 / XSA-147.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2015-10-29 13:34:17 +01:00
Ian Campbell 1c0e59ff15 arm: rate-limit logging from unimplemented PHYSDEVOP and HVMOP.
These are guest accessible and should therefore be rate-limited.
Moreover, include them only in debug builds.

This is CVE-2015-7813 / XSA-146.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
2015-10-29 13:33:38 +01:00
Ian Campbell 8b7df8e807 tools: libxl: CODING_STYLE: GC* cannot be used with NOGC
GC* assume an existing gc in scope, which means they can't be passed
NOGC. Instead recommend the use of the underlying functions with NOGC,
noting that this is excepitonal.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[ ijc -- refer to libxl__calloc not (nonexistent) libxl__alloc ]
2015-10-22 16:07:43 +01:00
Ian Campbell f8b201e720 tools: Update libxl flex outputs to Flex from Jessie.
This is the result of
  $ find -name \*.l -exec touch {} \;
  $ find -name \*.y -exec touch {} \;

and then rebuilding.

This avoids churn on the machine I use for committing which has been
updated, causing flex to go from 2.5.35-10.1 to 2.5.39-8.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-10-22 16:05:39 +01:00
Ian Campbell e08f3834c2 Config: Switch to unified qemu trees.
Upstream qemu is now in qemu-xen.git and the trad fork is in
qemu-xen-traditional.git.

QEMU_UPSTREAM_REVISION is currently a tag and
QEMU_TRADITIONAL_REVISION is a specific revision, so no changes are
required to those.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-10-21 13:50:22 +01:00
Ian Campbell 7f25baba1c docs: xl.cfg: permissive option is not PV only.
Since XSA-131 qemu-xen has defaulted to non-permissive mode and the
option was extended to cover that case in 015a373351 "tools: libxl:
allow permissive qemu-upstream pci passthrough".

Since I was rewrapping to adjust the text anyway I've split the safety
warning into a separate paragraph to make it more obvious.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Eric <epretorious@yahoo.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-10-07 12:25:11 +01:00
Ian Campbell 3f9dfe6808 MINIOS_UPSTREAM_REVISION Update
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-10-07 12:18:10 +01:00
Ian Campbell c6e348570c xen: write a high level description of the sub-arch choices for heap layout
The 3 options which (sub)arches have for the layout of their heaps is
a little subtle (in particular the two CONFIG_SEPARATE_XENHEAP=n
submodes) and can be a bit tricky to derive from the code.

Therefore try and write down some guidance on what the various modes
are.

Note that this is intended more as a high level overview rather than a
detailed guide to the full page allocator interfaces.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
2015-10-02 12:04:15 +01:00
Ian Campbell f304da4877 INSTALL: Mention MINIOS_UPSTREAM_URL
All the other ones seem to be there.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
2015-09-21 12:29:36 +01:00
Ian Campbell c4b717808f libxl: format fd flags with 0x since they are hex.
Commit 93f5194e72 "libxl: clear O_NONBLOCK|O_NDELAY on migration fd
and reinstate afterwards" added some logging of fcntl.F_GETFL at all
as %x without a 0x prefix to make it clear they numbers are hex. Fix
this alongwith an inadvertent logging of the fd itself as hex.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-09-11 15:57:45 +01:00
Ian Campbell 93f5194e72 libxl: clear O_NONBLOCK|O_NDELAY on migration fd and reinstate afterwards
The fd passed to us by libvirt for both save and restore has at least
O_NONBLOCK set, which libxl does not expect and therefore fails to
handle any EAGAIN which might arise.

This has been observed with migration v2, but if v1 used to work I
think that would be just be by luck and/or coincidence.

Unix convention (and the principal of least surprise) is usually to
ensure that an fd has no "strange" properties, such as being
non-blocking, when handing it to another component.

However for the convenience of the application arrange instead for
libxl to clear any unexpected flags on the file descriptors it is
given for save or restore and restore them to their original state at
the end. O_NDELAY could be similarly problematic so clear that as
well as O_NONBLOCK.

To do this introduce a pair of new helper functions one to modify+save
the flags and another to restore them and call them in the appropriate
places.

The migration v1 code appeared to do some things with O_NONBLOCK in
the checkpoint case. Migration v2 doesn't seem to do so, and in any
case I wouldn't expect it to be relying on libvirt's setting of
O_NONBLOCK when xl doesn't use that flag.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: Jim Fehlig <jfehlig@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Shriram Rajagopalan <rshriram@cs.ubc.ca>
Cc: Yang Hongyang <yanghy@cn.fujitsu.com>
2015-09-11 14:42:40 +01:00
Ian Campbell a1d95d0f87 Rerun autogen.sh to pickup new version number
315a8722b4 bumped the version after 4.6
branched. This picks up that change into the generated files.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-09-10 12:30:40 +01:00
Ian Campbell 664675adec MAINTAINERS: stable backports should be requested on xen-devel
As well as CC-ing the correct people. I just saw such a request on
xen-users and thought this was worth clarifying here too.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-09-09 13:12:32 +01:00
Ian Campbell 8747dba3b7 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-09-02 14:27:01 +01:00
Ian Campbell 743289d029 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-08-16 09:00:30 +01:00
Ian Campbell 23d01fc376 tools: libxl: fixup long line introduced by previous semantic patch
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-08-13 11:01:23 +01:00
Ian Campbell cb86677d2d tools: libxl: Remove unnecessary trailing \n from log messages.
Both xl's LOG and the various libxl logging mechanisms automatically
include a trailing \n.

Remove all unnecessary \n's from the logs messages with the following
semantic patch.

spatch also reindents (I couldn't see how to make it stop). In general
it has improved matters but in 1 case it has introduced a long line,
this will be fixed in the next patch.

Semantic patch, run as
spatch --in-place --no-includes --include-headers \
    --sp-file libxl-log-nl.spatch \
    tools/libxl/libxl*.[ch] tools/libxl/xl*.[ch]

=========

// Heavily inspired by https://lkml.org/lkml/2014/9/12/134

virtual patch
virtual context
virtual org
virtual report

// First the macros

@macro1@
identifier FN =~ "LOG|LOGE|LOGEV";
constant s1 =~ ".*\\n";
constant level;
@@
FN(level, s1, ...);

@script:python macro2@
s1 << macro1.s1;
s2;
@@

coccinelle.s2 = s1[:-3]+'"';

@macro3@
identifier macro1.FN;
constant macro1.level;
expression args;
constant macro1.s1;
identifier macro2.s2;
@@
-FN(level, s1, args);
+FN(level, s2, args);

@macro4@
identifier macro1.FN;
constant macro1.level;
constant macro1.s1;
identifier macro2.s2;
@@
-FN(level, s1);
+FN(level, s2);

// Now the functions

@log1@
identifier FN =~ "LIBXL__LOG(|_ERRNO|_ERRNOVAL)";
constant s1 =~ ".*\\n";
expression ctx;
constant level;
@@
FN(ctx, level, s1, ...);

@script:python log2@
s1 << log1.s1;
s2;
@@

coccinelle.s2 = s1[:-3]+'"';

@log3@
identifier log1.FN;
constant log1.level;
expression args;
expression log1.ctx;
constant log1.s1;
identifier log2.s2;
@@
-FN(ctx, level, s1, args);
+FN(ctx, level, s2, args);

@log4@
identifier log1.FN;
constant log1.level;
expression log1.ctx;
constant log1.s1;
identifier log2.s2;
@@
-FN(ctx, level, s1);
+FN(ctx, level, s2);
=========

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-08-13 11:01:23 +01:00
Ian Campbell 7d134b44ac gitignore: Don't ignore *.rej
These indicate a patch application went wrong, I want to see them in
"git status". This appears to have been imported from .hgignore where
it has been since 2005.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2015-08-13 11:00:20 +01:00
Ian Campbell 201eac8383 libxl: use correct command line for arm guests.
We need to use libxl__domain_build_state.pv_cmdline in order to pickup
the correct args when using pygrub. libxl_domain_build_info.cmdline is
any args statically configured by the user.

This is consistent with the call to xc_domain_allocate, which takes
the cmdline too (in that case for x86/PV usage).

state->pv_cmdline is also set for non-pygrub guests, since
libxl__bootloader_run propagates info->cmdline if no bootloader is
configured.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-08-06 13:45:49 +01:00
Ian Campbell 598fbeb9c1 Merge branch 'fsf-address-v1' of git://xenbits.xen.org/people/ianc/xen into staging 2015-07-30 15:31:18 +01:00
Ian Campbell 443701ef0c Replace FSF street address with canonical URL
As recommended in http://www.gnu.org/licenses/gpl-howto.en.html.

This is the result of:
$ git grep -El Mass\|Temple\|Franklin | xargs ./fsf.pl

Where fsf.pl is:
    #!/usr/bin/perl -w -pi.bak -0777
    my $repl = 'If not, see <http://www.gnu.org/licenses/>.';
    my $br = qr/(?:\s*\n\s*(?:[\*\#]|\/\/|\.\\" )?\s*|\s+)/;

    my $inwt = qr/[Ii]f${br}not,${br}write${br}(?:to${br})?the${br}Free${br}Software${br}Foundation,(?:${br}Inc\.,)?/;

    my $mass = qr/675${br}Mass${br}Ave,?${br}Cambridge,?${br}MA${br}02139,?${br}USA,?\.?/;
    my $franklin = qr/51${br}Franklin${br}St(?:reet)?(?:,${br}| - )Fifth${br}Floor,?${br}Boston,?${br}MA,?${br}02110-1301,?${br}USA,?\.?/;
    my $temple = qr/59${br}Temple${br}Place(?:,${br}| - )Suite${br}330,?${br}Boston,?${br}MA,?${br}021110?-1307,?${br}USA,?\.?/;

    s|$inwt$br$mass|$repl|m;
    s|$inwt$br$franklin|$repl|m;
    s|$inwt$br$temple|$repl|m;

The only remaining mentions of these addresses are in COPYING files which I
haven't touched.

Some of the changed files are imports from elsewhere, however
filtering them out is tricky, I think it is tolerable to have these
files be modified here and then perhaps reverted on the next sync,
since it's only 1-2 lines and obvious what is going on.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-29 11:14:07 +01:00
Ian Campbell fec8577da9 stubdom: Replace FSF street address with canonical URL in patches
Do these ones manually since the diff header needs fixup too.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-29 11:02:25 +01:00
Ian Campbell 19b17e240c Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-07-24 14:13:21 +01:00
Ian Campbell 78222eb476 tools: libxl: Use correct printf format for uint64_t
Since 25652f232c "tools/libxl: detect and avoid conflicts with RDM"
the build is broken for x86_32 and arm32 with:

libxl_dm.c: In function ‘libxl__domain_device_construct_rdm’:
libxl_dm.c:349:13: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 8 has type ‘uint64_t’ [-Werror=format=]
             LOG(ERROR, "RDM conflict at 0x%lx.\n", d_config->rdms[i].start);
             ^
libxl_dm.c:352:13: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 8 has type ‘uint64_t’ [-Werror=format=]
             LOG(WARN, "Ignoring RDM conflict at 0x%lx.\n",

Use PRIx64 for these.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Cc: Tiejun Chen <tiejun.chen@intel.com>
2015-07-24 11:44:41 +01:00
Ian Campbell ce6ce4a8a8 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-07-22 15:55:14 +01:00
Ian Campbell 1287ac109c tools: libxl: Refix "Initialise the fd of the unused half of a datacopier"
Applying the series out of order led to d72befc35f "tools/libxl:
Identify copywhat in stream v2 datacopiers" unintentionally reverting
part of 21d9b079e5 "tools/libxl: Initialise the fd of the unused
half of a datacopier".

Put this back.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-07-21 16:03:15 +01:00
Ian Campbell cd707bceb8 xen: arm: gic-v3: avoid \n in the middle of log messages
These result in log messages such as:

(XEN) d0v0: vGICD: RAZ on reserved register offset 0x00000c
(XEN) d0v0: vGICR: write r2 offset 0x000180
(XEN)  not found<G><3>traps.c:2417:d0v0 HSR=0x93820046 pc=0xffffffc000322bfc gva=0xffffff8000090180 gpa=0x0000008d110180

Fix this by rewording without a \n in the middle. Also add one at the end.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-21 14:58:08 +01:00
Ian Campbell 2909ad4c96 tools/hotplug: Add an initscript to start "xl devd" in a driver domain
The removal of the udev rules highlighted that although it has been
replaced by "xl devd" there isn't an initscript to replace it.

To enable this add a --pidfile option to xl devd.

Tested on Linux by running the script in dom0 and checking the daemon
was started/stopped, but not in an actual driver domain environment
since I don't have one conveniently available. I also checked that
running without the --pidfile option still works.

Scripts mainly cribbed from the xencommons for each platform.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad@darnok.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-07-17 12:20:52 +01:00
Ian Campbell 47e4d26f29 tools: libxl: check errors from libxl_create_logfile for stubdom log
Spotted by Coverity after the recent similar fix to
libxl__create_qemu_logfile.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-07-16 16:26:10 +01:00
Ian Campbell 989f3939bd xen: arm: bootfdt: Avoid reading off the front of *_cells array
In device_tree_for_each_node the call to the callback was using
{address,size}_cells[depth - 1], which at depth 0 could read off the
front of the array.

We already handled this correctly in the rest of the loop so fixup
this instance as well.

Reported-by: Chris (Christopher) Brand <chris.brand@broadcom.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Chris (Christopher) Brand <chris.brand@broadcom.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-16 16:25:26 +01:00
Ian Campbell f50fe3a569 tools: libxc: Add nomigrate stubs for xc_domain_(save|restore)2.
Fixes the build on ARM after the switch to migration v2 in
210b481752 "tools/libxc+libxl+xl: Save v2 streams" and
3a9ace0147 "tools/libxc+libxl+xl: Restore v2 streams".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-07-15 12:59:50 +01:00
Ian Campbell e9d3a85997 tools: libxl: Handle failure to create qemu dm logfile
If libxl_create_logfile fails for some reason then
libxl__create_qemu_logfile previously just carried on and dereferenced
the uninitialised logfile.

Check for the error from libxl_create_logfile, which has already
logged for us.

This was reported as Debian bug #784880.

Reported-by: Russell Coker <russell@coker.com.au>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: 784880@bugs.debian.org
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-07-15 10:53:51 +01:00
Ian Campbell 7617641fe8 tools: ocaml: Handle anonymous struct members of structs in libxl IDL
Julien has a patch "arm: Allow the user to specify the GIC version"
which adds an anonymous struct to libxl_domain_build_info:

    @ -480,6 +486,11 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                           ])),
                      ("invalid", None),
                      ], keyvar_init_val = "LIBXL_DOMAIN_TYPE_INVALID")),
    +
    +
    +    ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
    +                              ])),
    +
         ], dir=DIR_IN
     )

(libxl_gic_version is an enum). This is not currently supported by the
ocaml genwrap.py. Add a simple pass which handles simple anonymous
unions as top level members of a struct type, but not more deeply
nested since that would be a much more complex change and is not
currently required.

With Juliens patch applied the relevant resulting change to the .mli
is:

    --- tools/ocaml/libs/xl/_libxl_BACKUP_types.mli.in	2015-07-08 11:22:35.000000000 +0100
    +++ tools/ocaml/libs/xl/_libxl_types.mli.in	2015-07-08 12:25:56.000000000 +0100
    @@ -469,6 +477,10 @@ module Domain_build_info : sig

     	type type__union = Hvm of type_hvm | Pv of type_pv | Invalid

    +	type arch_arm__anon = {
    +		gic_version : gic_version;
    +	}
    +
     	type t =
     	{
     		max_vcpus : int;
    @@ -510,6 +522,7 @@ module Domain_build_info : sig
     		ramdisk : string option;
     		device_tree : string option;
     		xl_type : type__union;
    +		arch_arm : arch_arm__anon;
     	}
     	val default : ctx -> ?xl_type:domain_type -> unit -> t
     end

The .ml differs similarly. Without Julien's patch there is no change.

gen_struct is refactored slightly to take the indent level as an
argument, since it is now used at a different level.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Julien Grall <julien.grall@citrix.com>
Cc: Dave Scott <Dave.Scott@citrix.com>
Cc: Rob Hoes <Rob.Hoes@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Rob Hoes <rob.hoes@citrix.com>
Acked-by: David Scott <dave.scott@citrix.com>
2015-07-09 12:15:39 +01:00
Ian Campbell 89483dc2b3 tools: Do not add top-level tools dir to include path
Instead switch to an explicit -include $(XEN_ROOT)/tools/config.h to
pickup config.h.

Most places already do this, fixup the rest.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-08 11:14:13 +01:00
Ian Campbell 4219f4a20e tools: Link in-tree libvchan and libblktapctl users against lib....so
As with other in-tree users avoid -L + -l.

This avoids any confusion with versions of these libraries already
installed on the system and the possibility of linking against them by
mistake.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-08 11:14:13 +01:00
Ian Campbell e9d50129d3 tools: libxl: Log on more error paths on domain create failure
The setdefault functions do not generally log why they didn't like
things.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-08 11:14:12 +01:00
Ian Campbell 2545f08bd5 libxc: Correct log message in xc_map_foreign_bulk
Things are confusing enough as it is without using another function's
name here.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-08 11:14:12 +01:00
Ian Campbell 5eac60e3ae tools: libxc: fix "alocated" typo in comment
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-08 11:14:12 +01:00
Ian Campbell 015a373351 tools: libxl: allow permissive qemu-upstream pci passthrough.
Since XSA-131 qemu-xen now restricts access to PCI cfg by default. In
order to allow local configuration of the existing libxl_device_pci
"permissive" flag needs to be plumbed through via the new QMP property
added by the XSA-131 patches.

Versions of QEMU prior to XSA-131 did not support this permissive
property, so we only pass it if it is true. Older versions only
supported permissive mode.

qemu-xen-traditional already supports the permissive mode setting via
xenstore.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-07-07 16:23:11 +01:00
Ian Campbell 39c6664a0e xen: earlycpio: Pull in latest linux earlycpio.[ch]
AFAICT our current version does not correspond to any version in the
Linux history. This commit resynchronised to the state in Linux
commit 598bae70c2a8e35c8d39b610cca2b32afcf047af.

Differences from upstream: find_cpio_data is __init, printk instead of
pr_*.

This appears to fix Debian bug #785187. "Appears" because my test box
happens to be AMD and the issue is that the (valid) cpio generated by
the Intel ucode is not liked by the old Xen code. I've tested by
hacking the hypervisor to look for the Intel path.

Reported-by: Stephan Seitz <stse+debianbugs@fsing.rootsland.net>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Stephan Seitz <stse+debianbugs@fsing.rootsland.net>
Cc: 785187@bugs.debian.org
Acked-by: Jan Beulich <jbeulich@suse.com>
2015-07-07 15:10:45 +01:00
Ian Campbell 467e5cbb2f xen: arm: consolidate mmio and irq mapping to dom0
The code in the callbacks for dt_for_each_irq_map and
dt_for_each_range is very similar to the code in handle_device for
each non-pci device.

In fact the only major difference is that the irq callback needs to
call irq_set_spi_type in the PCI case. Refactor into a
map_dt_irq_to_domain callback which does the irq_set_spi_type and then
calls map_irq_to_domain which is also used from handle_device.

For mmio map_range_to_domain can already be used directly from
handle_device too. Note that the uses of PAGE_MASK in the
handle_device code here were unnecessary (and already removed from the
map_range_to_domain variant).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-07 15:10:45 +01:00
Ian Campbell f65399fdfd xen: arm: Import of_bus PCI entry from Linux (as a dt_bus entry)
This provides specific handlers for the PCI bus relating to matching
and translating. It's mostly similar to the defaults but includes some
additional error checks and other PCI specific bits.

There are some subtle differences in how the generic code vs. the pci
specific code here will handle buggy DTs (i.e. #*-cells which are not
as required by the pci bindings). This will mean we tolerate such
device trees better.

I say "buggy", but actually it's not clear to me from reading "PCI Bus
Binding to Open Firmware" that when the device_type is "pci" that
e.g. the text says "The value of "#address-cells" for PCI Bus Nodes is
3." and not "A PCI Bus Node must contain a #address-cells property
containing 3", iow the #address-cells might validly be implicit rather
than an actual property. Maybe that interpretation is bogus, but with
this patch we are are able to cope with DTs written by people who do
read it like that.

It also gets us the ability to parse the flags (cacheability),
although at the moment we only check them for validity rather than use
them.

Functions/types renamed and reindented (because apparently we do
that for these).

Needs a selection of IORESOURCE_* defines, which I've taken from Linux
and have included locally for now until we figure out where else they
might be needed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-07 15:10:44 +01:00
Ian Campbell 864f82adbc xen: arm: map child MMIO and IRQs to dom0 for PCI bus DT nodes.
This uses the dt_for_each_{irq_map,range} helpers to map the interrupt
and child MMIO regions to dom0. Since PCI busses are enumerable these
resources may not be otherwise described in the DT (although they can
be).

Although PCI is the only bus we handle this way the code should be
generic enough to apply to similar buses in the future.

This replaces the xgene specific mapping. Tested on Mustang and on a
model with a PCI virtio controller.

This patch doesn't stop recursing when it finds such a node, since
double mapping these resources if they do happen to be described is
(or should be) harmless

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-07 15:10:44 +01:00
Ian Campbell eed5e395e0 xen: arm: drop redundant extra call to vgic_reserve_virq
This is only needed if we are giving the IRQ to dom0 (as opposed to
setting it up for passthrough due to xen,passthrough property). There
is already a call to vgic_reserve_virq inside the if ( need_mapping ),
so drop this one.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-07 15:10:44 +01:00
Ian Campbell f9d08f49dc xen: dt: add dt_for_each_range helper
This function iterates over a node's ranges property and calls a
callback for each region. For now it only supplies the MMIO range (in
terms of CPU addresses, i.e. already translated).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-07 15:10:44 +01:00
Ian Campbell 5cefb30c86 xen: dt: add dt_for_each_irq_map helper
This function iterates over a nodes interrupt-map property and calls a
callback for each interrupt. For now it only supplies the translated
IRQ since my use case has no need of e.g. child unit address. These
can be added as needed by any future users.

This follows much the same logic as dt_irq_map_raw when parsing the
interrupt-map, but doesn't walk up the tree doing the actual
translation and it iterates over all entries instead of just looking
for the first match.

I looked into refactoring dt_irq_map_raw but I couldn't find a way
which I was confident in, plus I was reluctant to diverge from the
Linux roots of this function any further.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-07-07 15:10:44 +01:00
Ian Campbell d7f132c762 tools: Rerun autogen.sh with Jessie version of autoconf
I have upgraded the box which I use to do committing (and hence run
autogen.sh on) from Debian Wheezy to Jessie, resulting in a upgrade
from autoconf 2.69-1 to 2.69-8. To avoid noise from this transition
when the next configure.ac change occurs regenerate those files now.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
2015-07-07 15:10:44 +01:00
Ian Campbell 9ba66fc82e Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-07-03 16:33:45 +01:00
Ian Campbell 9379af08cc stubdom: vtpmmgr: Correctly format size_t with %z when printing.
Also contains a fix from Thomas Leonard (to use %u for "4 + 32", not
%lu) previously posted as part of "mini-os: enable compiler check for
printk format types" but with mini-os now having been split a separate
repo most of that change has been applied there.

This fixes the 32-bit build with updated mini-os which includes format
string checking.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-By: Samuel Thibault <samuel.thibault@ens-lyon.org>
[ ijc -- Updated MINIOS_UPSTREAM_REVISION ]
2015-07-03 11:11:28 +01:00
Ian Campbell 3b949cb131 xen: arm: Fixup stray hard tabs
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-06-30 15:20:30 +01:00
Ian Campbell 1f627301e6 xen: Install unstripped version -syms version into /usr/lib/debug
xen-*-syms cannot actually be booted, so putting it in /boot is a bit
misleading. It also happens to cause a warning from update-grub (so at
least it doesn't end up in grub.cfg)

/usr/lib/debug seems to be a pretty common path for installing such
debug info.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
[ ijc -- fixed typos ]
2015-06-30 15:00:53 +01:00
Ian Campbell fff2304e47 xen: arm: Log a warning message when a deprecated hypercall is used
A few folks have been caught out by OSes which call e.g.
HYPERVISOR_event_channel_op_compat which has been deprecated since
3.2.2 (i.e. long before Xen on ARM). Existing x86 code can still
safely and quietly using those calls, waiting for an unsuspecting ARM
porter to turn up and trip over it. This turns out to be rather
perplexing when it happens, since it can be obscured e.g. by various
conditionals like __XEN_INTERFACE_VERSION__ what is actually being
called.

Note that I'm making a distinction here between hypercalls which are
simply not used/implemented on arm (yet) and those which were
deprecated and replaced by a newer variant prior to Xen on ARM even
being invented.  The latter will never be implemented on ARM and have
non-deprecated aliases leading to confusion so those are the ones for
which a warning is useful.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Ard Biesheuvel <ard@linaro.org>
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-06-30 15:00:53 +01:00
Ian Campbell bdf741bf4d Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-06-26 14:49:27 +01:00
Ian Campbell 5f33fa2bca tools: libxl: Take the userdata lock around maxmem changes
There is an issue in libxl_set_memory_target whereby the target and
the max mem can get out of sync, this is because the call the
xc_domain_setmaxmem is not tied in any way to the xenstore transaction
which controls updates to the xenstore side of things.

Consider a domain with 1M of RAM (==target and maxmem for the sake of
argument) and two simultaneous calls to libxl_set_memory_target, both
with relative=0 and enforce=1, one with target=3 and the other with
target=5.

target=5 call                   target=3 call

transaction start
                                transaction start
write target=5 to xenstore
                                write target=3 to xenstore
setmaxmem(5)
                                setmaxmem(3)

transaction commit = success
                                transaction commit = EAGAIN

At this point maxmem=3 while target=5.

In reality the target=3 case will the retry and eventually (hopefully)
succeed with target=maxmem=3, however the bad state will persist for
some window which is undesirable. On failure other than EAGAIN all
bets are off anyway, but in that case we will likely stick in the bad
state until someone else sets the memory).

To fix this we slightly abuse the userdata lock which is used to
protect updates to the domain's json configuration. Abused because
maxmem is not actually stored in there, but is kept by Xen. However
the lock protects some semantically similar things and is convenient
to use here too.

libxl_domain_setmaxmem also takes the lock, since it reads
memory/target from xenstore before calling xc_domain_setmaxmem there
is a small (but perhaps not very interesting) race there too.

There is on more use of xc_domain_setmaxmem in libxl__build_pre.
However taking a lock around this would be tricky since the xenstore
parts are not done until libxl__build_post. I think this one could be
argued to be OK since the domid is not "public" yet, that is it has
not been returned to the application yet (as the result of the create
operation). Toolstacks which go round fiddling with random domid's
which they find lying on the floor should be taught to do better.

Add a doc note that taking the userdata lock requires the CTX_LOCK to
be held.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-06-26 12:59:10 +01:00
Ian Campbell 46bc4edd8c Update to SeaBIOS rel-1.8.2
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2015-06-26 12:56:59 +01:00
Ian Campbell d45e9b7c53 xen: arm: Do not expose PMU to domain 0
It uses a PPI which we cannot route to a guest, and will surely need
more support than just that anyway.

I noticed this on Mustang with UEFI where the built in DTB contains a
node of this type.

According to linux/Documentation/devicetree/bindings/arm/pmu.txt the
ARM v7 (Cortex-A{7,15}) PMUs require a PPI too, so blacklist them as
well.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-06-17 14:07:16 +01:00
Ian Campbell fcbfaf9d26 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-06-16 12:42:27 +01:00
Ian Campbell ecdae1cfaa Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-06-05 14:35:49 +01:00
Ian Campbell 6a7f7c988b xen: arm: add missing newline to error message.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-06-05 13:02:57 +01:00
Ian Campbell 47ec25a3c8 Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-05-29 13:22:31 +01:00
Ian Campbell 6b05648d12 xen: Simplify TSC domctls by removing double info field
There is no need to have this twice and we can simply inline
xen_guest_tsc_info into xen_domctl_tsc_info as well.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <JBeulich@suse.com>
2015-05-26 14:21:11 +01:00
Ian Campbell f057af7aad xen: x86: copy back tsc info, not pointer to tsc info in domctl
In 38b37ed827 "x86/domctl: cleanup", XEN_DOMCTL_gettscinfo was
changed to use the standard copyback mechanism.

However the output TSC Info is a guerst handle, i.e. a pointer to the
location for the information, copyback just copies the unchanged
pointer back.

Switch back to fetching the details into a local struct and explicitly
copying it back.

This caused test failures in the Cambridge instance of osstest, but
not for some reason in the production instance.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
2015-05-26 14:21:04 +01:00
Ian Campbell c2d58b03d1 docs: correct pod syntax
Olaf reports:
[  146s] man/xl.pod.1 around line 1529: '=item' outside of any '=over'
[  146s] man/xl.pod.1 around line 1531: You forgot a '=back' before '=head1'
[  146s] POD document had syntax errors at /usr/bin/pod2text line 84.
[  146s] Makefile:167: recipe for target 'txt/man/xl.1.txt' failed
[  146s] make[1]: *** [txt/man/xl.1.txt] Error 255

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
2015-05-21 19:01:03 +01:00
Ian Campbell b521422bd9 libxl: assign a default ssidref (XSM label) to guests
We have now arranged for SECINITSID_DOMU and SECINITSID_DOMDM to be
defined (correspondng to system_u:system_r:domU_t and
system_u:system_r:dm_dom_t respectively in the default policy). Use
these as the default for the SSID of every (stub)domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Cc: Wei.Liu2@citrix.com
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2015-05-21 15:25:53 +01:00
Ian Campbell 317cf71bc7 tools: Expose XSM Flask initial SIDs list to tools
By generating tools/include/xen-xsm/flask/flask.h using the same tool
as used during the hypervisor build.

Note that this is done regardless of whether XSM is enabled, since we
want the tools to be agnostic to whether or not XSM is enabled in the
hypervisor

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2015-05-21 15:25:47 +01:00
Ian Campbell de7fa4cefd xen: flask: Restrict generated header to xen + tools
This isn't strictly necessary but since it is going to be exposed via
tools/include in a later patch this will help prevent accidental
leakage beyond the tools.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2015-05-21 15:25:41 +01:00
Ian Campbell f06c84e047 xen: flask: Pass output directory as a parameter to mkflask.sh
When called from the tools side in a later patch we will want to
direct its output to the appropriate place.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
2015-05-21 15:25:35 +01:00
Ian Campbell a42eac01cb tools: Add AWK to set of tools checked for by configure
We are going to need this to generate the userspace flask.h header.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
[ ijc -- ran autogen.sh ]
2015-05-21 15:25:23 +01:00
Ian Campbell 28c0ec1d95 xen: arm: remove redundant declation of arch_get_xen_caps
It was recently commented out, but just remove it instead.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2015-05-20 13:05:28 +01:00
Ian Campbell 7cb37dfaaa Merge branch 'staging' of ssh://xenbits.xen.org/home/xen/git/xen into staging 2015-05-13 15:46:54 +01:00
Ian Campbell ee18075f5a xen: arm: slightly refactor gic DT node creation for domain 0.
Although in principal #interrupt-cells can vary it must always be 3
for a GIC (and we only support GIC as a guest interrupt controller),
so putting it in common code is OK.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@citrix.com>
2015-05-08 16:57:38 +01:00