]> git.proxmox.com Git - mirror_qemu.git/commit
linux-user: Fix locking order in fork_start()
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 4 Dec 2017 14:22:11 +0000 (14:22 +0000)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 29 Jan 2018 14:27:35 +0000 (08:27 -0600)
commit9327a8e2d639370960c1dc3e11ff5d9c2b26174c
tree2713ca1b1e193fa57267294fc74fa141d9264cfd
parent8ebfafa796ca0cb2b035a7f06f836a675d8b48be
linux-user: Fix locking order in fork_start()

Our locking order is that the tb lock should be taken
inside the mmap_lock, but fork_start() grabs locks the
other way around. This means that if a heavily multithreaded
guest process (such as Java) calls fork() it can deadlock,
with the thread that called fork() stuck in fork_start()
with the tb lock and waiting for the mmap lock, but some
other thread in tb_find() with the mmap lock and waiting
for the tb lock. The cpu_list_lock() should also always be
taken last, not first.

Fix this by making fork_start() grab the locks in the
right order. The order in which we drop locks doesn't
matter, so we leave fork_end() the way it is.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable@nongnu.org
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <1512397331-15238-1-git-send-email-peter.maydell@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
(cherry picked from commit 024949caf32805f4cc3e7d363a80084b47aac1f6)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
linux-user/main.c