Module Name: src
Committed By: maxv
Date: Sun Apr 26 13:37:15 UTC 2020
Modified Files:
src/common/lib/libc/arch/i386/atomic: atomic.S
src/common/lib/libc/arch/x86_64/atomic: atomic.S
src/sys/arch/x86/x86: patch.c
Log Message:
Drop the hardcoded array, use the hotpatch section.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/common/lib/libc/arch/i386/atomic/atomic.S
cvs rdiff -u -r1.18 -r1.19 src/common/lib/libc/arch/x86_64/atomic/atomic.S
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/x86/patch.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/common/lib/libc/arch/i386/atomic/atomic.S
diff -u src/common/lib/libc/arch/i386/atomic/atomic.S:1.24 src/common/lib/libc/arch/i386/atomic/atomic.S:1.25
--- src/common/lib/libc/arch/i386/atomic/atomic.S:1.24 Sat Apr 25 15:26:16 2020
+++ src/common/lib/libc/arch/i386/atomic/atomic.S Sun Apr 26 13:37:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.S,v 1.24 2020/04/25 15:26:16 bouyer Exp $ */
+/* $NetBSD: atomic.S,v 1.25 2020/04/26 13:37:14 maxv Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -44,7 +44,8 @@
#ifdef _HARDKERNEL
#include "opt_xen.h"
-#define LOCK(n) .Lpatch ## n: lock
+#include <machine/frameasm.h>
+#define LOCK(n) HOTPATCH(HP_NAME_NOLOCK, 1); lock
#define ENDLABEL(a) _ALIGN_TEXT; LABEL(a)
#else
#define LOCK(n) lock
@@ -269,12 +270,6 @@ ENTRY(sse2_mfence)
ret
END(sse2_mfence)
ENDLABEL(sse2_mfence_end)
-
-atomic_lockpatch:
- .globl atomic_lockpatch
- .long .Lpatch1, .Lpatch2, .Lpatch3, .Lpatch4, .Lpatch5
- .long .Lpatch6, .Lpatch7, .Lpatch8, .Lpatch9, .Lpatch10
- .long .Lpatch12, .Lpatch13, .Lpatch14, .Lpatch15, 0
#endif /* _HARDKERNEL */
ALIAS(atomic_add_32,_atomic_add_32)
Index: src/common/lib/libc/arch/x86_64/atomic/atomic.S
diff -u src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.18 src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.19
--- src/common/lib/libc/arch/x86_64/atomic/atomic.S:1.18 Sun Feb 17 07:34:44 2019
+++ src/common/lib/libc/arch/x86_64/atomic/atomic.S Sun Apr 26 13:37:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.S,v 1.18 2019/02/17 07:34:44 isaki Exp $ */
+/* $NetBSD: atomic.S,v 1.19 2020/04/26 13:37:14 maxv Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -39,7 +39,8 @@
#endif
#ifdef _HARDKERNEL
-#define LOCK(n) .Lpatch ## n: lock
+#include <machine/frameasm.h>
+#define LOCK(n) HOTPATCH(HP_NAME_NOLOCK, 1); lock
#define ENDLABEL(a) _ALIGN_TEXT; LABEL(a)
#else
#define LOCK(n) lock
@@ -285,15 +286,6 @@ ENTRY(sse2_mfence)
ret
END(sse2_mfence)
ENDLABEL(sse2_mfence_end)
-
-atomic_lockpatch:
- .globl atomic_lockpatch
- .quad .Lpatch1, .Lpatch2, .Lpatch3, .Lpatch4, .Lpatch5
- .quad .Lpatch6, .Lpatch7, .Lpatch8, .Lpatch9, .Lpatch10
- .quad .Lpatch12, .Lpatch13, .Lpatch14, .Lpatch15
- .quad .Lpatch16, .Lpatch17, .Lpatch18, .Lpatch19, .Lpatch20
- .quad .Lpatch21, .Lpatch22, .Lpatch24, .Lpatch25
- .quad .Lpatch26, 0
#endif /* _HARDKERNEL */
ALIAS(atomic_add_32,_atomic_add_32)
Index: src/sys/arch/x86/x86/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.40 src/sys/arch/x86/x86/patch.c:1.41
--- src/sys/arch/x86/x86/patch.c:1.40 Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/x86/patch.c Sun Apr 26 13:37:14 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: patch.c,v 1.40 2020/04/25 15:26:18 bouyer Exp $ */
+/* $NetBSD: patch.c,v 1.41 2020/04/26 13:37:14 maxv Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.40 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.41 2020/04/26 13:37:14 maxv Exp $");
#include "opt_lockdebug.h"
#ifdef i386
@@ -83,8 +83,6 @@ void _atomic_cas_64_end(void);
void _atomic_cas_cx8(void);
void _atomic_cas_cx8_end(void);
-extern void *atomic_lockpatch[];
-
#define X86_NOP 0x90
#define X86_REP 0xf3
#define X86_RET 0xc3
@@ -211,8 +209,6 @@ x86_patch(bool early)
/* lock -> nop */
x86_hotpatch(HP_NAME_NOLOCK, bytes, sizeof(bytes));
- for (int i = 0; atomic_lockpatch[i] != 0; i++)
- patchbytes(atomic_lockpatch[i], bytes, sizeof(bytes));
#endif
}