* [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end
@ 2024-05-21 21:06 Richard Henderson
2024-05-22 9:29 ` Bernhard Beschow
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Richard Henderson @ 2024-05-21 21:06 UTC (permalink / raw)
To: qemu-devel; +Cc: Bernhard Beschow
When passing disassembly data to plugin callbacks,
translator_st_len relies on db->tb->size having been set.
Fixes: 4c833c60e047 ("disas: Use translator_st to get disassembly data")
Reported-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/translator.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index c56967eecd..113edcffe3 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -214,14 +214,14 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
set_can_do_io(db, true);
tcg_ctx->emit_before_op = NULL;
+ /* May be used by disas_log or plugin callbacks. */
+ tb->size = db->pc_next - db->pc_first;
+ tb->icount = db->num_insns;
+
if (plugin_enabled) {
plugin_gen_tb_end(cpu, db->num_insns);
}
- /* The disas_log hook may use these values rather than recompute. */
- tb->size = db->pc_next - db->pc_first;
- tb->icount = db->num_insns;
-
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
&& qemu_log_in_addr_range(db->pc_first)) {
FILE *logfile = qemu_log_trylock();
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end
2024-05-21 21:06 [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end Richard Henderson
@ 2024-05-22 9:29 ` Bernhard Beschow
2024-05-22 17:11 ` Pierrick Bouvier
2024-05-27 9:37 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Bernhard Beschow @ 2024-05-22 9:29 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Am 21. Mai 2024 21:06:04 UTC schrieb Richard Henderson <richard.henderson@linaro.org>:
>When passing disassembly data to plugin callbacks,
>translator_st_len relies on db->tb->size having been set.
>
>Fixes: 4c833c60e047 ("disas: Use translator_st to get disassembly data")
Indeed! It even works better than ever by also fixing the range of the machine code. So:
Tested-by: Bernhard Beschow <shentey@gmail.com>
The only issue that remains is that the machine code is reversed, i.e. the first byte is output last. But that is a bug that existed before.
>Reported-by: Bernhard Beschow <shentey@gmail.com>
>Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>---
> accel/tcg/translator.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
>index c56967eecd..113edcffe3 100644
>--- a/accel/tcg/translator.c
>+++ b/accel/tcg/translator.c
>@@ -214,14 +214,14 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
> set_can_do_io(db, true);
> tcg_ctx->emit_before_op = NULL;
>
>+ /* May be used by disas_log or plugin callbacks. */
>+ tb->size = db->pc_next - db->pc_first;
>+ tb->icount = db->num_insns;
>+
> if (plugin_enabled) {
> plugin_gen_tb_end(cpu, db->num_insns);
> }
>
>- /* The disas_log hook may use these values rather than recompute. */
>- tb->size = db->pc_next - db->pc_first;
>- tb->icount = db->num_insns;
>-
> if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
> && qemu_log_in_addr_range(db->pc_first)) {
> FILE *logfile = qemu_log_trylock();
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end
2024-05-21 21:06 [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end Richard Henderson
2024-05-22 9:29 ` Bernhard Beschow
@ 2024-05-22 17:11 ` Pierrick Bouvier
2024-05-27 9:37 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Pierrick Bouvier @ 2024-05-22 17:11 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: Bernhard Beschow
On 5/21/24 14:06, Richard Henderson wrote:
> When passing disassembly data to plugin callbacks,
> translator_st_len relies on db->tb->size having been set.
>
> Fixes: 4c833c60e047 ("disas: Use translator_st to get disassembly data")
> Reported-by: Bernhard Beschow <shentey@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/translator.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
> index c56967eecd..113edcffe3 100644
> --- a/accel/tcg/translator.c
> +++ b/accel/tcg/translator.c
> @@ -214,14 +214,14 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
> set_can_do_io(db, true);
> tcg_ctx->emit_before_op = NULL;
>
> + /* May be used by disas_log or plugin callbacks. */
> + tb->size = db->pc_next - db->pc_first;
> + tb->icount = db->num_insns;
> +
> if (plugin_enabled) {
> plugin_gen_tb_end(cpu, db->num_insns);
> }
>
> - /* The disas_log hook may use these values rather than recompute. */
> - tb->size = db->pc_next - db->pc_first;
> - tb->icount = db->num_insns;
> -
> if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)
> && qemu_log_in_addr_range(db->pc_first)) {
> FILE *logfile = qemu_log_trylock();
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end
2024-05-21 21:06 [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end Richard Henderson
2024-05-22 9:29 ` Bernhard Beschow
2024-05-22 17:11 ` Pierrick Bouvier
@ 2024-05-27 9:37 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-05-27 9:37 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: Bernhard Beschow
On 21/5/24 23:06, Richard Henderson wrote:
> When passing disassembly data to plugin callbacks,
> translator_st_len relies on db->tb->size having been set.
>
> Fixes: 4c833c60e047 ("disas: Use translator_st to get disassembly data")
> Reported-by: Bernhard Beschow <shentey@gmail.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/translator.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Oops, missed.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-27 9:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 21:06 [PATCH] accel/tcg: Init tb size and icount before plugin_gen_tb_end Richard Henderson
2024-05-22 9:29 ` Bernhard Beschow
2024-05-22 17:11 ` Pierrick Bouvier
2024-05-27 9:37 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).