[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V4 13/13] xen/vm_event: Add RESUME option to vm_event_op domctl
Thus far mem_access and mem_sharing memops had been able to signal to Xen to start pulling responses off the corresponding rings. In this patch we retire these memops and add them to the option to the vm_event_op domctl. The vm_event_op domctl suboptions are the same for each ring thus we consolidate them into XEN_VM_EVENT_ENABLE/DISABLE/RESUME. As part of this patch in libxc we also rename the mem_access_enable/disable functions to monitor_enable/disable and move them into xc_monitor.c. Signed-off-by: Tamas K Lengyel <tamas.lengyel@xxxxxxxxxxxx> --- tools/libxc/include/xenctrl.h | 22 ++++++++++----------- tools/libxc/xc_mem_access.c | 25 ------------------------ tools/libxc/xc_mem_paging.c | 12 ++++++++++-- tools/libxc/xc_memshr.c | 15 ++++++-------- tools/libxc/xc_monitor.c | 22 +++++++++++++++++++++ tools/libxc/xc_vm_event.c | 6 +++--- tools/tests/xen-access/xen-access.c | 12 ++++++------ xen/arch/x86/mm/mem_sharing.c | 9 --------- xen/common/mem_access.c | 9 --------- xen/common/vm_event.c | 39 +++++++++++++++++++++++++++++++------ xen/include/public/domctl.h | 32 ++++++++++++++---------------- xen/include/public/memory.h | 16 +++++++-------- 12 files changed, 113 insertions(+), 106 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 3324132..3042e98 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -2269,6 +2269,7 @@ int xc_tmem_restore_extra(xc_interface *xch, int dom, int fd); */ int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id, uint32_t *port); int xc_mem_paging_disable(xc_interface *xch, domid_t domain_id); +int xc_mem_paging_resume(xc_interface *xch, domid_t domain_id); int xc_mem_paging_nominate(xc_interface *xch, domid_t domain_id, unsigned long gfn); int xc_mem_paging_evict(xc_interface *xch, domid_t domain_id, unsigned long gfn); @@ -2282,17 +2283,6 @@ int xc_mem_paging_load(xc_interface *xch, domid_t domain_id, */ /* - * Enables mem_access and returns the mapped ring page. - * Will return NULL on error. - * Caller has to unmap this page when done. - */ -void *xc_mem_access_enable(xc_interface *xch, domid_t domain_id, uint32_t *port); -void *xc_mem_access_enable_introspection(xc_interface *xch, domid_t domain_id, - uint32_t *port); -int xc_mem_access_disable(xc_interface *xch, domid_t domain_id); -int xc_mem_access_resume(xc_interface *xch, domid_t domain_id); - -/* * Set a range of memory to a specific access. * Allowed types are XENMEM_access_default, XENMEM_access_n, any combination of * XENMEM_access_ + (rwx), and XENMEM_access_rx2rw @@ -2309,7 +2299,17 @@ int xc_get_mem_access(xc_interface *xch, domid_t domain_id, /*** * Monitor control operations. + * + * Enables the VM event monitor ring and returns the mapped ring page. + * This ring is used to deliver mem_access events, as well a set of additional + * events that can be enabled with the xc_monitor_* functions. + * + * Will return NULL on error. + * Caller has to unmap this page when done. */ +void *xc_monitor_enable(xc_interface *xch, domid_t domain_id, uint32_t *port); +int xc_monitor_disable(xc_interface *xch, domid_t domain_id); +int xc_monitor_resume(xc_interface *xch, domid_t domain_id); int xc_monitor_mov_to_cr0(xc_interface *xch, domid_t domain_id, unsigned int op, unsigned int sync, unsigned int onchangeonly); diff --git a/tools/libxc/xc_mem_access.c b/tools/libxc/xc_mem_access.c index 37e776c..7050692 100644 --- a/tools/libxc/xc_mem_access.c +++ b/tools/libxc/xc_mem_access.c @@ -24,31 +24,6 @@ #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_vm_event_enable(xch, domain_id, HVM_PARAM_MONITOR_RING_PFN, - port); -} - -int xc_mem_access_disable(xc_interface *xch, domid_t domain_id) -{ - return xc_vm_event_control(xch, domain_id, - XEN_VM_EVENT_MONITOR_DISABLE, - XEN_DOMCTL_VM_EVENT_OP_MONITOR, - 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, diff --git a/tools/libxc/xc_mem_paging.c b/tools/libxc/xc_mem_paging.c index b635a4d..9e64190 100644 --- a/tools/libxc/xc_mem_paging.c +++ b/tools/libxc/xc_mem_paging.c @@ -48,7 +48,7 @@ int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id, } return xc_vm_event_control(xch, domain_id, - XEN_VM_EVENT_PAGING_ENABLE, + XEN_VM_EVENT_ENABLE, XEN_DOMCTL_VM_EVENT_OP_PAGING, port); } @@ -56,7 +56,15 @@ int xc_mem_paging_enable(xc_interface *xch, domid_t domain_id, int xc_mem_paging_disable(xc_interface *xch, domid_t domain_id) { return xc_vm_event_control(xch, domain_id, - XEN_VM_EVENT_PAGING_DISABLE, + XEN_VM_EVENT_DISABLE, + XEN_DOMCTL_VM_EVENT_OP_PAGING, + NULL); +} + +int xc_mem_paging_resume(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_RESUME, XEN_DOMCTL_VM_EVENT_OP_PAGING, NULL); } diff --git a/tools/libxc/xc_memshr.c b/tools/libxc/xc_memshr.c index 14cc1ce..0960c6d 100644 --- a/tools/libxc/xc_memshr.c +++ b/tools/libxc/xc_memshr.c @@ -53,7 +53,7 @@ int xc_memshr_ring_enable(xc_interface *xch, } return xc_vm_event_control(xch, domid, - XEN_VM_EVENT_SHARING_ENABLE, + XEN_VM_EVENT_ENABLE, XEN_DOMCTL_VM_EVENT_OP_SHARING, port); } @@ -62,7 +62,7 @@ int xc_memshr_ring_disable(xc_interface *xch, domid_t domid) { return xc_vm_event_control(xch, domid, - XEN_VM_EVENT_SHARING_DISABLE, + XEN_VM_EVENT_DISABLE, XEN_DOMCTL_VM_EVENT_OP_SHARING, NULL); } @@ -185,13 +185,10 @@ int xc_memshr_add_to_physmap(xc_interface *xch, int xc_memshr_domain_resume(xc_interface *xch, domid_t domid) { - xen_mem_sharing_op_t mso; - - memset(&mso, 0, sizeof(mso)); - - mso.op = XENMEM_sharing_op_resume; - - return xc_memshr_memop(xch, domid, &mso); + return xc_vm_event_control(xch, domid, + XEN_VM_EVENT_RESUME, + XEN_DOMCTL_VM_EVENT_OP_SHARING, + NULL); } int xc_memshr_debug_gfn(xc_interface *xch, diff --git a/tools/libxc/xc_monitor.c b/tools/libxc/xc_monitor.c index 9e807d1..a4d7b7a 100644 --- a/tools/libxc/xc_monitor.c +++ b/tools/libxc/xc_monitor.c @@ -23,6 +23,28 @@ #include "xc_private.h" +void *xc_monitor_enable(xc_interface *xch, domid_t domain_id, uint32_t *port) +{ + return xc_vm_event_enable(xch, domain_id, HVM_PARAM_MONITOR_RING_PFN, + port); +} + +int xc_monitor_disable(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_DISABLE, + XEN_DOMCTL_VM_EVENT_OP_MONITOR, + NULL); +} + +int xc_monitor_resume(xc_interface *xch, domid_t domain_id) +{ + return xc_vm_event_control(xch, domain_id, + XEN_VM_EVENT_RESUME, + XEN_DOMCTL_VM_EVENT_OP_MONITOR, + NULL); +} + int xc_monitor_mov_to_cr0(xc_interface *xch, domid_t domain_id, unsigned int op, unsigned int sync, unsigned int onchangeonly) diff --git a/tools/libxc/xc_vm_event.c b/tools/libxc/xc_vm_event.c index 7277e86..a5b3277 100644 --- a/tools/libxc/xc_vm_event.c +++ b/tools/libxc/xc_vm_event.c @@ -99,17 +99,17 @@ void *xc_vm_event_enable(xc_interface *xch, domid_t domain_id, int param, switch ( param ) { case HVM_PARAM_PAGING_RING_PFN: - op = XEN_VM_EVENT_PAGING_ENABLE; + op = XEN_VM_EVENT_ENABLE; mode = XEN_DOMCTL_VM_EVENT_OP_PAGING; break; case HVM_PARAM_MONITOR_RING_PFN: - op = XEN_VM_EVENT_MONITOR_ENABLE; + op = XEN_VM_EVENT_ENABLE; mode = XEN_DOMCTL_VM_EVENT_OP_MONITOR; break; case HVM_PARAM_SHARING_RING_PFN: - op = XEN_VM_EVENT_SHARING_ENABLE; + op = XEN_VM_EVENT_ENABLE; mode = XEN_DOMCTL_VM_EVENT_OP_SHARING; break; diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c index 0d1bf78..b1197ad 100644 --- a/tools/tests/xen-access/xen-access.c +++ b/tools/tests/xen-access/xen-access.c @@ -124,8 +124,8 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess) if ( mem_access_enable ) { - rc = xc_mem_access_disable(xenaccess->xc_handle, - xenaccess->vm_event.domain_id); + rc = xc_monitor_disable(xenaccess->xc_handle, + xenaccess->vm_event.domain_id); if ( rc != 0 ) { ERROR("Error tearing down domain xenaccess in xen"); @@ -196,9 +196,9 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id) /* Enable mem_access */ xenaccess->vm_event.ring_page = - xc_mem_access_enable(xenaccess->xc_handle, - xenaccess->vm_event.domain_id, - &xenaccess->vm_event.evtchn_port); + xc_monitor_enable(xenaccess->xc_handle, + xenaccess->vm_event.domain_id, + &xenaccess->vm_event.evtchn_port); if ( xenaccess->vm_event.ring_page == NULL ) { switch ( errno ) { @@ -322,7 +322,7 @@ static int xenaccess_resume_page(xenaccess_t *paging, vm_event_response_t *rsp) put_response(&paging->vm_event, rsp); /* Tell Xen page is ready */ - ret = xc_mem_access_resume(paging->xc_handle, paging->vm_event.domain_id); + ret = xc_monitor_resume(paging->xc_handle, paging->vm_event.domain_id); ret = xc_evtchn_notify(paging->vm_event.xce_handle, paging->vm_event.port); diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index e3ebc05..0a2fbb6 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1460,15 +1460,6 @@ int mem_sharing_memop(unsigned long cmd, } break; - case XENMEM_sharing_op_resume: - { - if ( !mem_sharing_enabled(d) ) - return -EINVAL; - - vm_event_resume(d, &d->vm_event->share); - } - break; - case XENMEM_sharing_op_debug_gfn: { unsigned long gfn = mso.u.debug.u.gfn; diff --git a/xen/common/mem_access.c b/xen/common/mem_access.c index 426f766..1ece9b5 100644 --- a/xen/common/mem_access.c +++ b/xen/common/mem_access.c @@ -58,15 +58,6 @@ int mem_access_memop(unsigned long cmd, switch ( mao.op ) { - case XENMEM_access_op_resume: - if ( unlikely(start_iter) ) - rc = -ENOSYS; - else - { - vm_event_resume(d, &d->vm_event->monitor); - rc = 0; - } - break; case XENMEM_access_op_set_access: rc = -EINVAL; diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 5b0d0d2..77d2663 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -579,7 +579,7 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, switch( vec->op ) { - case XEN_VM_EVENT_PAGING_ENABLE: + case XEN_VM_EVENT_ENABLE: { struct p2m_domain *p2m = p2m_get_hostp2m(d); @@ -609,13 +609,22 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, } break; - case XEN_VM_EVENT_PAGING_DISABLE: + case XEN_VM_EVENT_DISABLE: { if ( ved->ring_page ) rc = vm_event_disable(d, ved); } break; + case XEN_VM_EVENT_RESUME: + { + if ( ved->ring_page ) + vm_event_resume(d, ved); + else + rc = -ENODEV; + } + break; + default: rc = -ENOSYS; break; @@ -631,19 +640,28 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, switch( vec->op ) { - case XEN_VM_EVENT_MONITOR_ENABLE: + case XEN_VM_EVENT_ENABLE: rc = vm_event_enable(d, vec, ved, _VPF_mem_access, HVM_PARAM_MONITOR_RING_PFN, monitor_notification); break; - case XEN_VM_EVENT_MONITOR_DISABLE: + case XEN_VM_EVENT_DISABLE: if ( ved->ring_page ) { rc = vm_event_disable(d, ved); } break; + case XEN_VM_EVENT_RESUME: + { + if ( ved->ring_page ) + vm_event_resume(d, ved); + else + rc = -ENODEV; + } + break; + default: rc = -ENOSYS; break; @@ -659,7 +677,7 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, switch( vec->op ) { - case XEN_VM_EVENT_SHARING_ENABLE: + case XEN_VM_EVENT_ENABLE: { rc = -EOPNOTSUPP; /* pvh fixme: p2m_is_foreign types need addressing */ @@ -677,13 +695,22 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, } break; - case XEN_VM_EVENT_SHARING_DISABLE: + case XEN_VM_EVENT_DISABLE: { if ( ved->ring_page ) rc = vm_event_disable(d, ved); } break; + case XEN_VM_EVENT_RESUME: + { + if ( ved->ring_page ) + vm_event_resume(d, ved); + else + rc = -ENODEV; + } + break; + default: rc = -ENOSYS; break; diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index c82a992..68c53cc 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -756,6 +756,17 @@ struct xen_domctl_gdbsx_domstatus { /* XEN_DOMCTL_vm_event_op */ /* + * There are currently three rings available for VM events: + * sharing, monitor and paging. This hypercall allows one to + * control these rings (enable/disable), as well as to signal + * to the hypervisor to pull responses (resume) from the given + * ring. + */ +#define XEN_VM_EVENT_ENABLE 0 +#define XEN_VM_EVENT_DISABLE 1 +#define XEN_VM_EVENT_RESUME 2 + +/* * Domain memory paging * Page memory in and out. * Domctl interface to set up and tear down the @@ -771,9 +782,6 @@ struct xen_domctl_gdbsx_domstatus { */ #define XEN_DOMCTL_VM_EVENT_OP_PAGING 1 -#define XEN_VM_EVENT_PAGING_ENABLE 0 -#define XEN_VM_EVENT_PAGING_DISABLE 1 - /* * Monitor helper. * @@ -785,24 +793,17 @@ struct xen_domctl_gdbsx_domstatus { * of every page in a domain. When one of these permissions--independent, * read, write, and execute--is violated, the VCPU is paused and a memory event * is sent with what happened. The memory event handler can then resume the - * VCPU and redo the access with a XENMEM_access_op_resume hypercall. + * VCPU and redo the access with a XEN_VM_EVENT_RESUME option. * * See public/vm_event.h for the list of available events that can be * subscribed to via the monitor interface. * - * To enable MOV-TO-MSR interception on x86, it is necessary to enable this - * interface with the XEN_VM_EVENT_MONITOR_ENABLE_INTROSPECTION - * operator. - * - * The XEN_VM_EVENT_MONITOR_ENABLE* domctls return several + * The XEN_VM_EVENT_MONITOR_* domctls returns * non-standard error codes to indicate why access could not be enabled: * EBUSY - guest has or had access enabled, ring buffer still active * */ -#define XEN_DOMCTL_VM_EVENT_OP_MONITOR 2 - -#define XEN_VM_EVENT_MONITOR_ENABLE 0 -#define XEN_VM_EVENT_MONITOR_DISABLE 1 +#define XEN_DOMCTL_VM_EVENT_OP_MONITOR 2 /* * Sharing ENOMEM helper. @@ -819,13 +820,10 @@ struct xen_domctl_gdbsx_domstatus { */ #define XEN_DOMCTL_VM_EVENT_OP_SHARING 3 -#define XEN_VM_EVENT_SHARING_ENABLE 0 -#define XEN_VM_EVENT_SHARING_DISABLE 1 - /* Use for teardown/setup of helper<->hypervisor interface for paging, * access and sharing.*/ struct xen_domctl_vm_event_op { - uint32_t op; /* XEN_VM_EVENT_*_* */ + uint32_t op; /* XEN_VM_EVENT_* */ uint32_t mode; /* XEN_DOMCTL_VM_EVENT_OP_* */ uint32_t port; /* OUT: event channel for ring */ diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index e0cca46..329b690 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -385,9 +385,8 @@ typedef struct xen_mem_paging_op xen_mem_paging_op_t; DEFINE_XEN_GUEST_HANDLE(xen_mem_paging_op_t); #define XENMEM_access_op 21 -#define XENMEM_access_op_resume 0 -#define XENMEM_access_op_set_access 1 -#define XENMEM_access_op_get_access 2 +#define XENMEM_access_op_set_access 0 +#define XENMEM_access_op_get_access 1 typedef enum { XENMEM_access_n, @@ -438,12 +437,11 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_access_op_t); #define XENMEM_sharing_op_nominate_gfn 0 #define XENMEM_sharing_op_nominate_gref 1 #define XENMEM_sharing_op_share 2 -#define XENMEM_sharing_op_resume 3 -#define XENMEM_sharing_op_debug_gfn 4 -#define XENMEM_sharing_op_debug_mfn 5 -#define XENMEM_sharing_op_debug_gref 6 -#define XENMEM_sharing_op_add_physmap 7 -#define XENMEM_sharing_op_audit 8 +#define XENMEM_sharing_op_debug_gfn 3 +#define XENMEM_sharing_op_debug_mfn 4 +#define XENMEM_sharing_op_debug_gref 5 +#define XENMEM_sharing_op_add_physmap 6 +#define XENMEM_sharing_op_audit 7 #define XENMEM_SHARING_OP_S_HANDLE_INVALID (-10) #define XENMEM_SHARING_OP_C_HANDLE_INVALID (-9) -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |