提交 1d93f0f0 编写于 作者: J Jan Kiszka 提交者: Aurelien Jarno

Introduce proper compiler barrier

Define barrier() as optimization barrier and replace (potentially
unreliable) asm("") fences.
Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
Acked-by: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
上级 1e29a009
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "disas.h" #include "disas.h"
#include "tcg.h" #include "tcg.h"
#include "kvm.h" #include "kvm.h"
#include "qemu-barrier.h"
#if !defined(CONFIG_SOFTMMU) #if !defined(CONFIG_SOFTMMU)
#undef EAX #undef EAX
...@@ -233,7 +234,7 @@ int cpu_exec(CPUState *env1) ...@@ -233,7 +234,7 @@ int cpu_exec(CPUState *env1)
use it. */ use it. */
QEMU_BUILD_BUG_ON (sizeof (saved_env_reg) != sizeof (env)); QEMU_BUILD_BUG_ON (sizeof (saved_env_reg) != sizeof (env));
saved_env_reg = (host_reg_t) env; saved_env_reg = (host_reg_t) env;
asm(""); barrier();
env = env1; env = env1;
if (exit_request) { if (exit_request) {
...@@ -669,7 +670,7 @@ int cpu_exec(CPUState *env1) ...@@ -669,7 +670,7 @@ int cpu_exec(CPUState *env1)
#endif #endif
/* restore global registers */ /* restore global registers */
asm(""); barrier();
env = (void *) saved_env_reg; env = (void *) saved_env_reg;
/* fail safe : never use cpu_single_env outside cpu_exec() */ /* fail safe : never use cpu_single_env outside cpu_exec() */
......
...@@ -4,4 +4,7 @@ ...@@ -4,4 +4,7 @@
/* FIXME: arch dependant, x86 version */ /* FIXME: arch dependant, x86 version */
#define smp_wmb() asm volatile("" ::: "memory") #define smp_wmb() asm volatile("" ::: "memory")
/* Compiler barrier */
#define barrier() asm volatile("" ::: "memory")
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册