translate-all: introduce assert_no_pages_locked

The appended adds assertions to make sure we do not longjmp with page
locks held. Note that user-mode has nothing to check, since page_locks
are !user-mode only.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Emilio G. Cota 2018-02-22 20:50:29 -05:00 committed by Richard Henderson
parent 6d9abf85d5
commit faa9372c07
3 changed files with 16 additions and 0 deletions

View File

@ -273,6 +273,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
tcg_debug_assert(!have_mmap_lock()); tcg_debug_assert(!have_mmap_lock());
#endif #endif
tb_lock_reset(); tb_lock_reset();
assert_no_pages_locked();
} }
if (in_exclusive_region) { if (in_exclusive_region) {

View File

@ -658,6 +658,12 @@ do_assert_page_locked(const PageDesc *pd, const char *file, int line)
#define assert_page_locked(pd) do_assert_page_locked(pd, __FILE__, __LINE__) #define assert_page_locked(pd) do_assert_page_locked(pd, __FILE__, __LINE__)
void assert_no_pages_locked(void)
{
ht_pages_locked_debug_init();
g_assert(g_hash_table_size(ht_pages_locked_debug) == 0);
}
#else /* !CONFIG_DEBUG_TCG */ #else /* !CONFIG_DEBUG_TCG */
#define assert_page_locked(pd) #define assert_page_locked(pd)
@ -829,6 +835,7 @@ page_collection_lock(tb_page_addr_t start, tb_page_addr_t end)
set->tree = g_tree_new_full(tb_page_addr_cmp, NULL, NULL, set->tree = g_tree_new_full(tb_page_addr_cmp, NULL, NULL,
page_entry_destroy); page_entry_destroy);
set->max = NULL; set->max = NULL;
assert_no_pages_locked();
retry: retry:
g_tree_foreach(set->tree, page_entry_lock, NULL); g_tree_foreach(set->tree, page_entry_lock, NULL);

View File

@ -435,6 +435,14 @@ void tb_lock(void);
void tb_unlock(void); void tb_unlock(void);
void tb_lock_reset(void); void tb_lock_reset(void);
#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_DEBUG_TCG)
void assert_no_pages_locked(void);
#else
static inline void assert_no_pages_locked(void)
{
}
#endif
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
/** /**