linux-user: fix segfault deadlock

When entering the guest we take a lock to ensure that nobody else messes
with our TB chaining while we're doing it. If we get a segfault inside that
code, we manage to work on, but will not unlock the lock.

This patch forces unlocking of that lock in the segv handler. I'm not sure
this is the right approach though. Maybe we should rather make sure we don't
segfault in the code? I would greatly appreciate someone more intelligible
than me to look at this :).

Example code to trigger this is at: http://csgraf.de/tmp/conftest.c

Reported-by: Fabio Erculiani <lxnay@sabayon.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Alexander Graf
2012-01-13 17:05:41 +01:00
committed by Andreas Färber
parent 1b71cc7ca0
commit 6129f046f7
2 changed files with 14 additions and 0 deletions

View File

@@ -88,6 +88,10 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
pc, address, is_write, *(unsigned long *)old_set);
#endif
/* Maybe we're still holding the TB fiddling lock? */
spin_unlock_safe(&tb_lock);
/* XXX: locking issue */
if (is_write && h2g_valid(address)
&& page_unprotect(h2g(address), pc, puc)) {