Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Switch x86_lockpatch[] -> HOTPATCH().
details: https://anonhg.NetBSD.org/src/rev/468c74390fc4
branches: trunk
changeset: 358547:468c74390fc4
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Jan 07 13:15:23 2018 +0000
description:
Switch x86_lockpatch[] -> HOTPATCH().
diffstat:
sys/arch/amd64/amd64/lock_stubs.S | 19 ++++---------------
sys/arch/amd64/include/frameasm.h | 3 ++-
sys/arch/i386/i386/lock_stubs.S | 17 ++++++-----------
sys/arch/i386/include/frameasm.h | 6 +++++-
sys/arch/x86/x86/patch.c | 18 +++++++++---------
5 files changed, 26 insertions(+), 37 deletions(-)
diffs (175 lines):
diff -r e4504fac75d8 -r 468c74390fc4 sys/arch/amd64/amd64/lock_stubs.S
--- a/sys/arch/amd64/amd64/lock_stubs.S Sun Jan 07 12:42:46 2018 +0000
+++ b/sys/arch/amd64/amd64/lock_stubs.S Sun Jan 07 13:15:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock_stubs.S,v 1.26 2016/04/11 14:14:27 bouyer Exp $ */
+/* $NetBSD: lock_stubs.S,v 1.27 2018/01/07 13:15:23 maxv Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -47,7 +47,9 @@
#include "assym.h"
#define ENDLABEL(name,a) .align a; LABEL(name)
-#define LOCK(num) .Lpatch ## num: lock
+#define LOCK(num) \
+ HOTPATCH(HP_NAME_NOLOCK, 1) ; \
+ lock
#define RET(num) .Lret ## num: ret; nop; nop; ret
#ifndef LOCKDEBUG
@@ -333,19 +335,6 @@
RET(8)
END(__cpu_simple_lock_try)
-/*
- * Patchpoints to replace with NOP when ncpu == 1.
- */
-#ifndef LOCKDEBUG
- .type _C_LABEL(x86_lockpatch), @object
-LABEL(x86_lockpatch)
- .quad .Lpatch1, .Lpatch2, .Lpatch3, .Lpatch4
- .quad .Lpatch5, .Lpatch6, .Lpatch7, .Lpatch8
- .quad .Lpatch9
- .quad 0
-END(x86_lockpatch)
-#endif
-
.type _C_LABEL(x86_retpatch), @object
LABEL(x86_retpatch)
#ifndef LOCKDEBUG
diff -r e4504fac75d8 -r 468c74390fc4 sys/arch/amd64/include/frameasm.h
--- a/sys/arch/amd64/include/frameasm.h Sun Jan 07 12:42:46 2018 +0000
+++ b/sys/arch/amd64/include/frameasm.h Sun Jan 07 13:15:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: frameasm.h,v 1.24 2018/01/07 12:42:46 maxv Exp $ */
+/* $NetBSD: frameasm.h,v 1.25 2018/01/07 13:15:23 maxv Exp $ */
#ifndef _AMD64_MACHINE_FRAMEASM_H
#define _AMD64_MACHINE_FRAMEASM_H
@@ -37,6 +37,7 @@
#define HP_NAME_CLAC 1
#define HP_NAME_STAC 2
+#define HP_NAME_NOLOCK 3
#define HOTPATCH(name, size) \
123: ; \
diff -r e4504fac75d8 -r 468c74390fc4 sys/arch/i386/i386/lock_stubs.S
--- a/sys/arch/i386/i386/lock_stubs.S Sun Jan 07 12:42:46 2018 +0000
+++ b/sys/arch/i386/i386/lock_stubs.S Sun Jan 07 13:15:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock_stubs.S,v 1.26 2014/01/12 20:31:50 joerg Exp $ */
+/* $NetBSD: lock_stubs.S,v 1.27 2018/01/07 13:15:24 maxv Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -35,17 +35,20 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.26 2014/01/12 20:31:50 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.S,v 1.27 2018/01/07 13:15:24 maxv Exp $");
#include "opt_lockdebug.h"
#include <machine/cputypes.h>
+#include <machine/frameasm.h>
#include "assym.h"
#define ALIGN64 .align 64
#define ALIGN32 .align 32
-#define LOCK(num) .Lpatch ## num: lock
+#define LOCK(num) \
+ HOTPATCH(HP_NAME_NOLOCK, 1) ; \
+ lock
#define RET(num) .Lret ## num: ret; nop; nop; ret
#define ENDLABEL(name,a) .align a; LABEL(name)
@@ -361,14 +364,6 @@
*/
.data
-#ifndef LOCKDEBUG
-LABEL(x86_lockpatch)
- .long .Lpatch1, .Lpatch2, .Lpatch3, .Lpatch4
- .long .Lpatch5, .Lpatch6, .Lpatch7, .Lpatch12
- .long .Lpatch13
- .long 0
-#endif
-
LABEL(x86_retpatch)
#ifndef LOCKDEBUG
.long .Lret1, .Lret2, .Lret3, .Lret4, .Lret5
diff -r e4504fac75d8 -r 468c74390fc4 sys/arch/i386/include/frameasm.h
--- a/sys/arch/i386/include/frameasm.h Sun Jan 07 12:42:46 2018 +0000
+++ b/sys/arch/i386/include/frameasm.h Sun Jan 07 13:15:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: frameasm.h,v 1.19 2018/01/07 12:42:47 maxv Exp $ */
+/* $NetBSD: frameasm.h,v 1.20 2018/01/07 13:15:24 maxv Exp $ */
#ifndef _I386_FRAMEASM_H_
#define _I386_FRAMEASM_H_
@@ -27,6 +27,10 @@
testb $0xff,EVTCHN_UPCALL_PENDING(reg)
#endif
+#define HP_NAME_CLAC 1
+#define HP_NAME_STAC 2
+#define HP_NAME_NOLOCK 3
+
#define HOTPATCH(name, size) \
123: ; \
.section .rodata.hotpatch, "a" ; \
diff -r e4504fac75d8 -r 468c74390fc4 sys/arch/x86/x86/patch.c
--- a/sys/arch/x86/x86/patch.c Sun Jan 07 12:42:46 2018 +0000
+++ b/sys/arch/x86/x86/patch.c Sun Jan 07 13:15:23 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: patch.c,v 1.26 2018/01/07 12:42:46 maxv Exp $ */
+/* $NetBSD: patch.c,v 1.27 2018/01/07 13:15:24 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.26 2018/01/07 12:42:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.27 2018/01/07 13:15:24 maxv Exp $");
#include "opt_lockdebug.h"
#ifdef i386
@@ -83,7 +83,6 @@
void _atomic_cas_cx8(void);
void _atomic_cas_cx8_end(void);
-extern void *x86_lockpatch[];
extern void *x86_retpatch[];
extern void *atomic_lockpatch[];
@@ -195,17 +194,18 @@
#if !defined(GPROF)
if (!early && ncpu == 1) {
#ifndef LOCKDEBUG
+ /*
+ * Uniprocessor: kill LOCK prefixes.
+ */
const uint8_t bytes[] = {
X86_NOP
};
- /* Uniprocessor: kill LOCK prefixes. */
- for (i = 0; x86_lockpatch[i] != 0; i++)
- patchbytes(x86_lockpatch[i], bytes, sizeof(bytes));
- for (i = 0; atomic_lockpatch[i] != 0; i++)
- patchbytes(atomic_lockpatch[i], bytes, sizeof(bytes));
-#endif /* !LOCKDEBUG */
+ /* lock -> nop */
+ x86_hotpatch(HP_NAME_NOLOCK, bytes, sizeof(bytes));
+#endif
}
+
if (!early && (cpu_feature[0] & CPUID_SSE2) != 0) {
/*
* Faster memory barriers. We do not need to patch
Home |
Main Index |
Thread Index |
Old Index