From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41948) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMnt8-0000pF-VJ for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMnt3-0005AV-05 for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42224 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMnt2-0005AH-NK for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:08 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 10 Mar 2014 01:15:23 +0100 Message-Id: <1394410549-13751-15-git-send-email-afaerber@suse.de> In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de> References: <1394410549-13751-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v2 14/40] cpu: Move tb_jmp_cache field from CPU_COMMON to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= Clear it on reset. Signed-off-by: Andreas F=C3=A4rber --- 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 *e= nv, target_ulong cs_base, uint64_t flags) { + CPUState *cpu =3D 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] =3D tb; } /* we add the TB in the virtual pc hash table */ - env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] =3D tb; + cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] =3D tb; return tb; } =20 static inline TranslationBlock *tb_find_fast(CPUArchState *env) { + CPUState *cpu =3D ENV_GET_CPU(env); TranslationBlock *tb; target_ulong cs_base, pc; int flags; @@ -179,7 +181,7 @@ static inline TranslationBlock *tb_find_fast(CPUArchS= tate *env) always be the same before a given translated block is executed. */ cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); - tb =3D env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; + tb =3D cpu->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; if (unlikely(!tb || tb->pc !=3D pc || tb->cs_base !=3D cs_base || tb->flags !=3D flags)) { tb =3D 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 =3D NULL; =20 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)); =20 env->tlb_flush_addr =3D -1; env->tlb_flush_mask =3D 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 sin= glestep */ #define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external e= vent) */ =20 -#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; =20 +#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 { =20 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 =3D 0; cpu->icount_decr.u32 =3D 0; cpu->can_do_io =3D 0; + memset(cpu->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *)); } =20 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 =3D 0; =20 CPU_FOREACH(cpu) { - CPUArchState *env =3D 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)); } =20 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_pag= e_addr_t page_addr) /* remove the TB from the hash list */ h =3D tb_jmp_cache_hash_func(tb->pc); CPU_FOREACH(cpu) { - CPUArchState *env =3D cpu->env_ptr; - - if (env->tb_jmp_cache[h] =3D=3D tb) { - env->tb_jmp_cache[h] =3D NULL; + if (cpu->tb_jmp_cache[h] =3D=3D tb) { + cpu->tb_jmp_cache[h] =3D NULL; } } =20 @@ -1484,16 +1480,17 @@ void cpu_io_recompile(CPUArchState *env, uintptr_= t retaddr) =20 void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr) { + CPUState *cpu =3D ENV_GET_CPU(env); unsigned int i; =20 /* Discard jump cache entries for any tb which might potentially overlap the flushed page. */ i =3D 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 *)); =20 i =3D 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 *)); } =20 --=20 1.8.4.5