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-changelog

[Xen-changelog] [xen-unstable] libxc: convert gnttab interfaces over to

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxc: convert gnttab interfaces over to hypercall buffers
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Oct 2010 19:15:54 -0700
Delivery-date: Wed, 27 Oct 2010 19:19:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1287756891 -3600
# Node ID 13630d7f447f9760a547792be2f9bd777bc58d40
# Parent  22fd89a87e6efc4882034a49780dda61ae1f1bb7
libxc: convert gnttab interfaces over to hypercall buffers

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
---
 tools/libxc/xc_linux.c |   39 +++++++++++++++++----------------------
 tools/libxc/xenctrl.h  |    2 +-
 2 files changed, 18 insertions(+), 23 deletions(-)

diff -r 22fd89a87e6e -r 13630d7f447f tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Fri Oct 22 15:14:51 2010 +0100
+++ b/tools/libxc/xc_linux.c    Fri Oct 22 15:14:51 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);
+
+    if ( xc_hypercall_bounce_pre(xch, op) )
+    {
+        PERROR("Could not bounce buffer for grant table op hypercall");
+        goto out1;
+    }
 
     hypercall.op = __HYPERVISOR_grant_table_op;
     hypercall.arg[0] = cmd;
-    hypercall.arg[1] = (unsigned long)op;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(op);
     hypercall.arg[2] = count;
 
-    if ( lock_pages(xch, op, count* op_size) != 0 )
-    {
-        PERROR("Could not lock memory for Xen hypercall");
-        goto out1;
-    }
-
     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,26 +670,23 @@ 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)) )
-    {
-        ERROR("Alloc/lock frame_list in xc_gnttab_map_table\n");
-        if ( frame_list )
-            free(frame_list);
+    frame_list = xc_hypercall_buffer_alloc(xch, frame_list, query.nr_frames * 
sizeof(unsigned long));
+    if ( !frame_list )
+    {
+        ERROR("Could not allocate frame_list in xc_gnttab_map_table\n");
         return NULL;
     }
 
     pfn_list = malloc(query.nr_frames * sizeof(xen_pfn_t));
     if ( !pfn_list )
     {
-        ERROR("Could not lock pfn_list in xc_gnttab_map_table\n");
+        ERROR("Could not allocate pfn_list in xc_gnttab_map_table\n");
         goto err;
     }
 
     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);
 
diff -r 22fd89a87e6e -r 13630d7f447f tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Oct 22 15:14:51 2010 +0100
+++ b/tools/libxc/xenctrl.h     Fri Oct 22 15:14:51 2010 +0100
@@ -1290,7 +1290,7 @@ int xc_gnttab_set_max_grants(xc_interfac
 
 int xc_gnttab_op(xc_interface *xch, int cmd,
                  void * op, int op_size, int count);
-/* Logs iff lock_pages failes, otherwise doesn't. */
+/* Logs iff hypercall bounce fails, otherwise doesn't. */
 
 int xc_gnttab_get_version(xc_interface *xch, int domid); /* Never logs */
 grant_entry_v1_t *xc_gnttab_map_table_v1(xc_interface *xch, int domid, int 
*gnt_num);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxc: convert gnttab interfaces over to hypercall buffers, Xen patchbot-unstable <=