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 24 of 24] libxc: convert gnttab interfaces over to hy

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 24 of 24] libxc: convert gnttab interfaces over to hypercall buffers
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Mon, 06 Sep 2010 14:38:44 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Mon, 06 Sep 2010 07:12:23 -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 b0a0fd294854b3a0bf778125c85e56702ffecbc2
# Parent  afdedd2e14c342a381094df14de9446636780283
libxc: convert gnttab interfaces over to hypercall buffers

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

diff -r afdedd2e14c3 -r b0a0fd294854 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Mon Sep 06 14:28:11 2010 +0100
+++ b/tools/libxc/xc_linux.c    Mon Sep 06 14:28:11 2010 +0100
@@ -612,21 +612,22 @@ int xc_gnttab_op(xc_interface *xch, int 
 {
     int ret = 0;
     DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BOUNCE(op, count * op_size, 
XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
 
-    hypercall.op = __HYPERVISOR_grant_table_op;
-    hypercall.arg[0] = cmd;
-    hypercall.arg[1] = (unsigned long)op;
-    hypercall.arg[2] = count;
-
-    if ( lock_pages(xch, op, count* op_size) != 0 )
+    if ( xc_hypercall_bounce_pre(xch, op) )
     {
         PERROR("Could not lock memory for Xen hypercall");
         goto out1;
     }
 
+    hypercall.op = __HYPERVISOR_grant_table_op;
+    hypercall.arg[0] = cmd;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(op);
+    hypercall.arg[2] = count;
+
     ret = do_xen_hypercall(xch, &hypercall);
 
-    unlock_pages(xch, op, count * op_size);
+    xc_hypercall_bounce_post(xch, op);
 
  out1:
     return ret;
@@ -651,7 +652,7 @@ static void *_gnttab_map_table(xc_interf
     int rc, i;
     struct gnttab_query_size query;
     struct gnttab_setup_table setup;
-    unsigned long *frame_list = NULL;
+    DECLARE_HYPERCALL_BUFFER(unsigned long, frame_list);
     xen_pfn_t *pfn_list = NULL;
     grant_entry_v1_t *gnt = NULL;
 
@@ -669,13 +670,10 @@ static void *_gnttab_map_table(xc_interf
 
     *gnt_num = query.nr_frames * (PAGE_SIZE / sizeof(grant_entry_v1_t) );
 
-    frame_list = malloc(query.nr_frames * sizeof(unsigned long));
-    if ( !frame_list || lock_pages(xch, frame_list,
-                                   query.nr_frames * sizeof(unsigned long)) )
+    frame_list = xc_hypercall_buffer_alloc(xch, frame_list, query.nr_frames * 
sizeof(unsigned long));
+    if ( !frame_list )
     {
         ERROR("Alloc/lock frame_list in xc_gnttab_map_table\n");
-        if ( frame_list )
-            free(frame_list);
         return NULL;
     }
 
@@ -688,7 +686,7 @@ static void *_gnttab_map_table(xc_interf
 
     setup.dom = domid;
     setup.nr_frames = query.nr_frames;
-    set_xen_guest_handle(setup.frame_list, frame_list);
+    xc_set_xen_guest_handle(setup.frame_list, frame_list);
 
     /* XXX Any race with other setup_table hypercall? */
     rc = xc_gnttab_op(xch, GNTTABOP_setup_table, &setup, sizeof(setup),
@@ -713,10 +711,7 @@ static void *_gnttab_map_table(xc_interf
 
 err:
     if ( frame_list )
-    {
-        unlock_pages(xch, frame_list, query.nr_frames * sizeof(unsigned long));
-        free(frame_list);
-    }
+        xc_hypercall_buffer_free(xch, frame_list);
     if ( pfn_list )
         free(pfn_list);
 

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

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