[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 23 of 24] libxc: convert tmem interface over to hypercall buffers
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1283779691 -3600 # Node ID afdedd2e14c342a381094df14de9446636780283 # Parent 649c4386d5904838f801d30e908b0f3bb1387d2c libxc: convert tmem interface over to hypercall buffers Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 649c4386d590 -r afdedd2e14c3 tools/libxc/xc_tmem.c --- a/tools/libxc/xc_tmem.c Mon Sep 06 14:28:11 2010 +0100 +++ b/tools/libxc/xc_tmem.c Mon Sep 06 14:28:11 2010 +0100 @@ -25,21 +25,23 @@ static int do_tmem_op(xc_interface *xch, { int ret; DECLARE_HYPERCALL; + DECLARE_HYPERCALL_BOUNCE(op, sizeof(*op), XC_HYPERCALL_BUFFER_BOUNCE_BOTH); - hypercall.op = __HYPERVISOR_tmem_op; - hypercall.arg[0] = (unsigned long)op; - if (lock_pages(xch, op, sizeof(*op)) != 0) + if ( xc_hypercall_bounce_pre(xch, op) ) { PERROR("Could not lock memory for Xen hypercall"); return -EFAULT; } + + hypercall.op = __HYPERVISOR_tmem_op; + hypercall.arg[0] = HYPERCALL_BUFFER_AS_ARG(op); if ((ret = do_xen_hypercall(xch, &hypercall)) < 0) { if ( errno == EACCES ) DPRINTF("tmem operation failed -- need to" " rebuild the user-space tool set?\n"); } - unlock_pages(xch, op, sizeof(*op)); + xc_hypercall_bounce_post(xch, op); return ret; } @@ -54,36 +56,41 @@ int xc_tmem_control(xc_interface *xch, void *buf) { tmem_op_t op; + DECLARE_HYPERCALL_BOUNCE(buf, arg1, XC_HYPERCALL_BUFFER_BOUNCE_OUT); int rc; op.cmd = TMEM_CONTROL; op.pool_id = pool_id; op.u.ctrl.subop = subop; op.u.ctrl.cli_id = cli_id; - set_xen_guest_handle(op.u.ctrl.buf,buf); op.u.ctrl.arg1 = arg1; op.u.ctrl.arg2 = arg2; op.u.ctrl.arg3 = arg3; - - if (subop == TMEMC_LIST) { - if ((arg1 != 0) && (lock_pages(xch, buf, arg1) != 0)) - { - PERROR("Could not lock memory for Xen hypercall"); - return -ENOMEM; - } - } #ifdef VALGRIND if (arg1 != 0) memset(buf, 0, arg1); #endif + if ( arg1 != 0 ) + { + if ( buf == NULL ) + return -EINVAL; + if ( xc_hypercall_bounce_pre(xch, buf) ) + { + PERROR("Could not lock memory for Xen hypercall"); + return -ENOMEM; + } + + xc_set_xen_guest_handle(op.u.ctrl.buf, buf); + } + else + xc_set_xen_guest_handle(op.u.ctrl.buf, HYPERCALL_BUFFER_NULL); + rc = do_tmem_op(xch, &op); - if (subop == TMEMC_LIST) { - if (arg1 != 0) - unlock_pages(xch, buf, arg1); - } + if (arg1 != 0) + xc_hypercall_bounce_post(xch, buf); return rc; } _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |