2015-04-08 16:42:13 +02:00
|
|
|
From c9c7549d1dc3bab837165332f630b8f7fea4ad96 Mon Sep 17 00:00:00 2001
|
2012-07-11 16:55:34 +02:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Wed, 11 Jul 2012 16:47:42 +0200
|
|
|
|
Subject: [PATCH] linux-user: lock tb flushing too
|
2013-02-10 19:32:29 +01:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
2012-07-11 16:55:34 +02:00
|
|
|
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
2013-02-10 19:32:29 +01:00
|
|
|
[AF: Rebased onto exec.c/translate-all.c split for 1.4]
|
|
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
2012-07-11 16:55:34 +02:00
|
|
|
---
|
2014-01-17 23:04:30 +01:00
|
|
|
translate-all.c | 20 ++++++++++++++++++--
|
|
|
|
1 file changed, 18 insertions(+), 2 deletions(-)
|
2012-07-11 16:55:34 +02:00
|
|
|
|
2013-02-10 19:32:29 +01:00
|
|
|
diff --git a/translate-all.c b/translate-all.c
|
2015-03-21 12:46:36 +01:00
|
|
|
index 9f47ce7..c5984fb 100644
|
2013-02-10 19:32:29 +01:00
|
|
|
--- a/translate-all.c
|
|
|
|
+++ b/translate-all.c
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -715,19 +715,23 @@ static TranslationBlock *tb_alloc(target_ulong pc)
|
2012-07-11 16:55:34 +02:00
|
|
|
{
|
|
|
|
TranslationBlock *tb;
|
|
|
|
|
|
|
|
+ tcg_lock();
|
2013-05-14 22:46:08 +02:00
|
|
|
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) {
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
return NULL;
|
2013-02-10 19:32:29 +01:00
|
|
|
}
|
2013-05-14 22:46:08 +02:00
|
|
|
tb = &tcg_ctx.tb_ctx.tbs[tcg_ctx.tb_ctx.nb_tbs++];
|
2012-07-11 16:55:34 +02:00
|
|
|
tb->pc = pc;
|
|
|
|
tb->cflags = 0;
|
|
|
|
+ tcg_unlock();
|
|
|
|
return tb;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tb_free(TranslationBlock *tb)
|
|
|
|
{
|
|
|
|
+ tcg_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. */
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -736,6 +740,7 @@ void tb_free(TranslationBlock *tb)
|
2013-05-14 22:46:08 +02:00
|
|
|
tcg_ctx.code_gen_ptr = tb->tc_ptr;
|
|
|
|
tcg_ctx.tb_ctx.nb_tbs--;
|
2012-07-11 16:55:34 +02:00
|
|
|
}
|
|
|
|
+ tcg_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void invalidate_page_bitmap(PageDesc *p)
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -793,6 +798,7 @@ void tb_flush(CPUArchState *env1)
|
2013-05-14 22:46:08 +02:00
|
|
|
((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)) /
|
|
|
|
tcg_ctx.tb_ctx.nb_tbs : 0);
|
2012-07-11 16:55:34 +02:00
|
|
|
#endif
|
|
|
|
+ tcg_lock();
|
2013-05-14 22:46:08 +02:00
|
|
|
if ((unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer)
|
|
|
|
> tcg_ctx.code_gen_buffer_size) {
|
2014-03-20 01:26:56 +01:00
|
|
|
cpu_abort(cpu, "Internal error: code buffer overflow\n");
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -810,6 +816,7 @@ void tb_flush(CPUArchState *env1)
|
2012-07-11 16:55:34 +02:00
|
|
|
/* XXX: flush processor icache at this point if cache flush is
|
|
|
|
expensive */
|
2013-05-14 22:46:08 +02:00
|
|
|
tcg_ctx.tb_ctx.tb_flush_count++;
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_TB_CHECK
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1119,8 +1126,10 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,
|
2012-07-11 16:55:34 +02:00
|
|
|
int current_flags = 0;
|
|
|
|
#endif /* TARGET_HAS_PRECISE_SMC */
|
|
|
|
|
|
|
|
+ tcg_lock();
|
|
|
|
p = page_find(start >> TARGET_PAGE_BITS);
|
2013-02-10 19:32:29 +01:00
|
|
|
if (!p) {
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
return;
|
2013-02-10 19:32:29 +01:00
|
|
|
}
|
2012-07-11 16:55:34 +02:00
|
|
|
if (!p->code_bitmap &&
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1213,6 +1222,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,
|
2014-03-20 01:26:56 +01:00
|
|
|
cpu_resume_from_signal(cpu, NULL);
|
2012-07-11 16:55:34 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
+ tcg_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* len must be <= 8 and start must be a multiple of len */
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1424,13 +1434,16 @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
|
2012-07-11 16:55:34 +02:00
|
|
|
{
|
|
|
|
int m_min, m_max, m;
|
|
|
|
uintptr_t v;
|
|
|
|
- TranslationBlock *tb;
|
|
|
|
+ TranslationBlock *tb, *r;
|
|
|
|
|
|
|
|
+ tcg_lock();
|
2013-05-14 22:46:08 +02:00
|
|
|
if (tcg_ctx.tb_ctx.nb_tbs <= 0) {
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
return NULL;
|
2013-02-10 19:32:29 +01:00
|
|
|
}
|
2013-05-14 22:46:08 +02:00
|
|
|
if (tc_ptr < (uintptr_t)tcg_ctx.code_gen_buffer ||
|
|
|
|
tc_ptr >= (uintptr_t)tcg_ctx.code_gen_ptr) {
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* binary search (cf Knuth) */
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1441,6 +1454,7 @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
|
2013-05-14 22:46:08 +02:00
|
|
|
tb = &tcg_ctx.tb_ctx.tbs[m];
|
2012-07-11 16:55:34 +02:00
|
|
|
v = (uintptr_t)tb->tc_ptr;
|
2013-02-10 19:32:29 +01:00
|
|
|
if (v == tc_ptr) {
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
return tb;
|
2013-02-10 19:32:29 +01:00
|
|
|
} else if (tc_ptr < v) {
|
2012-07-11 16:55:34 +02:00
|
|
|
m_max = m - 1;
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1448,7 +1462,9 @@ static TranslationBlock *tb_find_pc(uintptr_t tc_ptr)
|
2012-07-11 16:55:34 +02:00
|
|
|
m_min = m + 1;
|
|
|
|
}
|
|
|
|
}
|
2013-05-14 22:46:08 +02:00
|
|
|
- return &tcg_ctx.tb_ctx.tbs[m_max];
|
|
|
|
+ r = &tcg_ctx.tb_ctx.tbs[m_max];
|
2012-07-11 16:55:34 +02:00
|
|
|
+ tcg_unlock();
|
|
|
|
+ return r;
|
|
|
|
}
|
|
|
|
|
2015-03-21 12:46:36 +01:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|