common/vm_event: synchronize vCPU state in vm_event_resume()
PATCH v3 1/1 common/vm_event: synchronize vCPU state in vm_event_resume()
Vm_event_vcpu_pause() needs to use vcpu_pause_nosync() in order for the current vCPU to not get stuck. A consequence of this is that the custom vm_event response handlers will not always see the real vCPU state in v->arch.user_regs. This patch makes sure that the state is always synchronized in vm_event_resume, before any handlers have been called. This problem especially affects vm_event_set_registers().
Simply checking vm_event_pause_count to make sure the vCPU is paused suffices since there's only one ring / consumer at a time, and events are being processed one-by-one, so the toolstack won't unpause the vCPU behind our backs.
---
Changes since V2:
- Updated the commit text.
--- xen/common/vm_event.c | 7 +++++++ 1 file changed, 7 insertions(+)
xen/common/vm_event.c +7 -0
@@ -388,6 +388,13 @@ void vm_event_resume(struct domain *d, struct vm_event_domain *ved) v = d->vcpu[rsp.vcpu_id];/* +* Make sure the vCPU state has been synchronized for the custom +* handlers. +*/ +if (atomic_read (&v->vm_event_pause_count) ) +sync_vcpu_execstate (v); + +/* * In some cases the response type needs extra handling, so here * we call the appropriate handlers. */
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 9 lines · Razvan Cojocaru
Vm_event_vcpu_pause()needs to usevcpu_pause_nosync()in order for the current vCPU to not get stuck. A consequence of this is that the customvm_eventresponse handlers will not always see the real vCPU state inv->arch.user_regs. This patch makes sure that the state is always synchronized invm_event_resume, before any handlers have been called. This problem especially affectsvm_event_set_registers().
Quoted 6 lines
Simply checking
vm_event_pause_countto make sure the vCPU is paused suffices since there's only one ring / consumer at a time, and events are being processed one-by-one, so the toolstack won't unpause the vCPU behind our backs.Signed-off-by Razvan Cojocaru <[email protected]>
xen/common/vm_event.c void vm_event_resume(struct domain *d, struct
Quoted 13 lines
---
Changes since V2:
- Updated the commit text.--- xen/common/vm_event.c | 7 +++++++ 1 file changed, 7 insertions(+)xen/common/vm_event.c +0
-0@@ -388,6 +388,13 @@ void vm_event_resume(struct domain *d, struct
vm_event_domain *ved)
Quoted 14 lines
xen/common/vm_event.c +7
-1v = d->vcpu[rsp.vcpu_id];/* +* Make sure the vCPU state has been synchronized for the custom +* handlers. +*/ +if (atomic_read (&v->vm_event_pause_count) ) +sync_vcpu_execstate (v); + +/* * In some cases the response type needs extra handling, so here * we call the appropriate handlers. */ --
Quoted 2 lines
1.9.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel