diff mbox

[v2,1/5] exec: [tcg] Refactor flush of per-CPU virtual TB cache

Message ID 147395464242.2399.4013716179287085683.stgit@fimbulvetr.bsc.es
State New
Headers show

Commit Message

Lluís Vilanova Sept. 15, 2016, 3:50 p.m. UTC
The function is reused in later patches.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 cputlb.c                |    2 +-
 include/exec/exec-all.h |    6 ++++++
 translate-all.c         |    9 +++++++--
 3 files changed, 14 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/cputlb.c b/cputlb.c
index d068ee5..686a09c 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -81,7 +81,7 @@  void tlb_flush(CPUState *cpu, int flush_global)
 
     memset(env->tlb_table, -1, sizeof(env->tlb_table));
     memset(env->tlb_v_table, -1, sizeof(env->tlb_v_table));
-    memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache));
+    tb_flush_jmp_cache_all(cpu);
 
     env->vtlb_index = 0;
     env->tlb_flush_addr = -1;
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index d008296..e2124dc 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -265,6 +265,12 @@  struct TranslationBlock {
 };
 
 void tb_free(TranslationBlock *tb);
+/**
+ * tb_flush_jmp_cache_all:
+ *
+ * Flush the virtual translation block cache.
+ */
+void tb_flush_jmp_cache_all(CPUState *env);
 void tb_flush(CPUState *cpu);
 void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
 
diff --git a/translate-all.c b/translate-all.c
index 0dd6466..ebd9fa0 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -851,8 +851,7 @@  void tb_flush(CPUState *cpu)
     tcg_ctx.tb_ctx.nb_tbs = 0;
 
     CPU_FOREACH(cpu) {
-        memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache));
-        cpu->tb_flushed = true;
+        tb_flush_jmp_cache_all(cpu);
     }
 
     qht_reset_size(&tcg_ctx.tb_ctx.htable, CODE_GEN_HTABLE_SIZE);
@@ -1579,6 +1578,12 @@  void tb_check_watchpoint(CPUState *cpu)
     }
 }
 
+void tb_flush_jmp_cache_all(CPUState *cpu)
+{
+    memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache));
+    cpu->tb_flushed = true;
+}
+
 #ifndef CONFIG_USER_ONLY
 /* in deterministic execution mode, instructions doing device I/Os
    must be at the end of the TB */