From: Konrad Rzeszutek Wilk Subject: [PATCH v2 3/4] libxc/tbuf: Use the xc_hypercall_bounce_[pre|post] instead of memcpy Date: Fri, 13 Jun 2014 16:41:23 -0400 Message-ID: <1402692084-931-4-git-send-email-konrad.wilk@oracle.com> References: <1402692084-931-1-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1402692084-931-1-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, george.dunlap@eu.citrix.com Cc: Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org for bounce buffer of the xc_cpumask_t. Signed-off-by: Konrad Rzeszutek Wilk --- tools/libxc/xc_tbuf.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c index 2828aee..85156dd 100644 --- a/tools/libxc/xc_tbuf.c +++ b/tools/libxc/xc_tbuf.c @@ -116,7 +116,7 @@ int xc_tbuf_disable(xc_interface *xch) int xc_tbuf_set_cpu_mask(xc_interface *xch, xc_cpumap_t mask, int bits) { DECLARE_SYSCTL; - DECLARE_HYPERCALL_BUFFER(uint8_t, bytemap); + DECLARE_HYPERCALL_BOUNCE(mask, 0, XC_HYPERCALL_BUFFER_BOUNCE_IN); int ret = -1; int local_bits; @@ -129,8 +129,9 @@ int xc_tbuf_set_cpu_mask(xc_interface *xch, xc_cpumap_t mask, int bits) PERROR("Wrong amount of bits supplied: %d > %d!\n", bits, local_bits); goto out; } - bytemap = xc_hypercall_buffer_alloc(xch, bytemap, DIV_ROUND_UP(bits, 8)); - if ( bytemap == NULL ) + + HYPERCALL_BOUNCE_SET_SIZE(mask, DIV_ROUND_UP(bits, 8)); + if ( xc_hypercall_bounce_pre(xch, mask) ) { PERROR("Could not allocate memory for xc_tbuf_set_cpu_mask hypercall"); goto out; @@ -140,14 +141,12 @@ int xc_tbuf_set_cpu_mask(xc_interface *xch, xc_cpumap_t mask, int bits) sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION; sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_cpu_mask; - memcpy(bytemap, mask, DIV_ROUND_UP(bits, 8)); - - set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, bytemap); + set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, mask); sysctl.u.tbuf_op.cpu_mask.nr_bits = bits; ret = do_sysctl(xch, &sysctl); - xc_hypercall_buffer_free(xch, bytemap); + xc_hypercall_bounce_post(xch, mask); out: return ret; -- 1.7.7.6