[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 07/19] tcg: enable tb_lock() for SoftMMU
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v6 07/19] tcg: enable tb_lock() for SoftMMU |
Date: |
Wed, 9 Nov 2016 14:57:36 +0000 |
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>
Reviewed-by: Richard Henderson <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 2c8baf5..cf828aa 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,9 +150,7 @@ TCGContext tcg_ctx;
bool parallel_cpus;
/* translation block context */
-#ifdef CONFIG_USER_ONLY
__thread int have_tb_lock;
-#endif
static void page_table_config_init(void)
{
@@ -172,30 +174,24 @@ static void page_table_config_init(void)
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
@@ -204,15 +200,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.10.1
- Re: [Qemu-devel] [PATCH v6 05/19] tcg: drop global lock during TCG code execution, (continued)
- [Qemu-devel] [PATCH v6 09/19] tcg: handle EXCP_ATOMIC exception for system emulation, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 02/19] tcg: add options for enabling MTTCG, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 08/19] tcg: enable thread-per-vCPU, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 06/19] tcg: remove global exit_request, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 12/19] cputlb: tweak qemu_ram_addr_from_host_nofail reporting, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 07/19] tcg: enable tb_lock() for SoftMMU,
Alex Bennée <=
- [Qemu-devel] [PATCH v6 10/19] cputlb: add assert_cpu_is_self checks, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 11/19] cputlb: introduce tlb_flush_* async work., Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 15/19] target-arm/cpu: don't reset TLB structures, use cputlb to do it, Alex Bennée, 2016/11/09
- [Qemu-devel] [PATCH v6 16/19] target-arm: ensure BQL taken for ARM_CP_IO register access, Alex Bennée, 2016/11/09