X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=cpu-exec.c;h=31c089dac0a7db66ac4d6270c293d1294bbc598a;hb=035873283b3f7514ad77d409870ccfd5f9680d9e;hp=e74e55656a4028579562615b010472d999d3176a;hpb=404e7a4f4af753bd2aef649adf79e7434fb6dc31;p=qemu.git diff --git a/cpu-exec.c b/cpu-exec.c index e74e55656..31c089dac 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -23,8 +23,6 @@ #include "qemu/atomic.h" #include "sysemu/qtest.h" -//#define CONFIG_DEBUG_EXEC - bool qemu_cpu_has_work(CPUState *cpu) { return cpu_has_work(cpu); @@ -217,6 +215,14 @@ int cpu_exec(CPUArchState *env) cpu_single_env = env; + /* As long as cpu_single_env is null, up to the assignment just above, + * requests by other threads to exit the execution loop are expected to + * be issued using the exit_request global. We must make sure that our + * evaluation of the global value is performed past the cpu_single_env + * value transition point, which requires a memory barrier as well as + * an instruction scheduling constraint on modern architectures. */ + smp_mb(); + if (unlikely(exit_request)) { cpu->exit_request = 1; } @@ -567,7 +573,7 @@ int cpu_exec(CPUArchState *env) env->exception_index = EXCP_INTERRUPT; cpu_loop_exit(env); } -#if defined(DEBUG_DISAS) || defined(CONFIG_DEBUG_EXEC) +#if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) { /* restore flags in standard format */ #if defined(TARGET_I386) @@ -582,7 +588,7 @@ int cpu_exec(CPUArchState *env) log_cpu_state(env, 0); #endif } -#endif /* DEBUG_DISAS || CONFIG_DEBUG_EXEC */ +#endif /* DEBUG_DISAS */ spin_lock(&tcg_ctx.tb_ctx.tb_lock); tb = tb_find_fast(env); /* Note: we do it here to avoid a gcc bug on Mac OS X when @@ -594,11 +600,10 @@ int cpu_exec(CPUArchState *env) next_tb = 0; tcg_ctx.tb_ctx.tb_invalidated_flag = 0; } -#ifdef CONFIG_DEBUG_EXEC - qemu_log_mask(CPU_LOG_EXEC, "Trace %p [" TARGET_FMT_lx "] %s\n", - tb->tc_ptr, tb->pc, - lookup_symbol(tb->pc)); -#endif + if (qemu_loglevel_mask(CPU_LOG_EXEC)) { + qemu_log("Trace %p [" TARGET_FMT_lx "] %s\n", + tb->tc_ptr, tb->pc, lookup_symbol(tb->pc)); + } /* see if we can patch the calling TB. When the TB spans two pages, we cannot safely do a direct jump. */