aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/libxc/Makefile1
-rw-r--r--tools/libxc/xc_domain.c11
-rw-r--r--tools/libxc/xc_mem_access.c42
-rw-r--r--tools/libxc/xc_misc.c60
-rw-r--r--tools/libxc/xenctrl.h28
5 files changed, 142 insertions, 0 deletions
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index e042be7ea0..5a7677e996 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -28,6 +28,7 @@ CTRL_SRCS-y += xc_resume.c
CTRL_SRCS-y += xc_tmem.c
CTRL_SRCS-y += xc_mem_event.c
CTRL_SRCS-y += xc_mem_paging.c
+CTRL_SRCS-y += xc_mem_access.c
CTRL_SRCS-y += xc_memshr.c
CTRL_SRCS-y += xc_hcall_buf.c
CTRL_SRCS-y += xc_foreign_memory.c
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 2f4a990de8..98ca5ed49e 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -1442,6 +1442,17 @@ int xc_domain_debug_control(xc_interface *xc, uint32_t domid, uint32_t sop, uint
return do_domctl(xc, &domctl);
}
+int xc_domain_set_access_required(xc_interface *xch,
+ uint32_t domid,
+ unsigned int required)
+{
+ DECLARE_DOMCTL;
+
+ domctl.cmd = XEN_DOMCTL_set_access_required;
+ domctl.domain = domid;
+ domctl.u.access_required.access_required = required;
+ return do_domctl(xch, &domctl);
+}
/*
* Local variables:
diff --git a/tools/libxc/xc_mem_access.c b/tools/libxc/xc_mem_access.c
new file mode 100644
index 0000000000..b9e66bbd07
--- /dev/null
+++ b/tools/libxc/xc_mem_access.c
@@ -0,0 +1,42 @@
+/******************************************************************************
+ *
+ * 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"
+
+
+int xc_mem_access_resume(xc_interface *xch, domid_t domain_id, unsigned long gfn)
+{
+ return xc_mem_event_control(xch, domain_id,
+ XEN_DOMCTL_MEM_EVENT_OP_ACCESS_RESUME,
+ XEN_DOMCTL_MEM_EVENT_OP_ACCESS, NULL, NULL,
+ gfn);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 47f97c55f2..f4004b1d82 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -511,6 +511,66 @@ int xc_hvm_set_mem_type(
return rc;
}
+int xc_hvm_set_mem_access(
+ xc_interface *xch, domid_t dom, hvmmem_access_t mem_access, uint64_t first_pfn, uint64_t nr)
+{
+ DECLARE_HYPERCALL;
+ DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_mem_access, arg);
+ int rc;
+
+ arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+ if ( arg == NULL )
+ {
+ PERROR("Could not allocate memory for xc_hvm_set_mem_access hypercall");
+ return -1;
+ }
+
+ arg->domid = dom;
+ arg->hvmmem_access = mem_access;
+ arg->first_pfn = first_pfn;
+ arg->nr = nr;
+
+ hypercall.op = __HYPERVISOR_hvm_op;
+ hypercall.arg[0] = HVMOP_set_mem_access;
+ hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+ rc = do_xen_hypercall(xch, &hypercall);
+
+ xc_hypercall_buffer_free(xch, arg);
+
+ return rc;
+}
+
+int xc_hvm_get_mem_access(
+ xc_interface *xch, domid_t dom, uint64_t pfn, hvmmem_access_t* mem_access)
+{
+ DECLARE_HYPERCALL;
+ DECLARE_HYPERCALL_BUFFER(struct xen_hvm_get_mem_access, arg);
+ int rc;
+
+ arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+ if ( arg == NULL )
+ {
+ PERROR("Could not allocate memory for xc_hvm_get_mem_access hypercall");
+ return -1;
+ }
+
+ arg->domid = dom;
+ arg->pfn = pfn;
+
+ hypercall.op = __HYPERVISOR_hvm_op;
+ hypercall.arg[0] = HVMOP_get_mem_access;
+ hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+ rc = do_xen_hypercall(xch, &hypercall);
+
+ if ( !rc )
+ *mem_access = arg->hvmmem_access;
+
+ xc_hypercall_buffer_free(xch, arg);
+
+ return rc;
+}
/*
* Local variables:
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 4827303b73..aec258662f 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -701,6 +701,19 @@ int xc_domain_setdebugging(xc_interface *xch,
uint32_t domid,
unsigned int enable);
+/**
+ * This function sets or clears the requirement that an access memory
+ * event listener is required on the domain.
+ *
+ * @parm xch a handle to an open hypervisor interface
+ * @parm domid the domain id to send trigger
+ * @parm enable true to require a listener
+ * return 0 on success, -1 on failure
+ */
+int xc_domain_set_access_required(xc_interface *xch,
+ uint32_t domid,
+ unsigned int required);
+
/*
* CPUPOOL MANAGEMENT FUNCTIONS
*/
@@ -1398,6 +1411,19 @@ int xc_hvm_modified_memory(
int xc_hvm_set_mem_type(
xc_interface *xch, domid_t dom, hvmmem_type_t memtype, uint64_t first_pfn, uint64_t nr);
+/*
+ * Set a range of memory to a specific access.
+ * Allowed types are HVMMEM_access_default, HVMMEM_access_n, any combination of
+ * HVM_access_ + (rwx), and HVM_access_rx2rw
+ */
+int xc_hvm_set_mem_access(
+ xc_interface *xch, domid_t dom, hvmmem_access_t memaccess, uint64_t first_pfn, uint64_t nr);
+
+/*
+ * Gets the mem access for the given page (returned in memacess on success)
+ */
+int xc_hvm_get_mem_access(
+ xc_interface *xch, domid_t dom, uint64_t pfn, hvmmem_access_t* memaccess);
/*
* LOGGING AND ERROR REPORTING
@@ -1704,6 +1730,8 @@ int xc_mem_paging_evict(xc_interface *xch, domid_t domain_id, unsigned long gfn)
int xc_mem_paging_prep(xc_interface *xch, domid_t domain_id, unsigned long gfn);
int xc_mem_paging_resume(xc_interface *xch, domid_t domain_id,
unsigned long gfn);
+int xc_mem_access_resume(xc_interface *xch, domid_t domain_id,
+ unsigned long gfn);
/**
* memshr operations