Add Xen 4.4 evtchn ioctl wrappers.  Patch from Antony Saba
(antony.saba@fireeye.com).  Second of two patches from #337740.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14454 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
index 4a2c092..1fafd55 100644
--- a/coregrind/m_syswrap/syswrap-linux.c
+++ b/coregrind/m_syswrap/syswrap-linux.c
@@ -7101,6 +7101,47 @@
                     (Addr)args->arr, sizeof(*(args->arr)) * args->num);
       break;
    }
+
+   case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ: {
+         struct vki_xen_ioctl_evtchn_bind_virq *args =
+            (struct vki_xen_ioctl_evtchn_bind_virq *)(ARG3);
+         PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ(virq)",
+                 (Addr)&args->virq, sizeof(args->virq));
+      }
+      break;
+   case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN: {
+         struct vki_xen_ioctl_evtchn_bind_interdomain *args =
+            (struct vki_xen_ioctl_evtchn_bind_interdomain *)(ARG3);
+         PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN(remote_domain)",
+                 (Addr)&args->remote_domain, sizeof(args->remote_domain));
+         PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN(remote_port)",
+                 (Addr)&args->remote_port, sizeof(args->remote_port));
+      }
+      break;
+   case VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT: {
+         struct vki_xen_ioctl_evtchn_bind_unbound_port *args =
+            (struct vki_xen_ioctl_evtchn_bind_unbound_port *)(ARG3);
+         PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT(remote_domain)",
+                 (Addr)&args->remote_domain, sizeof(args->remote_domain));
+      }
+      break;
+   case VKI_XEN_IOCTL_EVTCHN_UNBIND: {
+         struct vki_xen_ioctl_evtchn_unbind *args =
+            (struct vki_xen_ioctl_evtchn_unbind *)(ARG3);
+         PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_UNBIND(port)",
+                 (Addr)&args->port, sizeof(args->port));
+      }
+      break;
+   case VKI_XEN_IOCTL_EVTCHN_NOTIFY: {
+         struct vki_xen_ioctl_evtchn_notify *args =
+            (struct vki_xen_ioctl_evtchn_notify*)(ARG3);
+         PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_notify(port)",
+                 (Addr)&args->port, sizeof(args->port));
+      }
+      break;
+   case VKI_XEN_IOCTL_EVTCHN_RESET:
+      /* No input*/
+      break;
 #endif
 
    /* To do: figure out which software layer extends the sign of 'request' */
@@ -8370,25 +8411,25 @@
 
 #ifdef ENABLE_XEN
    case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL: {
-      SyscallArgs harrghs;
-      struct vki_xen_privcmd_hypercall *args =
-         (struct vki_xen_privcmd_hypercall *)(ARG3);
+       SyscallArgs harrghs;
+       struct vki_xen_privcmd_hypercall *args =
+          (struct vki_xen_privcmd_hypercall *)(ARG3);
 
-      if (!args)
-         break;
+       if (!args)
+          break;
 
-      VG_(memset)(&harrghs, 0, sizeof(harrghs));
-      harrghs.sysno = args->op;
-      harrghs.arg1 = args->arg[0];
-      harrghs.arg2 = args->arg[1];
-      harrghs.arg3 = args->arg[2];
-      harrghs.arg4 = args->arg[3];
-      harrghs.arg5 = args->arg[4];
-      harrghs.arg6 = harrghs.arg7 = harrghs.arg8 = 0;
+       VG_(memset)(&harrghs, 0, sizeof(harrghs));
+       harrghs.sysno = args->op;
+       harrghs.arg1 = args->arg[0];
+       harrghs.arg2 = args->arg[1];
+       harrghs.arg3 = args->arg[2];
+       harrghs.arg4 = args->arg[3];
+       harrghs.arg5 = args->arg[4];
+       harrghs.arg6 = harrghs.arg7 = harrghs.arg8 = 0;
 
-      WRAPPER_POST_NAME(xen, hypercall) (tid, &harrghs, status);
+       WRAPPER_POST_NAME(xen, hypercall) (tid, &harrghs, status);
+      }
       break;
-   };
 
    case VKI_XEN_IOCTL_PRIVCMD_MMAP:
       break;
@@ -8404,6 +8445,15 @@
        POST_MEM_WRITE((Addr)args->err, sizeof(*(args->err)) * args->num);
       }
       break;
+
+   case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ:
+   case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN:
+   case VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT:
+   case VKI_XEN_IOCTL_EVTCHN_UNBIND:
+   case VKI_XEN_IOCTL_EVTCHN_NOTIFY:
+   case VKI_XEN_IOCTL_EVTCHN_RESET:
+      /* No output */
+      break;
 #endif
 
    /* To do: figure out which software layer extends the sign of 'request' */
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
index 3828c33..bab688e 100644
--- a/include/vki/vki-linux.h
+++ b/include/vki/vki-linux.h
@@ -3237,6 +3237,46 @@
 #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2 _VKI_IOC(_VKI_IOC_NONE, 'P', 4, sizeof(struct vki_xen_privcmd_mmapbatch_v2))
 
 //----------------------------------------------------------------------
+// Xen evtchn IOCTL
+//----------------------------------------------------------------------
+
+#define VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ				\
+	_VKI_IOC(_VKI_IOC_NONE, 'E', 0, sizeof(struct vki_xen_ioctl_evtchn_bind_virq))
+struct vki_xen_ioctl_evtchn_bind_virq {
+	vki_uint32_t virq;
+	vki_uint32_t port;
+};
+
+#define VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN			\
+	_VKI_IOC(_VKI_IOC_NONE, 'E', 1, sizeof(struct vki_xen_ioctl_evtchn_bind_interdomain))
+struct vki_xen_ioctl_evtchn_bind_interdomain {
+	vki_uint32_t remote_domain;
+	vki_uint32_t remote_port;
+};
+
+#define VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT			\
+	_VKI_IOC(_VKI_IOC_NONE, 'E', 2, sizeof(struct vki_xen_ioctl_evtchn_bind_unbound_port))
+struct vki_xen_ioctl_evtchn_bind_unbound_port {
+	vki_uint32_t remote_domain;
+};
+
+#define VKI_XEN_IOCTL_EVTCHN_UNBIND				\
+	_VKI_IOC(_VKI_IOC_NONE, 'E', 3, sizeof(struct vki_xen_ioctl_evtchn_unbind))
+struct vki_xen_ioctl_evtchn_unbind {
+	vki_uint32_t port;
+};
+
+#define VKI_XEN_IOCTL_EVTCHN_NOTIFY				\
+	_VKI_IOC(_VKI_IOC_NONE, 'E', 4, sizeof(struct vki_xen_ioctl_evtchn_notify))
+struct vki_xen_ioctl_evtchn_notify {
+	vki_uint32_t port;
+};
+
+#define VKI_XEN_IOCTL_EVTCHN_RESET				\
+	_VKI_IOC(_VKI_IOC_NONE, 'E', 5, 0)
+
+
+//----------------------------------------------------------------------
 // From linux-3.4.0/include/linux/fs.h
 //----------------------------------------------------------------------