From: Ian Campbell Date: Fri, 29 Jan 2016 16:28:42 +0000 (+0000) Subject: libxendevicemodel: support for marking memory dirty X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=55227469fdc11bc4ff66c926eeffed2e13c4924a;p=people%2Fliuw%2Flibxenctrl-split%2Fxen.git libxendevicemodel: support for marking memory dirty XXX underlying hypercall is not stable. Note this with the version of @@UNSTABLE. Also in order to build need to define __XEN_TOOLS__, use a separate source file to avoid accidentally poluting the stable bits of the library. TBD replace hypercall with a stable variant and move to core.c + version as @@1.0 Signed-off-by: Ian Campbell --- diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile index 49599990f2..7410de35ca 100644 --- a/tools/libs/devicemodel/Makefile +++ b/tools/libs/devicemodel/Makefile @@ -13,7 +13,7 @@ CFLAGS += $(CFLAGS_libxencall) LDLIBS += $(LDLIBS_libxentoollog) LDLIBS += $(LDLIBS_libxencall) -SRCS-y += core.c +SRCS-y += core.c core_unstable.c SRCS-y += emuirq.c emuirq_unstable.c SRCS-y += ioreqserv_unstable.c @@ -26,6 +26,7 @@ LIB += libxendevicemodel.so endif # XXX These use unstable hypervisor interfaces +core_unstable.o core_unstable.opic: CFLAGS += -D__XEN_TOOLS__ emuirq_unstable.o emuirq_unstable.opic: CFLAGS += -D__XEN_TOOLS__ ioreqserv_unstable.o ioreqserv_unstable.opic: CFLAGS += -D__XEN_TOOLS__ diff --git a/tools/libs/devicemodel/core_unstable.c b/tools/libs/devicemodel/core_unstable.c new file mode 100644 index 0000000000..af9e0bc9a2 --- /dev/null +++ b/tools/libs/devicemodel/core_unstable.c @@ -0,0 +1,60 @@ +/* + * 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 . + */ + +#include +#include +#include + +#include "private.h" + +int xendevicemodel_mark_memory_region_dirty(xendevicemodel_handle *dm, + xen_pfn_t start, xen_pfn_t nr) +{ + xen_hvm_modified_memory_t *arg; + int ret = -1; + + arg = xencall_alloc_buffer(dm->call, sizeof(*arg)); + if ( arg == NULL ) + { + LOGE(ERROR, "unable to allocate memory for modified memory hypercall"); + goto err; + } + + arg->domid = dm->domid; + arg->first_pfn = start; + arg->nr = nr; + + ret = xencall2(dm->call, __HYPERVISOR_hvm_op, + HVMOP_modified_memory, + (uintptr_t)arg); + + if ( ret ) + LOGE(ERROR, "modified memory hypercall failed"); + + xencall_free_buffer(dm->call, arg); + + err: + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h index 42058b752d..0858d68e9f 100644 --- a/tools/libs/devicemodel/include/xendevicemodel.h +++ b/tools/libs/devicemodel/include/xendevicemodel.h @@ -144,6 +144,18 @@ int xendevicemodel_set_isa_irq_level(xendevicemodel_handle *dm, int xendevicemodel_inject_msi(xendevicemodel_handle *dm, uint64_t addr, uint32_t data); +/* + * Memory handling + * =============== + */ + +/* + * Indicates to the hypervisor that emulation has resulting in the + * specified region of RAM has being modified. + */ +int xendevicemodel_mark_memory_region_dirty(xendevicemodel_handle *dm, + xen_pfn_t start, xen_pfn_t nr); + /* * IOREQ Servers * ============= diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map index f544eadbad..ea183c0903 100644 --- a/tools/libs/devicemodel/libxendevicemodel.map +++ b/tools/libs/devicemodel/libxendevicemodel.map @@ -10,6 +10,8 @@ UNSTABLE { xendevicemodel_unmap_pcidev_from_ioreq_server; xendevicemodel_destroy_ioreq_server; + xendevicemodel_mark_memory_region_dirty; + xendevicemodel_inject_msi; };