summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-12-13 17:40:14 +0200
committerAvi Kivity <avi@qumranet.com>2007-12-13 17:40:14 +0200
commit37454a38f13f5d97c8c6589eb0be4f0f161e794e (patch)
tree1ccd3f17ddf544d228c7514d1ad10a7f75aaba0f /kernel
parent8778f7f9c1c96cbe671815afb54cac5b47fa28eb (diff)
kvm: external module: cmpxchg64() compatibility
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/external-module-compat.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/external-module-compat.h b/kernel/external-module-compat.h
index ea94f305..1dc5a967 100644
--- a/kernel/external-module-compat.h
+++ b/kernel/external-module-compat.h
@@ -322,6 +322,28 @@ static inline void __kvm_set_64bit(u64 *ptr, u64 val)
#undef set_64bit
#define set_64bit __kvm_set_64bit
+static inline unsigned long long __kvm_cmpxchg64(volatile void *ptr,
+ unsigned long long old,
+ unsigned long long new)
+{
+ unsigned long long prev;
+ __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
+ : "=A"(prev)
+ : "b"((unsigned long)new),
+ "c"((unsigned long)(new >> 32)),
+ "m"(*__xg(ptr)),
+ "0"(old)
+ : "memory");
+ return prev;
+}
+
+#define kvm_cmpxchg64(ptr,o,n)\
+ ((__typeof__(*(ptr)))__kvm_cmpxchg64((ptr),(unsigned long long)(o),\
+ (unsigned long long)(n)))
+
+#undef cmpxchg64
+#define cmpxchg64(ptr, o, n) kvm_cmpxchg64(ptr, o, n)
+
#endif
#ifndef CONFIG_PREEMPT_NOTIFIERS