tools/libxc: Add xc_vmtrace_* functions

Add functions in libxc that use the new XEN_DOMCTL_vmtrace interface.

Signed-off-by: Michał Leszczyński <michal.leszczynski@cert.pl>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
This commit is contained in:
Michał Leszczyński authored and Andrew Cooper committed 2021-02-05 17:37:28 +00:00
1 parent 1cee4bd97c
commit 53aaa792fd
3 files changed
+202

No files matched your search

+73
View File
@@ -1583,6 +1583,79 @@ int xc_tbuf_set_cpu_mask(xc_interface *xch, xc_cpumap_t mask);
int xc_tbuf_set_evt_mask(xc_interface *xch, uint32_t mask);
/**
* Enable vmtrace for given vCPU.
*
* @parm xch a handle to an open hypervisor interface
* @parm domid domain identifier
* @parm vcpu vcpu identifier
* @return 0 on success, -1 on failure
*/
int xc_vmtrace_enable(xc_interface *xch, uint32_t domid, uint32_t vcpu);
/**
* Enable vmtrace for given vCPU.
*
* @parm xch a handle to an open hypervisor interface
* @parm domid domain identifier
* @parm vcpu vcpu identifier
* @return 0 on success, -1 on failure
*/
int xc_vmtrace_disable(xc_interface *xch, uint32_t domid, uint32_t vcpu);
/**
* Enable vmtrace for a given vCPU, along with resetting status/offset
* details.
*
* @parm xch a handle to an open hypervisor interface
* @parm domid domain identifier
* @parm vcpu vcpu identifier
* @return 0 on success, -1 on failure
*/
int xc_vmtrace_reset_and_enable(xc_interface *xch, uint32_t domid,
uint32_t vcpu);
/**
* Get current output position inside the trace buffer.
*
* Repeated calls will return different values if tracing is enabled. It is
* platform specific what happens when the buffer fills completely.
*
* @parm xch a handle to an open hypervisor interface
* @parm domid domain identifier
* @parm vcpu vcpu identifier
* @parm pos current output position in bytes
* @return 0 on success, -1 on failure
*/
int xc_vmtrace_output_position(xc_interface *xch, uint32_t domid,
uint32_t vcpu, uint64_t *pos);
/**
* Get platform specific vmtrace options.
*
* @parm xch a handle to an open hypervisor interface
* @parm domid domain identifier
* @parm vcpu vcpu identifier
* @parm key platform-specific input
* @parm value platform-specific output
* @return 0 on success, -1 on failure
*/
int xc_vmtrace_get_option(xc_interface *xch, uint32_t domid,
uint32_t vcpu, uint64_t key, uint64_t *value);
/**
* Set platform specific vntvmtrace options.
*
* @parm xch a handle to an open hypervisor interface
* @parm domid domain identifier
* @parm vcpu vcpu identifier
* @parm key platform-specific input
* @parm value platform-specific input
* @return 0 on success, -1 on failure
*/
int xc_vmtrace_set_option(xc_interface *xch, uint32_t domid,
uint32_t vcpu, uint64_t key, uint64_t value);
int xc_domctl(xc_interface *xch, struct xen_domctl *domctl);
int xc_sysctl(xc_interface *xch, struct xen_sysctl *sysctl);
+1
View File
@@ -22,6 +22,7 @@ SRCS-y += xc_pm.c
SRCS-y += xc_cpu_hotplug.c
SRCS-y += xc_resume.c
SRCS-y += xc_vm_event.c
SRCS-y += xc_vmtrace.c
SRCS-y += xc_monitor.c
SRCS-y += xc_mem_paging.c
SRCS-y += xc_mem_access.c
+128
View File
@@ -0,0 +1,128 @@
/******************************************************************************
* xc_vmtrace.c
*
* API for manipulating hardware tracing features
*
* Copyright (c) 2020, Michal Leszczynski
*
* Copyright 2020 CERT Polska. All rights reserved.
* Use is subject to license terms.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; If not, see <http://www.gnu.org/licenses/>.
*/
#include "xc_private.h"
int xc_vmtrace_enable(
xc_interface *xch, uint32_t domid, uint32_t vcpu)
{
struct xen_domctl domctl = {
.cmd = XEN_DOMCTL_vmtrace_op,
.domain = domid,
.u.vmtrace_op = {
.cmd = XEN_DOMCTL_vmtrace_enable,
.vcpu = vcpu,
},
};
return do_domctl(xch, &domctl);
}
int xc_vmtrace_disable(
xc_interface *xch, uint32_t domid, uint32_t vcpu)
{
struct xen_domctl domctl = {
.cmd = XEN_DOMCTL_vmtrace_op,
.domain = domid,
.u.vmtrace_op = {
.cmd = XEN_DOMCTL_vmtrace_disable,
.vcpu = vcpu,
},
};
return do_domctl(xch, &domctl);
}
int xc_vmtrace_reset_and_enable(
xc_interface *xch, uint32_t domid, uint32_t vcpu)
{
struct xen_domctl domctl = {
.cmd = XEN_DOMCTL_vmtrace_op,
.domain = domid,
.u.vmtrace_op = {
.cmd = XEN_DOMCTL_vmtrace_reset_and_enable,
.vcpu = vcpu,
},
};
return do_domctl(xch, &domctl);
}
int xc_vmtrace_output_position(
xc_interface *xch, uint32_t domid, uint32_t vcpu, uint64_t *pos)
{
struct xen_domctl domctl = {
.cmd = XEN_DOMCTL_vmtrace_op,
.domain = domid,
.u.vmtrace_op = {
.cmd = XEN_DOMCTL_vmtrace_output_position,
.vcpu = vcpu,
},
};
int rc = do_domctl(xch, &domctl);
if ( !rc )
*pos = domctl.u.vmtrace_op.value;
return rc;
}
int xc_vmtrace_get_option(
xc_interface *xch, uint32_t domid, uint32_t vcpu,
uint64_t key, uint64_t *value)
{
struct xen_domctl domctl = {
.cmd = XEN_DOMCTL_vmtrace_op,
.domain = domid,
.u.vmtrace_op = {
.cmd = XEN_DOMCTL_vmtrace_get_option,
.vcpu = vcpu,
.key = key,
},
};
int rc = do_domctl(xch, &domctl);
if ( !rc )
*value = domctl.u.vmtrace_op.value;
return rc;
}
int xc_vmtrace_set_option(
xc_interface *xch, uint32_t domid, uint32_t vcpu,
uint64_t key, uint64_t value)
{
struct xen_domctl domctl = {
.cmd = XEN_DOMCTL_vmtrace_op,
.domain = domid,
.u.vmtrace_op = {
.cmd = XEN_DOMCTL_vmtrace_set_option,
.vcpu = vcpu,
.key = key,
.value = value,
},
};
return do_domctl(xch, &domctl);
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.