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

[Xen-devel] [PATCH 02 of 25] libxc: convert xc_version over to hypercall buffers



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1287650254 -3600
# Node ID f262590f9b94d9f6da603082748fe9f560becc7d
# Parent  a40c36db2a03279fcb6a0525359d6a95de4e4800
libxc: convert xc_version over to hypercall buffers

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r a40c36db2a03 -r f262590f9b94 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Thu Oct 21 09:37:34 2010 +0100
+++ b/tools/libxc/xc_private.c  Thu Oct 21 09:37:34 2010 +0100
@@ -569,42 +569,46 @@ int xc_sysctl(xc_interface *xch, struct 
 
 int xc_version(xc_interface *xch, int cmd, void *arg)
 {
-    int rc, argsize = 0;
+    DECLARE_HYPERCALL_BOUNCE(arg, 0, XC_HYPERCALL_BUFFER_BOUNCE_OUT); /* Size 
unknown until cmd decoded */
+    size_t sz = 0;
+    int rc;
 
     switch ( cmd )
     {
     case XENVER_extraversion:
-        argsize = sizeof(xen_extraversion_t);
+        sz = sizeof(xen_extraversion_t);
         break;
     case XENVER_compile_info:
-        argsize = sizeof(xen_compile_info_t);
+        sz = sizeof(xen_compile_info_t);
         break;
     case XENVER_capabilities:
-        argsize = sizeof(xen_capabilities_info_t);
+        sz = sizeof(xen_capabilities_info_t);
         break;
     case XENVER_changeset:
-        argsize = sizeof(xen_changeset_info_t);
+        sz = sizeof(xen_changeset_info_t);
         break;
     case XENVER_platform_parameters:
-        argsize = sizeof(xen_platform_parameters_t);
+        sz = sizeof(xen_platform_parameters_t);
         break;
     }
 
-    if ( (argsize != 0) && (lock_pages(xch, arg, argsize) != 0) )
+    HYPERCALL_BOUNCE_SET_SIZE(arg, sz);
+
+    if ( (sz != 0) && xc_hypercall_bounce_pre(xch, arg) )
     {
-        PERROR("Could not lock memory for version hypercall");
+        PERROR("Could not bounce buffer for version hypercall");
         return -ENOMEM;
     }
 
 #ifdef VALGRIND
-    if (argsize != 0)
-        memset(arg, 0, argsize);
+    if (sz != 0)
+        memset(hypercall_bounce_get(bounce), 0, sz);
 #endif
 
-    rc = do_xen_version(xch, cmd, arg);
+    rc = do_xen_version(xch, cmd, HYPERCALL_BUFFER(arg));
 
-    if ( argsize != 0 )
-        unlock_pages(xch, arg, argsize);
+    if ( sz != 0 )
+        xc_hypercall_bounce_post(xch, arg);
 
     return rc;
 }
diff -r a40c36db2a03 -r f262590f9b94 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h  Thu Oct 21 09:37:34 2010 +0100
+++ b/tools/libxc/xc_private.h  Thu Oct 21 09:37:34 2010 +0100
@@ -166,13 +166,14 @@ void xc__hypercall_bounce_post(xc_interf
 
 int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall);
 
-static inline int do_xen_version(xc_interface *xch, int cmd, void *dest)
+static inline int do_xen_version(xc_interface *xch, int cmd, 
xc_hypercall_buffer_t *dest)
 {
     DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER_ARGUMENT(dest);
 
     hypercall.op     = __HYPERVISOR_xen_version;
     hypercall.arg[0] = (unsigned long) cmd;
-    hypercall.arg[1] = (unsigned long) dest;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(dest);
 
     return do_xen_hypercall(xch, &hypercall);
 }

_______________________________________________
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®.