aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86/system.h
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2007-11-21 11:38:51 +0000
committerKeir Fraser <keir.fraser@citrix.com>2007-11-21 11:38:51 +0000
commitbfa574998d0556c260f0e9fef1e0bf409f363d78 (patch)
treec251fb135e62e7670e145974bb90b56ad18cd29d /xen/include/asm-x86/system.h
parent8163649f9e2a6c48b3391bd05e2b4d83af1b4e8a (diff)
downloadxen-bfa574998d0556c260f0e9fef1e0bf409f363d78.tar.gz
xen-bfa574998d0556c260f0e9fef1e0bf409f363d78.tar.bz2
xen-bfa574998d0556c260f0e9fef1e0bf409f363d78.zip
x86: Make IDT/GDT/LDT updates safe.
This involves either determining that the entry will not be read/written while the update takes place, or atomically making the entry 'present', or doing the entire write atomically, as appropriate. This issue raised, and original patch provided, by Jan Beulich. Signed-off-by: Keir Fraser <keir.fraser@eu.citrix.com>
Diffstat (limited to 'xen/include/asm-x86/system.h')
-rw-r--r--xen/include/asm-x86/system.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
index c464e1d454..7d000522e7 100644
--- a/xen/include/asm-x86/system.h
+++ b/xen/include/asm-x86/system.h
@@ -256,6 +256,17 @@ static always_inline unsigned long long __cmpxchg8b(
})
#endif
+static inline void atomic_write64(uint64_t *p, uint64_t v)
+{
+#ifdef __i386__
+ uint64_t w = *p, x;
+ while ( (x = __cmpxchg8b(p, w, v)) != w )
+ w = x;
+#else
+ *p = v;
+#endif
+}
+
#if defined(__i386__)
#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
#define rmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")