diff mbox

[kvm-unit-tests,v7,05/11] x86: Introduce lib/x86/asm/barrier.h

Message ID 725a2f02f6459bd7fbeb8b52c8b9614e011b07cf.1462457467.git.agordeev@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Gordeev May 5, 2016, 2:26 p.m. UTC
Make x86 consistent with other architectures and put
memory barrier defines to lib/x86/asm/barrier.h

Cc: Andrew Jones <drjones@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Radim Kr?má? <rkrcmar@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 lib/x86/asm/barrier.h | 13 +++++++++++++
 lib/x86/smp.h         |  4 ----
 x86/hyperv_stimer.c   |  1 +
 x86/kvmclock.c        |  1 +
 4 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100644 lib/x86/asm/barrier.h
diff mbox

Patch

diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
new file mode 100644
index 0000000..d602a2c
--- /dev/null
+++ b/lib/x86/asm/barrier.h
@@ -0,0 +1,13 @@ 
+#ifndef _ASM_X86_BARRIER_H_
+#define _ASM_X86_BARRIER_H_
+/*
+ * Copyright (C) 2016, Red Hat Inc, Alexander Gordeev <agordeev@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.
+ */
+
+#define mb()	asm volatile("mfence":::"memory")
+#define rmb()	asm volatile("lfence":::"memory")
+#define wmb()	asm volatile("sfence":::"memory")
+
+#endif
diff --git a/lib/x86/smp.h b/lib/x86/smp.h
index 566018f..afabac8 100644
--- a/lib/x86/smp.h
+++ b/lib/x86/smp.h
@@ -2,10 +2,6 @@ 
 #define __SMP_H
 #include <asm/spinlock.h>
 
-#define mb() 	asm volatile("mfence":::"memory")
-#define rmb()	asm volatile("lfence":::"memory")
-#define wmb()	asm volatile("sfence" ::: "memory")
-
 void smp_init(void);
 
 int cpu_count(void);
diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c
index 9a971ef..6382938 100644
--- a/x86/hyperv_stimer.c
+++ b/x86/hyperv_stimer.c
@@ -8,6 +8,7 @@ 
 #include "smp.h"
 #include "atomic.h"
 #include "hyperv.h"
+#include "asm/barrier.h"
 
 #define MAX_CPUS 4
 
diff --git a/x86/kvmclock.c b/x86/kvmclock.c
index 327e60d..208d43c 100644
--- a/x86/kvmclock.c
+++ b/x86/kvmclock.c
@@ -3,6 +3,7 @@ 
 #include "atomic.h"
 #include "processor.h"
 #include "kvmclock.h"
+#include "asm/barrier.h"
 
 #define unlikely(x)	__builtin_expect(!!(x), 0)
 #define likely(x)	__builtin_expect(!!(x), 1)