translate-all: introduce assert_no_pages_locked
authorEmilio G. Cota <cota@braap.org>
Fri, 23 Feb 2018 01:50:29 +0000 (20:50 -0500)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 15 Jun 2018 17:42:55 +0000 (07:42 -1000)
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>
accel/tcg/cpu-exec.c
accel/tcg/translate-all.c
include/exec/exec-all.h

index 7570c59f0946ffab596162c7437b9a168d65d31a..d75c35380ab9cf707114fb33c71f1ed5da01f163 100644 (file)
@@ -273,6 +273,7 @@ void cpu_exec_step_atomic(CPUState *cpu)
         tcg_debug_assert(!have_mmap_lock());
 #endif
         tb_lock_reset();
+        assert_no_pages_locked();
     }
 
     if (in_exclusive_region) {
index 8b378586f48b8ef4e02c8de2ca3f21348a240e61..c75298d08a0d3689f4179f80a6594a4ca72ea3e7 100644 (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__)
 
+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 */
 
 #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,
                                 page_entry_destroy);
     set->max = NULL;
+    assert_no_pages_locked();
 
  retry:
     g_tree_foreach(set->tree, page_entry_lock, NULL);
index 8d92e3cea90801eeb0885ba4ac09925821efca49..4f07a170527d77ab49c2f7091ee288c4dd9c8cbe 100644 (file)
@@ -435,6 +435,14 @@ void tb_lock(void);
 void tb_unlock(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)
 
 /**