Files
xen/tools/libxc/xc_mem_access.c
T
Razvan Cojocaru 9b160a10cf x86, libxc: force-enable relevant MSR events
Vmx_disable_intercept_for_msr() will now refuse to disable interception of
MSRs needed for memory introspection. It is not possible to gate this on
mem_access being active for the domain, since by the time mem_access does
become active the interception for the interesting MSRs has already been
disabled (vmx_disable_intercept_for_msr() runs very early on).

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Tim Deegan <tim@xen.org>
2014-09-18 14:56:43 +02:00

106 lines
3.0 KiB
C

/******************************************************************************
*
* tools/libxc/xc_mem_access.c
*
* Interface to low-level memory access mode functionality
*
* Copyright (c) 2011 Virtuata, Inc.
*
* 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; either
* version 2.1 of the License, or (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "xc_private.h"
#include <xen/memory.h>
void *xc_mem_access_enable(xc_interface *xch, domid_t domain_id, uint32_t *port)
{
return xc_mem_event_enable(xch, domain_id, HVM_PARAM_ACCESS_RING_PFN,
port, 0);
}
void *xc_mem_access_enable_introspection(xc_interface *xch, domid_t domain_id,
uint32_t *port)
{
return xc_mem_event_enable(xch, domain_id, HVM_PARAM_ACCESS_RING_PFN,
port, 1);
}
int xc_mem_access_disable(xc_interface *xch, domid_t domain_id)
{
return xc_mem_event_control(xch, domain_id,
XEN_DOMCTL_MEM_EVENT_OP_ACCESS_DISABLE,
XEN_DOMCTL_MEM_EVENT_OP_ACCESS,
NULL);
}
int xc_mem_access_resume(xc_interface *xch, domid_t domain_id)
{
xen_mem_access_op_t mao =
{
.op = XENMEM_access_op_resume,
.domid = domain_id
};
return do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao));
}
int xc_set_mem_access(xc_interface *xch,
domid_t domain_id,
xenmem_access_t access,
uint64_t first_pfn,
uint32_t nr)
{
xen_mem_access_op_t mao =
{
.op = XENMEM_access_op_set_access,
.domid = domain_id,
.access = access,
.pfn = first_pfn,
.nr = nr
};
return do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao));
}
int xc_get_mem_access(xc_interface *xch,
domid_t domain_id,
uint64_t pfn,
xenmem_access_t *access)
{
int rc;
xen_mem_access_op_t mao =
{
.op = XENMEM_access_op_get_access,
.domid = domain_id,
.pfn = pfn
};
rc = do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao));
if ( rc == 0 )
*access = mao.access;
return rc;
}
/*
* Local variables:
* mode: C
* c-file-style: "BSD"
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/