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

[Xen-devel] Re: [PATCHv2] valgrind support for Xen privcmd ioctls / hypercalls



1.    Yes , In my first email  i fix some errors to let your patch match
valgrind-3.6.1 . My patch is nearly the same as yours. only some line
numbers is different . And my patch is below:

diff --git a/configure.in b/configure.in
index 62e1837..e71ecd6 100644
--- a/configure.in
+++ b/configure.in
@@ -1608,6 +1608,11 @@ elif test x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_AIX5 ;
then
   mflag_secondary=-q32
 fi

+AC_ARG_WITH(xen,
+   [  --with-xen=             Specify location of Xen headers],
+   XEN_CFLAGS=-I$withval
+)
+AC_SUBST(XEN_CFLAGS)

 AC_ARG_WITH(mpicc,
    [  --with-mpicc=           Specify name of MPI2-ised C compiler],
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index d9d1bca..d7216f9 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -211,6 +211,7 @@
  m_syswrap/priv_syswrap-aix5.h \
  m_syswrap/priv_syswrap-darwin.h \
  m_syswrap/priv_syswrap-main.h \
+ m_syswrap/priv_syswrap-xen.h \
  m_ume/priv_ume.h


#----------------------------------------------------------------------------
@@ -338,6 +339,7 @@
  m_syswrap/syswrap-ppc64-aix5.c \
  m_syswrap/syswrap-x86-darwin.c \
  m_syswrap/syswrap-amd64-darwin.c \
+ m_syswrap/syswrap-xen.c \
  m_ume/elf.c \
  m_ume/macho.c \
  m_ume/main.c \
@@ -350,7 +352,7 @@
 libcoregrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_CPPFLAGS = \
     $(AM_CPPFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
 libcoregrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_CFLAGS = \
-    $(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
+    $(AM_CFLAGS_@VGCONF_PLATFORM_PRI_CAPS@) @XEN_CFLAGS@
 libcoregrind_@VGCONF_ARCH_PRI@_@VGCONF_OS@_a_CCASFLAGS = \
     $(AM_CCASFLAGS_@VGCONF_PLATFORM_PRI_CAPS@)
 if VGCONF_HAVE_PLATFORM_SEC
diff --git a/coregrind/m_debuginfo/debuginfo.c
b/coregrind/m_debuginfo/debuginfo.c
index 08babd0..5272fae 100644
--- a/coregrind/m_debuginfo/debuginfo.c
+++ b/coregrind/m_debuginfo/debuginfo.c
@@ -637,6 +637,11 @@ ULong VG_(di_notify_mmap)( Addr a, Bool allow_SkFileV )
    if (!filename)
       return 0;

+   if (strncmp(filename, "/proc/xen/", 10) == 0) {
+      //VG_(printf)("ignoring mmap of %s\n", filename);
+      return 0;
+   }
+
    if (debug)
       VG_(printf)("di_notify_mmap-2: %s\n", filename);

diff --git a/coregrind/m_syswrap/priv_syswrap-xen.h
b/coregrind/m_syswrap/priv_syswrap-xen.h
new file mode 100644
index 0000000..42505bb
--- /dev/null
+++ b/coregrind/m_syswrap/priv_syswrap-xen.h
@@ -0,0 +1,13 @@
+#ifndef __PRIV_SYSWRAP_XEN_H
+#define __PRIV_SYSWRAP_XEN_H
+
+DECL_TEMPLATE(xen, ioctl_privcmd_hypercall);
+DECL_TEMPLATE(xen, ioctl_privcmd_mmap);
+DECL_TEMPLATE(xen, ioctl_privcmd_mmapbatch);
+DECL_TEMPLATE(xen, ioctl_privcmd_mmapbatch_v2);
+
+#endif   // __PRIV_SYSWRAP_XEN_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/coregrind/m_syswrap/syswrap-linux.c
b/coregrind/m_syswrap/syswrap-linux.c
index 247402d..baa33c2 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -57,7 +57,7 @@
 #include "priv_types_n_macros.h"
 #include "priv_syswrap-generic.h"
 #include "priv_syswrap-linux.h"
-
+#include "priv_syswrap-xen.h"

 // Run a thread from beginning to end and return the thread's
 // scheduler-return-code.
@@ -4864,6 +4864,20 @@ PRE(sys_ioctl)
       }
       break;

+
+   case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL:
+      WRAPPER_PRE_NAME(xen, ioctl_privcmd_hypercall)(tid, layout, arrghs,
status, flags);
+      break;
+   case VKI_XEN_IOCTL_PRIVCMD_MMAP:
+      WRAPPER_PRE_NAME(xen, ioctl_privcmd_mmap)(tid, layout, arrghs,
status, flags);
+      break;
+   case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH:
+      WRAPPER_PRE_NAME(xen, ioctl_privcmd_mmapbatch)(tid, layout, arrghs,
status, flags);
+      break;
+   case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2:
+      WRAPPER_PRE_NAME(xen, ioctl_privcmd_mmapbatch_v2)(tid, layout,
arrghs, status, flags);
+      break;
+
    default:
       /* EVIOC* are variable length and return size written on success */
       switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) {
@@ -5676,6 +5676,19 @@ POST(sys_ioctl)
       }
       break;

+   case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL:
+      WRAPPER_POST_NAME(xen, ioctl_privcmd_hypercall)(tid, arrghs, status);
+      break;
+   case VKI_XEN_IOCTL_PRIVCMD_MMAP:
+      WRAPPER_POST_NAME(xen, ioctl_privcmd_mmap)(tid, arrghs, status);
+      break;
+   case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH:
+      WRAPPER_POST_NAME(xen, ioctl_privcmd_mmapbatch)(tid, arrghs, status);
+      break;
+   case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2:
+      WRAPPER_POST_NAME(xen, ioctl_privcmd_mmapbatch_v2)(tid, arrghs,
status);
+      break;
+
    default:
       /* EVIOC* are variable length and return size written on success */
       switch (ARG2 & ~(_VKI_IOC_SIZEMASK << _VKI_IOC_SIZESHIFT)) {
diff --git a/coregrind/m_syswrap/syswrap-xen.c
b/coregrind/m_syswrap/syswrap-xen.c
new file mode 100644
index 0000000..5e87f8e
--- /dev/null
+++ b/coregrind/m_syswrap/syswrap-xen.c
@@ -0,0 +1,751 @@
+#include "pub_core_basics.h"
+#include "pub_core_vki.h"
+#include "pub_core_vkiscnums.h"
+#include "pub_core_threadstate.h"
+#include "pub_core_aspacemgr.h"
+#include "pub_core_debuginfo.h"    // VG_(di_notify_*)
+#include "pub_core_transtab.h"     // VG_(discard_translations)
+#include "pub_core_xarray.h"
+#include "pub_core_clientstate.h"
+#include "pub_core_debuglog.h"
+#include "pub_core_libcbase.h"
+#include "pub_core_libcassert.h"
+#include "pub_core_libcfile.h"
+#include "pub_core_libcprint.h"
+#include "pub_core_libcproc.h"
+#include "pub_core_libcsignal.h"
+#include "pub_core_mallocfree.h"
+#include "pub_core_tooliface.h"
+#include "pub_core_options.h"
+#include "pub_core_scheduler.h"
+#include "pub_core_signals.h"
+#include "pub_core_syscall.h"
+#include "pub_core_syswrap.h"
+
+#include "priv_types_n_macros.h"
+#include "priv_syswrap-generic.h"
+#include "priv_syswrap-xen.h"
+
+#include <stdint.h>
+
+#define __XEN_TOOLS__
+
+#include &lt;xen/xen.h&gt;
+#include &lt;xen/sysctl.h&gt;
+#include &lt;xen/domctl.h&gt;
+#include &lt;xen/memory.h&gt;
+#include &lt;xen/event_channel.h&gt;
+#include &lt;xen/version.h&gt;
+
+#include &lt;xen/hvm/hvm_op.h&gt;
+
+#define PRE(name)       DEFN_PRE_TEMPLATE(xen, name)
+#define POST(name)      DEFN_POST_TEMPLATE(xen, name)
+
+PRE(ioctl_privcmd_hypercall)
+{
+   struct vki_xen_privcmd_hypercall *args = (struct
vki_xen_privcmd_hypercall *)(ARG3);
+
+   if (!args)
+      return;
+
+
+   switch (args->op) {
+   case __HYPERVISOR_memory_op:
+      PRINT("__HYPERVISOR_memory_op ( %lld, %llx )", args->arg[0],
args->arg[1]);
+
+      switch (args->arg[0]) {
+      case XENMEM_set_memory_map: {
+        xen_foreign_memory_map_t *arg = (xen_foreign_memory_map_t
*)(unsigned int)args->arg[1];
+        PRE_MEM_READ("XENMEM_set_memory_map", (Addr)&arg->domid,
sizeof(arg->domid));
+        PRE_MEM_READ("XENMEM_set_memory_map", (Addr)&arg->map,
sizeof(arg->map));
+        break;
+      }
+      case XENMEM_increase_reservation:
+      case XENMEM_decrease_reservation:
+      case XENMEM_populate_physmap: {
+        struct xen_memory_reservation *memory_reservation = (struct
xen_memory_reservation *)(unsigned int)args->arg[1];
+        char *which;
+
+        switch (args->arg[0]) {
+        case XENMEM_increase_reservation:
+           which = "XENMEM_increase_reservation";
+           break;
+        case XENMEM_decrease_reservation:
+           which = "XENMEM_decrease_reservation";
+           PRE_MEM_READ(which, (Addr)memory_reservation->extent_start.p,
sizeof(xen_pfn_t) * memory_reservation->nr_extents);
+        case XENMEM_populate_physmap:
+           which = "XENMEM_populate_physmap";
+           PRE_MEM_READ(which, (Addr)memory_reservation->extent_start.p,
sizeof(xen_pfn_t) * memory_reservation->nr_extents);
+           break;
+        default:
+           which = "XENMEM_unknown";
+           break;
+        }
+
+        PRE_MEM_READ(which, (Addr)&memory_reservation->extent_start,
sizeof(memory_reservation->extent_start));
+        PRE_MEM_READ(which, (Addr)&memory_reservation->nr_extents,
sizeof(memory_reservation->nr_extents));
+        PRE_MEM_READ(which, (Addr)&memory_reservation->extent_order,
sizeof(memory_reservation->extent_order));
+        PRE_MEM_READ(which, (Addr)&memory_reservation->mem_flags,
sizeof(memory_reservation->mem_flags));
+        PRE_MEM_READ(which, (Addr)&memory_reservation->domid,
sizeof(memory_reservation->domid));
+
+        break;
+      }
+
+      default:
+        VG_(printf)("pre __HYPERVISOR_memory_op unknown command %lld\n",
args->arg[0]);
+        break;
+      }
+      break;
+
+   case __HYPERVISOR_mmuext_op: {
+          mmuext_op_t *ops = (void *)(unsigned int)args->arg[0];
+          unsigned int i, nr = args->arg[1];
+          //unsigned int *pdone = (void *)(unsigned int)args->arg[2];
+          //unsigned int foreigndom = args->arg[3];
+          //VG_(printf)("HYPERVISOR_mmuext_op %d ops at %p on dom%d done at
%p\n", nr, ops, foreigndom, pdone);
+          for (i=0; i&lt;nr; i++) {
+                  mmuext_op_t *op = ops + i;
+                  PRE_MEM_READ(&quot;__HYPERVISOR_MMUEXT_OP&quot;,
(Addr)&amp;op-&gt;cmd, sizeof(op->cmd));
+                  switch(op->cmd) {
+                  case MMUEXT_PIN_L1_TABLE:
+                  case MMUEXT_PIN_L2_TABLE:
+                  case MMUEXT_PIN_L3_TABLE:
+                  case MMUEXT_PIN_L4_TABLE:
+                  case MMUEXT_UNPIN_TABLE:
+                  case MMUEXT_NEW_BASEPTR:
+                  case MMUEXT_CLEAR_PAGE:
+                  case MMUEXT_COPY_PAGE:
+                  case MMUEXT_MARK_SUPER:
+                  case MMUEXT_UNMARK_SUPER:
+                          PRE_MEM_READ("__HYPERVISOR_MMUEXT_OP arg1.mfn",
(Addr)&op->arg1.mfn, sizeof(op->arg1.mfn));
+                          break;
+
+                  case MMUEXT_INVLPG_LOCAL:
+                  case MMUEXT_INVLPG_ALL:
+                  case MMUEXT_SET_LDT:
+                          PRE_MEM_READ("__HYPERVISOR_MMUEXT_OP arg1.mfn",
(Addr)&op->arg1.linear_addr, sizeof(op->arg1.linear_addr));
+                          break;
+
+                  case MMUEXT_TLB_FLUSH_LOCAL:
+                  case MMUEXT_TLB_FLUSH_MULTI:
+                  case MMUEXT_INVLPG_MULTI:
+                  case MMUEXT_TLB_FLUSH_ALL:
+                  case MMUEXT_FLUSH_CACHE:
+                  case MMUEXT_NEW_USER_BASEPTR:
+                  case MMUEXT_FLUSH_CACHE_GLOBAL:
+                          /* None */
+                          break;
+                  }
+
+                  switch(op->cmd) {
+                  case MMUEXT_SET_LDT:
+                          PRE_MEM_READ("__HYPERVISOR_MMUEXT_OP
arg2.nr_ents", (Addr)&op->arg2.nr_ents, sizeof(op->arg2.nr_ents));
+                          break;
+
+                  case MMUEXT_TLB_FLUSH_MULTI:
+                  case MMUEXT_INVLPG_MULTI:
+                          /* How many??? */
+                          PRE_MEM_READ("__HYPERVISOR_MMUEXT_OP
arg2.vcpumask", (Addr)&op->arg2.vcpumask, sizeof(op->arg2.vcpumask));
+                          break;
+
+                  case MMUEXT_COPY_PAGE:
+                          PRE_MEM_READ("__HYPERVISOR_MMUEXT_OP
arg2.src_mfn", (Addr)&op->arg2.src_mfn, sizeof(op->arg2.src_mfn));
+                          break;
+
+                  case MMUEXT_PIN_L1_TABLE:
+                  case MMUEXT_PIN_L2_TABLE:
+                  case MMUEXT_PIN_L3_TABLE:
+                  case MMUEXT_PIN_L4_TABLE:
+                  case MMUEXT_UNPIN_TABLE:
+                  case MMUEXT_NEW_BASEPTR:
+                  case MMUEXT_TLB_FLUSH_LOCAL:
+                  case MMUEXT_INVLPG_LOCAL:
+                  case MMUEXT_TLB_FLUSH_ALL:
+                  case MMUEXT_INVLPG_ALL:
+                  case MMUEXT_FLUSH_CACHE:
+                  case MMUEXT_NEW_USER_BASEPTR:
+                  case MMUEXT_CLEAR_PAGE:
+                  case MMUEXT_FLUSH_CACHE_GLOBAL:
+                  case MMUEXT_MARK_SUPER:
+                  case MMUEXT_UNMARK_SUPER:
+                          /* None */
+                          break;
+                  }
+          }
+          break;
+   }
+
+   case __HYPERVISOR_event_channel_op:
+   case __HYPERVISOR_event_channel_op_compat: {
+      __vki_u32 cmd;
+      void *arg;
+      int compat = 0;
+
+      if (args->op == __HYPERVISOR_event_channel_op) {
+        cmd = args->arg[0];
+        arg = (void *)(unsigned int)args->arg[1];
+      } else {
+        struct evtchn_op *evtchn = (struct evtchn_op *)(unsigned
int)args->arg[0];
+        cmd = evtchn->cmd;
+        arg = &evtchn->u;
+        compat = 1;
+      }
+      PRINT("__HYPERVISOR_event_channel_op ( %d, %p )%s", cmd, arg, compat
? " compat" : "");
+
+      switch (cmd) {
+      case EVTCHNOP_alloc_unbound: {
+        struct evtchn_alloc_unbound *alloc_unbound = arg;
+        PRE_MEM_READ("EVTCHNOP_alloc_unbound", (Addr)&alloc_unbound->dom,
sizeof(alloc_unbound->dom));
+        PRE_MEM_READ("EVTCHNOP_alloc_unbound",
(Addr)&alloc_unbound->remote_dom, sizeof(alloc_unbound->remote_dom));
+        break;
+      }
+      default:
+        VG_(printf)("pre __HYPERVISOR_event_channel_op unknown command
%d\n", cmd);
+        break;
+      }
+      break;
+   }
+
+   case __HYPERVISOR_xen_version:
+      PRINT("__HYPERVISOR_xen_version ( %lld, %llx )", args->arg[0],
args->arg[1]);
+
+      switch (args->arg[0]) {
+      case XENVER_version:
+      case XENVER_extraversion:
+      case XENVER_compile_info:
+      case XENVER_capabilities:
+      case XENVER_changeset:
+      case XENVER_platform_parameters:
+      case XENVER_get_features:
+      case XENVER_pagesize:
+      case XENVER_guest_handle:
+      case XENVER_commandline:
+        /* No inputs */
+        break;
+
+      default:
+        VG_(printf)("pre __HYPERVISOR_xen_version unknown command %lld\n",
args->arg[0]);
+        break;
+      }
+      break;
+      break;
+   case __HYPERVISOR_sysctl: {
+      struct xen_sysctl *sysctl = (struct xen_sysctl *)(unsigned
int)args->arg[0];
+
+      PRINT("__HYPERVISOR_sysctl ( %d )", sysctl->cmd);
+
+      /* Single argument hypercall */
+      PRE_MEM_READ("hypercall", ARG3, 8 + ( 8 * 1 ) );
+
+      /*
+       * Common part of xen_sysctl:
+       *    uint32_t cmd;
+       *    uint32_t interface_version;
+       */
+      PRE_MEM_READ("__HYPERVISOR_sysctl", args->arg[0], sizeof(uint32_t) +
sizeof(uint32_t));
+
+      if (!sysctl || sysctl->interface_version !=
XEN_SYSCTL_INTERFACE_VERSION)
+        /* BUG ? */
+        return;
+
+#define __PRE_XEN_SYSCTL_READ(_sysctl, _union, _field)
PRE_MEM_READ("XEN_SYSCTL_" # _sysctl, \
+                                                       
(Addr)&sysctl->u._union._field, \
+                                                       
sizeof(sysctl->u._union._field))
+#define PRE_XEN_SYSCTL_READ(_sysctl, _field) __PRE_XEN_SYSCTL_READ(_sysctl,
_sysctl, _field)
+      switch (sysctl->cmd) {
+      case XEN_SYSCTL_getdomaininfolist:
+        PRE_XEN_SYSCTL_READ(getdomaininfolist, first_domain);
+        PRE_XEN_SYSCTL_READ(getdomaininfolist, max_domains);
+        PRE_XEN_SYSCTL_READ(getdomaininfolist, buffer);
+        break;
+
+      case XEN_SYSCTL_cpupool_op:
+        /* yes the interface is this fucking barking */
+        PRE_XEN_SYSCTL_READ(cpupool_op, op);
+
+        switch(sysctl->u.cpupool_op.op) {
+        case XEN_SYSCTL_CPUPOOL_OP_CREATE:
+        case XEN_SYSCTL_CPUPOOL_OP_DESTROY:
+        case XEN_SYSCTL_CPUPOOL_OP_INFO:
+        case XEN_SYSCTL_CPUPOOL_OP_ADDCPU:
+        case XEN_SYSCTL_CPUPOOL_OP_RMCPU:
+        case XEN_SYSCTL_CPUPOOL_OP_MOVEDOMAIN:
+           PRE_XEN_SYSCTL_READ(cpupool_op, cpupool_id);
+        }
+
+        if (sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_CREATE)
+           PRE_XEN_SYSCTL_READ(cpupool_op, sched_id);
+
+        if (sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_MOVEDOMAIN)
+           PRE_XEN_SYSCTL_READ(cpupool_op, domid);
+
+        if (sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_ADDCPU ||
+            sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_RMCPU)
+           PRE_XEN_SYSCTL_READ(cpupool_op, cpu);
+
+        break;
+
+      case XEN_SYSCTL_physinfo:
+        /* No input params */
+        break;
+
+      default:
+        VG_(printf)("pre sysctl version %x unknown cmd %d\n",
+                    sysctl->interface_version, sysctl->cmd);
+        break;
+      }
+#undef PRE_XEN_SYSCTL_READ
+#undef __PRE_XEN_SYSCTL_READ
+   }
+      break;
+
+   case __HYPERVISOR_domctl: {
+      struct xen_domctl *domctl = (struct xen_domctl *)(unsigned
int)args->arg[0];
+
+      PRINT("__HYPERVISOR_domctl ( %d )", domctl->cmd);
+
+      /* Single argument hypercall */
+      PRE_MEM_READ("hypercall", ARG3, 8 + ( 8 * 1 ) );
+
+      /*
+       * Common part of xen_domctl:
+       *    uint32_t cmd;
+       *    uint32_t interface_version;
+       *    domid_t  domain;
+       */
+      PRE_MEM_READ("__HYPERVISOR_domctl", args->arg[0], sizeof(uint32_t) +
sizeof(uint32_t) + sizeof(domid_t));
+
+      if (!domctl || domctl->interface_version !=
XEN_DOMCTL_INTERFACE_VERSION)
+        /* BUG ? */
+        return;
+
+      //PRE_REG_READ1(long, "__HYPERVISOR_domctl",);
+#define __PRE_XEN_DOMCTL_READ(_domctl, _union, _field)
PRE_MEM_READ("XEN_DOMCTL_" # _domctl, \
+                                                       
(Addr)&domctl->u._union._field, \
+                                                       
sizeof(domctl->u._union._field))
+#define PRE_XEN_DOMCTL_READ(_domctl, _field) __PRE_XEN_DOMCTL_READ(_domctl,
_domctl, _field)
+
+      switch (domctl->cmd) {
+      case XEN_DOMCTL_destroydomain:
+      case XEN_DOMCTL_pausedomain:
+      case XEN_DOMCTL_max_vcpus:
+      case XEN_DOMCTL_get_address_size:
+      case XEN_DOMCTL_gettscinfo:
+      case XEN_DOMCTL_getdomaininfo:
+      case XEN_DOMCTL_unpausedomain:
+        /* No input fields. */
+        break;
+
+      case XEN_DOMCTL_createdomain:
+        PRE_XEN_DOMCTL_READ(createdomain, ssidref);
+        PRE_XEN_DOMCTL_READ(createdomain, handle);
+        PRE_XEN_DOMCTL_READ(createdomain, flags);
+        break;
+
+      case XEN_DOMCTL_max_mem:
+        PRE_XEN_DOMCTL_READ(max_mem, max_memkb);
+        break;
+
+      case XEN_DOMCTL_set_address_size:
+        __PRE_XEN_DOMCTL_READ(set_address_size, address_size, size);
+        break;
+
+      case XEN_DOMCTL_settscinfo:
+        __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info, info.tsc_mode);
+        __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info, info.gtsc_khz);
+        __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info, info.incarnation);
+        __PRE_XEN_DOMCTL_READ(settscinfo, tsc_info, info.elapsed_nsec);
+        break;
+
+      case XEN_DOMCTL_hypercall_init:
+        PRE_XEN_DOMCTL_READ(hypercall_init, gmfn);
+        break;
+
+      case XEN_DOMCTL_getvcpuinfo:
+        PRE_XEN_DOMCTL_READ(getvcpuinfo, vcpu);
+        break;
+
+      case XEN_DOMCTL_getvcpuaffinity:
+        __PRE_XEN_DOMCTL_READ(getvcpuaffinity, vcpuaffinity, vcpu);
+        break;
+
+      case XEN_DOMCTL_setvcpuaffinity:
+        __PRE_XEN_DOMCTL_READ(setvcpuaffinity, vcpuaffinity, vcpu);
+        PRE_MEM_READ("XEN_DOMCTL_setvcpuaffinity",
+                     (Addr)domctl->u.vcpuaffinity.cpumap.bitmap.p,
+                       domctl->u.vcpuaffinity.cpumap.nr_cpus / 8);
+        break;
+
+      case XEN_DOMCTL_getvcpucontext:
+        __PRE_XEN_DOMCTL_READ(getvcpucontext, vcpucontext, vcpu);
+        break;
+
+      case XEN_DOMCTL_setvcpucontext:
+        __PRE_XEN_DOMCTL_READ(setvcpucontext, vcpucontext, vcpu);
+        __PRE_XEN_DOMCTL_READ(setvcpucontext, vcpucontext, ctxt.p);
+        break;
+
+      case XEN_DOMCTL_set_cpuid:
+        PRE_MEM_READ("XEN_DOMCTL_set_cpuid", (Addr)&domctl->u.cpuid,
sizeof(domctl->u.cpuid));
+        break;
+      default:
+        VG_(printf)("pre domctl version %x unknown cmd %d on domain %d\n",
+                    domctl->interface_version, domctl->cmd,
domctl->domain);
+        break;
+      }
+#undef PRE_XEN_DOMCTL_READ
+#undef __PRE_XEN_DOMCTL_READ
+   }
+      break;
+
+   case __HYPERVISOR_hvm_op: {
+      unsigned long op = args->arg[0];
+      void *arg = (void *)(unsigned long)args->arg[1];
+
+      PRINT("__HYPERVISOR_hvm_op ( %ld, %p )", op, arg);
+
+      //PRE_REG_READ1(long, "__HYPERVISOR_hvm_op",);
+#define __PRE_XEN_HVMOP_READ(_hvm_op, _type, _field)
PRE_MEM_READ("XEN_HVMOP_" # _hvm_op, \
+                                                                 
(Addr)&((_type*)arg)->_field, \
+                                                       
sizeof(((_type*)arg)->_field))
+#define PRE_XEN_HVMOP_READ(_hvm_op, _field) __PRE_XEN_HVMOP_READ(_hvm_op,
"xen_hvm_" # _hvm_op "_t", _field)
+
+      switch (op) {
+      case HVMOP_set_param:
+        __PRE_XEN_HVMOP_READ(set_param, xen_hvm_param_t, domid);
+        __PRE_XEN_HVMOP_READ(set_param, xen_hvm_param_t, index);
+        __PRE_XEN_HVMOP_READ(set_param, xen_hvm_param_t, value);
+        break;
+
+      case HVMOP_get_param:
+        __PRE_XEN_HVMOP_READ(get_param, xen_hvm_param_t, domid);
+        __PRE_XEN_HVMOP_READ(get_param, xen_hvm_param_t, index);
+        break;
+
+      default:
+        VG_(printf)("pre hvm_op unknown OP %ld\n", op);
+        break;
+#undef __PRE_XEN_HVMOP_READ
+#undef PRE_XEN_HVMOP_READ
+      }
+   }
+      break;
+
+   default:
+      VG_(printf)("pre unknown hypercall %lld ( %#llx, %#llx, %#llx, %#llx,
%#llx )\n",
+                 args->op, args->arg[0], args->arg[1], args->arg[2],
args->arg[3], args->arg[4]);
+   }
+}
+
+POST(ioctl_privcmd_hypercall)
+{
+   struct vki_xen_privcmd_hypercall *args = (struct
vki_xen_privcmd_hypercall *)(ARG3);
+
+   if (!args)
+      return;
+
+   switch (args->op) {
+   case __HYPERVISOR_memory_op:
+      switch (args->arg[0]) {
+      case XENMEM_set_memory_map:
+      case XENMEM_decrease_reservation:
+        /* No outputs */
+        break;
+      case XENMEM_increase_reservation:
+      case XENMEM_populate_physmap: {
+        struct xen_memory_reservation *memory_reservation = (struct
xen_memory_reservation *)(unsigned int)args->arg[1];
+
+        POST_MEM_WRITE((Addr)memory_reservation->extent_start.p,
sizeof(xen_pfn_t) * ARG1);
+      }
+        break;
+
+      default:
+        VG_(printf)("post __HYPERVISOR_memory_op unknown command %lld\n",
args->arg[0]);
+        break;
+      }
+      break;
+
+   case __HYPERVISOR_mmuext_op: {
+          //mmuext_op_t *ops = (void *)(unsigned int)args->arg[0];
+          //unsigned int nr = args->arg[1];
+          unsigned int *pdone = (void *)(unsigned int)args->arg[2];
+          //unsigned int foreigndom = args->arg[3];
+          /* simplistic */
+          POST_MEM_WRITE((Addr)pdone, sizeof(*pdone));
+          break;
+   }
+
+   case __HYPERVISOR_event_channel_op:
+   case __HYPERVISOR_event_channel_op_compat: {
+      __vki_u32 cmd;
+      void *arg;
+
+      if (args->op == __HYPERVISOR_event_channel_op) {
+        cmd = args->arg[0];
+        arg = (void *)(unsigned int)args->arg[1];
+      } else {
+        struct evtchn_op *evtchn = (struct evtchn_op *)(unsigned
int)args->arg[0];
+        cmd = evtchn->cmd;
+        arg = &evtchn->u;
+      }
+      switch (cmd) {
+      case EVTCHNOP_alloc_unbound: {
+        struct evtchn_alloc_unbound *alloc_unbound = arg;
+        POST_MEM_WRITE((Addr)&alloc_unbound->port,
sizeof(alloc_unbound->port));
+        break;
+      }
+      default:
+        VG_(printf)("post __HYPERVISOR_event_channel_op unknown command
%d\n", cmd);
+        break;
+      }
+      break;
+
+   }
+
+   case __HYPERVISOR_xen_version:
+      switch (args->arg[0]) {
+      case XENVER_version:
+        /* No outputs */
+        break;
+      case XENVER_extraversion:
+        POST_MEM_WRITE((Addr)args->arg[1], sizeof(xen_extraversion_t));
+        break;
+      case XENVER_compile_info:
+        POST_MEM_WRITE((Addr)args->arg[1], sizeof(xen_compile_info_t));
+        break;
+      case XENVER_capabilities:
+        POST_MEM_WRITE((Addr)args->arg[1],
sizeof(xen_capabilities_info_t));
+        break;
+      case XENVER_changeset:
+        POST_MEM_WRITE((Addr)args->arg[1], sizeof(xen_changeset_info_t));
+        break;
+      case XENVER_platform_parameters:
+        POST_MEM_WRITE((Addr)args->arg[1],
sizeof(xen_platform_parameters_t));
+        break;
+      case XENVER_get_features:
+        POST_MEM_WRITE((Addr)args->arg[1], sizeof(xen_feature_info_t));
+        break;
+      case XENVER_pagesize:
+        /* No outputs */
+        break;
+      case XENVER_guest_handle:
+        POST_MEM_WRITE((Addr)args->arg[1], sizeof(xen_domain_handle_t));
+        break;
+      case XENVER_commandline:
+        POST_MEM_WRITE((Addr)args->arg[1], sizeof(xen_commandline_t));
+        break;
+      default:
+        VG_(printf)("post __HYPERVISOR_xen_version unknown command %lld\n",
args->arg[0]);
+        break;
+      }
+      break;
+
+   case __HYPERVISOR_sysctl: {
+      struct xen_sysctl *sysctl = (struct xen_sysctl *)(unsigned
int)args->arg[0];
+
+      if (!sysctl || sysctl->interface_version !=
XEN_SYSCTL_INTERFACE_VERSION)
+        return;
+
+#define __POST_XEN_SYSCTL_WRITE(_sysctl, _union, _field)
POST_MEM_WRITE((Addr)&sysctl->u._union._field,
sizeof(sysctl->u._union._field));
+#define POST_XEN_SYSCTL_WRITE(_sysctl, _field)
__POST_XEN_SYSCTL_WRITE(_sysctl, _sysctl, _field)
+      switch (sysctl->cmd) {
+      case XEN_SYSCTL_getdomaininfolist:
+        POST_XEN_SYSCTL_WRITE(getdomaininfolist, num_domains);
+        POST_MEM_WRITE((Addr)sysctl->u.getdomaininfolist.buffer.p,
+                       sizeof(xen_domctl_getdomaininfo_t) *
sysctl->u.getdomaininfolist.num_domains);
+        break;
+
+      case XEN_SYSCTL_cpupool_op:
+        if (sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_CREATE ||
+            sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_INFO)
+           POST_XEN_SYSCTL_WRITE(cpupool_op, cpupool_id);
+        if (sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_INFO) {
+           POST_XEN_SYSCTL_WRITE(cpupool_op, sched_id);
+           POST_XEN_SYSCTL_WRITE(cpupool_op, n_dom);
+        }
+        if (sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_INFO ||
+            sysctl->u.cpupool_op.op == XEN_SYSCTL_CPUPOOL_OP_FREEINFO)
+           POST_XEN_SYSCTL_WRITE(cpupool_op, cpumap);
+        break;
+
+      case XEN_SYSCTL_physinfo:
+        POST_XEN_SYSCTL_WRITE(physinfo, threads_per_core);
+        POST_XEN_SYSCTL_WRITE(physinfo, cores_per_socket);
+        POST_XEN_SYSCTL_WRITE(physinfo, nr_cpus);
+        POST_XEN_SYSCTL_WRITE(physinfo, max_cpu_id);
+        POST_XEN_SYSCTL_WRITE(physinfo, nr_nodes);
+        POST_XEN_SYSCTL_WRITE(physinfo, max_node_id);
+ POST_XEN_SYSCTL_WRITE(physinfo, cpu_khz);
+        POST_XEN_SYSCTL_WRITE(physinfo, total_pages);
+        POST_XEN_SYSCTL_WRITE(physinfo, free_pages);
+        POST_XEN_SYSCTL_WRITE(physinfo, scrub_pages);
+        POST_XEN_SYSCTL_WRITE(physinfo, hw_cap[8]);
+        POST_XEN_SYSCTL_WRITE(physinfo, capabilities);
+        break;
+
+      default:
+        VG_(printf)("post sysctl version %x cmd %d\n",
+                    sysctl->interface_version, sysctl->cmd);
+        break;
+      }
+#undef POST_XEN_SYSCTL_WRITE
+#undef __POST_XEN_SYSCTL_WRITE
+      break;
+   }
+
+   case __HYPERVISOR_domctl: {
+      struct xen_domctl *domctl = (struct xen_domctl *)(unsigned
int)args->arg[0];
+
+      if (!domctl || domctl->interface_version !=
XEN_DOMCTL_INTERFACE_VERSION)
+        return;
+
+#define __POST_XEN_DOMCTL_WRITE(_domctl, _union, _field)
POST_MEM_WRITE((Addr)&domctl->u._union._field,
sizeof(domctl->u._union._field));
+#define POST_XEN_DOMCTL_WRITE(_domctl, _field)
__POST_XEN_DOMCTL_WRITE(_domctl, _domctl, _field)
+      switch (domctl->cmd) {
+      case XEN_DOMCTL_createdomain:
+      case XEN_DOMCTL_destroydomain:
+      case XEN_DOMCTL_pausedomain:
+      case XEN_DOMCTL_max_mem:
+      case XEN_DOMCTL_set_address_size:
+      case XEN_DOMCTL_settscinfo:
+      case XEN_DOMCTL_hypercall_init:
+      case XEN_DOMCTL_setvcpuaffinity:
+      case XEN_DOMCTL_setvcpucontext:
+      case XEN_DOMCTL_set_cpuid:
+      case XEN_DOMCTL_unpausedomain:
+        /* No output fields */
+        break;
+
+      case XEN_DOMCTL_max_vcpus:
+        POST_XEN_DOMCTL_WRITE(max_vcpus, max);
+
+      case XEN_DOMCTL_get_address_size:
+        __POST_XEN_DOMCTL_WRITE(get_address_size, address_size, size);
+        break;
+
+      case XEN_DOMCTL_gettscinfo:
+        __POST_XEN_DOMCTL_WRITE(settscinfo, tsc_info, info.tsc_mode);
+        __POST_XEN_DOMCTL_WRITE(settscinfo, tsc_info, info.gtsc_khz);
+        __POST_XEN_DOMCTL_WRITE(settscinfo, tsc_info, info.incarnation);
+        __POST_XEN_DOMCTL_WRITE(settscinfo, tsc_info, info.elapsed_nsec);
+        break;
+
+      case XEN_DOMCTL_getvcpuinfo:
+        POST_XEN_DOMCTL_WRITE(getvcpuinfo, online);
+        POST_XEN_DOMCTL_WRITE(getvcpuinfo, blocked);
+        POST_XEN_DOMCTL_WRITE(getvcpuinfo, running);
+        POST_XEN_DOMCTL_WRITE(getvcpuinfo, cpu_time);
+        POST_XEN_DOMCTL_WRITE(getvcpuinfo, cpu);
+        break;
+
+      case XEN_DOMCTL_getvcpuaffinity:
+        POST_MEM_WRITE((Addr)domctl->u.vcpuaffinity.cpumap.bitmap.p,
+                       domctl->u.vcpuaffinity.cpumap.nr_cpus / 8);
+        break;
+
+      case XEN_DOMCTL_getdomaininfo:
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, domain);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, flags);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, tot_pages);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, max_pages);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, shr_pages);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, shared_info_frame);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, cpu_time);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, nr_online_vcpus);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, max_vcpu_id);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, ssidref);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, handle);
+        POST_XEN_DOMCTL_WRITE(getdomaininfo, cpupool);
+        break;
+
+      case XEN_DOMCTL_getvcpucontext:
+        __POST_XEN_DOMCTL_WRITE(getvcpucontext, vcpucontext, ctxt.p);
+        break;
+
+      default:
+        VG_(printf)("post domctl version %x cmd %d on domain %d\n",
+                    domctl->interface_version, domctl->cmd,
domctl->domain);
+        break;
+      }
+#undef POST_XEN_DOMCTL_WRITE
+#undef __POST_XEN_DOMCTL_WRITE
+      break;
+   }
+
+
+   case __HYPERVISOR_hvm_op: {
+      unsigned long op = args->arg[0];
+      void *arg = (void *)(unsigned long)args->arg[1];
+
+#define __POST_XEN_HVMOP_WRITE(_hvm_op, _type, _field)
POST_MEM_WRITE((Addr)&((_type*)arg)->_field, \
+                                                                     
sizeof(((_type*)arg)->_field))
+#define POST_XEN_HVMOP_WRITE(_hvm_op, _field) __PRE_XEN_HVMOP_READ(_hvm_op,
"xen_hvm_" # _hvm_op "_t", _field)
+      switch (op) {
+      case HVMOP_set_param:
+        /* No output paramters */
+        break;
+
+      case HVMOP_get_param:
+        __POST_XEN_HVMOP_WRITE(get_param, xen_hvm_param_t, value);
+        break;
+
+      default:
+        VG_(printf)("post hvm_op unknown OP %ld\n", op);
+        break;
+#undef __POST_XEN_HVMOP_WRITE
+#undef POST_XEN_HVMOP_WRITE
+      }
+   }
+      break;
+
+   default:
+      VG_(printf)("post unknown hypercall %lld ( %#llx, %#llx, %#llx,
%#llx, %#llx )\n",
+                 args->op, args->arg[0], args->arg[1], args->arg[2],
args->arg[3], args->arg[4]);
+      break;
+   }
+}
+
+
+PRE(ioctl_privcmd_mmap)
+{
+   struct vki_xen_privcmd_mmap *args = (struct vki_xen_privcmd_mmap
*)(ARG3);
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP", (Addr)&args->num,
sizeof(args->num));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP", (Addr)&args->dom,
sizeof(args->dom));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP", (Addr)args->entry,
sizeof(*(args->entry)) * args->num);
+}
+
+PRE(ioctl_privcmd_mmapbatch)
+{
+   struct vki_xen_privcmd_mmapbatch *args = (struct
vki_xen_privcmd_mmapbatch *)(ARG3);
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH", (Addr)&args->num,
sizeof(args->num));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH", (Addr)&args->dom,
sizeof(args->dom));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH", (Addr)&args->addr,
sizeof(args->addr));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH", (Addr)args->arr,
sizeof(*(args->arr)) * args->num);
+}
+
+PRE(ioctl_privcmd_mmapbatch_v2)
+{
+   struct vki_xen_privcmd_mmapbatch_v2 *args = (struct
vki_xen_privcmd_mmapbatch_v2 *)(ARG3);
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2", (Addr)&args->num,
sizeof(args->num));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2", (Addr)&args->dom,
sizeof(args->dom));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2", (Addr)&args->addr,
sizeof(args->addr));
+   PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2", (Addr)args->arr,
sizeof(*(args->arr)) * args->num);
+}
+
+POST(ioctl_privcmd_mmap)
+{
+   //struct vki_xen_privcmd_mmap *args = (struct vki_xen_privcmd_mmap
*)(ARG3);
+}
+
+POST(ioctl_privcmd_mmapbatch)
+{
+   struct vki_xen_privcmd_mmapbatch *args = (struct
vki_xen_privcmd_mmapbatch *)(ARG3);
+   POST_MEM_WRITE((Addr)args->arr, sizeof(*(args->arr)) * args->num);
+}
+
+POST(ioctl_privcmd_mmapbatch_v2)
+{
+   struct vki_xen_privcmd_mmapbatch_v2 *args = (struct
vki_xen_privcmd_mmapbatch_v2 *)(ARG3);
+   POST_MEM_WRITE((Addr)args->err, sizeof(*(args->err)) * args->num);
+}
diff --git a/include/Makefile.am b/include/Makefile.am
index 33d0857..22bffa7 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -54,7 +54,8 @@ vki/vki-scnums-ppc32-linux.h \
  vki/vki-scnums-ppc64-linux.h \
  vki/vki-scnums-x86-linux.h \
  vki/vki-scnums-arm-linux.h \
- vki/vki-scnums-darwin.h
+ vki/vki-scnums-darwin.h
+ vki/vki-xen.h

 noinst_HEADERS = \
  vki/vki-ppc32-aix5.h \
diff --git a/include/pub_tool_vki.h b/include/pub_tool_vki.h
index 73a4174..c4c117f 100644
--- a/include/pub_tool_vki.h
+++ b/include/pub_tool_vki.h
@@ -47,6 +47,7 @@

 #if defined(VGO_linux)
 #  include "vki/vki-linux.h"
+#  include "vki/vki-xen.h"
 #elif defined(VGP_ppc32_aix5)
 #  include "vki/vki-ppc32-aix5.h"
 #elif defined(VGP_ppc64_aix5)
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
index beff378..1214300 100644
--- a/include/vki/vki-linux.h
+++ b/include/vki/vki-linux.h
@@ -2717,6 +2717,51 @@ struct vki_getcpu_cache {
 #define VKI_EV_MAX 0x1f
 #define VKI_EV_CNT (VKI_EV_MAX+1)

+//----------------------------------------------------------------------
+// Xen privcmd IOCTL
+//----------------------------------------------------------------------
+
+typedef unsigned long __vki_xen_pfn_t;
+
+struct vki_xen_privcmd_hypercall {
+       __vki_u64 op;
+       __vki_u64 arg[5];
+};
+
+struct vki_xen_privcmd_mmap_entry {
+        __vki_u64 va;
+        __vki_u64 mfn;
+        __vki_u64 npages;
+};
+
+struct vki_xen_privcmd_mmap {
+        int num;
+        __vki_u16 dom; /* target domain */
+        struct vki_xen_privcmd_mmap_entry *entry;
+};
+
+struct vki_xen_privcmd_mmapbatch {
+        int num;     /* number of pages to populate */
+        __vki_u16 dom; /* target domain */
+        __vki_u64 addr;  /* virtual address */
+        __vki_xen_pfn_t *arr; /* array of mfns - top nibble set on err */
+};
+
+struct vki_xen_privcmd_mmapbatch_v2 {
+        unsigned int num; /* number of pages to populate */
+        __vki_u16 dom;      /* target domain */
+        __vki_u64 addr;       /* virtual address */
+        const __vki_xen_pfn_t *arr; /* array of mfns */
+        int __user *err;  /* array of error codes */
+};
+
+#define VKI_XEN_IOCTL_PRIVCMD_HYPERCALL    _VKI_IOC(_VKI_IOC_NONE, 'P', 0,
sizeof(struct vki_xen_privcmd_hypercall))
+#define VKI_XEN_IOCTL_PRIVCMD_MMAP         _VKI_IOC(_VKI_IOC_NONE, 'P', 2,
sizeof(struct vki_xen_privcmd_mmap))
+
+#define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH    _VKI_IOC(_VKI_IOC_NONE, 'P', 3,
sizeof(struct vki_xen_privcmd_mmapbatch))
+#define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2 _VKI_IOC(_VKI_IOC_NONE, 'P', 4,
sizeof(struct vki_xen_privcmd_mmapbatch_v2))
+
+
 #endif // __VKI_LINUX_H

 /*--------------------------------------------------------------------*/
diff --git a/include/vki/vki-xen.h b/include/vki/vki-xen.h
new file mode 100644
index 0000000..7842cc9
--- /dev/null
+++ b/include/vki/vki-xen.h
@@ -0,0 +1,8 @@
+#ifndef __VKI_XEN_H
+#define __VKI_XEN_H
+
+#endif // __VKI_XEN_H
+
+/*--------------------------------------------------------------------*/
+/*--- end                                                          ---*/
+/*--------------------------------------------------------------------*/ 

2.  after patch it . this time i use autoconf/automake inside valgrind-3.6.1
and run "./configure --with-xen=/usr/include/xen/"
    and below is the configure output:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for ranlib... ranlib
checking for a sed that does not truncate output... /bin/sed
checking for ar... /usr/bin/ar
checking for perl... /usr/bin/perl
checking for gdb... /usr/bin/gdb
checking dependency style of gcc... gcc3
checking for diff -u... yes
checking for a supported version of gcc... ok (4.1.2)
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a supported CPU... ok (i686)
checking for a 64-bit only build... no
checking for a 32-bit only build... no
checking for a supported OS... ok (linux-gnu)
checking for the kernel version... 2.6 family (2.6.18.8-xen)
checking for a supported CPU/OS combination... ok (x86-linux)
checking for use as an inner Valgrind... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking features.h usability... yes
checking features.h presence... yes
checking for features.h... yes
checking the GLIBC_VERSION version... 2.7 family
checking for CLOCK_MONOTONIC... yes
checking for PTHREAD_MUTEX_ADAPTIVE_NP... yes
checking for PTHREAD_MUTEX_ERRORCHECK_NP... yes
checking for PTHREAD_MUTEX_RECURSIVE_NP... yes
checking for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP... yes
checking for pthread_mutex_t.__m_kind... no
checking for pthread_mutex_t.__data.__kind... yes
checking for Altivec... no
checking for pthread_create@xxxxxxxx()... yes
checking for eventfd()... no
checking if gcc accepts -m32... yes
checking if gcc accepts -maix32... no
checking if gcc accepts -m64... no
checking if gcc accepts -maix64... no
checking if gcc accepts -mmmx... yes
checking if gcc accepts -msse... yes
checking if gcc accepts -mpreferred-stack-boundary... yes
checking if gcc accepts -Wno-pointer-sign... yes
checking if gcc accepts -Wno-empty-body... no
checking if gcc accepts -Wno-format-zero-length... yes
checking if gcc accepts -Wno-uninitialized... yes
checking if gcc accepts -Wextra or -W... -Wextra
checking if gcc accepts -fno-stack-protector... yes
checking if gcc accepts --param inline-unit-growth... yes
checking if the linker accepts -Wl,--build-id=none... yes
checking if ppc32/64 as supports mtocrf/mfocrf... no
checking if x86/amd64 assembler speaks SSE3... yes
checking if x86/amd64 assembler speaks SSSE3... no
checking if x86/amd64 assembler supports 'pclmulqdq'... no
checking if x86/amd64 assembler supports 'lzcnt'... no
checking for TLS support... yes
checking for ANSI C header files... (cached) yes
checking asm/unistd.h usability... yes
checking asm/unistd.h presence... yes
checking for asm/unistd.h... yes
checking endian.h usability... yes
checking endian.h presence... yes
checking for endian.h... yes
checking mqueue.h usability... yes
checking mqueue.h presence... yes
checking for mqueue.h... yes
checking sys/endian.h usability... no
checking sys/endian.h presence... no
checking for sys/endian.h... no
checking sys/epoll.h usability... yes
checking sys/epoll.h presence... yes
checking for sys/epoll.h... yes
checking sys/eventfd.h usability... no
checking sys/eventfd.h presence... no
checking for sys/eventfd.h... no
checking sys/klog.h usability... yes
checking sys/klog.h presence... yes
checking for sys/klog.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking sys/signal.h usability... yes
checking sys/signal.h presence... yes
checking for sys/signal.h... yes
checking sys/signalfd.h usability... no
checking sys/signalfd.h presence... no
checking for sys/signalfd.h... no
checking sys/syscall.h usability... yes
checking sys/syscall.h presence... yes
checking for sys/syscall.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for sys/types.h... (cached) yes
checking for uid_t in sys/types.h... yes
checking for off_t... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for working memcmp... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... yes
checking return type of signal handlers... void
checking for clock_gettime in -lrt... yes
checking for clock_gettime... yes
checking for epoll_create... yes
checking for epoll_pwait... yes
checking for floor... no
checking for klogctl... yes
checking for mallinfo... yes
checking for memchr... yes
checking for memset... yes
checking for mkdir... yes
checking for mremap... yes
checking for ppoll... yes
checking for pthread_barrier_init... yes
checking for pthread_condattr_setclock... yes
checking for pthread_mutex_timedlock... yes
checking for pthread_rwlock_timedrdlock... yes
checking for pthread_rwlock_timedwrlock... yes
checking for pthread_spin_lock... yes
checking for pthread_yield... yes
checking for readlinkat... yes
checking for semtimedop... yes
checking for signalfd... yes
checking for sigwaitinfo... yes
checking for strchr... yes
checking for strdup... yes
checking for strpbrk... yes
checking for strrchr... yes
checking for strstr... yes
checking for syscall... yes
checking for timerfd... no
checking for utimensat... yes
checking primary target for usable MPI2-compliant C compiler and mpi.h... no
checking secondary target for usable MPI2-compliant C compiler and mpi.h...
no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for boost... yes
checking for OpenMP... yes
checking if gcc supports __sync_bool_compare_and_swap... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating VEX/Makefile
config.status: creating valgrind.spec
config.status: creating valgrind.pc
config.status: creating glibc-2.X.supp
config.status: creating docs/Makefile
config.status: creating tests/Makefile
config.status: creating tests/vg_regtest
config.status: creating perf/Makefile
config.status: creating perf/vg_perf
config.status: creating include/Makefile
config.status: creating auxprogs/Makefile
config.status: creating mpi/Makefile
config.status: creating coregrind/Makefile
config.status: creating memcheck/Makefile
config.status: creating memcheck/tests/Makefile
config.status: creating memcheck/tests/amd64/Makefile
config.status: creating memcheck/tests/x86/Makefile
config.status: creating memcheck/tests/linux/Makefile
config.status: creating memcheck/tests/darwin/Makefile
config.status: creating memcheck/tests/amd64-linux/Makefile
config.status: creating memcheck/tests/x86-linux/Makefile
config.status: creating memcheck/tests/ppc32/Makefile
config.status: creating memcheck/tests/ppc64/Makefile
config.status: creating memcheck/perf/Makefile
config.status: creating cachegrind/Makefile
config.status: creating cachegrind/tests/Makefile
config.status: creating cachegrind/tests/x86/Makefile
config.status: creating cachegrind/cg_annotate
config.status: creating cachegrind/cg_diff
config.status: creating callgrind/Makefile
config.status: creating callgrind/callgrind_annotate
config.status: creating callgrind/callgrind_control
config.status: creating callgrind/tests/Makefile
config.status: creating helgrind/Makefile
config.status: creating helgrind/tests/Makefile
config.status: creating massif/Makefile
config.status: creating massif/tests/Makefile
config.status: creating massif/perf/Makefile
config.status: creating massif/ms_print
config.status: creating lackey/Makefile
config.status: creating lackey/tests/Makefile
config.status: creating none/Makefile
config.status: creating none/tests/Makefile
config.status: creating none/tests/amd64/Makefile
config.status: creating none/tests/ppc32/Makefile
config.status: creating none/tests/ppc64/Makefile
config.status: creating none/tests/x86/Makefile
config.status: creating none/tests/arm/Makefile
config.status: creating none/tests/linux/Makefile
config.status: creating none/tests/darwin/Makefile
config.status: creating none/tests/x86-linux/Makefile
config.status: creating exp-ptrcheck/Makefile
config.status: creating exp-ptrcheck/tests/Makefile
config.status: creating drd/Makefile
config.status: creating drd/scripts/download-and-build-splash2
config.status: creating drd/tests/Makefile
config.status: creating exp-bbv/Makefile
config.status: creating exp-bbv/tests/Makefile
config.status: creating exp-bbv/tests/x86/Makefile
config.status: creating exp-bbv/tests/x86-linux/Makefile
config.status: creating exp-bbv/tests/amd64-linux/Makefile
config.status: creating exp-bbv/tests/ppc32-linux/Makefile
config.status: creating exp-bbv/tests/arm-linux/Makefile
config.status: creating exp-dhat/Makefile
config.status: creating exp-dhat/tests/Makefile
config.status: creating coregrind/link_tool_exe_linux
config.status: creating coregrind/link_tool_exe_darwin
config.status: creating coregrind/link_tool_exe_aix5
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

         Maximum build arch: x86
         Primary build arch: x86
       Secondary build arch: 
                   Build OS: linux
       Primary build target: X86_LINUX
     Secondary build target: 
         Default supp files: exp-ptrcheck.supp xfree-3.supp xfree-4.supp
glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp 

3, Now I run make , it has the output messages:
    echo "# This is a generated file, composed of the following suppression
rules:" > default.supp
echo "# " exp-ptrcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp
glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp  >> default.supp
cat exp-ptrcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp
glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp  >> default.supp
make  all-recursive
make[1]: Entering directory `/home/popo/valgrind-3.6.1'
Making all in include
make[2]: Entering directory `/home/popo/valgrind-3.6.1/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/popo/valgrind-3.6.1/include'
Making all in VEX
make[2]: Entering directory `/home/popo/valgrind-3.6.1/VEX'
make  all-am
make[3]: Entering directory `/home/popo/valgrind-3.6.1/VEX'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/home/popo/valgrind-3.6.1/VEX'
make[2]: Leaving directory `/home/popo/valgrind-3.6.1/VEX'
Making all in coregrind
make[2]: Entering directory `/home/popo/valgrind-3.6.1/coregrind'
make  all-am
make[3]: Entering directory `/home/popo/valgrind-3.6.1/coregrind'
gcc -DHAVE_CONFIG_H -I. -I..  -I.. -I../include -I../VEX/pub -DVGA_x86=1
-DVGO_linux=1 -DVGP_x86_linux=1 -I../coregrind
-DVG_LIBDIR="\"/usr/local/lib/valgrind"\" -DVG_PLATFORM="\"x86-linux\"" 
-m32 -mpreferred-stack-boundary=2 -O2 -g -Wall -Wmissing-prototypes -Wshadow
-Wpointer-arith -Wstrict-prototypes -Wmissing-declarations
-Wno-format-zero-length -fno-strict-aliasing @XEN_CFLAGS@ -Wno-long-long 
-Wno-pointer-sign -fno-stack-protector -MT
libcoregrind_x86_linux_a-m_debuglog.o -MD -MP -MF
.deps/libcoregrind_x86_linux_a-m_debuglog.Tpo -c -o
libcoregrind_x86_linux_a-m_debuglog.o `test -f 'm_debuglog.c' || echo
'./'`m_debuglog.c
gcc: @XEN_CFLAGS@ïdoesn't exist the file or directory
make[3]: *** [libcoregrind_x86_linux_a-m_debuglog.o] error 1
make[3]: Leaving directory `/home/popo/valgrind-3.6.1/coregrind'
make[2]: *** [all] error 2
make[2]: Leaving directory `/home/popo/valgrind-3.6.1/coregrind'
make[1]: *** [all-recursive] error 1
make[1]: Leaving directory `/home/popo/valgrind-3.6.1'
make: *** [all] error 2

4, I am now doing a research about the memory leak of hypervisor of xen in
my college with my teacher . and i wonder if you have the valgrind tool
support for xen hypervisor ?  and if you have the valgrind tool support for
hypervisor well , can you give me one ? I need the tool to finish my job
however i can't handle it well .....sigh...
5, another question is :  if i have the valgrind tool support for hypervisor
, how to use the memcheck tool to detect the memory leak of xen hypervisor ?
i know how to use the tool to detect normal binary file but i don't know how
to detect xen hypervisor .
   for example , there is a normal c file name test.c . first use "gcc -g -o
test test.c"  to produce binary file test .  then use "valgrind
--tool=memcheck --leak-check=yes ./test" to detect the memory leak of "test"
. 
 however , how to use the memcheck tool to do my job ?
  1) first compile the xen_4.1.1 src files ?
  2) second how to use your valgrind tool?
  is this right ?

Thank you !

--
View this message in context: 
http://xen.1045712.n5.nabble.com/PATCHv2-valgrind-support-for-Xen-privcmd-ioctls-hypercalls-tp2640861p4568310.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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