1 | The following changes since commit 3c8c36c9087da957f580a9bb5ebf7814a753d1c6: | 1 | The following changes since commit 60ab36907ded2918d33683f2b66f603b7400d8f3: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/kraxel/tags/ui-20201104-pull-request' into staging (2020-11-04 16:52:17 +0000) | 3 | Update VERSION for v7.2.0-rc0 (2022-11-08 15:53:41 -0500) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/rth7680/qemu.git tags/pull-tcg-20201104 | 7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20221109 |
8 | 8 | ||
9 | for you to fetch changes up to c56caea3b2a4ef5d760266f554df0d92c5a45f87: | 9 | for you to fetch changes up to 344b63b380541a63c02ef7a8a6ae66cb0b6f0273: |
10 | 10 | ||
11 | tcg: Revert "tcg/optimize: Flush data at labels not TCG_OPF_BB_END" (2020-11-04 10:35:40 -0800) | 11 | accel/tcg: Split out setjmp_gen_code (2022-11-09 12:29:03 +1100) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Fix assert in set_jmp_reset_offset | 14 | Fix -Werror=clobbered issue with tb_gen_code |
15 | Revert cross-branch optimization in tcg/optimize.c. | ||
16 | 15 | ||
17 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
18 | Richard Henderson (2): | 17 | Richard Henderson (2): |
19 | tcg: Remove assert from set_jmp_reset_offset | 18 | tcg: Move TCG_TARGET_HAS_direct_jump init to tb_gen_code |
20 | tcg: Revert "tcg/optimize: Flush data at labels not TCG_OPF_BB_END" | 19 | accel/tcg: Split out setjmp_gen_code |
21 | 20 | ||
22 | tcg/optimize.c | 35 +++++++++++++++++------------------ | 21 | accel/tcg/translate-all.c | 68 +++++++++++++++++++++++------------------------ |
23 | tcg/tcg.c | 9 +++++---- | 22 | tcg/tcg.c | 12 +++++++++ |
24 | 2 files changed, 22 insertions(+), 22 deletions(-) | 23 | 2 files changed, 45 insertions(+), 35 deletions(-) |
25 | diff view generated by jsdifflib |
1 | Since 6e6c4efed99, there has been a more appropriate range check | 1 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | done later at the end of tcg_gen_code. There, a failing range | ||
3 | check results in a returned error code, which causes the TB to | ||
4 | be restarted at half the size. | ||
5 | |||
6 | Reported-by: Sai Pavan Boddu <saipava@xilinx.com> | ||
7 | Tested-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 3 | --- |
11 | tcg/tcg.c | 9 +++++---- | 4 | accel/tcg/translate-all.c | 10 ---------- |
12 | 1 file changed, 5 insertions(+), 4 deletions(-) | 5 | tcg/tcg.c | 12 ++++++++++++ |
6 | 2 files changed, 12 insertions(+), 10 deletions(-) | ||
13 | 7 | ||
8 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
9 | index XXXXXXX..XXXXXXX 100644 | ||
10 | --- a/accel/tcg/translate-all.c | ||
11 | +++ b/accel/tcg/translate-all.c | ||
12 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
13 | trace_translate_block(tb, pc, tb->tc.ptr); | ||
14 | |||
15 | /* generate machine code */ | ||
16 | - tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; | ||
17 | - tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; | ||
18 | - tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; | ||
19 | - if (TCG_TARGET_HAS_direct_jump) { | ||
20 | - tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; | ||
21 | - tcg_ctx->tb_jmp_target_addr = NULL; | ||
22 | - } else { | ||
23 | - tcg_ctx->tb_jmp_insn_offset = NULL; | ||
24 | - tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; | ||
25 | - } | ||
26 | |||
27 | #ifdef CONFIG_PROFILER | ||
28 | qatomic_set(&prof->tb_count, prof->tb_count + 1); | ||
14 | diff --git a/tcg/tcg.c b/tcg/tcg.c | 29 | diff --git a/tcg/tcg.c b/tcg/tcg.c |
15 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tcg/tcg.c | 31 | --- a/tcg/tcg.c |
17 | +++ b/tcg/tcg.c | 32 | +++ b/tcg/tcg.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool tcg_resolve_relocs(TCGContext *s) | 33 | @@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) |
19 | 34 | } | |
20 | static void set_jmp_reset_offset(TCGContext *s, int which) | 35 | #endif |
21 | { | 36 | |
22 | - size_t off = tcg_current_code_size(s); | 37 | + /* Initialize goto_tb jump offsets. */ |
23 | - s->tb_jmp_reset_offset[which] = off; | 38 | + tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; |
24 | - /* Make sure that we didn't overflow the stored offset. */ | 39 | + tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; |
25 | - assert(s->tb_jmp_reset_offset[which] == off); | 40 | + tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; |
26 | + /* | 41 | + if (TCG_TARGET_HAS_direct_jump) { |
27 | + * We will check for overflow at the end of the opcode loop in | 42 | + tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; |
28 | + * tcg_gen_code, where we bound tcg_current_code_size to UINT16_MAX. | 43 | + tcg_ctx->tb_jmp_target_addr = NULL; |
29 | + */ | 44 | + } else { |
30 | + s->tb_jmp_reset_offset[which] = tcg_current_code_size(s); | 45 | + tcg_ctx->tb_jmp_insn_offset = NULL; |
31 | } | 46 | + tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; |
32 | 47 | + } | |
33 | #include "tcg-target.c.inc" | 48 | + |
49 | tcg_reg_alloc_start(s); | ||
50 | |||
51 | /* | ||
34 | -- | 52 | -- |
35 | 2.25.1 | 53 | 2.34.1 |
36 | 54 | ||
37 | 55 | diff view generated by jsdifflib |
1 | This reverts commit cd0372c515c4732d8bd3777cdd995c139c7ed7ea. | 1 | Isolate the code protected by setjmp. Fixes: |
---|---|---|---|
2 | 2 | ||
3 | The patch is incorrect in that it retains copies between globals and | 3 | translate-all.c: In function ‘tb_gen_code’: |
4 | non-local temps, and non-local temps still die at the end of the BB. | 4 | translate-all.c:748:51: error: argument ‘cflags’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] |
5 | 5 | ||
6 | Failing test case for hppa: | 6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | |||
8 | .globl _start | ||
9 | _start: | ||
10 | cmpiclr,= 0x24,%r19,%r0 | ||
11 | cmpiclr,<> 0x2f,%r19,%r19 | ||
12 | |||
13 | ---- 00010057 0001005b | ||
14 | movi_i32 tmp0,$0x24 | ||
15 | sub_i32 tmp1,tmp0,r19 | ||
16 | mov_i32 tmp2,tmp0 | ||
17 | mov_i32 tmp3,r19 | ||
18 | movi_i32 tmp1,$0x0 | ||
19 | |||
20 | ---- 0001005b 0001005f | ||
21 | brcond_i32 tmp2,tmp3,eq,$L1 | ||
22 | movi_i32 tmp0,$0x2f | ||
23 | sub_i32 tmp1,tmp0,r19 | ||
24 | mov_i32 tmp2,tmp0 | ||
25 | mov_i32 tmp3,r19 | ||
26 | movi_i32 tmp1,$0x0 | ||
27 | mov_i32 r19,tmp1 | ||
28 | setcond_i32 psw_n,tmp2,tmp3,ne | ||
29 | set_label $L1 | ||
30 | |||
31 | In this case, both copies of "mov_i32 tmp3,r19" are removed. The | ||
32 | second because opt thought it was redundant. The first is removed | ||
33 | later by liveness because tmp3 is known to be dead. This leaves | ||
34 | the setcond_i32 with an uninitialized input. | ||
35 | |||
36 | Revert the entire patch for 5.2, and a proper optimization across | ||
37 | the branch may be considered for the next development cycle. | ||
38 | |||
39 | Reported-by: qemu@igor2.repo.hu | ||
40 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
41 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
42 | --- | 8 | --- |
43 | tcg/optimize.c | 35 +++++++++++++++++------------------ | 9 | accel/tcg/translate-all.c | 58 ++++++++++++++++++++++----------------- |
44 | 1 file changed, 17 insertions(+), 18 deletions(-) | 10 | 1 file changed, 33 insertions(+), 25 deletions(-) |
45 | 11 | ||
46 | diff --git a/tcg/optimize.c b/tcg/optimize.c | 12 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
47 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/tcg/optimize.c | 14 | --- a/accel/tcg/translate-all.c |
49 | +++ b/tcg/optimize.c | 15 | +++ b/accel/tcg/translate-all.c |
50 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | 16 | @@ -XXX,XX +XXX,XX @@ void page_collection_unlock(struct page_collection *set) |
51 | } | 17 | |
52 | } | 18 | #endif /* !CONFIG_USER_ONLY */ |
53 | } | 19 | |
54 | - /* fall through */ | 20 | +/* |
55 | + goto do_reset_output; | 21 | + * Isolate the portion of code gen which can setjmp/longjmp. |
56 | 22 | + * Return the size of the generated code, or negative on error. | |
57 | default: | 23 | + */ |
58 | do_default: | 24 | +static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb, |
59 | - /* | 25 | + target_ulong pc, void *host_pc, |
60 | - * Default case: we know nothing about operation (or were unable | 26 | + int *max_insns, int64_t *ti) |
61 | - * to compute the operation result) so no propagation is done. | 27 | +{ |
62 | - */ | 28 | + int ret = sigsetjmp(tcg_ctx->jmp_trans, 0); |
63 | - for (i = 0; i < nb_oargs; i++) { | 29 | + if (unlikely(ret != 0)) { |
64 | - reset_temp(op->args[i]); | 30 | + return ret; |
65 | - /* | 31 | + } |
66 | - * Save the corresponding known-zero bits mask for the | 32 | + |
67 | - * first output argument (only one supported so far). | 33 | + tcg_func_start(tcg_ctx); |
68 | - */ | 34 | + |
69 | - if (i == 0) { | 35 | + tcg_ctx->cpu = env_cpu(env); |
70 | - arg_info(op->args[i])->mask = mask; | 36 | + gen_intermediate_code(env_cpu(env), tb, *max_insns, pc, host_pc); |
71 | + /* Default case: we know nothing about operation (or were unable | 37 | + assert(tb->size != 0); |
72 | + to compute the operation result) so no propagation is done. | 38 | + tcg_ctx->cpu = NULL; |
73 | + We trash everything if the operation is the end of a basic | 39 | + *max_insns = tb->icount; |
74 | + block, otherwise we only trash the output args. "mask" is | 40 | + |
75 | + the non-zero bits mask for the first output arg. */ | 41 | +#ifdef CONFIG_PROFILER |
76 | + if (def->flags & TCG_OPF_BB_END) { | 42 | + qatomic_set(&tcg_ctx->prof.tb_count, tcg_ctx->prof.tb_count + 1); |
77 | + bitmap_zero(temps_used.l, nb_temps); | 43 | + qatomic_set(&tcg_ctx->prof.interm_time, |
78 | + } else { | 44 | + tcg_ctx->prof.interm_time + profile_getclock() - *ti); |
79 | + do_reset_output: | 45 | + *ti = profile_getclock(); |
80 | + for (i = 0; i < nb_oargs; i++) { | 46 | +#endif |
81 | + reset_temp(op->args[i]); | 47 | + |
82 | + /* Save the corresponding known-zero bits mask for the | 48 | + return tcg_gen_code(tcg_ctx, tb, pc); |
83 | + first output argument (only one supported so far). */ | 49 | +} |
84 | + if (i == 0) { | 50 | + |
85 | + arg_info(op->args[i])->mask = mask; | 51 | /* Called with mmap_lock held for user mode emulation. */ |
86 | + } | 52 | TranslationBlock *tb_gen_code(CPUState *cpu, |
87 | } | 53 | target_ulong pc, target_ulong cs_base, |
88 | } | 54 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, |
89 | break; | 55 | int gen_code_size, search_size, max_insns; |
56 | #ifdef CONFIG_PROFILER | ||
57 | TCGProfile *prof = &tcg_ctx->prof; | ||
58 | - int64_t ti; | ||
59 | #endif | ||
60 | + int64_t ti; | ||
61 | void *host_pc; | ||
62 | |||
63 | assert_memory_lock(); | ||
64 | @@ -XXX,XX +XXX,XX @@ TranslationBlock *tb_gen_code(CPUState *cpu, | ||
65 | ti = profile_getclock(); | ||
66 | #endif | ||
67 | |||
68 | - gen_code_size = sigsetjmp(tcg_ctx->jmp_trans, 0); | ||
69 | - if (unlikely(gen_code_size != 0)) { | ||
70 | - goto error_return; | ||
71 | - } | ||
90 | - | 72 | - |
91 | - case INDEX_op_set_label: | 73 | - tcg_func_start(tcg_ctx); |
92 | - /* Trash everything at the start of a new extended bb. */ | 74 | - |
93 | - bitmap_zero(temps_used.l, nb_temps); | 75 | - tcg_ctx->cpu = env_cpu(env); |
94 | - break; | 76 | - gen_intermediate_code(cpu, tb, max_insns, pc, host_pc); |
95 | } | 77 | - assert(tb->size != 0); |
96 | 78 | - tcg_ctx->cpu = NULL; | |
97 | /* Eliminate duplicate and redundant fence instructions. */ | 79 | - max_insns = tb->icount; |
80 | - | ||
81 | trace_translate_block(tb, pc, tb->tc.ptr); | ||
82 | |||
83 | - /* generate machine code */ | ||
84 | - | ||
85 | -#ifdef CONFIG_PROFILER | ||
86 | - qatomic_set(&prof->tb_count, prof->tb_count + 1); | ||
87 | - qatomic_set(&prof->interm_time, | ||
88 | - prof->interm_time + profile_getclock() - ti); | ||
89 | - ti = profile_getclock(); | ||
90 | -#endif | ||
91 | - | ||
92 | - gen_code_size = tcg_gen_code(tcg_ctx, tb, pc); | ||
93 | + gen_code_size = setjmp_gen_code(env, tb, pc, host_pc, &max_insns, &ti); | ||
94 | if (unlikely(gen_code_size < 0)) { | ||
95 | - error_return: | ||
96 | switch (gen_code_size) { | ||
97 | case -1: | ||
98 | /* | ||
98 | -- | 99 | -- |
99 | 2.25.1 | 100 | 2.34.1 |
100 | 101 | ||
101 | 102 | diff view generated by jsdifflib |