[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v4 08/28] translate-all: Add assert_(memory|tb)_lock a
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [RFC v4 08/28] translate-all: Add assert_(memory|tb)_lock annotations |
Date: |
Thu, 11 Aug 2016 16:24:04 +0100 |
This adds calls to the assert_(memory|tb)_lock for all public APIs which
are documented as needing them held for linux-user mode. The asserts are
NOPs for system-mode although these will be converted when MTTCG is
enabled.
Signed-off-by: Alex Bennée <address@hidden>
---
v4
- mention tb_locks as well
- tweak commit message
---
translate-all.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/translate-all.c b/translate-all.c
index a3448e1..213685c 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -449,6 +449,10 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int
alloc)
void **lp;
int i;
+ if (alloc) {
+ assert_memory_lock();
+ }
+
/* Level 1. Always allocated. */
lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1));
@@ -815,6 +819,8 @@ static TranslationBlock *tb_alloc(target_ulong pc)
{
TranslationBlock *tb;
+ assert_tb_lock();
+
if (tcg_ctx.tb_ctx.nb_tbs >= tcg_ctx.code_gen_max_blocks) {
return NULL;
}
@@ -828,6 +834,8 @@ static TranslationBlock *tb_alloc(target_ulong pc)
/* Called with tb_lock held. */
void tb_free(TranslationBlock *tb)
{
+ assert_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. */
@@ -1054,6 +1062,8 @@ void tb_phys_invalidate(TranslationBlock *tb,
tb_page_addr_t page_addr)
uint32_t h;
tb_page_addr_t phys_pc;
+ assert_tb_lock();
+
atomic_set(&tb->invalid, true);
/* remove the TB from the hash list */
@@ -1111,7 +1121,7 @@ static void build_page_bitmap(PageDesc *p)
tb_end = tb_start + tb->size;
if (tb_end > TARGET_PAGE_SIZE) {
tb_end = TARGET_PAGE_SIZE;
- }
+ }
} else {
tb_start = 0;
tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK);
@@ -1134,6 +1144,8 @@ static inline void tb_alloc_page(TranslationBlock *tb,
bool page_already_protected;
#endif
+ assert_memory_lock();
+
tb->page_addr[n] = page_addr;
p = page_find_alloc(page_addr >> TARGET_PAGE_BITS, 1);
tb->page_next[n] = p->first_tb;
@@ -1190,6 +1202,8 @@ static void tb_link_page(TranslationBlock *tb,
tb_page_addr_t phys_pc,
{
uint32_t h;
+ assert_memory_lock();
+
/* add in the page list */
tb_alloc_page(tb, 0, phys_pc & TARGET_PAGE_MASK);
if (phys_page2 != -1) {
@@ -1221,6 +1235,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
+ assert_memory_lock();
phys_pc = get_page_addr_code(env, pc);
if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) {
@@ -1349,6 +1364,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
*/
void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end)
{
+ assert_memory_lock();
+
while (start < end) {
tb_invalidate_phys_page_range(start, end, 0);
start &= TARGET_PAGE_MASK;
@@ -1385,6 +1402,8 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start,
tb_page_addr_t end,
uint32_t current_flags = 0;
#endif /* TARGET_HAS_PRECISE_SMC */
+ assert_memory_lock();
+
p = page_find(start >> TARGET_PAGE_BITS);
if (!p) {
return;
@@ -1983,6 +2002,7 @@ void page_set_flags(target_ulong start, target_ulong end,
int flags)
assert(end < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
#endif
assert(start < end);
+ assert_memory_lock();
start = start & TARGET_PAGE_MASK;
end = TARGET_PAGE_ALIGN(end);
--
2.7.4
- [Qemu-devel] [RFC v4 00/28] Base enabling patches for MTTCG, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 02/28] translate_all: DEBUG_FLUSH -> DEBUG_TB_FLUSH, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 04/28] cpu-exec: include cpu_index in CPU_LOG_EXEC messages, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 01/28] cpus: make all_vcpus_paused() return bool, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 03/28] translate-all: add DEBUG_LOCKING asserts, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 05/28] docs: new design document multi-thread-tcg.txt (DRAFTING), Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 08/28] translate-all: Add assert_(memory|tb)_lock annotations,
Alex Bennée <=
- [Qemu-devel] [RFC v4 10/28] target-arm/arm-powerctl: wake up sleeping CPUs, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 07/28] linux-user/elfload: ensure mmap_lock() held while setting up, Alex Bennée, 2016/08/11
- [Qemu-devel] [RFC v4 06/28] tcg: comment on which functions have to be called with tb_lock held, Alex Bennée, 2016/08/11
- [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