exec-all: bring tb->invalid into tb->cflags

This gets rid of a hole in struct TranslationBlock.

Backports commit 84f1c148da2b35fbb5a436597872765257e8914e from qemu
This commit is contained in:
Emilio G. Cota 2018-03-05 02:46:17 -05:00 committed by Lioncash
parent 210d13ec49
commit b4a7d8b773
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
4 changed files with 6 additions and 7 deletions

View file

@ -133,7 +133,8 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
if (tb->pc == pc &&
tb->page_addr[0] == phys_page1 &&
tb->cs_base == cs_base &&
tb->flags == flags) {
tb->flags == flags &&
!(atomic_read(&tb->cflags) & CF_INVALID)) {
if (tb->page_addr[1] == -1) {
/* done, we have a match */
@ -250,7 +251,7 @@ static inline TranslationBlock *tb_find(CPUState *cpu,
/* Check if translation buffer has been flushed */
if (cpu->tb_flushed) {
cpu->tb_flushed = false;
} else if (!tb->invalid) {
} else if (!(tb->cflags & CF_INVALID)) {
tb_add_jump(last_tb, tb_exit, tb);
}
}

View file

@ -216,8 +216,7 @@ struct TranslationBlock {
#define CF_NOCACHE 0x10000 /* To be freed after execution */
#define CF_USE_ICOUNT 0x20000
#define CF_IGNORE_ICOUNT 0x40000 /* Do not generate icount code */
uint16_t invalid;
#define CF_INVALID 0x80000 /* TB is stale. Setters must acquire tb_lock */
void *tc_ptr; /* pointer to the translated code */
uint8_t *tc_search; /* pointer to search data */

View file

@ -32,7 +32,7 @@ tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base,
tb->pc == *pc &&
tb->cs_base == *cs_base &&
tb->flags == *flags &&
!atomic_read(&tb->invalid))) {
!(atomic_read(&tb->cflags) & CF_INVALID))) {
return tb;
}
tb = tb_htable_lookup(cpu, *pc, *cs_base, *flags);

View file

@ -1110,7 +1110,7 @@ void tb_phys_invalidate(struct uc_struct *uc,
uint32_t h;
tb_page_addr_t phys_pc;
atomic_set(&tb->invalid, true);
atomic_set(&tb->cflags, tb->cflags | CF_INVALID);
/* remove the TB from the hash list */
phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
@ -1323,7 +1323,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
tb->cs_base = cs_base;
tb->flags = flags;
tb->cflags = cflags;
tb->invalid = false;
#ifdef CONFIG_PROFILER
tcg_ctx->tb_count1++; /* includes aborted translations because of