diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2021-05-24 19:04:53 +0200 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2021-05-26 15:33:59 -0700 |
commit | e5ceadff47ddec1513a56f96d9df246f62c90875 (patch) | |
tree | ced5b40c000523b5c6c8954bf1cf33548fee4c47 /accel/tcg/tb-lookup.h | |
parent | 824f4bac9ffa2757293290c7edd065dc84a6521e (diff) | |
download | qemu-e5ceadff47ddec1513a56f96d9df246f62c90875.zip qemu-e5ceadff47ddec1513a56f96d9df246f62c90875.tar.gz qemu-e5ceadff47ddec1513a56f96d9df246f62c90875.tar.bz2 |
accel/tcg: Keep TranslationBlock headers local to TCG
Only the TCG accelerator uses the TranslationBlock API.
Move the tb-context.h / tb-hash.h / tb-lookup.h from the
global namespace to the TCG one (in accel/tcg).
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210524170453.3791436-3-f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'accel/tcg/tb-lookup.h')
-rw-r--r-- | accel/tcg/tb-lookup.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/accel/tcg/tb-lookup.h b/accel/tcg/tb-lookup.h new file mode 100644 index 0000000..9c9e007 --- /dev/null +++ b/accel/tcg/tb-lookup.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2017, Emilio G. Cota <cota@braap.org> + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef EXEC_TB_LOOKUP_H +#define EXEC_TB_LOOKUP_H + +#ifdef NEED_CPU_H +#include "cpu.h" +#else +#include "exec/poison.h" +#endif + +#include "exec/exec-all.h" +#include "tb-hash.h" + +/* Might cause an exception, so have a longjmp destination ready */ +static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, + target_ulong cs_base, + uint32_t flags, uint32_t cflags) +{ + TranslationBlock *tb; + uint32_t hash; + + /* we should never be trying to look up an INVALID tb */ + tcg_debug_assert(!(cflags & CF_INVALID)); + + hash = tb_jmp_cache_hash_func(pc); + tb = qatomic_rcu_read(&cpu->tb_jmp_cache[hash]); + + if (likely(tb && + tb->pc == pc && + tb->cs_base == cs_base && + tb->flags == flags && + tb->trace_vcpu_dstate == *cpu->trace_dstate && + tb_cflags(tb) == cflags)) { + return tb; + } + tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags); + if (tb == NULL) { + return NULL; + } + qatomic_set(&cpu->tb_jmp_cache[hash], tb); + return tb; +} + +#endif /* EXEC_TB_LOOKUP_H */ |