mirror of
https://github.com/xemu-project/xemu.git
synced 2026-07-11 01:24:41 +02:00
accel/tcg: Move post-load tb_flush to vm_change_state hook
We need not call tb_flush once per cpu, only once per vmload. By moving the call from cpu_common_post_load to a tcg-specific vm_change_state_handler, we do even better than that: we only flush when called from HMP triggered loadvm, when we had old state to flush. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
#include "qemu/target-info.h"
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
#include "hw/boards.h"
|
||||
#include "exec/tb-flush.h"
|
||||
#include "system/runstate.h"
|
||||
#endif
|
||||
#include "accel/accel-ops.h"
|
||||
#include "accel/accel-cpu-ops.h"
|
||||
@@ -82,6 +84,23 @@ static void tcg_accel_instance_init(Object *obj)
|
||||
|
||||
bool one_insn_per_tb;
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
static void tcg_vm_change_state(void *opaque, bool running, RunState state)
|
||||
{
|
||||
if (state == RUN_STATE_RESTORE_VM) {
|
||||
/*
|
||||
* loadvm will update the content of RAM, bypassing the usual
|
||||
* mechanisms that ensure we flush TBs for writes to memory
|
||||
* we've translated code from, so we must flush all TBs.
|
||||
*
|
||||
* vm_stop() has just stopped all cpus, so we are exclusive.
|
||||
*/
|
||||
assert(!running);
|
||||
tb_flush__exclusive_or_serial();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int tcg_init_machine(AccelState *as, MachineState *ms)
|
||||
{
|
||||
TCGState *s = TCG_STATE(as);
|
||||
@@ -124,6 +143,8 @@ static int tcg_init_machine(AccelState *as, MachineState *ms)
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
qemu_add_vm_change_state_handler(tcg_vm_change_state, NULL);
|
||||
#endif
|
||||
|
||||
tcg_allowed = true;
|
||||
|
||||
Reference in New Issue
Block a user