From: Richard Henderson Date: Tue, 23 Sep 2025 20:26:53 +0000 (-0700) Subject: accel/tcg: Improve buffer overflow in tb_gen_code X-Git-Tag: v10.2.0-rc1~97^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebf7a5d294a336c7701018884587646d89030073;p=thirdparty%2Fqemu.git accel/tcg: Improve buffer overflow in tb_gen_code If we only have one vcpu, or within cpu_exec_step_atomic, we needn't jump all the way back out to the cpu loop to empty the code gen buffer. Signed-off-by: Richard Henderson --- diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 31bc0f8bc58..da9d7f16752 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -289,6 +289,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, TCGTBCPUState s) tb = tcg_tb_alloc(tcg_ctx); if (unlikely(!tb)) { /* flush must be done */ + if (cpu_in_serial_context(cpu)) { + tb_flush__exclusive_or_serial(); + goto buffer_overflow; + } queue_tb_flush(cpu); mmap_unlock(); /* Make the execution loop process the flush as soon as possible. */