[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] vm_event: make sure the domain is paused in key domctls
This patch pauses the domain for all writes through the 'ad' pointer in monitor_domctl(), defers a domain_unpause() call until after the CRs are updated for the MONITOR_EVENT_WRITE_CTRLREG case, and makes sure that the domain is paused for both vm_event enable and disable cases in vm_event_domctl(). Thanks go to Andrew Cooper for his review and suggestions. Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> --- xen/arch/x86/monitor.c | 18 ++++++++++-------- xen/common/vm_event.c | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 7611f7b..bb1920a 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -80,7 +80,9 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) return 0; case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP: - d->arch.mem_access_emulate_each_rep = !!mop->event; + domain_pause(d); + ad->mem_access_emulate_each_rep = !!mop->event; + domain_unpause(d); return 0; } @@ -109,6 +111,8 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) if ( rc ) return rc; + domain_pause(d); + if ( mop->u.mov_to_cr.sync ) ad->monitor.write_ctrlreg_sync |= ctrlreg_bitmask; else @@ -119,20 +123,18 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) else ad->monitor.write_ctrlreg_onchangeonly &= ~ctrlreg_bitmask; - domain_pause(d); - if ( !status ) ad->monitor.write_ctrlreg_enabled |= ctrlreg_bitmask; else ad->monitor.write_ctrlreg_enabled &= ~ctrlreg_bitmask; - domain_unpause(d); - if ( mop->u.mov_to_cr.index == VM_EVENT_X86_CR3 ) /* Latches new CR3 mask through CR0 code */ for_each_vcpu ( d, v ) hvm_update_guest_cr(v, 0); + domain_unpause(d); + break; } @@ -144,6 +146,8 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) if ( rc ) return rc; + domain_pause(d); + if ( mop->op == XEN_DOMCTL_MONITOR_OP_ENABLE && mop->u.mov_to_msr.extended_capture ) { @@ -154,7 +158,6 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) } else ad->monitor.mov_to_msr_extended = 0; - domain_pause(d); ad->monitor.mov_to_msr_enabled = !status; domain_unpause(d); break; @@ -196,9 +199,8 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) if ( rc ) return rc; - ad->monitor.guest_request_sync = mop->u.guest_request.sync; - domain_pause(d); + ad->monitor.guest_request_sync = mop->u.guest_request.sync; ad->monitor.guest_request_enabled = !status; domain_unpause(d); break; diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 28a7add..9d18c8d 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -624,15 +624,21 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, if ( p2m->pod.entry_count ) break; + domain_pause(d); rc = vm_event_enable(d, vec, ved, _VPF_mem_paging, HVM_PARAM_PAGING_RING_PFN, mem_paging_notification); + domain_unpause(d); } break; case XEN_VM_EVENT_DISABLE: if ( ved->ring_page ) + { + domain_pause(d); rc = vm_event_disable(d, ved); + domain_unpause(d); + } break; case XEN_VM_EVENT_RESUME: @@ -658,14 +664,20 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, switch( vec->op ) { case XEN_VM_EVENT_ENABLE: + domain_pause(d); rc = vm_event_enable(d, vec, ved, _VPF_mem_access, HVM_PARAM_MONITOR_RING_PFN, monitor_notification); + domain_unpause(d); break; case XEN_VM_EVENT_DISABLE: if ( ved->ring_page ) + { + domain_pause(d); rc = vm_event_disable(d, ved); + domain_unpause(d); + } break; case XEN_VM_EVENT_RESUME: @@ -701,14 +713,20 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, if ( !hap_enabled(d) ) break; + domain_pause(d); rc = vm_event_enable(d, vec, ved, _VPF_mem_sharing, HVM_PARAM_SHARING_RING_PFN, mem_sharing_notification); + domain_unpause(d); break; case XEN_VM_EVENT_DISABLE: if ( ved->ring_page ) + { + domain_pause(d); rc = vm_event_disable(d, ved); + domain_unpause(d); + } break; case XEN_VM_EVENT_RESUME: -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |