[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 24/38] cpu-exec: reset mmap_lock after exiting the CPU
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [RFC 24/38] cpu-exec: reset mmap_lock after exiting the CPU loop |
Date: |
Sun, 23 Aug 2015 20:23:53 -0400 |
Otherwise after an exception we end up in a deadlock.
Signed-off-by: Emilio G. Cota <address@hidden>
---
bsd-user/mmap.c | 12 ++++++++++++
cpu-exec.c | 1 +
include/exec/exec-all.h | 2 ++
linux-user/mmap.c | 8 ++++++++
4 files changed, 23 insertions(+)
diff --git a/bsd-user/mmap.c b/bsd-user/mmap.c
index 092bf7f..b37a8f5 100644
--- a/bsd-user/mmap.c
+++ b/bsd-user/mmap.c
@@ -48,6 +48,14 @@ void mmap_unlock(void)
}
}
+void mmap_lock_reset(void)
+{
+ while (mmap_lock_count) {
+ mmap_lock_count--;
+ pthread_mutex_unlock(&mmap_mutex);
+ }
+}
+
/* Grab lock to make sure things are in a consistent state after fork(). */
void mmap_fork_start(void)
{
@@ -72,6 +80,10 @@ void mmap_lock(void)
void mmap_unlock(void)
{
}
+
+void mmap_lock_reset(void)
+{
+}
#endif
/* NOTE: all the constants are the HOST ones, but addresses are target. */
diff --git a/cpu-exec.c b/cpu-exec.c
index a1700ac..f758928 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -630,6 +630,7 @@ int cpu_exec(CPUState *cpu)
env = &x86_cpu->env;
#endif
tb_lock_reset();
+ mmap_lock_reset();
cpu_exit_loop_lock_reset(cpu);
}
} /* for(;;) */
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index b1934bf..3b8399a 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -334,6 +334,7 @@ void tlb_fill(CPUState *cpu, target_ulong addr, int
is_write, int mmu_idx,
#if defined(CONFIG_USER_ONLY)
void mmap_lock(void);
void mmap_unlock(void);
+void mmap_lock_reset(void);
static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1,
target_ulong addr)
{
@@ -342,6 +343,7 @@ static inline tb_page_addr_t
get_page_addr_code(CPUArchState *env1, target_ulong
#else
static inline void mmap_lock(void) {}
static inline void mmap_unlock(void) {}
+static inline void mmap_lock_reset(void) {}
/* cputlb.c */
tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr);
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 78e1b2d..8ee80f5 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -51,6 +51,14 @@ void mmap_unlock(void)
}
}
+void mmap_lock_reset(void)
+{
+ if (mmap_lock_count) {
+ mmap_lock_count = 0;
+ pthread_mutex_unlock(&mmap_mutex);
+ }
+}
+
/* Grab lock to make sure things are in a consistent state after fork(). */
void mmap_fork_start(void)
{
--
1.9.1
- [Qemu-devel] [RFC 15/38] radix-tree: add generic lockless radix tree module, (continued)
- [Qemu-devel] [RFC 29/38] tcg: export have_tb_lock, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 25/38] cpu: add barriers around cpu->tcg_exit_req, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 23/38] cpu-exec: grab iothread lock during interrupt handling, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 24/38] cpu-exec: reset mmap_lock after exiting the CPU loop,
Emilio G. Cota <=
- [Qemu-devel] [RFC 09/38] rcu: fix comment with s/rcu_gp_lock/rcu_registry_lock/, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 30/38] translate-all: add tb_lock assertions, Emilio G. Cota, 2015/08/23
- [Qemu-devel] [RFC 26/38] cpu: protect tb_jmp_cache with seqlock, Emilio G. Cota, 2015/08/23
[Qemu-devel] [RFC 36/38] cputlb: use tcg_sched_work for tlb_flush_page_all, Emilio G. Cota, 2015/08/23
[Qemu-devel] [RFC 35/38] cputlb: use cpu_tcg_sched_work for tlb_flush_all, Emilio G. Cota, 2015/08/23