From: KONRAD Frederic <fred.kon...@greensocs.com> tb_flush is not thread safe we definitely need to exit VCPUs to do that. This introduces tb_flush_safe which just creates an async safe work which will do a tb_flush later.
Signed-off-by: KONRAD Frederic <fred.kon...@greensocs.com> --- include/exec/exec-all.h | 1 + translate-all.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e9512df..246df68 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -200,6 +200,7 @@ struct TBContext { void tb_free(TranslationBlock *tb); void tb_flush(CPUState *cpu); +void tb_flush_safe(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); #if defined(USE_DIRECT_JUMP) diff --git a/translate-all.c b/translate-all.c index fc5162a..7094bf0 100644 --- a/translate-all.c +++ b/translate-all.c @@ -818,6 +818,21 @@ static void page_flush_tb(void) } } +static void tb_flush_work(void *opaque) +{ + CPUState *cpu = opaque; + tb_flush(cpu); +} + +void tb_flush_safe(CPUState *cpu) +{ +#if 0 /* !MTTCG */ + tb_flush(cpu); +#else + async_run_safe_work_on_cpu(cpu, tb_flush_work, cpu); +#endif /* MTTCG */ +} + /* flush all the translation blocks */ /* XXX: tb_flush is currently not thread safe */ void tb_flush(CPUState *cpu) -- 1.9.0