Received: from eggs.gnu.org ([2001:4830:134:3::10]:33018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ7-0006yd-6T for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTfZ4-0000ka-FY for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:45 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ4-0000kK-9s for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:42 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2249220869 for ; Sun, 23 Aug 2015 20:24:42 -0400 (EDT) From: "Emilio G. Cota" Date: Sun, 23 Aug 2015 20:23:53 -0400 Message-Id: <1440375847-17603-25-git-send-email-cota@braap.org> In-Reply-To: <1440375847-17603-1-git-send-email-cota@braap.org> References: <1440375847-17603-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [RFC 24/38] cpu-exec: reset mmap_lock after exiting the CPU loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Cc: mark.burton@greensocs.com, a.rigo@virtualopensystems.com, guillaume.delbergue@greensocs.com, pbonzini@redhat.com, alex.bennee@linaro.org, Frederic Konrad Otherwise after an exception we end up in a deadlock. Signed-off-by: Emilio G. Cota --- 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