[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v4 21/28] tcg: enable tb_lock() for SoftMMU
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [RFC v4 21/28] tcg: enable tb_lock() for SoftMMU |
Date: |
Thu, 11 Aug 2016 16:24:17 +0100 |
tb_lock() has long been used for linux-user mode to protect code
generation. By enabling it now we prepare for MTTCG and ensure all code
generation is serialised by this lock. The other major structure that
needs protecting is the l1_map and its PageDesc structures. For the
SoftMMU case we also use tb_lock() to protect these structures instead
of linux-user mmap_lock() which as the name suggests serialises updates
to the structure as a result of guest mmap operations.
Signed-off-by: Alex Bennée <address@hidden>
---
v4
- split from main tcg: enable thread-per-vCPU patch
---
translate-all.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/translate-all.c b/translate-all.c
index c53ae8c..cfb009a 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -82,7 +82,11 @@
#endif
#ifdef CONFIG_SOFTMMU
-#define assert_memory_lock() do { /* nothing */ } while (0)
+#define assert_memory_lock() do { \
+ if (DEBUG_MEM_LOCKS) { \
+ g_assert(have_tb_lock); \
+ } \
+ } while (0)
#else
#define assert_memory_lock() do { \
if (DEBUG_MEM_LOCKS) { \
@@ -146,36 +150,28 @@ static void *l1_map[V_L1_SIZE];
TCGContext tcg_ctx;
/* translation block context */
-#ifdef CONFIG_USER_ONLY
__thread int have_tb_lock;
-#endif
void tb_lock(void)
{
-#ifdef CONFIG_USER_ONLY
assert(!have_tb_lock);
qemu_mutex_lock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock++;
-#endif
}
void tb_unlock(void)
{
-#ifdef CONFIG_USER_ONLY
assert(have_tb_lock);
have_tb_lock--;
qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
-#endif
}
void tb_lock_reset(void)
{
-#ifdef CONFIG_USER_ONLY
if (have_tb_lock) {
qemu_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);
have_tb_lock = 0;
}
-#endif
}
#ifdef DEBUG_LOCKING
@@ -184,15 +180,11 @@ void tb_lock_reset(void)
#define DEBUG_TB_LOCKS 0
#endif
-#ifdef CONFIG_SOFTMMU
-#define assert_tb_lock() do { /* nothing */ } while (0)
-#else
#define assert_tb_lock() do { \
if (DEBUG_TB_LOCKS) { \
g_assert(have_tb_lock); \
} \
} while (0)
-#endif
static TranslationBlock *tb_find_pc(uintptr_t tc_ptr);
--
2.7.4
- [Qemu-devel] [RFC v4 15/28] tcg: rename tcg_current_cpu to tcg_current_rr_cpu, (continued)
- [Qemu-devel] [RFC v4 15/28] tcg: rename tcg_current_cpu to tcg_current_rr_cpu, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 09/28] tcg: protect TBContext with tb_lock., Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 11/28] tcg: move tcg_exec_all and helpers above thread fn, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 14/28] tcg: add kick timer for single-threaded vCPU emulation, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 12/28] tcg: cpus rm tcg_exec_all(), Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 13/28] tcg: add options for enabling MTTCG, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 17/28] cpus: re-factor out handle_icount_deadline, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 18/28] tcg: remove global exit_request, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 19/28] tcg: move locking for tb_invalidate_phys_page_range up, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 16/28] tcg: drop global lock during TCG code execution, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 21/28] tcg: enable tb_lock() for SoftMMU,
Alex Bennée <=
- [Qemu-devel] [RFC v4 22/28] tcg: enable thread-per-vCPU, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 25/28] cputlb: introduce tlb_flush_* async work., Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 23/28] atomic: introduce cmpxchg_bool, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 24/28] cputlb: add assert_cpu_is_self checks, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 26/28] cputlb: tweak qemu_ram_addr_from_host_nofail reporting, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 20/28] cpus: tweak sleeping and safe_work rules for MTTCG, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 28/28] cputlb: make tlb_flush_by_mmuidx safe for MTTCG, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 27/28] cputlb: make tlb_reset_dirty safe for MTTCG, Alex Bennée, 2016/08/11
- Re: [Qemu-devel] [RFC v4 00/28] Base enabling patches for MTTCG, Alex Bennée, 2016/08/11