diff options
author | kib <kib@FreeBSD.org> | 2008-12-05 21:17:54 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2008-12-05 21:17:54 +0000 |
commit | ffffd56bb1825f5b368552057f4ec22d7a8d091c (patch) | |
tree | 4e5d49a323133d940541ef8714de5f3c002d6bc3 /sys/i386 | |
parent | ccad2ebfb201232304a87b7e7df40462dbede7b5 (diff) | |
download | FreeBSD-src-ffffd56bb1825f5b368552057f4ec22d7a8d091c.zip FreeBSD-src-ffffd56bb1825f5b368552057f4ec22d7a8d091c.tar.gz |
Unconditionally use locked addition of zero to tip of the stack for
memory barriers on i386. It works as a serialization instruction on
all IA32 CPUs.
Alternative solution of using {s,l,}fence requires run-time checking
of the presense of the corresponding SSE or SSE2 extensions, and
possible boot-time patching of the kernel text.
Suggested by: many
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/include/atomic.h | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/sys/i386/include/atomic.h b/sys/i386/include/atomic.h index f6bcf0c..e800d0e 100644 --- a/sys/i386/include/atomic.h +++ b/sys/i386/include/atomic.h @@ -32,20 +32,9 @@ #error this file needs sys/cdefs.h as a prerequisite #endif - -#if defined(I686_CPU) -#define mb() __asm__ __volatile__ ("mfence;": : :"memory") -#define wmb() __asm__ __volatile__ ("sfence;": : :"memory") -#define rmb() __asm__ __volatile__ ("lfence;": : :"memory") -#else -/* - * do we need a serializing instruction? - */ -#define mb() -#define wmb() -#define rmb() -#endif - +#define mb() __asm __volatile("lock;addl $0,(%esp)") +#define wmb() __asm __volatile("lock;addl $0,(%esp)") +#define rmb() __asm __volatile("lock;addl $0,(%esp)") /* * Various simple operations on memory, each of which is atomic in the |