]> xenbits.xensource.com Git - xen.git/commit
x86/vm_event: fix race between __context_switch() and vm_event_resume()
authorRazvan Cojocaru <rcojocaru@bitdefender.com>
Mon, 8 May 2017 12:54:00 +0000 (14:54 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 8 May 2017 12:54:00 +0000 (14:54 +0200)
commit461f0482033b09ade2f3e38c8c33f1c15bc8defc
tree21f91cdf2c8df50f292a54d079114349053dd3a1
parent1366a0e76db67953368dc4ca85bcbb28d0f3003f
x86/vm_event: fix race between __context_switch() and vm_event_resume()

The introspection agent can reply to a vm_event faster than
vmx_vmexit_handler() can complete in some cases, where it is then
not safe for vm_event_set_registers() to modify v->arch.user_regs.
In the test scenario, we were stepping over an INT3 breakpoint by
setting RIP += 1. The quick reply tended to complete before the VCPU
triggering the introspection event had properly paused and been
descheduled. If the reply occurs before __context_switch() happens,
__context_switch() clobbers the reply by overwriting
v->arch.user_regs from the stack. If we don't pass through
__context_switch() (due to switching to the idle vCPU), reply data
wouldn't be picked up when switching back straight to the original
vCPU.

This patch ensures that vm_event_resume() code only sets per-VCPU
data to be used for the actual setting of registers later in
hvm_do_resume() (similar to the model used to control setting of CRs
and MSRs).

The patch additionally removes the sync_vcpu_execstate(v) call from
vm_event_resume(), which is no longer necessary, which removes the
associated broadcast TLB flush (read: performance improvement).

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/x86/hvm/vm_event.c
xen/arch/x86/vm_event.c
xen/common/vm_event.c
xen/include/asm-x86/vm_event.h