Files
xen/tools/libxc/xc_evtchn.c
T
emellor@leeni.uk.xensource.com a22292f2bb Make it possible to run valgrind on code linked with the libxc libraries.
Valgrind cannot see when a hypercall has initialised entries in a data
structure, so appropriate memsets have been placed before using dom0_op_t,
privcmd_hypercall_t, and a couple of miscellaneous blocks passed into this
layer.  This initialises the block so that valgrind considers it to be valid,
but the data therein will be immediately overwritten by the hypercall, all
being well.

These changes are semantically neutral if -DVALGRIND is not set.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
2005-11-22 16:31:16 +01:00

68 lines
1.6 KiB
C

/******************************************************************************
* xc_evtchn.c
*
* API for manipulating and accessing inter-domain event channels.
*
* Copyright (c) 2004, K A Fraser.
*/
#include "xc_private.h"
static int do_evtchn_op(int xc_handle, evtchn_op_t *op)
{
int ret = -1;
DECLARE_HYPERCALL;
hypercall.op = __HYPERVISOR_event_channel_op;
hypercall.arg[0] = (unsigned long)op;
if ( mlock(op, sizeof(*op)) != 0 )
{
PERROR("do_evtchn_op: op mlock failed");
goto out;
}
if ((ret = do_xen_hypercall(xc_handle, &hypercall)) < 0)
ERROR("do_evtchn_op: HYPERVISOR_event_channel_op failed: %d", ret);
safe_munlock(op, sizeof(*op));
out:
return ret;
}
int xc_evtchn_alloc_unbound(int xc_handle,
uint32_t dom,
uint32_t remote_dom)
{
int rc;
evtchn_op_t op = {
.cmd = EVTCHNOP_alloc_unbound,
.u.alloc_unbound.dom = (domid_t)dom,
.u.alloc_unbound.remote_dom = (domid_t)remote_dom };
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
rc = op.u.alloc_unbound.port;
return rc;
}
int xc_evtchn_status(int xc_handle,
uint32_t dom,
int port,
xc_evtchn_status_t *status)
{
int rc;
evtchn_op_t op = {
.cmd = EVTCHNOP_status,
.u.status.dom = (domid_t)dom,
.u.status.port = port };
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
memcpy(status, &op.u.status, sizeof(*status));
return rc;
}