[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/23] translate-all: define and use DEBUG_TB_CHECK_G
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PULL 14/23] translate-all: define and use DEBUG_TB_CHECK_GATE |
Date: |
Mon, 9 Oct 2017 17:55:51 -0700 |
From: "Emilio G. Cota" <address@hidden>
This prevents bit rot by ensuring the debug code is compiled when
building a user-mode target.
Unfortunately the helpers are user-mode-only so we cannot fully
get rid of the ifdef checks. Add a comment to explain this.
Suggested-by: Alex Bennée <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
accel/tcg/translate-all.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 6b853b329c..26efad302d 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -82,6 +82,12 @@
#undef DEBUG_TB_CHECK
#endif
+#ifdef DEBUG_TB_CHECK
+#define DEBUG_TB_CHECK_GATE 1
+#else
+#define DEBUG_TB_CHECK_GATE 0
+#endif
+
/* Access to the various translations structures need to be serialised via
locks
* for consistency. This is automatic for SoftMMU based system
* emulation due to its single threaded nature. In user-mode emulation
@@ -950,7 +956,13 @@ void tb_flush(CPUState *cpu)
}
}
-#ifdef DEBUG_TB_CHECK
+/*
+ * Formerly ifdef DEBUG_TB_CHECK. These debug functions are user-mode-only,
+ * so in order to prevent bit rot we compile them unconditionally in user-mode,
+ * and let the optimizer get rid of them by wrapping their user-only callers
+ * with if (DEBUG_TB_CHECK_GATE).
+ */
+#ifdef CONFIG_USER_ONLY
static void
do_tb_invalidate_check(struct qht *ht, void *p, uint32_t hash, void *userp)
@@ -994,7 +1006,7 @@ static void tb_page_check(void)
qht_iter(&tcg_ctx.tb_ctx.htable, do_tb_page_check, NULL);
}
-#endif
+#endif /* CONFIG_USER_ONLY */
static inline void tb_page_remove(TranslationBlock **ptb, TranslationBlock *tb)
{
@@ -1236,8 +1248,10 @@ static void tb_link_page(TranslationBlock *tb,
tb_page_addr_t phys_pc,
h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->trace_vcpu_dstate);
qht_insert(&tcg_ctx.tb_ctx.htable, tb, h);
-#ifdef DEBUG_TB_CHECK
- tb_page_check();
+#ifdef CONFIG_USER_ONLY
+ if (DEBUG_TB_CHECK_GATE) {
+ tb_page_check();
+ }
#endif
}
@@ -2223,8 +2237,10 @@ int page_unprotect(target_ulong address, uintptr_t pc)
/* and since the content will be modified, we must invalidate
the corresponding translated code. */
current_tb_invalidated |= tb_invalidate_phys_page(addr, pc);
-#ifdef DEBUG_TB_CHECK
- tb_invalidate_check(addr);
+#ifdef CONFIG_USER_ONLY
+ if (DEBUG_TB_CHECK_GATE) {
+ tb_invalidate_check(addr);
+ }
#endif
}
mprotect((void *)g2h(host_start), qemu_host_page_size,
--
2.13.6
- [Qemu-devel] [PULL 06/23] tcg/i386: constify tcg_target_callee_save_regs, (continued)
- [Qemu-devel] [PULL 06/23] tcg/i386: constify tcg_target_callee_save_regs, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 08/23] tcg: remove addr argument from lookup_tb_ptr, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 07/23] tcg/mips: constify tcg_target_callee_save_regs, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 09/23] tcg: consolidate TB lookups in tb_lookup__cpu_state, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 10/23] exec-all: bring tb->invalid into tb->cflags, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 12/23] exec-all: introduce TB_PAGE_ADDR_FMT, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 11/23] translate-all: define and use DEBUG_TB_FLUSH_GATE, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 13/23] translate-all: define and use DEBUG_TB_INVALIDATE_GATE, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 15/23] exec-all: extract tb->tc_* into a separate struct tc_tb, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 17/23] tcg: take .helpers out of TCGContext, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 14/23] translate-all: define and use DEBUG_TB_CHECK_GATE,
Richard Henderson <=
- [Qemu-devel] [PULL 19/23] util: move qemu_real_host_page_size/mask to osdep.h, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 16/23] tci: move tci_regs to tcg_qemu_tb_exec's stack, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 20/23] osdep: introduce qemu_mprotect_rwx/none, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 21/23] translate-all: use qemu_protect_rwx/none helpers, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 18/23] tcg: allocate optimizer temps with tcg_malloc, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 22/23] tcg: define TCG_HIGHWATER, Richard Henderson, 2017/10/09
- [Qemu-devel] [PULL 23/23] tcg/mips: delete commented out extern keyword., Richard Henderson, 2017/10/09
- Re: [Qemu-devel] [PULL 00/23] Queued TCG patches, no-reply, 2017/10/09
- Re: [Qemu-devel] [PULL 00/23] Queued TCG patches, no-reply, 2017/10/09
- Re: [Qemu-devel] [PULL 00/23] Queued TCG patches, Peter Maydell, 2017/10/10