Files
xen/tools/libxc/xc_tbuf.c
T
kfraser@localhost.localdomain 1df421476a Replace dom0_ops hypercall with three new hypercalls:
1. platform_op -- used by dom0 kernel to perform actions on the
    hardware platform (e.g., MTRR access, microcode update, platform
    quirks, ...)
 2. domctl -- used by management tools to control a specified domain
 3. sysctl -- used by management tools for system-wide actions

Benefits include more sensible factoring of actions to
hypercalls. Also allows tool compatibility to be tracked separately
from the dom0 kernel. The assumption is that it will be easier to
replace libxenctrl, libxenguest and Xen as a matched set if the
dom0 kernel does not need to be replaced too (e.g., because that
would require vendor revalidation).

From here on we hope to maintain dom0 kernel compatibility. This
promise is not extended to tool compatibility beyond the existing
guarantee that compatibility will not be broken within a three-level
stable release [3.0.2, 3.0.3, etc.].

Signed-off-by: Keir Fraser <keir@xensource.com>
2006-08-25 18:39:10 +01:00

133 lines
3.3 KiB
C

/******************************************************************************
* xc_tbuf.c
*
* API for manipulating and accessing trace buffer parameters
*
* Copyright (c) 2005, Rob Gardner
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2 of the
* License.
*/
#include "xc_private.h"
static int tbuf_enable(int xc_handle, int enable)
{
DECLARE_SYSCTL;
sysctl.cmd = XEN_SYSCTL_tbuf_op;
sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
if (enable)
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_enable;
else
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_disable;
return xc_sysctl(xc_handle, &sysctl);
}
int xc_tbuf_set_size(int xc_handle, unsigned long size)
{
DECLARE_SYSCTL;
sysctl.cmd = XEN_SYSCTL_tbuf_op;
sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_size;
sysctl.u.tbuf_op.size = size;
return xc_sysctl(xc_handle, &sysctl);
}
int xc_tbuf_get_size(int xc_handle, unsigned long *size)
{
int rc;
DECLARE_SYSCTL;
sysctl.cmd = XEN_SYSCTL_tbuf_op;
sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
rc = xc_sysctl(xc_handle, &sysctl);
if (rc == 0)
*size = sysctl.u.tbuf_op.size;
return rc;
}
int xc_tbuf_enable(int xc_handle, size_t cnt, unsigned long *mfn,
unsigned long *size)
{
DECLARE_SYSCTL;
int rc;
/*
* Ignore errors (at least for now) as we get an error if size is already
* set (since trace buffers cannot be reallocated). If we really have no
* buffers at all then tbuf_enable() will fail, so this is safe.
*/
(void)xc_tbuf_set_size(xc_handle, cnt);
if ( tbuf_enable(xc_handle, 1) != 0 )
return -1;
sysctl.cmd = XEN_SYSCTL_tbuf_op;
sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
rc = xc_sysctl(xc_handle, &sysctl);
if ( rc == 0 )
{
*size = sysctl.u.tbuf_op.size;
*mfn = sysctl.u.tbuf_op.buffer_mfn;
}
return 0;
}
int xc_tbuf_disable(int xc_handle)
{
return tbuf_enable(xc_handle, 0);
}
int xc_tbuf_set_cpu_mask(int xc_handle, uint32_t mask)
{
DECLARE_SYSCTL;
int ret = -1;
sysctl.cmd = XEN_SYSCTL_tbuf_op;
sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_cpu_mask;
set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, (uint8_t *)&mask);
sysctl.u.tbuf_op.cpu_mask.nr_cpus = sizeof(mask) * 8;
if ( mlock(&mask, sizeof(mask)) != 0 )
{
PERROR("Could not lock memory for Xen hypercall");
goto out;
}
ret = do_sysctl(xc_handle, &sysctl);
safe_munlock(&mask, sizeof(mask));
out:
return ret;
}
int xc_tbuf_set_evt_mask(int xc_handle, uint32_t mask)
{
DECLARE_SYSCTL;
sysctl.cmd = XEN_SYSCTL_tbuf_op;
sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_evt_mask;
sysctl.u.tbuf_op.evt_mask = mask;
return do_sysctl(xc_handle, &sysctl);
}