From: Liren Wei Date: Sun, 4 Jul 2021 14:31:26 +0000 (+0800) Subject: accel/tcg: Hoist tcg_tb_insert() up above tb_link_page() X-Git-Tag: v6.1.0-rc0~27^2~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4cba756cb6c6173321c4aad2035d5a86100eef7;p=thirdparty%2Fqemu.git accel/tcg: Hoist tcg_tb_insert() up above tb_link_page() TranslationBlocks not inserted into the corresponding region tree shall be regarded as partially initialized objects, and needs to be finalized first before inserting into QHT. Signed-off-by: Liren Wei Message-Id: Signed-off-by: Richard Henderson --- diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 7929a7e3203..75e4d065574 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1657,6 +1657,13 @@ TranslationBlock *tb_gen_code(CPUState *cpu, return tb; } + /* + * Insert TB into the corresponding region tree before publishing it + * through QHT. Otherwise rewinding happened in the TB might fail to + * lookup itself using host PC. + */ + tcg_tb_insert(tb); + /* check next page if needed */ virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK; phys_page2 = -1; @@ -1675,9 +1682,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, orig_aligned -= ROUND_UP(sizeof(*tb), qemu_icache_linesize); qatomic_set(&tcg_ctx->code_gen_ptr, (void *)orig_aligned); tb_destroy(tb); + tcg_tb_remove(tb); return existing_tb; } - tcg_tb_insert(tb); return tb; }