Switch x86_lockpatch[] -> HOTPATCH().

This commit is contained in:
maxv 2018-01-07 13:15:23 +00:00
parent 99d8611c28
commit 9ef803fea5
5 changed files with 26 additions and 37 deletions

View File

@ -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 @@ ENTRY(__cpu_simple_lock_try)
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

View File

@ -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: ; \

View File

@ -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 @@ END(__cpu_simple_lock_try)
*/
.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

View File

@ -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" ; \

View File

@ -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_64_end(void);
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 @@ x86_patch(bool early)
#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