qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, "Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH qom-cpu v2 14/40] cpu: Move tb_jmp_cache field from CPU_COMMON to CPUState
Date: Mon, 10 Mar 2014 01:15:23 +0100	[thread overview]
Message-ID: <1394410549-13751-15-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de>

Clear it on reset.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 cpu-exec.c              |  6 ++++--
 cputlb.c                |  2 +-
 include/exec/cpu-defs.h |  4 ----
 include/qom/cpu.h       |  4 ++++
 qom/cpu.c               |  1 +
 translate-all.c         | 15 ++++++---------
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/cpu-exec.c b/cpu-exec.c
index 9d98f21..dd8da53 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -118,6 +118,7 @@ static TranslationBlock *tb_find_slow(CPUArchState *env,
                                       target_ulong cs_base,
                                       uint64_t flags)
 {
+    CPUState *cpu = ENV_GET_CPU(env);
     TranslationBlock *tb, **ptb1;
     unsigned int h;
     tb_page_addr_t phys_pc, phys_page1;
@@ -165,12 +166,13 @@ static TranslationBlock *tb_find_slow(CPUArchState *env,
         tcg_ctx.tb_ctx.tb_phys_hash[h] = tb;
     }
     /* we add the TB in the virtual pc hash table */
-    env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
+    cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
     return tb;
 }
 
 static inline TranslationBlock *tb_find_fast(CPUArchState *env)
 {
+    CPUState *cpu = ENV_GET_CPU(env);
     TranslationBlock *tb;
     target_ulong cs_base, pc;
     int flags;
@@ -179,7 +181,7 @@ static inline TranslationBlock *tb_find_fast(CPUArchState *env)
        always be the same before a given translated block
        is executed. */
     cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
-    tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
+    tb = cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
     if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
                  tb->flags != flags)) {
         tb = tb_find_slow(env, pc, cs_base, flags);
diff --git a/cputlb.c b/cputlb.c
index 0fbaa39..0eb1801 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -58,7 +58,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
     cpu->current_tb = NULL;
 
     memset(env->tlb_table, -1, sizeof(env->tlb_table));
-    memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
+    memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache));
 
     env->tlb_flush_addr = -1;
     env->tlb_flush_mask = 0;
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
index 8a3f3f2..2ba3df7 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -60,9 +60,6 @@ typedef uint64_t target_ulong;
 #define EXCP_DEBUG      0x10002 /* cpu stopped after a breakpoint or singlestep */
 #define EXCP_HALTED     0x10003 /* cpu is halted (waiting for external event) */
 
-#define TB_JMP_CACHE_BITS 12
-#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
-
 /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for
    addresses on the same page.  The top bits are the same.  This allows
    TLB invalidation to quickly clear a subset of the hash table.  */
@@ -134,7 +131,6 @@ typedef struct CPUWatchpoint {
 #define CPU_COMMON                                                      \
     /* soft mmu support */                                              \
     CPU_COMMON_TLB                                                      \
-    struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE];           \
                                                                         \
     /* from this point: preserved by CPU reset */                       \
     /* ice debug support */                                             \
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 3156b16..ada8a5a 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -153,6 +153,9 @@ typedef struct icount_decr_u16 {
 struct KVMState;
 struct kvm_run;
 
+#define TB_JMP_CACHE_BITS 12
+#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
+
 /**
  * CPUState:
  * @cpu_index: CPU index (informative).
@@ -219,6 +222,7 @@ struct CPUState {
 
     void *env_ptr; /* CPUArchState */
     struct TranslationBlock *current_tb;
+    struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE];
     struct GDBRegisterState *gdb_regs;
     int gdb_num_regs;
     int gdb_num_g_regs;
diff --git a/qom/cpu.c b/qom/cpu.c
index 13dc6f6..0a04147 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -245,6 +245,7 @@ static void cpu_common_reset(CPUState *cpu)
     cpu->icount_extra = 0;
     cpu->icount_decr.u32 = 0;
     cpu->can_do_io = 0;
+    memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));
 }
 
 static bool cpu_common_has_work(CPUState *cs)
diff --git a/translate-all.c b/translate-all.c
index 6bb3933..c067011 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -704,9 +704,7 @@ void tb_flush(CPUArchState *env1)
     tcg_ctx.tb_ctx.nb_tbs = 0;
 
     CPU_FOREACH(cpu) {
-        CPUArchState *env = cpu->env_ptr;
-
-        memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
+        memset(cpu->tb_jmp_cache, 0, sizeof(cpu->tb_jmp_cache));
     }
 
     memset(tcg_ctx.tb_ctx.tb_phys_hash, 0, sizeof(tcg_ctx.tb_ctx.tb_phys_hash));
@@ -857,10 +855,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
     /* remove the TB from the hash list */
     h = tb_jmp_cache_hash_func(tb->pc);
     CPU_FOREACH(cpu) {
-        CPUArchState *env = cpu->env_ptr;
-
-        if (env->tb_jmp_cache[h] == tb) {
-            env->tb_jmp_cache[h] = NULL;
+        if (cpu->tb_jmp_cache[h] == tb) {
+            cpu->tb_jmp_cache[h] = NULL;
         }
     }
 
@@ -1484,16 +1480,17 @@ void cpu_io_recompile(CPUArchState *env, uintptr_t retaddr)
 
 void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr)
 {
+    CPUState *cpu = ENV_GET_CPU(env);
     unsigned int i;
 
     /* Discard jump cache entries for any tb which might potentially
        overlap the flushed page.  */
     i = tb_jmp_cache_hash_page(addr - TARGET_PAGE_SIZE);
-    memset(&env->tb_jmp_cache[i], 0,
+    memset(&cpu->tb_jmp_cache[i], 0,
            TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *));
 
     i = tb_jmp_cache_hash_page(addr);
-    memset(&env->tb_jmp_cache[i], 0,
+    memset(&cpu->tb_jmp_cache[i], 0,
            TB_JMP_PAGE_SIZE * sizeof(TranslationBlock *));
 }
 
-- 
1.8.4.5

  parent reply	other threads:[~2014-03-10  0:16 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10  0:15 [Qemu-devel] [PATCH qom-cpu v2 00/40] QOM CPUState, part 13: Emptying CPU_COMMON Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 01/40] target-alpha: Clean up ENV_GET_CPU() usage Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 02/40] target-arm: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 03/40] target-i386: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 04/40] target-ppc: " Andreas Färber
2014-03-12 22:56   ` Stuart Brady
2014-03-12 23:53     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 05/40] target-s390x: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 06/40] target-sparc: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 07/40] target-unicore32: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 08/40] target-xtensa: " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 09/40] cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook Andreas Färber
2014-03-10  7:52   ` Paolo Bonzini
2014-03-11 23:47     ` Andreas Färber
2014-03-12 17:58       ` Paolo Bonzini
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 10/40] cpu: Move mem_io_{pc, vaddr} fields from CPU_COMMON to CPUState Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 11/40] cpu: Move can_do_io field " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 12/40] cpu: Move icount_extra " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 13/40] cpu: Move icount_decr " Andreas Färber
2014-03-10  0:15 ` Andreas Färber [this message]
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 15/40] cpu: Move jmp_env " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 16/40] cpu: Move exception_index " Andreas Färber
2014-03-11 22:29   ` Andreas Färber
2014-03-13  0:56     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 17/40] cpu: Move opaque " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 18/40] cpu: Move watchpoint fields " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 19/40] cpu: Move breakpoints field " Andreas Färber
2014-03-12 23:08   ` Stuart Brady
2014-03-12 23:59     ` Andreas Färber
2014-03-13  0:40       ` Stuart Brady
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 20/40] exec: Change tlb_fill() argument " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 21/40] cpu-exec: Change cpu_loop_exit() " Andreas Färber
2014-03-11 22:35   ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 22/40] translate-all: Change cpu_restore_state() " Andreas Färber
2014-03-11 15:02   ` Max Filippov
2014-03-11 23:23     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 23/40] translate-all: Change cpu_restore_state_from_tb() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 24/40] translate-all: Change tb_check_watchpoint() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 25/40] translate-all: Change cpu_io_recompile() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 26/40] translate-all: Change tb_gen_code() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 27/40] translate-all: Change tb_flush_jmp_cache() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 28/40] target-ppc: Use PowerPCCPU in PowerPCCPUClass::handle_mmu_fault hook Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 29/40] exec: Change cpu_watchpoint_{insert, remove{, _by_ref, _all}} argument Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 30/40] exec: Change cpu_breakpoint_{insert, " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 31/40] cpu-exec: Change cpu_resume_from_signal() argument to CPUState Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 32/40] cputlb: Change tlb_unprotect_code_phys() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 33/40] exec: Change memory_region_section_get_iotlb() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 34/40] exec: Change cpu_abort() " Andreas Färber
2014-03-12 23:28   ` Andreas Färber
2014-03-13  0:59     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 35/40] target-cris: Replace DisasContext::env field with CRISCPU Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 36/40] target-microblaze: Replace DisasContext::env field with MicroBlazeCPU Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 37/40] cputlb: Change tlb_flush_page() argument to CPUState Andreas Färber
2014-03-11 15:05   ` Max Filippov
2014-03-13  0:33     ` Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 38/40] cputlb: Change tlb_flush() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 39/40] cputlb: Change tlb_set_page() " Andreas Färber
2014-03-10  0:15 ` [Qemu-devel] [PATCH qom-cpu v2 40/40] user-exec: Change exception_action() " Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394410549-13751-15-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).