summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2022-04-09 12:07:00 +0000
committerriastradh <riastradh@NetBSD.org>2022-04-09 12:07:00 +0000
commitada4ec3b9731eac4133a1d2cd45d9cd339255aea (patch)
treee73817fe5e9ed7350331e64ba4d07164ccd13122 /common
parentb0368ae930fa0dda589992ab92624911dfd107dc (diff)
x86: Every load is a load-acquire, so membar_consumer is a noop.
lfence is only needed for MD logic, such as operations on I/O memory rather than normal cacheable memory, or special instructions like RDTSC -- never for MI synchronization between threads/CPUs. No need for hot-patching to do lfence here. (The x86_lfence function might reasonably be patched on i386 to do lfence for MD logic, but it isn't now and this doesn't change that.)
Diffstat (limited to 'common')
-rw-r--r--common/lib/libc/arch/i386/atomic/atomic.S19
-rw-r--r--common/lib/libc/arch/x86_64/atomic/atomic.S19
2 files changed, 12 insertions, 26 deletions
diff --git a/common/lib/libc/arch/i386/atomic/atomic.S b/common/lib/libc/arch/i386/atomic/atomic.S
index db801550bd2..fe29a5294a4 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.30 2022/04/06 22:47:56 riastradh Exp $ */
+/* $NetBSD: atomic.S,v 1.31 2022/04/09 12:07:00 riastradh Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -46,12 +46,10 @@
#include "opt_xen.h"
#include <machine/frameasm.h>
#define LOCK HOTPATCH(HP_NAME_NOLOCK, 1); lock
-#define HOTPATCH_SSE2_LFENCE HOTPATCH(HP_NAME_SSE2_LFENCE, 7);
#define HOTPATCH_SSE2_MFENCE HOTPATCH(HP_NAME_SSE2_MFENCE, 7);
#define HOTPATCH_CAS_64 HOTPATCH(HP_NAME_CAS_64, 49);
#else
#define LOCK lock
-#define HOTPATCH_SSE2_LFENCE /* nothing */
#define HOTPATCH_SSE2_MFENCE /* nothing */
#define HOTPATCH_CAS_64 /* nothing */
#endif
@@ -181,10 +179,11 @@ ENTRY(_atomic_cas_32_ni)
END(_atomic_cas_32_ni)
ENTRY(_membar_consumer)
- HOTPATCH_SSE2_LFENCE
- /* 7 bytes of instructions */
- LOCK
- addl $0, -4(%esp)
+ /*
+ * Every load from normal memory is a load-acquire on x86, so
+ * there is never any need for explicit barriers to order
+ * load-before-anything.
+ */
ret
END(_membar_consumer)
@@ -396,12 +395,6 @@ STRONG_ALIAS(_membar_exit,_membar_producer)
#ifdef _HARDKERNEL
.section .rodata
-LABEL(sse2_lfence)
- lfence
- ret
- nop; nop; nop;
-LABEL(sse2_lfence_end)
-
LABEL(sse2_mfence)
mfence
ret
diff --git a/common/lib/libc/arch/x86_64/atomic/atomic.S b/common/lib/libc/arch/x86_64/atomic/atomic.S
index 7f18d12e87e..1a627c221c7 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.23 2022/04/06 22:47:57 riastradh Exp $ */
+/* $NetBSD: atomic.S,v 1.24 2022/04/09 12:07:00 riastradh Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -41,11 +41,9 @@
#ifdef _HARDKERNEL
#include <machine/frameasm.h>
#define LOCK HOTPATCH(HP_NAME_NOLOCK, 1); lock
-#define HOTPATCH_SSE2_LFENCE HOTPATCH(HP_NAME_SSE2_LFENCE, 8);
#define HOTPATCH_SSE2_MFENCE HOTPATCH(HP_NAME_SSE2_MFENCE, 8);
#else
#define LOCK lock
-#define HOTPATCH_SSE2_LFENCE /* nothing */
#define HOTPATCH_SSE2_MFENCE /* nothing */
#endif
@@ -256,10 +254,11 @@ END(_atomic_cas_64_ni)
/* memory barriers */
ENTRY(_membar_consumer)
- HOTPATCH_SSE2_LFENCE
- /* 8 bytes of instructions */
- LOCK
- addq $0, -8(%rsp)
+ /*
+ * Every load from normal memory is a load-acquire on x86, so
+ * there is never any need for explicit barriers to order
+ * load-before-anything.
+ */
ret
END(_membar_consumer)
@@ -419,12 +418,6 @@ STRONG_ALIAS(_membar_exit,_membar_producer)
#ifdef _HARDKERNEL
.section .rodata
-LABEL(sse2_lfence)
- lfence
- ret
- nop; nop; nop; nop;
-LABEL(sse2_lfence_end)
-
LABEL(sse2_mfence)
mfence
ret