Skip to contentSkip to conversation

translate: early exit in tb_flush if there is no tcg

PATCH Applied Christian Borntraeger 2 participants 3 messages Aug 25, 2016 – Aug 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 translate: early exit in tb_flush if there is no tcg

tb_flush does all kind of things, which are very tcg specific. As it is called from some places even for KVM (e.g. gdb server) it is better to detect these cases and do an early exit.
This also fixes a crash in the gdb server that was triggered by commit 909eaac9bbc2 ("tb hash: track translated blocks with qht").

---
 translate-all.c | 3 +++
 1 file changed, 3 insertions(+)
translate-all.c +3 -0
index efeba29..0dd6466 100644
@@ -834,6 +834,9 @@ static void page_flush_tb(void)
 /* XXX: tb_flush is currently not thread safe */
 void tb_flush(CPUState *cpu)
 {
+    if (!tcg_enabled()) {
+        return;
+    }
 #if defined(DEBUG_FLUSH)
     printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n",
            (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer),
Signature · 1 line
2.5.5
#1 lore raw
Quoted 6 lines · Christian Borntraeger

tb_flush does all kind of things, which are very tcg specific. As it is called from some places even for KVM (e.g. gdb server) it is better to detect these cases and do an early exit.
This also fixes a crash in the gdb server that was triggered by commit 909eaac9bbc2 ("tb hash: track translated blocks with qht").

Forgot to CC Peter.

Quoted 23 lines
---
 translate-all.c | 3 +++
 1 file changed, 3 insertions(+)
translate-all.c +3 -0
index efeba29..0dd6466 100644
@@ -834,6 +834,9 @@ static void page_flush_tb(void)
 /* XXX: tb_flush is currently not thread safe */
 void tb_flush(CPUState *cpu)
 {
+    if (!tcg_enabled()) {
+        return;
+    }
 #if defined(DEBUG_FLUSH)
     printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n",
            (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer),
#2 lore raw
Quoted 18 lines · Christian Borntraeger
Quoted 6 lines · Christian Borntraeger

tb_flush does all kind of things, which are very tcg specific. As it is called from some places even for KVM (e.g. gdb server) it is better to detect these cases and do an early exit.
This also fixes a crash in the gdb server that was triggered by commit 909eaac9bbc2 ("tb hash: track translated blocks with qht").

Forgot to CC Peter.

Quoted 8 lines
---
 translate-all.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 15 lines
Quoted 6 lines
translate-all.c +0 -0
index efeba29..0dd6466 100644

translate-all.c static void page_flush_tb(void) · line 842

Quoted 9 lines
translate-all.c +3 -0
@@ -834,6 +834,9 @@ static void page_flush_tb(void)
 /* XXX: tb_flush is currently not thread safe */
 void tb_flush(CPUState *cpu)
 {
+    if (!tcg_enabled()) {
+        return;
+    }
 #if defined(DEBUG_FLUSH)
     printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n",
            (unsigned long)(tcg_ctx.code_gen_ptr - tcg_ctx.code_gen_buffer),

Applied to master, thanks.

-- PMM