]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
libxendevicemodel: support for marking memory dirty
authorIan Campbell <ian.campbell@citrix.com>
Fri, 29 Jan 2016 16:28:42 +0000 (16:28 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 10 Feb 2016 17:09:54 +0000 (17:09 +0000)
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 <ian.campbell@citrix.com>
tools/libs/devicemodel/Makefile
tools/libs/devicemodel/core_unstable.c [new file with mode: 0644]
tools/libs/devicemodel/include/xendevicemodel.h
tools/libs/devicemodel/libxendevicemodel.map

index 49599990f2adcf9299c8ddac90a2ba3fd7946622..7410de35ca87007caf2870801c89da052378a20b 100644 (file)
@@ -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 (file)
index 0000000..af9e0bc
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+
+#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:
+ */
index 42058b752d31259d42811ab120dca626a9c0536b..0858d68e9f1a336d4f31d7bc8bb13ed292bc3bdb 100644 (file)
@@ -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
  * =============
index f544eadbada2b3379f31aaf18702e81dcbb730d4..ea183c09031d2adfc714e4339fd9f1766683c4ff 100644 (file)
@@ -10,6 +10,8 @@ UNSTABLE {
                xendevicemodel_unmap_pcidev_from_ioreq_server;
                xendevicemodel_destroy_ioreq_server;
 
+               xendevicemodel_mark_memory_region_dirty;
+
                xendevicemodel_inject_msi;
 };