libxc changes to allow getting and setting the memory access permissions
Signed-off-by: Joe Epstein <jepstein98@xxxxxxxxx>
diff -r 4e108cf56d07 tools/libxc/Makefile
--- a/tools/libxc/Makefile Mon Dec 27 08:00:09 2010 +0000
+++ b/tools/libxc/Makefile Tue Dec 28 22:31:15 2010 -0800
@@ -28,6 +28,7 @@
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 -r 4e108cf56d07 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c Mon Dec 27 08:00:09 2010 +0000
+++ b/tools/libxc/xc_misc.c Tue Dec 28 22:31:15 2010 -0800
@@ -511,6 +511,66 @@
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 -r 4e108cf56d07 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Mon Dec 27 08:00:09 2010 +0000
+++ b/tools/libxc/xenctrl.h Tue Dec 28 22:31:15 2010 -0800
@@ -1398,6 +1398,20 @@
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 +1718,8 @@
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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|