2018-08-03 18:05:13 +02:00
|
|
|
From d082166f9ab67080ceddde9293fac81adf5519f2 Mon Sep 17 00:00:00 2001
|
2012-02-01 00:10:40 +01:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Fri, 13 Jan 2012 17:05:41 +0100
|
|
|
|
Subject: [PATCH] linux-user: fix segfault deadlock
|
2013-05-14 22:46:08 +02:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
2012-02-01 00:10:40 +01:00
|
|
|
|
|
|
|
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>
|
2016-01-19 19:31:32 +01:00
|
|
|
[AF: Drop spinlock_safe_unlock() and switch to tb_lock_reset() (bonzini)]
|
2013-05-14 22:46:08 +02:00
|
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
2012-02-01 00:10:40 +01:00
|
|
|
---
|
2017-12-14 01:53:24 +01:00
|
|
|
accel/tcg/user-exec.c | 4 ++++
|
2016-01-19 19:31:32 +01:00
|
|
|
1 file changed, 4 insertions(+)
|
2012-02-01 00:10:40 +01:00
|
|
|
|
2017-12-14 01:53:24 +01:00
|
|
|
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
|
2018-05-01 17:20:58 +02:00
|
|
|
index 26a3ffbba1..43bbf92f36 100644
|
2017-12-14 01:53:24 +01:00
|
|
|
--- a/accel/tcg/user-exec.c
|
|
|
|
+++ b/accel/tcg/user-exec.c
|
2018-05-01 17:20:58 +02:00
|
|
|
@@ -103,6 +103,10 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info,
|
2016-01-19 19:31:32 +01:00
|
|
|
printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
|
|
|
|
pc, address, is_write, *(unsigned long *)old_set);
|
2012-02-01 00:10:40 +01:00
|
|
|
#endif
|
|
|
|
+
|
|
|
|
+ /* Maybe we're still holding the TB fiddling lock? */
|
2016-01-19 19:31:32 +01:00
|
|
|
+ tb_lock_reset();
|
2012-02-01 00:10:40 +01:00
|
|
|
+
|
|
|
|
/* XXX: locking issue */
|
2018-05-01 17:20:58 +02:00
|
|
|
/* Note that it is important that we don't call page_unprotect() unless
|
|
|
|
* this is really a "write to nonwriteable page" fault, because
|