[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 11/13] xen: XEN_DOMCTL_shadow_op hypercall



And some of the sub-subops.  It is a little hacky given the legacy way of
having several methods of enabling/disbling LOG_DIRTY mode.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 coregrind/m_syswrap/syswrap-xen.c |   64 +++++++++++++++++++++++++++++++++++++
 include/vki/vki-xen-domctl.h      |   36 ++++++++++++++++++++-
 2 files changed, 99 insertions(+), 1 deletion(-)

diff --git a/coregrind/m_syswrap/syswrap-xen.c 
b/coregrind/m_syswrap/syswrap-xen.c
index ea4a7c0..056f2b8 100644
--- a/coregrind/m_syswrap/syswrap-xen.c
+++ b/coregrind/m_syswrap/syswrap-xen.c
@@ -696,6 +696,49 @@ PRE(domctl)
       __PRE_XEN_DOMCTL_READ(getvcpuextstate, vcpuextstate, buffer);
       break;
 
+   case VKI_XEN_DOMCTL_shadow_op:
+       PRE_XEN_DOMCTL_READ(shadow_op, op);
+
+       switch(domctl->u.shadow_op.op)
+       {
+       case VKI_XEN_DOMCTL_SHADOW_OP_OFF:
+           /* No further inputs */
+           break;
+
+       case VKI_XEN_DOMCTL_SHADOW_OP_ENABLE:
+           PRE_XEN_DOMCTL_READ(shadow_op, mode);
+           switch(domctl->u.shadow_op.mode)
+           {
+           case XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY:
+               goto domctl_shadow_op_enable_logdirty;
+
+
+           default:
+               bad_subop(tid, layout, arrghs, status, flags,
+                         "__HYPERVISOR_domctl shadowop mode",
+                         domctl->u.shadow_op.mode);
+               break;
+           }
+
+       case VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY:
+       domctl_shadow_op_enable_logdirty:
+           /* No further inputs */
+           break;
+
+       case VKI_XEN_DOMCTL_SHADOW_OP_CLEAN:
+       case VKI_XEN_DOMCTL_SHADOW_OP_PEEK:
+           PRE_XEN_DOMCTL_READ(shadow_op, dirty_bitmap);
+           PRE_XEN_DOMCTL_READ(shadow_op, pages);
+           break;
+
+       default:
+           bad_subop(tid, layout, arrghs, status, flags,
+                     "__HYPERVISOR_domctl shadow(10)",
+                     domctl->u.shadow_op.op);
+           break;
+       }
+       break;
+
    default:
       bad_subop(tid, layout, arrghs, status, flags,
                 "__HYPERVISOR_domctl", domctl->cmd);
@@ -1212,6 +1255,27 @@ POST(domctl){
                      domctl->u.vcpuextstate.size);
       break;
 
+   case VKI_XEN_DOMCTL_shadow_op:
+       switch(domctl->u.shadow_op.op)
+       {
+       case VKI_XEN_DOMCTL_SHADOW_OP_OFF:
+           /* No outputs */
+           break;
+
+       case VKI_XEN_DOMCTL_SHADOW_OP_CLEAN:
+       case VKI_XEN_DOMCTL_SHADOW_OP_PEEK:
+           POST_XEN_DOMCTL_WRITE(shadow_op, pages);
+           POST_XEN_DOMCTL_WRITE(shadow_op, stats.fault_count);
+           POST_XEN_DOMCTL_WRITE(shadow_op, stats.dirty_count);
+           if(domctl->u.shadow_op.dirty_bitmap.p)
+               POST_MEM_WRITE((Addr)domctl->u.shadow_op.dirty_bitmap.p,
+                              domctl->u.shadow_op.pages * sizeof(vki_uint8_t));
+           break;
+
+       default:
+           break;
+       }
+       break;
    }
 #undef POST_XEN_DOMCTL_WRITE
 #undef __POST_XEN_DOMCTL_WRITE
diff --git a/include/vki/vki-xen-domctl.h b/include/vki/vki-xen-domctl.h
index 67dc2ef..7cce4af 100644
--- a/include/vki/vki-xen-domctl.h
+++ b/include/vki/vki-xen-domctl.h
@@ -173,6 +173,40 @@ struct vki_xen_domctl_vcpuaffinity {
     struct vki_xenctl_bitmap cpumap; /* IN/OUT */
 };
 
+struct vki_xen_domctl_shadow_op_stats {
+    vki_uint32_t fault_count;
+    vki_uint32_t dirty_count;
+};
+
+/* vki_xen_domctl_shadow_op.op is an utter mess for compatibily reasons. */
+
+struct vki_xen_domctl_shadow_op {
+    vki_uint32_t op; /* IN */
+
+#define VKI_XEN_DOMCTL_SHADOW_OP_OFF               0
+#define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE           32
+#define VKI_XEN_DOMCTL_SHADOW_OP_CLEAN            11
+#define VKI_XEN_DOMCTL_SHADOW_OP_PEEK             12
+#define VKI_XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION   30
+#define VKI_XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION   31
+
+#define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_TEST       1
+#define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY   2
+#define VKI_XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE  3
+
+    vki_uint32_t mode;
+
+#define XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT  (1 << 1)
+#define XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY (1 << 2)
+#define XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE (1 << 3)
+#define XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL  (1 << 4)
+
+    vki_uint32_t mb;
+    VKI_XEN_GUEST_HANDLE_64(vki_uint8) dirty_bitmap;
+    vki_xen_uint64_aligned_t pages;
+    struct vki_xen_domctl_shadow_op_stats stats;
+};
+
 struct vki_xen_domctl_max_mem {
     /* IN variables. */
     vki_xen_uint64_aligned_t max_memkb;
@@ -285,7 +319,7 @@ struct vki_xen_domctl {
         struct vki_xen_domctl_getpageframeinfo3 getpageframeinfo3;
         struct vki_xen_domctl_nodeaffinity      nodeaffinity;
         struct vki_xen_domctl_vcpuaffinity      vcpuaffinity;
-        //struct vki_xen_domctl_shadow_op         shadow_op;
+        struct vki_xen_domctl_shadow_op         shadow_op;
         struct vki_xen_domctl_max_mem           max_mem;
         struct vki_xen_domctl_vcpucontext       vcpucontext;
         struct vki_xen_domctl_getvcpuinfo       getvcpuinfo;
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.