summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-04-09 12:07:29 +0000
committerriastradh <riastradh@NetBSD.org>2022-04-09 12:07:29 +0000
commiteb4604b3cc117526802475fd11541c9ca3ba96f7 (patch)
tree7b4e9c3b95a7b7b0cda855ac371fc73705e11f92 /common
parent4b86535e66bcd3b963eb5d5c7153bf2816be6c58 (diff)
x86: Add a note on membar_sync and mfence.
Diffstat (limited to 'common')
-rw-r--r--common/lib/libc/arch/i386/atomic/atomic.S8
-rw-r--r--common/lib/libc/arch/x86_64/atomic/atomic.S8
2 files changed, 14 insertions, 2 deletions
diff --git a/common/lib/libc/arch/i386/atomic/atomic.S b/common/lib/libc/arch/i386/atomic/atomic.S
index ea752023326..f46d91fbc5a 100644
--- a/common/lib/libc/arch/i386/atomic/atomic.S
+++ b/common/lib/libc/arch/i386/atomic/atomic.S
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.S,v 1.32 2022/04/09 12:07:17 riastradh Exp $ */
+/* $NetBSD: atomic.S,v 1.33 2022/04/09 12:07:29 riastradh Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -197,6 +197,12 @@ ENTRY(_membar_producer)
END(_membar_producer)
ENTRY(_membar_sync)
+ /*
+ * MFENCE, or a serializing instruction like a locked addq,
+ * is necessary to order store-before-load. Every other
+ * ordering -- load-before-anything, anything-before-store --
+ * is already guaranteed without explicit barriers.
+ */
HOTPATCH_SSE2_MFENCE
/* 7 bytes of instructions */
LOCK
diff --git a/common/lib/libc/arch/x86_64/atomic/atomic.S b/common/lib/libc/arch/x86_64/atomic/atomic.S
index 4e845abca91..c784d087cfd 100644
--- a/common/lib/libc/arch/x86_64/atomic/atomic.S
+++ b/common/lib/libc/arch/x86_64/atomic/atomic.S
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.S,v 1.25 2022/04/09 12:07:17 riastradh Exp $ */
+/* $NetBSD: atomic.S,v 1.26 2022/04/09 12:07:29 riastradh Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -272,6 +272,12 @@ ENTRY(_membar_producer)
END(_membar_producer)
ENTRY(_membar_sync)
+ /*
+ * MFENCE, or a serializing instruction like a locked addq,
+ * is necessary to order store-before-load. Every other
+ * ordering -- load-before-anything, anything-before-store --
+ * is already guaranteed without explicit barriers.
+ */
HOTPATCH_SSE2_MFENCE
/* 8 bytes of instructions */
LOCK