From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ7-000706-Qi for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTfZ6-0000mO-2c for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:45 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:60791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ5-0000m9-UA for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:43 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BA14A2068E for ; Sun, 23 Aug 2015 20:24:43 -0400 (EDT) From: "Emilio G. Cota" Date: Sun, 23 Aug 2015 20:23:59 -0400 Message-Id: <1440375847-17603-31-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 30/38] translate-all: add tb_lock assertions 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 Signed-off-by: Emilio G. Cota --- translate-all.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/translate-all.c b/translate-all.c index df65c83..e7b4a31 100644 --- a/translate-all.c +++ b/translate-all.c @@ -252,6 +252,8 @@ static int cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb, int64_t ti; #endif + assert(have_tb_lock); + #ifdef CONFIG_PROFILER ti = profile_getclock(); #endif @@ -442,6 +444,10 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) void **lp; int i; +#ifdef CONFIG_SOFTMMU + assert(have_tb_lock); +#endif + /* Level 1. Always allocated. */ lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1)); @@ -767,6 +773,8 @@ static TranslationBlock *tb_alloc(target_ulong pc) { TranslationBlock *tb; + assert(have_tb_lock); + if (tcg_ctx.tb_ctx.nb_tbs >= tcg_ctx.code_gen_max_blocks || (tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer) >= tcg_ctx.code_gen_buffer_max_size) { @@ -781,6 +789,8 @@ static TranslationBlock *tb_alloc(target_ulong pc) /* Called with tb_lock held. */ void tb_free(TranslationBlock *tb) { + assert(have_tb_lock); + /* In practice this is mostly used for single use temporary TB Ignore the hard cases and just back up if this TB happens to be the last one generated. */ @@ -933,6 +943,8 @@ static void tb_page_check(void) TranslationBlock *tb; int i, flags1, flags2; + assert(have_tb_lock); + for (i = 0; i < CODE_GEN_PHYS_HASH_SIZE; i++) { TBPhysHashSlot *slot = &tcg_ctx.tb_ctx.tb_phys_hash[i]; @@ -1034,6 +1046,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) unsigned int n1; TranslationBlock *tb1, *tb2; + assert(have_tb_lock); + /* Now remove the TB from the hash list, so that tb_find_slow * cannot find it anymore. */ @@ -1120,6 +1134,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong virt_page2; int code_gen_size; + assert(have_tb_lock); + phys_pc = get_page_addr_code(env, pc); if (use_icount) { cflags |= CF_USE_ICOUNT; @@ -1428,6 +1444,10 @@ static inline void tb_alloc_page(TranslationBlock *tb, bool page_already_protected; #endif +#ifdef CONFIG_SOFTMMU + assert(have_tb_lock); +#endif + tb->page_addr[n] = page_addr; p = page_find_alloc(page_addr >> TARGET_PAGE_BITS, 1); tb->page_next[n] = p->first_tb; @@ -1486,6 +1506,10 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, unsigned int h; TBPhysHashSlot *slot; +#ifdef CONFIG_SOFTMMU + assert(have_tb_lock); +#endif + /* add in the physical hash table */ h = tb_phys_hash_func(phys_pc); slot = &tcg_ctx.tb_ctx.tb_phys_hash[h]; @@ -1527,6 +1551,8 @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr) uintptr_t v; TranslationBlock *tb; + assert(have_tb_lock); + if (tcg_ctx.tb_ctx.nb_tbs <= 0) { return NULL; } @@ -1579,6 +1605,8 @@ void tb_check_watchpoint(CPUState *cpu) { TranslationBlock *tb; + assert(have_tb_lock); + tb = tb_find_pc(cpu->mem_io_pc); if (tb) { /* We can use retranslation to find the PC. */ -- 1.9.1