Use the hotpatch framework when patching _atomic_cas_64.
This commit is contained in:
parent
23a77a734f
commit
712bef211f
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic.S,v 1.28 2020/04/26 14:49:17 maxv Exp $ */
|
||||
/* $NetBSD: atomic.S,v 1.29 2020/05/01 08:32:50 maxv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -48,12 +48,12 @@
|
|||
#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 ENDLABEL(a) _ALIGN_TEXT; LABEL(a)
|
||||
#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 ENDLABEL(a) /* nothing */
|
||||
#define HOTPATCH_CAS_64 /* nothing */
|
||||
#endif
|
||||
|
||||
.text
|
||||
|
@ -207,10 +207,12 @@ END(_membar_sync)
|
|||
STRONG_ALIAS(_atomic_cas_64,_atomic_cas_cx8)
|
||||
#else
|
||||
ENTRY(_atomic_cas_64)
|
||||
HOTPATCH_CAS_64
|
||||
/* 49 bytes of instructions */
|
||||
#ifdef _HARDKERNEL
|
||||
pushf
|
||||
cli
|
||||
#endif /* _HARDKERNEL */
|
||||
#endif
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl 12(%esp), %edi
|
||||
|
@ -229,17 +231,17 @@ ENTRY(_atomic_cas_64)
|
|||
popl %edi
|
||||
#ifdef _HARDKERNEL
|
||||
popf
|
||||
#endif /* _HARDKERNEL */
|
||||
#endif
|
||||
ret
|
||||
2:
|
||||
movl 0(%edi), %eax
|
||||
movl 4(%edi), %edx
|
||||
jmp 1b
|
||||
END(_atomic_cas_64)
|
||||
ENDLABEL(_atomic_cas_64_end)
|
||||
#endif /* !XEN */
|
||||
#endif /* !XENPV */
|
||||
|
||||
ENTRY(_atomic_cas_cx8)
|
||||
/* 49 bytes of instructions */
|
||||
pushl %edi
|
||||
pushl %ebx
|
||||
movl 12(%esp), %edi
|
||||
|
@ -253,14 +255,10 @@ ENTRY(_atomic_cas_cx8)
|
|||
popl %edi
|
||||
ret
|
||||
#ifdef _HARDKERNEL
|
||||
#ifdef GPROF
|
||||
.space 16, 0x90
|
||||
#else
|
||||
.space 32, 0x90
|
||||
.space 20, 0xCC
|
||||
#endif
|
||||
#endif /* _HARDKERNEL */
|
||||
END(_atomic_cas_cx8)
|
||||
ENDLABEL(_atomic_cas_cx8_end)
|
||||
LABEL(_atomic_cas_cx8_end)
|
||||
#endif /* __HAVE_ATOMIC64_OPS || _KERNEL */
|
||||
|
||||
ALIAS(atomic_add_32,_atomic_add_32)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: frameasm.h,v 1.31 2020/04/26 14:49:17 maxv Exp $ */
|
||||
/* $NetBSD: frameasm.h,v 1.32 2020/05/01 08:32:50 maxv Exp $ */
|
||||
|
||||
#ifndef _I386_FRAMEASM_H_
|
||||
#define _I386_FRAMEASM_H_
|
||||
|
@ -50,6 +50,7 @@
|
|||
#define HP_NAME_RETFENCE 4
|
||||
#define HP_NAME_SSE2_LFENCE 5
|
||||
#define HP_NAME_SSE2_MFENCE 6
|
||||
#define HP_NAME_CAS_64 7
|
||||
|
||||
#define HOTPATCH(name, size) \
|
||||
123: ; \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: patch.c,v 1.43 2020/04/30 17:17:33 maxv Exp $ */
|
||||
/* $NetBSD: patch.c,v 1.44 2020/05/01 08:32:50 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.43 2020/04/30 17:17:33 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.44 2020/05/01 08:32:50 maxv Exp $");
|
||||
|
||||
#include "opt_lockdebug.h"
|
||||
#ifdef i386
|
||||
|
@ -69,14 +69,6 @@ void i686_mutex_spin_exit(int);
|
|||
void i686_mutex_spin_exit_end(void);
|
||||
void i686_mutex_spin_exit_patch(void);
|
||||
|
||||
void _atomic_cas_64(void);
|
||||
void _atomic_cas_64_end(void);
|
||||
void _atomic_cas_cx8(void);
|
||||
void _atomic_cas_cx8_end(void);
|
||||
|
||||
#define X86_NOP 0x90
|
||||
#define X86_REP 0xf3
|
||||
#define X86_RET 0xc3
|
||||
#define X86_CS 0x2e
|
||||
#define X86_DS 0x3e
|
||||
#define X86_GROUP_0F 0x0f
|
||||
|
@ -229,11 +221,11 @@ x86_patch(bool early)
|
|||
* may be gone.
|
||||
*/
|
||||
if ((cpu_feature[0] & CPUID_CX8) != 0) {
|
||||
patchfunc(
|
||||
_atomic_cas_cx8, _atomic_cas_cx8_end,
|
||||
_atomic_cas_64, _atomic_cas_64_end,
|
||||
NULL
|
||||
);
|
||||
extern uint8_t _atomic_cas_cx8, _atomic_cas_cx8_end;
|
||||
|
||||
bytes = &_atomic_cas_cx8;
|
||||
size = (size_t)&_atomic_cas_cx8_end - (size_t)&_atomic_cas_cx8;
|
||||
x86_hotpatch(HP_NAME_CAS_64, bytes, size);
|
||||
}
|
||||
|
||||
#if !defined(SPLDEBUG)
|
||||
|
|
Loading…
Reference in New Issue