WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 16 of 24] libxc: convert acm interfaces over to hyper

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 16 of 24] libxc: convert acm interfaces over to hypercall buffers
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 06 Sep 2010 14:38:36 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 06 Sep 2010 06:57:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1283780300@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1283779691 -3600
# Node ID c42a409a5c56732462d9effa844ebc2f7d06ba60
# Parent  44b73f8b623f9e9567d0188f1fa1a566f4e00b1b
libxc: convert acm interfaces over to hypercall buffers

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

diff -r 44b73f8b623f -r c42a409a5c56 tools/libxc/xc_acm.c
--- a/tools/libxc/xc_acm.c      Mon Sep 06 14:28:11 2010 +0100
+++ b/tools/libxc/xc_acm.c      Mon Sep 06 14:28:11 2010 +0100
@@ -27,12 +27,19 @@ int xc_acm_op(xc_interface *xch, int cmd
 {
     int ret;
     DECLARE_HYPERCALL;
-    struct xen_acmctl acmctl;
+    DECLARE_HYPERCALL_BUFFER(struct xen_acmctl, acmctl);
+
+    acmctl = xc_hypercall_buffer_alloc(xch, acmctl, sizeof(*acmctl));
+    if ( acmctl == NULL )
+    {
+        PERROR("Could not lock memory for Xen hypercall");
+        return -EFAULT;
+    }
 
     switch (cmd) {
         case ACMOP_setpolicy: {
             struct acm_setpolicy *setpolicy = (struct acm_setpolicy *)arg;
-            memcpy(&acmctl.u.setpolicy,
+            memcpy(&acmctl->u.setpolicy,
                    setpolicy,
                    sizeof(struct acm_setpolicy));
         }
@@ -40,7 +47,7 @@ int xc_acm_op(xc_interface *xch, int cmd
 
         case ACMOP_getpolicy: {
             struct acm_getpolicy *getpolicy = (struct acm_getpolicy *)arg;
-            memcpy(&acmctl.u.getpolicy,
+            memcpy(&acmctl->u.getpolicy,
                    getpolicy,
                    sizeof(struct acm_getpolicy));
         }
@@ -48,7 +55,7 @@ int xc_acm_op(xc_interface *xch, int cmd
 
         case ACMOP_dumpstats: {
             struct acm_dumpstats *dumpstats = (struct acm_dumpstats *)arg;
-            memcpy(&acmctl.u.dumpstats,
+            memcpy(&acmctl->u.dumpstats,
                    dumpstats,
                    sizeof(struct acm_dumpstats));
         }
@@ -56,7 +63,7 @@ int xc_acm_op(xc_interface *xch, int cmd
 
         case ACMOP_getssid: {
             struct acm_getssid *getssid = (struct acm_getssid *)arg;
-            memcpy(&acmctl.u.getssid,
+            memcpy(&acmctl->u.getssid,
                    getssid,
                    sizeof(struct acm_getssid));
         }
@@ -64,7 +71,7 @@ int xc_acm_op(xc_interface *xch, int cmd
 
         case ACMOP_getdecision: {
             struct acm_getdecision *getdecision = (struct acm_getdecision 
*)arg;
-            memcpy(&acmctl.u.getdecision,
+            memcpy(&acmctl->u.getdecision,
                    getdecision,
                    sizeof(struct acm_getdecision));
         }
@@ -72,7 +79,7 @@ int xc_acm_op(xc_interface *xch, int cmd
 
         case ACMOP_chgpolicy: {
             struct acm_change_policy *change_policy = (struct 
acm_change_policy *)arg;
-            memcpy(&acmctl.u.change_policy,
+            memcpy(&acmctl->u.change_policy,
                    change_policy,
                    sizeof(struct acm_change_policy));
         }
@@ -80,40 +87,36 @@ int xc_acm_op(xc_interface *xch, int cmd
 
         case ACMOP_relabeldoms: {
             struct acm_relabel_doms *relabel_doms = (struct acm_relabel_doms 
*)arg;
-            memcpy(&acmctl.u.relabel_doms,
+            memcpy(&acmctl->u.relabel_doms,
                    relabel_doms,
                    sizeof(struct acm_relabel_doms));
         }
         break;
     }
 
-    acmctl.cmd = cmd;
-    acmctl.interface_version = ACM_INTERFACE_VERSION;
+    acmctl->cmd = cmd;
+    acmctl->interface_version = ACM_INTERFACE_VERSION;
 
     hypercall.op = __HYPERVISOR_xsm_op;
-    hypercall.arg[0] = (unsigned long)&acmctl;
-    if ( lock_pages(xch, &acmctl, sizeof(acmctl)) != 0)
-    {
-        PERROR("Could not lock memory for Xen hypercall");
-        return -EFAULT;
-    }
+    hypercall.arg[0] = HYPERCALL_BUFFER_AS_ARG(acmctl);
     if ( (ret = do_xen_hypercall(xch, &hypercall)) < 0)
     {
         if ( errno == EACCES )
             DPRINTF("acmctl operation failed -- need to"
                     " rebuild the user-space tool set?\n");
     }
-    unlock_pages(xch, &acmctl, sizeof(acmctl));
 
     switch (cmd) {
         case ACMOP_getdecision: {
             struct acm_getdecision *getdecision = (struct acm_getdecision 
*)arg;
             memcpy(getdecision,
-                   &acmctl.u.getdecision,
+                   &acmctl->u.getdecision,
                    sizeof(struct acm_getdecision));
             break;
         }
     }
+
+    xc_hypercall_buffer_free(xch, acmctl);
 
     return ret;
 }

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

<Prev in Thread] Current Thread [Next in Thread>