accel/tcg: Clear tcg_ctx->gen_tb on buffer overflow
authorRichard Henderson <richard.henderson@linaro.org>
Wed, 26 Jul 2023 19:58:08 +0000 (12:58 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Mon, 31 Jul 2023 19:19:13 +0000 (12:19 -0700)
On overflow of code_gen_buffer, we unlock the guest pages we had been
translating, but failed to clear gen_tb.  On restart, if we cannot
allocate a TB, we exit to the main loop to perform the flush of all
TBs as soon as possible.  With garbage in gen_tb, we hit an assert:

../src/accel/tcg/tb-maint.c:348:page_unlock__debug: \
    assertion failed: (page_is_locked(pd))

Fixes: deba78709ae8 ("accel/tcg: Always lock pages before translation")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
accel/tcg/translate-all.c

index a1782db5dd732508197d59ecb2a775ab59f099f9..b2d4e22c17d44e3ab47d5c2edbc2854fef9565a9 100644 (file)
@@ -374,6 +374,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
                           "Restarting code generation for "
                           "code_gen_buffer overflow\n");
             tb_unlock_pages(tb);
+            tcg_ctx->gen_tb = NULL;
             goto buffer_overflow;
 
         case -2: