diff mbox

translate: early exit in tb_flush if there is no tcg

Message ID 1472148686-39841-1-git-send-email-borntraeger@de.ibm.com
State New
Headers show

Commit Message

Christian Borntraeger Aug. 25, 2016, 6:11 p.m. UTC
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").

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Reported-by: Richard Henderson <rth@twiddle.net>
Reported-by: Brent Baccala <cosine@freesoft.org>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 translate-all.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Christian Borntraeger Aug. 25, 2016, 6:38 p.m. UTC | #1
On 08/25/2016 02:11 PM, Christian Borntraeger wrote:
> 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.

> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
> Reported-by: Richard Henderson <rth@twiddle.net>
> Reported-by: Brent Baccala <cosine@freesoft.org>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  translate-all.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/translate-all.c b/translate-all.c
> index efeba29..0dd6466 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -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),
>
Peter Maydell Aug. 30, 2016, 12:57 p.m. UTC | #2
On 25 August 2016 at 19:38, Christian Borntraeger
<borntraeger@de.ibm.com> wrote:
> On 08/25/2016 02:11 PM, Christian Borntraeger wrote:
>> 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.
>
>> Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
>> Reported-by: Richard Henderson <rth@twiddle.net>
>> Reported-by: Brent Baccala <cosine@freesoft.org>
>> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
>> ---
>>  translate-all.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/translate-all.c b/translate-all.c
>> index efeba29..0dd6466 100644
>> --- a/translate-all.c
>> +++ b/translate-all.c
>> @@ -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
diff mbox

Patch

diff --git a/translate-all.c b/translate-all.c
index efeba29..0dd6466 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -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),