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 hvmop interfaces over to h

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxc: convert hvmop interfaces over to hypercall buffers
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Oct 2010 19:15:50 -0700
Delivery-date: Wed, 27 Oct 2010 19:18:49 -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 001e48a6f088cf023a0d8dc7d604c49264189019
# Parent  f0caf8b361c4093f4f9efd32b24be303563dffa4
libxc: convert hvmop 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_domain.c |   52 +++++++------
 tools/libxc/xc_misc.c   |  187 +++++++++++++++++++++++++-----------------------
 2 files changed, 126 insertions(+), 113 deletions(-)

diff -r f0caf8b361c4 -r 001e48a6f088 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Fri Oct 22 15:14:51 2010 +0100
+++ b/tools/libxc/xc_domain.c   Fri Oct 22 15:14:51 2010 +0100
@@ -1027,38 +1027,42 @@ int xc_set_hvm_param(xc_interface *handl
 int xc_set_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long value)
 {
     DECLARE_HYPERCALL;
-    xen_hvm_param_t arg;
-    int rc;
+    DECLARE_HYPERCALL_BUFFER(xen_hvm_param_t, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg));
+    if ( arg == NULL )
+        return -1;
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_set_param;
-    hypercall.arg[1] = (unsigned long)&arg;
-    arg.domid = dom;
-    arg.index = param;
-    arg.value = value;
-    if ( lock_pages(handle, &arg, sizeof(arg)) != 0 )
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+    arg->domid = dom;
+    arg->index = param;
+    arg->value = value;
+    rc = do_xen_hypercall(handle, &hypercall);
+    xc_hypercall_buffer_free(handle, arg);
+    return rc;
+}
+
+int xc_get_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long *value)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(xen_hvm_param_t, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(handle, arg, sizeof(*arg));
+    if ( arg == NULL )
         return -1;
-    rc = do_xen_hypercall(handle, &hypercall);
-    unlock_pages(handle, &arg, sizeof(arg));
-    return rc;
-}
-
-int xc_get_hvm_param(xc_interface *handle, domid_t dom, int param, unsigned 
long *value)
-{
-    DECLARE_HYPERCALL;
-    xen_hvm_param_t arg;
-    int rc;
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_get_param;
-    hypercall.arg[1] = (unsigned long)&arg;
-    arg.domid = dom;
-    arg.index = param;
-    if ( lock_pages(handle, &arg, sizeof(arg)) != 0 )
-        return -1;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+    arg->domid = dom;
+    arg->index = param;
     rc = do_xen_hypercall(handle, &hypercall);
-    unlock_pages(handle, &arg, sizeof(arg));
-    *value = arg.value;
+    *value = arg->value;
+    xc_hypercall_buffer_free(handle, arg);
     return rc;
 }
 
diff -r f0caf8b361c4 -r 001e48a6f088 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Fri Oct 22 15:14:51 2010 +0100
+++ b/tools/libxc/xc_misc.c     Fri Oct 22 15:14:51 2010 +0100
@@ -313,18 +313,19 @@ int xc_hvm_set_pci_intx_level(
     unsigned int level)
 {
     DECLARE_HYPERCALL;
-    struct xen_hvm_set_pci_intx_level _arg, *arg = &_arg;
-    int rc;
-
-    if ( (rc = hcall_buf_prep(xch, (void **)&arg, sizeof(*arg))) != 0 )
-    {
-        PERROR("Could not lock memory");
-        return rc;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_pci_intx_level, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_set_pci_intx_level 
hypercall");
+        return -1;
     }
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_set_pci_intx_level;
-    hypercall.arg[1] = (unsigned long)arg;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
 
     arg->domid  = dom;
     arg->domain = domain;
@@ -335,7 +336,7 @@ int xc_hvm_set_pci_intx_level(
 
     rc = do_xen_hypercall(xch, &hypercall);
 
-    hcall_buf_release(xch, (void **)&arg, sizeof(*arg));
+    xc_hypercall_buffer_free(xch, arg);
 
     return rc;
 }
@@ -346,18 +347,19 @@ int xc_hvm_set_isa_irq_level(
     unsigned int level)
 {
     DECLARE_HYPERCALL;
-    struct xen_hvm_set_isa_irq_level _arg, *arg = &_arg;
-    int rc;
-
-    if ( (rc = hcall_buf_prep(xch, (void **)&arg, sizeof(*arg))) != 0 )
-    {
-        PERROR("Could not lock memory");
-        return rc;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_isa_irq_level, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_set_isa_irq_level 
hypercall");
+        return -1;
     }
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_set_isa_irq_level;
-    hypercall.arg[1] = (unsigned long)arg;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
 
     arg->domid   = dom;
     arg->isa_irq = isa_irq;
@@ -365,7 +367,7 @@ int xc_hvm_set_isa_irq_level(
 
     rc = do_xen_hypercall(xch, &hypercall);
 
-    hcall_buf_release(xch, (void **)&arg, sizeof(*arg));
+    xc_hypercall_buffer_free(xch, arg);
 
     return rc;
 }
@@ -374,26 +376,27 @@ int xc_hvm_set_pci_link_route(
     xc_interface *xch, domid_t dom, uint8_t link, uint8_t isa_irq)
 {
     DECLARE_HYPERCALL;
-    struct xen_hvm_set_pci_link_route arg;
-    int rc;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_pci_link_route, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_set_pci_link_route 
hypercall");
+        return -1;
+    }
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_set_pci_link_route;
-    hypercall.arg[1] = (unsigned long)&arg;
-
-    arg.domid   = dom;
-    arg.link    = link;
-    arg.isa_irq = isa_irq;
-
-    if ( (rc = lock_pages(xch, &arg, sizeof(arg))) != 0 )
-    {
-        PERROR("Could not lock memory");
-        return rc;
-    }
-
-    rc = do_xen_hypercall(xch, &hypercall);
-
-    unlock_pages(xch, &arg, sizeof(arg));
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    arg->domid   = dom;
+    arg->link    = link;
+    arg->isa_irq = isa_irq;
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+    xc_hypercall_buffer_free(xch, arg);
 
     return rc;
 }
@@ -404,28 +407,32 @@ int xc_hvm_track_dirty_vram(
     unsigned long *dirty_bitmap)
 {
     DECLARE_HYPERCALL;
-    struct xen_hvm_track_dirty_vram arg;
-    int rc;
+    DECLARE_HYPERCALL_BOUNCE(dirty_bitmap, (nr+31) / 32, 
XC_HYPERCALL_BUFFER_BOUNCE_BOTH);
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_track_dirty_vram, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL || xc_hypercall_bounce_pre(xch, dirty_bitmap) )
+    {
+        PERROR("Could not bounce memory for xc_hvm_track_dirty_vram 
hypercall");
+        rc = -1;
+        goto out;
+    }
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_track_dirty_vram;
-    hypercall.arg[1] = (unsigned long)&arg;
-
-    arg.domid     = dom;
-    arg.first_pfn = first_pfn;
-    arg.nr        = nr;
-    set_xen_guest_handle(arg.dirty_bitmap, (uint8_t *)dirty_bitmap);
-
-    if ( (rc = lock_pages(xch, &arg, sizeof(arg))) != 0 )
-    {
-        PERROR("Could not lock memory");
-        return rc;
-    }
-
-    rc = do_xen_hypercall(xch, &hypercall);
-
-    unlock_pages(xch, &arg, sizeof(arg));
-
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    arg->domid     = dom;
+    arg->first_pfn = first_pfn;
+    arg->nr        = nr;
+    xc_set_xen_guest_handle(arg->dirty_bitmap, dirty_bitmap);
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+out:
+    xc_hypercall_buffer_free(xch, arg);
+    xc_hypercall_bounce_post(xch, dirty_bitmap);
     return rc;
 }
 
@@ -433,26 +440,27 @@ int xc_hvm_modified_memory(
     xc_interface *xch, domid_t dom, uint64_t first_pfn, uint64_t nr)
 {
     DECLARE_HYPERCALL;
-    struct xen_hvm_modified_memory arg;
-    int rc;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_modified_memory, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_modified_memory 
hypercall");
+        return -1;
+    }
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_modified_memory;
-    hypercall.arg[1] = (unsigned long)&arg;
-
-    arg.domid     = dom;
-    arg.first_pfn = first_pfn;
-    arg.nr        = nr;
-
-    if ( (rc = lock_pages(xch, &arg, sizeof(arg))) != 0 )
-    {
-        PERROR("Could not lock memory");
-        return rc;
-    }
-
-    rc = do_xen_hypercall(xch, &hypercall);
-
-    unlock_pages(xch, &arg, sizeof(arg));
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    arg->domid     = dom;
+    arg->first_pfn = first_pfn;
+    arg->nr        = nr;
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+    xc_hypercall_buffer_free(xch, arg);
 
     return rc;
 }
@@ -461,27 +469,28 @@ int xc_hvm_set_mem_type(
     xc_interface *xch, domid_t dom, hvmmem_type_t mem_type, uint64_t 
first_pfn, uint64_t nr)
 {
     DECLARE_HYPERCALL;
-    struct xen_hvm_set_mem_type arg;
-    int rc;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_mem_type, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_set_mem_type hypercall");
+        return -1;
+    }
+
+    arg->domid        = dom;
+    arg->hvmmem_type  = mem_type;
+    arg->first_pfn    = first_pfn;
+    arg->nr           = nr;
 
     hypercall.op     = __HYPERVISOR_hvm_op;
     hypercall.arg[0] = HVMOP_set_mem_type;
-    hypercall.arg[1] = (unsigned long)&arg;
-
-    arg.domid        = dom;
-    arg.hvmmem_type  = mem_type;
-    arg.first_pfn    = first_pfn;
-    arg.nr           = nr;
-
-    if ( (rc = lock_pages(xch, &arg, sizeof(arg))) != 0 )
-    {
-        PERROR("Could not lock memory");
-        return rc;
-    }
-
-    rc = do_xen_hypercall(xch, &hypercall);
-
-    unlock_pages(xch, &arg, sizeof(arg));
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+    xc_hypercall_buffer_free(xch, arg);
 
     return rc;
 }

_______________________________________________
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 hvmop interfaces over to hypercall buffers, Xen patchbot-unstable <=