qemu/hw/char
Ian Campbell e0cb42ae4b xen: Switch uses of xc_map_foreign_{pages,bulk} to use libxenforeignmemory API.
In Xen 4.7 we are refactoring parts libxenctrl into a number of
separate libraries which will provide backward and forward API and ABI
compatiblity.

One such library will be libxenforeignmemory which provides access to
privileged foreign mappings and which will provide an interface
equivalent to xc_map_foreign_{pages,bulk}.

The new xenforeignmemory_map() function behaves like
xc_map_foreign_pages() when the err argument is NULL and like
xc_map_foreign_bulk() when err is non-NULL, which maps into the shim
here onto checking err == NULL and calling the appropriate old
function.

Note that xenforeignmemory_map() takes the number of pages before the
arrays themselves, in order to support potentially future use of
variable-length-arrays in the prototype (in the future, when Xen's
baseline toolchain requirements are new enough to ensure VLAs are
supported).

In preparation for adding support for libxenforeignmemory add support
to the <=4.0 and <=4.6 compat code in xen_common.h to allow us to
switch to using the new API. These shims will disappear for versions
of Xen which include libxenforeignmemory.

Since libxenforeignmemory will have its own handle type but for <= 4.6
the functionality is provided by using a libxenctrl handle we
introduce a new global xen_fmem alongside the existing xen_xc. In fact
we make xen_fmem a pointer to the existing xen_xc, which then works
correctly with both <=4.0 (xc handle is an int) and <=4.6 (xc handle
is a pointer). In the latter case xen_fmem is actually a double
indirect pointer, but it all falls out in the wash.

Unlike libxenctrl libxenforeignmemory has an explicit unmap function,
rather than just specifying that munmap should be used, so the unmap
paths are updated to use xenforeignmemory_unmap, which is a shim for
munmap on these versions of xen. The mappings in xen-hvm.c do not
appear to be unmapped (which makes sense for a qemu-dm process)

In fb_disconnect this results in a change from simply mmap over the
existing mapping (with an implicit munmap) to expliclty unmapping with
xenforeignmemory_unmap and then mapping the required anonymous memory
in the same hole. I don't think this is a problem since any other
thread which was racily touching this region would already be running
the risk of hitting the mapping halfway through the call. If this is
thought to be a problem then we could consider adding an extra API to
the libxenforeignmemory interface to replace a foreign mapping with
anonymous shared memory, but I'd prefer not to.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2016-01-26 17:19:35 +00:00
..
cadence_uart.c char: cadence_uart: Split state struct and type into header 2015-05-18 16:41:12 +01:00
debugcon.c qdev: Remove hex8/32/64 property types 2014-02-14 21:12:04 +01:00
digic-uart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
escc.c qapi: Don't let implicit enum MAX member collide 2015-12-17 08:21:28 +01:00
etraxfs_ser.c cris: avoid "naked" qemu_log 2015-12-17 17:33:47 +01:00
exynos4210_uart.c hw: Don't use hw_error() for machine initialization errors 2016-01-13 11:58:58 +01:00
grlib_apbuart.c grlib_apbuart: QOM cast cleanup 2013-07-29 21:06:27 +02:00
imx_serial.c i.MX: Standardize i.MX serial debug. 2015-10-27 13:16:21 +00:00
ipoctal232.c savevm: Remove all the unneeded version_minimum_id_old (rest) 2014-05-14 15:24:51 +02:00
lm32_juart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
lm32_uart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
Makefile.objs stm32f2xx_USART: Add the stm32f2xx USART Controller 2015-03-11 13:21:05 +00:00
mcf_uart.c hw: fix mask for ColdFire UART command register 2015-08-14 23:40:32 +02:00
milkymist-uart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
omap_uart.c arm: Use g_new() & friends where that makes obvious sense 2015-09-07 10:39:27 +01:00
parallel.c Move parallel_hds_isa_init to hw/isa/isa-bus.c 2015-06-05 17:09:58 +02:00
pl011.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
sclpconsole-lm.c sclp: sort into categories 2015-04-30 13:21:41 +02:00
sclpconsole.c sclp: sort into categories 2015-04-30 13:21:41 +02:00
serial-isa.c serial: serial_hds_isa_init() shouldn't fail 2015-02-24 00:19:06 +01:00
serial-pci.c Include qapi/qmp/qerror.h exactly where needed 2015-06-22 18:20:41 +02:00
serial.c Use error_fatal to simplify obvious fatal errors 2016-01-13 11:58:58 +01:00
sh_serial.c sh4: Fix serial line access for Linux kernels later than 3.2 2013-10-02 22:55:28 +04:00
spapr_vty.c spapr-vty: Use TYPE_ definition instead of hardcoding 2015-07-07 17:44:53 +02:00
stm32f2xx_usart.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00
virtio-console.c virtio-console: notify chardev when writable 2015-05-29 09:56:01 +02:00
virtio-serial-bus.c virtio serial port: fix to incomplete QOMify 2016-01-13 15:19:51 +05:30
xen_console.c xen: Switch uses of xc_map_foreign_{pages,bulk} to use libxenforeignmemory API. 2016-01-26 17:19:35 +00:00
xilinx_uartlite.c sysbus: Make devices picking up backends unavailable with -device 2015-04-02 15:30:44 +02:00