tools/libxendevicemodel: introduce the new library
PATCH 3/4 tools/libxendevicemodel: introduce a Linux-specific implementation
In reply to Paul DurrantMy recent patch [1] to the Linux privcmd module introduced a dedicated mechanism for making dm_op hypercalls.
This patch adds the necessary code to libxendevicemodel to take advantage of that mechanism if it is implemented in the tools domain kernel.
[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=ab520be8
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/include/xen-sys/Linux/privcmd.h | 13 ++++ tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/linux.c | 123 ++++++++++++++++++++++++++++++++++ tools/libs/devicemodel/private.h | 4 ++ 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 tools/libs/devicemodel/linux.c
tools/include/xen-sys/Linux/privcmd.h +13 -0
@@ -75,6 +75,17 @@ typedef struct privcmd_mmapbatch_v2 {int __user *err;/* array of error codes */ } privcmd_mmapbatch_v2_t; +typedef struct privcmd_dm_op_buf { +void __user *uptr; +size_t size; +}privcmd_dm_op_buf_t ; + +typedef struct privcmd_dm_op { +domid_t dom; +__u16 num; +const privcmd_dm_op_buf_t __user *ubufs; +}privcmd_dm_op_t ; +/* * @cmd: IOCTL_PRIVCMD_HYPERCALL * @arg: &privcmd_hypercall_t
@@ -88,5 +99,7 @@ typedef struct privcmd_mmapbatch_v2 { _IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))#define IOCTL_PRIVCMD_MMAPBATCH_V2 \ _IOC(_IOC_NONE, 'P', 4, sizeof(privcmd_mmapbatch_v2_t)) +#define IOCTL_PRIVCMD_DM_OP \ + _IOC(_IOC_NONE, 'P', 5, sizeof(privcmd_dm_op_t))#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
tools/libs/devicemodel/Makefile +1 -1
@@ -11,7 +11,7 @@ CFLAGS += $(CFLAGS_libxentoollog) CFLAGS += $(CFLAGS_libxencall) SRCS-y += core.c -SRCS-$(CONFIG_Linux) += compat.c +SRCS-$(CONFIG_Linux) += linux.c SRCS-$(CONFIG_FreeBSD) += compat.c SRCS-$(CONFIG_SunOS) += compat.c SRCS-$(CONFIG_NetBSD) += compat.c
tools/libs/devicemodel/linux.c new file +123 -0
123 lines not on this page · raw message
tools/libs/devicemodel/private.h +4 -0
@@ -11,6 +11,7 @@ struct xendevicemodel_handle {xentoollog_logger *logger, *logger_tofree;unsigned int flags;xencall_handle *xcall; +int fd; };struct xendevicemodel_buf {
@@ -28,6 +29,9 @@ int osdep_xendevicemodel_op(xendevicemodel_handle *dmod, domid_t domid, unsigned int nr_bufs, struct xendevicemodel_buf bufs[]); +#define PERROR(_f...) \ + xtl_log(dmod->logger, XTL_ERROR, errno, "xendevicemodel", _f) +#endif /*
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 4/4 tools/libxendevicemodel: add a call to restrict the handle
In reply to Paul DurrantMy recent patch [1] to the Linux privcmd module introduced a mechanism to restrict an open file handle to subsequently only accept operations for a specified domain.
This patch extends the libxendevicemodel API and make use of the mechanism in the Linux-specific code to restrict operations on the interface handle.
[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=4610d240
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/include/xen-sys/Linux/privcmd.h | 2 ++ tools/libs/devicemodel/compat.c | 9 +++++++++ tools/libs/devicemodel/core.c | 5 +++++ tools/libs/devicemodel/include/xendevicemodel.h | 10 ++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 1 + tools/libs/devicemodel/linux.c | 11 +++++++++++ tools/libs/devicemodel/private.h | 3 +++ 7 files changed, 41 insertions(+)
tools/include/xen-sys/Linux/privcmd.h +2 -0
@@ -101,5 +101,7 @@ typedef struct privcmd_dm_op { _IOC(_IOC_NONE, 'P', 4, sizeof(privcmd_mmapbatch_v2_t))#define IOCTL_PRIVCMD_DM_OP \ _IOC(_IOC_NONE, 'P', 5, sizeof(privcmd_dm_op_t)) +#define IOCTL_PRIVCMD_RESTRICT \ + _IOC(_IOC_NONE, 'P', 6, sizeof(domid_t))#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
tools/libs/devicemodel/compat.c +9 -0
@@ -15,6 +15,8 @@* License along with this library; If not, see <http://www.gnu.org/licenses/>. */ +#include <errno.h> +#include "private.h" int osdep_xendevicemodel_open (xendevicemodel_handle *dmod)
@@ -34,6 +36,13 @@ int osdep_xendevicemodel_op(xendevicemodel_handle *dmod,return xendevicemodel_xcall (dmod, domid, nr_bufs, bufs); } +int osdep_xendevicemodel_restrict (xendevicemodel_handle *dmod, +domid_t domid) +{ + errno =EOPNOTSUPP ; +return -1 ; +} +/* * Local variables: * mode: C
tools/libs/devicemodel/core.c +5 -0
@@ -492,6 +492,11 @@ int xendevicemodel_inject_event(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); } +int xendevicemodel_restrict (xendevicemodel_handle *dmod,domid_t domid) +{ +return osdep_xendevicemodel_restrict (dmod, domid); +} +/* * Local variables: * mode: C
tools/libs/devicemodel/include/xendevicemodel.h +10 -0
@@ -283,6 +283,16 @@ int xendevicemodel_inject_event( xendevicemodel_handle *dmod, domid_t domid, int vcpu, uint8_t vector, uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2); +/** +* This function restricts the use of this handle to the specified +* domain. +* +* @parm dmod handle to the open devicemodel interface +* @parm domid the domain id +* @return 0 on success, -1 on failure. +*/ +int xendevicemodel_restrict (xendevicemodel_handle *dmod,domid_t domid); +#endif /* __XEN_TOOLS__ */ #endif /* XENDEVICEMODEL_H */
tools/libs/devicemodel/libxendevicemodel.map +1 -0
@@ -17,6 +17,7 @@ VERS_1.0 { xendevicemodel_modified_memory; xendevicemodel_set_mem_type; xendevicemodel_inject_event; + xendevicemodel_restrict; xendevicemodel_close; local: *; /* Do not expose anything by default */ };
tools/libs/devicemodel/linux.c +11 -0
@@ -112,6 +112,17 @@ int osdep_xendevicemodel_op(xendevicemodel_handle *dmod,return 0 ; } +int osdep_xendevicemodel_restrict (xendevicemodel_handle *dmod, +domid_t domid) +{ +if (dmod->fd <0 ) { + errno =EOPNOTSUPP ; +return -1 ; + } + +return ioctl (dmod->fd,IOCTL_PRIVCMD_RESTRICT , &domid); +} +/* * Local variables: * mode: C
tools/libs/devicemodel/private.h +3 -0
@@ -29,6 +29,9 @@ int osdep_xendevicemodel_op(xendevicemodel_handle *dmod, domid_t domid, unsigned int nr_bufs, struct xendevicemodel_buf bufs[]); +int osdep_xendevicemodel_restrict ( +xendevicemodel_handle *dmod,domid_t domid); + #define PERROR(_f...) \ xtl_log(dmod->logger, XTL_ERROR, errno, "xendevicemodel", _f)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/4 tools/libxendevicemodel: introduce the new library
The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the dm_op hypercall added by commit 524a98c2.
This patch adds the boilerplate for the new library, with only open() and close() entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch.
NOTE: After applying this patch libxenctrl will depend on libxendevicemodel
and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively.
[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-traditional.git;a=commit;h=a445da7e
[2] http://xenbits.xen.org/gitweb/?p=people/pauldu/mini-os.git;a=commit;h=41c9f2ae
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Samuel Thibault <[email protected]>
--- stubdom/Makefile | 17 ++++++- tools/Makefile | 1 + tools/Rules.mk | 10 +++- tools/libs/Makefile | 1 + tools/libs/devicemodel/Makefile | 66 ++++++++++++++++++++++++ tools/libs/devicemodel/core.c | 68 +++++++++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 40 +++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 6 +++ tools/libs/devicemodel/private.h | 22 ++++++++ tools/libxc/Makefile | 3 +- tools/libxc/xc_private.c | 11 +++- tools/libxc/xc_private.h | 4 ++ 12 files changed, 243 insertions(+), 6 deletions(-) create mode 100644 tools/libs/devicemodel/Makefile create mode 100644 tools/libs/devicemodel/core.c create mode 100644 tools/libs/devicemodel/include/xendevicemodel.h create mode 100644 tools/libs/devicemodel/libxendevicemodel.map create mode 100644 tools/libs/devicemodel/private.h
stubdom/Makefile +15 -2
@@ -337,13 +337,16 @@ libs-$(XEN_TARGET_ARCH)/call/stamp: $(XEN_ROOT)/tools/libs/call/Makefile libs-$(XEN_TARGET_ARCH)/foreignmemory/stamp: $(XEN_ROOT)/tools/libs/foreignmemory/Makefile $(do_links) +libs-$(XEN_TARGET_ARCH)/devicemodel/stamp: $(XEN_ROOT)/tools/libs/devicemodel/Makefile + $(do_links) + libxc-$(XEN_TARGET_ARCH)/stamp: $(XEN_ROOT)/tools/libxc/Makefile $(do_links) xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile $(do_links) -LINK_LIBS_DIRS := toollog evtchn gnttab call foreignmemory +LINK_LIBS_DIRS := toollog evtchn gnttab call foreignmemory devicemodel LINK_DIRS := libxc-$(XEN_TARGET_ARCH) xenstore $(foreach dir,$(LINK_LIBS_DIRS),libs-$(XEN_TARGET_ARCH)/$(dir)) LINK_STAMPS := $(foreach dir,$(LINK_DIRS),$(dir)/stamp)
@@ -414,12 +417,21 @@ libs-$(XEN_TARGET_ARCH)/foreignmemory/libxenforeignmemory.a: mk-headers-$(XEN_TA CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory ####### +# libxendevicemodel +####### + +.PHONY: libxendevicemodel +libxendevicemodel: libs-$(XEN_TARGET_ARCH)/devicemodel/libxendevicemodel.a +libs-$(XEN_TARGET_ARCH)/devicemodel/libxendevicemodel.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE) + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/devicemodel + +####### # libxc ####### .PHONY: libxc libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a -libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoollog libxenevtchn libxengnttab libxencall libxenforeignmemory cross-zlib +libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoollog libxenevtchn libxengnttab libxencall libxenforeignmemory libxendevicemodel cross-zlib CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libxc-$(XEN_TARGET_ARCH) libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a
@@ -616,6 +628,7 @@ clean: [ ! -e libs-$(XEN_TARGET_ARCH)/gnttab/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/gnttab clean [ ! -e libs-$(XEN_TARGET_ARCH)/call/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/call clean [ ! -e libs-$(XEN_TARGET_ARCH)/foreignmemory/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/foreignmemory clean + [ ! -e libs-$(XEN_TARGET_ARCH)/devicemodel/Makefile ] || $(MAKE) DESTDIR= -C libs-$(XEN_TARGET_ARCH)/devicemodel clean [ ! -e libxc-$(XEN_TARGET_ARCH)/Makefile ] || $(MAKE) DESTDIR= -C libxc-$(XEN_TARGET_ARCH) clean -[ ! -d ioemu ] || $(MAKE) DESTDIR= -C ioemu clean -[ ! -d xenstore ] || $(MAKE) DESTDIR= -C xenstore clean
tools/Makefile +1 -0
@@ -281,6 +281,7 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/gnttab \ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call \ -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory \ + -Wl,-rpath-link=$(XEN_ROOT)/tools/libs/devicemodel \ $(QEMU_UPSTREAM_RPATH)" \ --bindir=$(LIBEXEC_BIN) \ --datadir=$(SHAREDIR)/qemu-xen \
tools/Rules.mk +8 -2
@@ -15,6 +15,7 @@ XEN_LIBXENEVTCHN = $(XEN_ROOT)/tools/libs/evtchn XEN_LIBXENGNTTAB = $(XEN_ROOT)/tools/libs/gnttab XEN_LIBXENCALL = $(XEN_ROOT)/tools/libs/call XEN_LIBXENFOREIGNMEMORY = $(XEN_ROOT)/tools/libs/foreignmemory +XEN_LIBXENDEVICEMODEL = $(XEN_ROOT)/tools/libs/devicemodel XEN_LIBXC = $(XEN_ROOT)/tools/libxc XEN_XENLIGHT = $(XEN_ROOT)/tools/libxl XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore
@@ -117,10 +118,15 @@ CFLAGS_libxenforeignmemory = -I$(XEN_LIBXENFOREIGNMEMORY)/include $(CFLAGS_xenin LDLIBS_libxenforeignmemory = $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(libextension) SHLIB_libxenforeignmemory = -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY) +CFLAGS_libxendevicemodel = -I$(XEN_LIBXENDEVICEMODEL)/include $(CFLAGS_xeninclude) +SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) +LDLIBS_libxendevicemodel = $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension) +SHLIB_libxendevicemodel = -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL) + # code which compiles against libxenctrl get __XEN_TOOLS__ and # therefore sees the unstable hypercall interfaces. -CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) +CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ +SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) $(SHLIB_libxendevicemodel) LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension) SHLIB_libxenctrl = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC)
tools/libs/Makefile +1 -0
@@ -7,5 +7,6 @@ SUBDIRS-y += evtchn SUBDIRS-y += gnttab SUBDIRS-y += call SUBDIRS-y += foreignmemory +SUBDIRS-y += devicemodel all clean install distclean: %: subdirs-%
tools/libs/devicemodel/Makefile new file +66 -0
66 lines not on this page · raw message
tools/libs/devicemodel/core.c new file +68 -0
68 lines not on this page · raw message
tools/libs/devicemodel/include/xendevicemodel.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (c) 2017 Citrix Systems Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; If not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef XENDEVICEMODEL_H +#define XENDEVICEMODEL_H + +/* Callers who don't care don't need to #include <xentoollog.h> */ +struct xentoollog_logger ; + +typedef struct xendevicemodel_handle xendevicemodel_handle ; + +xendevicemodel_handle *xendevicemodel_open (struct xentoollog_logger *logger, +unsigned int open_flags); + +int xendevicemodel_close (xendevicemodel_handle *dmod); + +#endif /* XENDEVICEMODEL_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libs/devicemodel/libxendevicemodel.map new file +6 -0
@@ -0,0 +1,6 @@ +VERS_1.0 { + global: + xendevicemodel_open; + xendevicemodel_close; + local: *; /* Do not expose anything by default */ +};
tools/libs/devicemodel/private.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef XENDEVICEMODEL_PRIVATE_H +#define XENDEVICEMODEL_PRIVATE_H + +#include <xentoollog.h> +#include <xendevicemodel.h> + +struct xendevicemodel_handle { +xentoollog_logger *logger, *logger_tofree; +unsigned int flags; +}; + +#endif + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
tools/libxc/Makefile +2 -1
@@ -113,6 +113,7 @@ CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE CFLAGS += $(PTHREAD_CFLAGS) CFLAGS += $(CFLAGS_libxentoollog) CFLAGS += $(CFLAGS_libxenevtchn) +CFLAGS += $(CFLAGS_libxendevicemodel) CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y)) CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))
@@ -217,7 +218,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR) $(SYMLINK_SHLIB) $< $@ libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(LDLIBS_libxendevicemodel) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) # libxenguest
tools/libxc/xc_private.c +10 -1
@@ -65,12 +65,18 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger, xch->fmem =xenforeignmemory_open (xch->error_handler,0 ); -if ( xch->xcall ==NULL ) +if ( xch->fmem ==NULL ) + goto err; + + xch->dmod =xendevicemodel_open (xch->error_handler,0 ); + +if ( xch->dmod ==NULL ) goto err;return xch; err: +xenforeignmemory_close (xch->fmem);xencall_close (xch->xcall);xtl_logger_destroy (xch->error_handler_tofree);if (xch != &xch_buf)free (xch);
@@ -90,6 +96,9 @@ int xc_interface_close(xc_interface *xch) rc =xenforeignmemory_close (xch->fmem);if (rc)PERROR ("Could not close foreign memory interface" ); + rc =xendevicemodel_close (xch->dmod); +if (rc)PERROR ("Could not close device model interface" ); +xtl_logger_destroy (xch->dombuild_logger_tofree);xtl_logger_destroy (xch->error_handler_tofree);
tools/libxc/xc_private.h +4 -0
@@ -36,6 +36,7 @@#include <xencall.h> #include <xenforeignmemory.h> +#include <xendevicemodel.h> #include <xen/sys/privcmd.h>
@@ -97,6 +98,9 @@ struct xc_interface_core {/* Foreign mappings */ xenforeignmemory_handle *fmem; + +/* Device model */ +xendevicemodel_handle *dmod; };int osdep_privcmd_open (xc_interface *xch);
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/4 tools/libxendevicemodel: extract functions and add a compat layer
This patch extracts all functions resulting in a dm_op hypercall from libxenctrl and moves them into libxendevicemodel. It also adds a compat layer into libxenctrl, which can be selected by defining XC_WANT_COMPAT_DEVICEMODEL_API to 1 before including xenctrl.h.
With this patch the core of libxendevicemodel still uses libxencall to issue the dm_op hypercalls, but this is done by calling through code that can be modified on a per-OS basis. A subsequent patch will add a Linux- specific variant.
NOTE: After applying this patch the compat layer will need to be enabled
in qemu-xen-traditional by applying patch [1].
[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-traditional.git;a=commit;h=82d15bd7
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/Makefile | 1 + tools/Rules.mk | 2 +- tools/libs/devicemodel/Makefile | 10 +- tools/libs/devicemodel/compat.c | 45 +++ tools/libs/devicemodel/core.c | 435 ++++++++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 258 ++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 16 + tools/libs/devicemodel/private.h | 19 ++ tools/libxc/Makefile | 1 + tools/libxc/include/xenctrl.h | 197 ----------- tools/libxc/include/xenctrl_compat.h | 47 +++ tools/libxc/xc_devicemodel_compat.c | 139 ++++++++ tools/libxc/xc_domain.c | 201 ----------- tools/libxc/xc_misc.c | 154 --------- tools/libxc/xc_private.c | 73 ---- 15 files changed, 970 insertions(+), 628 deletions(-) create mode 100644 tools/libs/devicemodel/compat.c create mode 100644 tools/libxc/xc_devicemodel_compat.c
tools/Makefile +1 -0
@@ -262,6 +262,7 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find --extra-cflags="-DXC_WANT_COMPAT_EVTCHN_API=1 \ -DXC_WANT_COMPAT_GNTTAB_API=1 \ -DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \ + -DXC_WANT_COMPAT_DEVICEMODEL_API=1 \ -I$(XEN_ROOT)/tools/include \ -I$(XEN_ROOT)/tools/libs/toollog/include \ -I$(XEN_ROOT)/tools/libs/evtchn/include \
tools/Rules.mk +1 -1
@@ -119,7 +119,7 @@ LDLIBS_libxenforeignmemory = $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(lib SHLIB_libxenforeignmemory = -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY) CFLAGS_libxendevicemodel = -I$(XEN_LIBXENDEVICEMODEL)/include $(CFLAGS_xeninclude) -SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) +SHDEPS_libxendevicemodel = $(SHLIB_libxentoollog) $(SHLIB_xencall) LDLIBS_libxendevicemodel = $(XEN_LIBXENDEVICEMODEL)/libxendevicemodel$(libextension) SHLIB_libxendevicemodel = -Wl,-rpath-link=$(XEN_LIBXENDEVICEMODEL)
tools/libs/devicemodel/Makefile +8 -2
@@ -8,8 +8,14 @@ SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map CFLAGS += -Werror -Wmissing-prototypes CFLAGS += -I./include $(CFLAGS_xeninclude) CFLAGS += $(CFLAGS_libxentoollog) - -SRCS-y += core.c +CFLAGS += $(CFLAGS_libxencall) + +SRCS-y += core.c +SRCS-$(CONFIG_Linux) += compat.c +SRCS-$(CONFIG_FreeBSD) += compat.c +SRCS-$(CONFIG_SunOS) += compat.c +SRCS-$(CONFIG_NetBSD) += compat.c +SRCS-$(CONFIG_MiniOS) += compat.c LIB_OBJS := $(patsubst %.c,%.o,$(SRCS-y)) PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS-y))
tools/libs/devicemodel/compat.c new file +45 -0
45 lines not on this page · raw message
tools/libs/devicemodel/core.c +435 -0
467 lines not on this page · raw message
tools/libs/devicemodel/include/xendevicemodel.h +258 -0
270 lines not on this page · raw message
tools/libs/devicemodel/libxendevicemodel.map +16 -0
@@ -1,6 +1,22 @@ VERS_1.0 { global: xendevicemodel_open; + xendevicemodel_create_ioreq_server; + xendevicemodel_get_ioreq_server_info; + xendevicemodel_map_io_range_to_ioreq_server; + xendevicemodel_unmap_io_range_from_ioreq_server; + xendevicemodel_map_pcidev_to_ioreq_server; + xendevicemodel_unmap_pcidev_from_ioreq_server; + xendevicemodel_destroy_ioreq_server; + xendevicemodel_set_ioreq_server_state; + xendevicemodel_set_pci_intx_level; + xendevicemodel_set_isa_irq_level; + xendevicemodel_set_pci_link_route; + xendevicemodel_inject_msi; + xendevicemodel_track_dirty_vram; + xendevicemodel_modified_memory; + xendevicemodel_set_mem_type; + xendevicemodel_inject_event; xendevicemodel_close; local: *; /* Do not expose anything by default */ };
tools/libs/devicemodel/private.h +19 -0
@@ -1,14 +1,33 @@#ifndef XENDEVICEMODEL_PRIVATE_H #define XENDEVICEMODEL_PRIVATE_H +#define __XEN_TOOLS__ 1 +#include <xentoollog.h> #include <xendevicemodel.h> +#include <xencall.h> struct xendevicemodel_handle {xentoollog_logger *logger, *logger_tofree;unsigned int flags; +xencall_handle *xcall; +}; + +struct xendevicemodel_buf { +void *ptr; +size_t size; }; +int xendevicemodel_xcall (xendevicemodel_handle *dmod, +domid_t domid,unsigned int nr_bufs, +struct xendevicemodel_buf bufs[]); + +int osdep_xendevicemodel_open (xendevicemodel_handle *dmod); +int osdep_xendevicemodel_close (xendevicemodel_handle *dmod); +int osdep_xendevicemodel_op (xendevicemodel_handle *dmod, +domid_t domid,unsigned int nr_bufs, +struct xendevicemodel_buf bufs[]); +#endif /*
tools/libxc/Makefile +1 -0
@@ -50,6 +50,7 @@ CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd.c CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c CTRL_SRCS-y += xc_evtchn_compat.c CTRL_SRCS-y += xc_gnttab_compat.c +CTRL_SRCS-y += xc_devicemodel_compat.c GUEST_SRCS-y := GUEST_SRCS-y += xg_private.c xc_suspend.c
tools/libxc/include/xenctrl.h +0 -197
209 lines not on this page · raw message
tools/libxc/include/xenctrl_compat.h +47 -0
53 lines not on this page · raw message
tools/libxc/xc_devicemodel_compat.c new file +139 -0
139 lines not on this page · raw message
tools/libxc/xc_domain.c +0 -201
207 lines not on this page · raw message
tools/libxc/xc_misc.c +0 -154
160 lines not on this page · raw message
tools/libxc/xc_private.c +0 -73
79 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 31 lines · Paul Durrant
The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the
dm_ophypercall added by commit524a98c2.This patch adds the boilerplate for the new library, with only
open()andclose()entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch.NOTE: After applying this patch libxenctrl will depend on libxendevicemodel
and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively.[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-traditional.git;a=commit;h=a445da7e
[2] http://xenbits.xen.org/gitweb/?p=people/pauldu/mini-os.git;a=commit;h=41c9f2aeSigned-off-by Paul Durrant <[email protected]>---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Samuel Thibault <[email protected]>--- stubdom/Makefile | 17 ++++++- tools/Makefile | 1 + tools/Rules.mk | 10 +++- tools/libs/Makefile | 1 + tools/libs/devicemodel/Makefile | 66 ++++++++++++++++++++++++ tools/libs/devicemodel/core.c | 68 +++++++++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 40 +++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 6 +++ tools/libs/devicemodel/private.h | 22 ++++++++ tools/libxc/Makefile | 3 +-
Quoted 9 lines
tools/libxc/xc_private.c | 11 +++- tools/libxc/xc_private.h | 4 ++ 12 files changed, 243 insertions(+), 6 deletions(-) create mode 100644 tools/libs/devicemodel/Makefile create mode 100644 tools/libs/devicemodel/core.c create mode 100644 tools/libs/devicemodel/include/xendevicemodel.h create mode 100644 tools/libs/devicemodel/libxendevicemodel.map create mode 100644 tools/libs/devicemodel/private.h
I skimmed through all the Makefile changes, assuming they are copied from existing files, they look fine.
Quoted 26 lines
tools/libxc/Makefile +2
-1@@ -113,6 +113,7 @@ CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE CFLAGS += $(PTHREAD_CFLAGS) CFLAGS += $(CFLAGS_libxentoollog) CFLAGS += $(CFLAGS_libxenevtchn) +CFLAGS += $(CFLAGS_libxendevicemodel) CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y)) CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))@@ -217,7 +218,7 @@ libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR) $(SYMLINK_SHLIB) $< $@ libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(LDLIBS_libxendevicemodel) $(PTHREAD_LIBS) $(APPEND_LDFLAGS) # libxenguesttools/libxc/xc_private.c +0
-0
tools/libxc/xc_private.c struct xc_interface_core *xc_interface_open(xentoollog_logger *logger, · line 70
Quoted 7 lines
tools/libxc/xc_private.c +3
-1@@ -65,12 +65,18 @@ struct xc_interface_core *xc_interface_open(xentoollog_logger *logger, xch->fmem =xenforeignmemory_open (xch->error_handler,0 ); -if ( xch->xcall ==NULL ) +if ( xch->fmem ==NULL ) + goto err; +
This is a bug fix that should be split out and backported.
Other than this, the code looks fine.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/libxendevicemodel: extract functions and add a compat layer
In reply to Paul DurrantQuoted 10 lines · Paul Durrant
This patch extracts all functions resulting in a
dm_ophypercall from libxenctrl and moves them into libxendevicemodel. It also adds a compat layer into libxenctrl, which can be selected by definingXC_WANT_COMPAT_DEVICEMODEL_APIto 1 before includingxenctrl.h.With this patch the core of libxendevicemodel still uses libxencall to issue the
dm_ophypercalls, but this is done by calling through code that can be modified on a per-OS basis. A subsequent patch will add a Linux- specific variant.
Quoted 5 lines
NOTE: After applying this patch the compat layer will need to be enabled
in qemu-xen-traditional by applying patch [1].[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-traditional.git;a=commit;h=82d15bd7
This needs an ack from Ian, though that patch itself is trivial.
Quoted 8 lines
tools/libs/devicemodel/core.c +8
-0+ +int xendevicemodel_track_dirty_vram ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t first_pfn, +uint32_t nr,unsigned long *dirty_bitmap) +{ +struct xen_dm_op op; +struct xen_dm_op_track_dirty_vram *data; +
tools/libs/devicemodel/core.c err: · line 433
Quoted 10 lines
tools/libs/devicemodel/core.c +10
-0+memset (&op,0 ,sizeof (op)); + + op.op = XEN_DMOP_track_dirty_vram; + data = &op.u.track_dirty_vram; + + data->first_pfn = first_pfn; + data->nr = nr; + +return xendevicemodel_op (dmod, domid,2 , &op,sizeof (op), + dirty_bitmap, (nr +7 ) /8 );
FYI You might need to rebase -- I will commit a patch from Jan to fix type promotion at some point.
"libxc: don't pass uninitialized data to do_dm_op()"
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 4/4] tools/libxendevicemodel: add a call to restrict the handle
In reply to Paul DurrantQuoted 11 lines · Paul Durrant
My recent patch [1] to the Linux privcmd module introduced a mechanism to restrict an open file handle to subsequently only accept operations for a specified domain.
This patch extends the libxendevicemodel API and make use of the mechanism in the Linux-specific code to restrict operations on the interface handle.
[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=4610d240
Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/4] tools/libxendevicemodel: introduce a Linux-specific implementation
In reply to Paul DurrantQuoted 10 lines · Paul Durrant
My recent patch [1] to the Linux privcmd module introduced a dedicated mechanism for making
dm_ophypercalls.This patch adds the necessary code to libxendevicemodel to take advantage of that mechanism if it is implemented in the tools domain kernel.
[1] https://git.kernel.org/cgit/linux/kernel/git/ostr/linux.git/commit/?id=ab520be8
Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 97 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 20 February 2017 15:08
To: Paul Durrant <[email protected]>
Cc: [email protected]; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Samuel Thibault <samuel.thibault@ens- lyon.org>
Subject: Re: [PATCH 1/4]tools/libxendevicemodel: introduce the new libraryQuoted 9 lines · Paul Durrant
The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the
dm_ophypercall added by commit524a98c2.This patch adds the boilerplate for the new library, with only
open()andclose()entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch.NOTE: After applying this patch libxenctrl will depend on
libxendevicemodel
Quoted 4 lines
and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively.
[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-
traditional.git;a=commit;h=a445da7e
Quoted 1 line
os.git;a=commit;h=41c9f2ae
Quoted 6 lines
Signed-off-by Paul Durrant <[email protected]>---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Samuel Thibault <[email protected]>Quoted 6 lines
--- stubdom/Makefile | 17 ++++++- tools/Makefile | 1 + tools/Rules.mk | 10 +++- tools/libs/Makefile | 1 + tools/libs/devicemodel/Makefile | 66++++++++++++++++++++++++
Quoted 1 line
tools/libs/devicemodel/core.c | 68+++++++++++++++++++++++++
Quoted 1 line
tools/libs/devicemodel/include/xendevicemodel.h | 40+++++++++++++++
Quoted 12 lines
tools/libs/devicemodel/libxendevicemodel.map | 6 +++ tools/libs/devicemodel/private.h | 22 ++++++++ tools/libxc/Makefile | 3 +- tools/libxc/xc_private.c | 11 +++- tools/libxc/xc_private.h | 4 ++ 12 files changed, 243 insertions(+), 6 deletions(-) create mode 100644 tools/libs/devicemodel/Makefile create mode 100644 tools/libs/devicemodel/core.c create mode 100644 tools/libs/devicemodel/include/xendevicemodel.h create mode 100644 tools/libs/devicemodel/libxendevicemodel.map create mode 100644 tools/libs/devicemodel/private.hI skimmed through all the
Makefilechanges, assuming they are copied from existing files, they look fine.tools/libxc/Makefile libxenctrl.so.$(MAJOR):
Quoted 13 lines
tools/libxc/Makefile +1
-0@@ -113,6 +113,7 @@ CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE CFLAGS += $(PTHREAD_CFLAGS) CFLAGS += $(CFLAGS_libxentoollog) CFLAGS += $(CFLAGS_libxenevtchn) +CFLAGS += $(CFLAGS_libxendevicemodel) CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y)) CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))@@ -217,7 +218,7 @@ libxenctrl.so.$(MAJOR):libxenctrl.so.$(MAJOR).$(MINOR)
tools/libxc/Makefile libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR)
Quoted 4 lines
tools/libxc/Makefile +0
-1$(SYMLINK_SHLIB) $< $@ libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS) - $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
tools/libxc/Makefile libxenctrl.so.$(MAJOR): · line 221
Quoted 1 line
tools/libxc/Makefile +1
-0+ $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxengntshr) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(LDLIBS_libxendevicemodel) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
tools/libxc/xc_private.c struct xc_interface_core
Quoted 8 lines
tools/libxc/Makefile +0
-0# libxenguesttools/libxc/xc_private.c +0
-0@@ -65,12 +65,18 @@ struct xc_interface_core*xc_interface_open(xentoollog_logger *logger,
Quoted 1 line
Quoted 8 lines
tools/libxc/xc_private.c struct xc_interface_core *xc_interface_open(xentoollog_logger *logger, · line 70
Quoted 6 lines
xch->fmem = xenforeignmemory_open(xch->error_handler, 0);tools/libxc/xc_private.c +3
-1-if ( xch->xcall ==NULL ) +if ( xch->fmem ==NULL ) + goto err; +This is a bug fix that should be split out and backported.
Yeah, I forgot I fixed that along the way. I'll split it out.
Quoted 3 lines
Other than this, the code looks fine.
Thanks,
Paul
Quoted 1 line
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · Wei Liu
Quoted 4 lines · Paul Durrant
The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the
dm_ophypercall added by commit524a98c2.
Quoted 7 lines
Quoted 7 lines
This patch adds the boilerplate for the new library, with only
open()andclose()entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch.NOTE: After applying this patch libxenctrl will depend on libxendevicemodel
and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively.
Forgot to say:
Quoted 2 lines
Need an ack from Ian.
Quoted 2 lines
Need an ack from Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 30 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 20 February 2017 15:12
To: Paul Durrant <[email protected]>
Cc: [email protected]; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Samuel Thibault <samuel.thibault@ens- lyon.org>
Subject: Re: [PATCH 1/4]tools/libxendevicemodel: introduce the new libraryQuoted 10 lines · Wei Liu
Quoted 9 lines · Paul Durrant
The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the
dm_ophypercall added by commit524a98c2.This patch adds the boilerplate for the new library, with only
open()andclose()entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch.NOTE: After applying this patch libxenctrl will depend on
libxendevicemodel
Quoted 2 lines
Quoted 2 lines
and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively.
Forgot to say:
Quoted 2 lines
Quoted 2 lines
[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-
traditional.git;a=commit;h=a445da7e
Quoted 7 lines
Need an ack from Ian.
Quoted 1 line
Quoted 1 line
os.git;a=commit;h=41c9f2ae
Quoted 1 line
Quoted 1 line
Need an ack from Samuel
OK. I guess the right thing is to get those committed first and then move the tags in Config.mk on in the next version of this series?
Paul
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/4] tools/libxendevicemodel: extract functions and add a compat layer
In reply to Wei LiuQuoted 51 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 20 February 2017 15:09
To: Paul Durrant <[email protected]>
Cc: [email protected]; Ian Jackson <[email protected]>; Wei Liu <[email protected]>
Subject: Re: [PATCH 2/4]tools/libxendevicemodel: extract functions and add a compat layerQuoted 10 lines · Paul Durrant
This patch extracts all functions resulting in a
dm_ophypercall from libxenctrl and moves them into libxendevicemodel. It also adds a compat layer into libxenctrl, which can be selected by definingXC_WANT_COMPAT_DEVICEMODEL_APIto 1 before includingxenctrl.h.With this patch the core of libxendevicemodel still uses libxencall to issue the
dm_ophypercalls, but this is done by calling through code that can be modified on a per-OS basis. A subsequent patch will add a Linux- specific variant.Quoted 4 lines
NOTE: After applying this patch the compat layer will need to be enabled
in qemu-xen-traditional by applying patch [1].[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-
traditional.git;a=commit;h=82d15bd7
Quoted 1 line
This needs an ack from Ian, though that patch itself is trivial.
Quoted 8 lines
tools/libs/devicemodel/core.c +8
-0+ +int xendevicemodel_track_dirty_vram ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t first_pfn, +uint32_t nr,unsigned long *dirty_bitmap) +{ +struct xen_dm_op op; +struct xen_dm_op_track_dirty_vram *data; +tools/libs/devicemodel/core.c err: · line 433
Quoted 10 lines
tools/libs/devicemodel/core.c +10
-0+memset (&op,0 ,sizeof (op)); + + op.op = XEN_DMOP_track_dirty_vram; + data = &op.u.track_dirty_vram; + + data->first_pfn = first_pfn; + data->nr = nr; + +return xendevicemodel_op (dmod, domid,2 , &op,sizeof (op), + dirty_bitmap, (nr +7 ) /8 );FYI You might need to rebase -- I will commit a patch from Jan to fix type promotion at some point.
Quoted 2 lines
"libxc: don't pass uninitialized data to
do_dm_op()"
Ok. Thanks for the heads-up.
Paul
Quoted 1 line
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 32 lines · Paul Durrant
Quoted 32 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 20 February 2017 15:12
To: Paul Durrant <[email protected]>
Cc: [email protected]; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Samuel Thibault <samuel.thibault@ens- lyon.org>
Subject: Re: [PATCH 1/4]tools/libxendevicemodel: introduce the new libraryQuoted 10 lines · Wei Liu
Quoted 9 lines · Paul Durrant
The new xendevicemodel library is intended to be used by all Xen device models such that the only hypercall that use will be the
dm_ophypercall added by commit524a98c2.This patch adds the boilerplate for the new library, with only
open()andclose()entry points, and calls to those from libxenctrl in preparation for the compat layer added by a subsequent patch.NOTE: After applying this patch libxenctrl will depend on
libxendevicemodel
Quoted 2 lines
Quoted 2 lines
and so patches [1] and [2] must be applied to qemu-xen-traditional and mini-os respectively.
Forgot to say:
Quoted 2 lines
Quoted 2 lines
[1] http://xenbits.xen.org/gitweb/?p=people/pauldu/qemu-xen-
traditional.git;a=commit;h=a445da7e
Need an ack from Ian.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
os.git;a=commit;h=41c9f2ae
Quoted 1 line
Quoted 1 line
Need an ack from Samuel
OK. I guess the right thing is to get those committed first and then move the tags in Config.mk on in the next version of this series?
Yes.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Samuel Thibault
Acked-byQuoted 6 lines · Wei Liu, on lun. 20 févr. 2017 15:20:08 +0000, wrote:
Quoted 5 lines · Paul Durrant
Quoted 5 lines
From: Wei Liu [mailto:[email protected]]
Quoted 2 lines
Need an ack from Samuel
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel