Fix -Werror=clobbered issue with tb_gen_code

-----BEGIN PGP SIGNATURE-----
 
 iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmNrBscdHHJpY2hhcmQu
 aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9Fpwf/Rfj6jdVXlHX4mlWe
 snuTeLYDMxZkcCEobPlM6MTG3bVetmulQD09bf6rppOSfiG4LjcLwQtIYafXNG98
 EJiIZJNOsQen6MXtFlv9ZeqWi8PBe+4YQbIT3fOn5BC9p0BxS0aiIrTM36PpvKE9
 PV7I+KpwoNUeMSaJHf/jH+Q272Tk1jlW3GYzygbX/XHxsoLz9byRO9A0AMwClAOF
 XuNx+0+3w8xGfapsMU/oBkSMVFj03jsm07PMgvipMfT9s8qcTgzCyK8VeJPp9WHz
 9gn4mvVnEBQU1W3K2SCx1o3pyFaqmyMwnE0BixWKVEM9zAaJEBN5iYCn4QX0TH3y
 Hmzc8g==
 =YF54
 -----END PGP SIGNATURE-----

Merge tag 'pull-tcg-20221109' of https://gitlab.com/rth7680/qemu into staging

Fix -Werror=clobbered issue with tb_gen_code

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmNrBscdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV9Fpwf/Rfj6jdVXlHX4mlWe
# snuTeLYDMxZkcCEobPlM6MTG3bVetmulQD09bf6rppOSfiG4LjcLwQtIYafXNG98
# EJiIZJNOsQen6MXtFlv9ZeqWi8PBe+4YQbIT3fOn5BC9p0BxS0aiIrTM36PpvKE9
# PV7I+KpwoNUeMSaJHf/jH+Q272Tk1jlW3GYzygbX/XHxsoLz9byRO9A0AMwClAOF
# XuNx+0+3w8xGfapsMU/oBkSMVFj03jsm07PMgvipMfT9s8qcTgzCyK8VeJPp9WHz
# 9gn4mvVnEBQU1W3K2SCx1o3pyFaqmyMwnE0BixWKVEM9zAaJEBN5iYCn4QX0TH3y
# Hmzc8g==
# =YF54
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 08 Nov 2022 20:47:51 EST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* tag 'pull-tcg-20221109' of https://gitlab.com/rth7680/qemu:
  accel/tcg: Split out setjmp_gen_code
  tcg: Move TCG_TARGET_HAS_direct_jump init to tb_gen_code

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2022-11-09 13:26:45 -05:00
commit 2ccad61746
2 changed files with 45 additions and 35 deletions

View File

@ -742,6 +742,37 @@ void page_collection_unlock(struct page_collection *set)
#endif /* !CONFIG_USER_ONLY */
/*
* Isolate the portion of code gen which can setjmp/longjmp.
* Return the size of the generated code, or negative on error.
*/
static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb,
target_ulong pc, void *host_pc,
int *max_insns, int64_t *ti)
{
int ret = sigsetjmp(tcg_ctx->jmp_trans, 0);
if (unlikely(ret != 0)) {
return ret;
}
tcg_func_start(tcg_ctx);
tcg_ctx->cpu = env_cpu(env);
gen_intermediate_code(env_cpu(env), tb, *max_insns, pc, host_pc);
assert(tb->size != 0);
tcg_ctx->cpu = NULL;
*max_insns = tb->icount;
#ifdef CONFIG_PROFILER
qatomic_set(&tcg_ctx->prof.tb_count, tcg_ctx->prof.tb_count + 1);
qatomic_set(&tcg_ctx->prof.interm_time,
tcg_ctx->prof.interm_time + profile_getclock() - *ti);
*ti = profile_getclock();
#endif
return tcg_gen_code(tcg_ctx, tb, pc);
}
/* Called with mmap_lock held for user mode emulation. */
TranslationBlock *tb_gen_code(CPUState *cpu,
target_ulong pc, target_ulong cs_base,
@ -754,8 +785,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
int gen_code_size, search_size, max_insns;
#ifdef CONFIG_PROFILER
TCGProfile *prof = &tcg_ctx->prof;
int64_t ti;
#endif
int64_t ti;
void *host_pc;
assert_memory_lock();
@ -805,43 +836,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
ti = profile_getclock();
#endif
gen_code_size = sigsetjmp(tcg_ctx->jmp_trans, 0);
if (unlikely(gen_code_size != 0)) {
goto error_return;
}
tcg_func_start(tcg_ctx);
tcg_ctx->cpu = env_cpu(env);
gen_intermediate_code(cpu, tb, max_insns, pc, host_pc);
assert(tb->size != 0);
tcg_ctx->cpu = NULL;
max_insns = tb->icount;
trace_translate_block(tb, pc, tb->tc.ptr);
/* generate machine code */
tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;
tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;
tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset;
if (TCG_TARGET_HAS_direct_jump) {
tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg;
tcg_ctx->tb_jmp_target_addr = NULL;
} else {
tcg_ctx->tb_jmp_insn_offset = NULL;
tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg;
}
#ifdef CONFIG_PROFILER
qatomic_set(&prof->tb_count, prof->tb_count + 1);
qatomic_set(&prof->interm_time,
prof->interm_time + profile_getclock() - ti);
ti = profile_getclock();
#endif
gen_code_size = tcg_gen_code(tcg_ctx, tb, pc);
gen_code_size = setjmp_gen_code(env, tb, pc, host_pc, &max_insns, &ti);
if (unlikely(gen_code_size < 0)) {
error_return:
switch (gen_code_size) {
case -1:
/*

View File

@ -4228,6 +4228,18 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start)
}
#endif
/* Initialize goto_tb jump offsets. */
tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID;
tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID;
tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset;
if (TCG_TARGET_HAS_direct_jump) {
tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg;
tcg_ctx->tb_jmp_target_addr = NULL;
} else {
tcg_ctx->tb_jmp_insn_offset = NULL;
tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg;
}
tcg_reg_alloc_start(s);
/*