]> Git Repo - qemu.git/commit
cpus: fix deadlock and segfault in qemu_mutex_lock_iothread
authorPaolo Bonzini <[email protected]>
Fri, 27 Feb 2015 18:58:23 +0000 (19:58 +0100)
committerPaolo Bonzini <[email protected]>
Mon, 2 Mar 2015 09:57:07 +0000 (10:57 +0100)
commit6b49809c597331803ea941eadda813e5bb4e8fe2
tree20c4918782dc9ffeb186a1da2f40e8e47e92738e
parentf6758f7d6b8b483eb1d061937ed06da830c1ecb8
cpus: fix deadlock and segfault in qemu_mutex_lock_iothread

When two threads (other than the low-priority TCG VCPU thread)
are competing for the iothread lock, a deadlock can happen.  This
is because iothread_requesting_mutex is set to false by the first
thread that gets the mutex, and then the VCPU thread might never
yield from the execution loop.  If iothread_requesting_mutex is
changed from a bool to a counter, the deadlock is fixed.

However, there is another bug in qemu_mutex_lock_iothread that
can be triggered by the new call_rcu thread.  The bug happens
if qemu_mutex_lock_iothread is called before the CPUs are
created.  In that case, first_cpu is NULL and the caller
segfaults in qemu_mutex_lock_iothread.  To fix this, just
do not do the kick if first_cpu is NULL.

Reported-by: Leon Alrae <[email protected]>
Reported-by: Andreas Gustafsson <[email protected]>
Tested-by: Leon Alrae <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
cpus.c
This page took 0.025128 seconds and 4 git commands to generate.