Module Name: src
Committed By: snj
Date: Fri Apr 3 17:42:36 UTC 2009
Modified Files:
src/common/lib/libc/arch/i386/atomic [netbsd-5]: atomic.S
src/sys/arch/amd64/amd64 [netbsd-5]: spl.S
src/sys/arch/x86/x86 [netbsd-5]: patch.c
Log Message:
Pull up following revision(s) (requested by enami in ticket #645):
common/lib/libc/arch/i386/atomic/atomic.S: revision 1.17
sys/arch/amd64/amd64/spl.S: revision 1.21
sys/arch/x86/x86/patch.c: revision 1.17
So that profile kernel runs again,
- Adjust the size of functions used to patch.
- Fix the jump offset of mcount call when patching functions.
Approved by Andrew Doran.
To generate a diff of this commit:
cvs rdiff -u -r1.13.4.1 -r1.13.4.2 \
src/common/lib/libc/arch/i386/atomic/atomic.S
cvs rdiff -u -r1.20 -r1.20.6.1 src/sys/arch/amd64/amd64/spl.S
cvs rdiff -u -r1.14.4.2 -r1.14.4.3 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.13.4.1 src/common/lib/libc/arch/i386/atomic/atomic.S:1.13.4.2
--- src/common/lib/libc/arch/i386/atomic/atomic.S:1.13.4.1 Mon Feb 2 03:06:12 2009
+++ src/common/lib/libc/arch/i386/atomic/atomic.S Fri Apr 3 17:42:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.S,v 1.13.4.1 2009/02/02 03:06:12 snj Exp $ */
+/* $NetBSD: atomic.S,v 1.13.4.2 2009/04/03 17:42:36 snj Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -211,7 +211,11 @@
popl %ebx
popl %edi
ret
+#ifdef GPROF
+ .space 16, 0x90
+#else
.space 32, 0x90
+#endif
ENDLABEL(_atomic_cas_cx8_end)
ENTRY(sse2_lfence)
Index: src/sys/arch/amd64/amd64/spl.S
diff -u src/sys/arch/amd64/amd64/spl.S:1.20 src/sys/arch/amd64/amd64/spl.S:1.20.6.1
--- src/sys/arch/amd64/amd64/spl.S:1.20 Tue Jul 1 18:49:20 2008
+++ src/sys/arch/amd64/amd64/spl.S Fri Apr 3 17:42:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: spl.S,v 1.20 2008/07/01 18:49:20 bouyer Exp $ */
+/* $NetBSD: spl.S,v 1.20.6.1 2009/04/03 17:42:36 snj Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -209,6 +209,10 @@
nop
nop
.align 16
+#ifdef GPROF
+ nop
+ .align 16
+#endif
LABEL(spllower_end)
#endif /* !XEN */
Index: src/sys/arch/x86/x86/patch.c
diff -u src/sys/arch/x86/x86/patch.c:1.14.4.2 src/sys/arch/x86/x86/patch.c:1.14.4.3
--- src/sys/arch/x86/x86/patch.c:1.14.4.2 Thu Feb 19 20:42:34 2009
+++ src/sys/arch/x86/x86/patch.c Fri Apr 3 17:42:36 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: patch.c,v 1.14.4.2 2009/02/19 20:42:34 snj Exp $ */
+/* $NetBSD: patch.c,v 1.14.4.3 2009/04/03 17:42:36 snj 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.14.4.2 2009/02/19 20:42:34 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: patch.c,v 1.14.4.3 2009/04/03 17:42:36 snj Exp $");
#include "opt_lockdebug.h"
@@ -83,29 +83,44 @@
#define X86_DS 0x3e
#define X86_GROUP_0F 0x0f
+static void
+adjust_jumpoff(uint8_t *ptr, void *from_s, void *to_s)
+{
+
+ /* Branch hints */
+ if (ptr[0] == X86_CS || ptr[0] == X86_DS)
+ ptr++;
+ /* Conditional jumps */
+ if (ptr[0] == X86_GROUP_0F)
+ ptr++;
+ /* 4-byte relative jump or call */
+ *(uint32_t *)(ptr + 1 - (uintptr_t)from_s + (uintptr_t)to_s) +=
+ ((uint32_t)(uintptr_t)from_s - (uint32_t)(uintptr_t)to_s);
+}
+
static void __unused
patchfunc(void *from_s, void *from_e, void *to_s, void *to_e,
void *pcrel)
{
- uint8_t *ptr;
if ((uintptr_t)from_e - (uintptr_t)from_s !=
(uintptr_t)to_e - (uintptr_t)to_s)
panic("patchfunc: sizes do not match (from=%p)", from_s);
memcpy(to_s, from_s, (uintptr_t)to_e - (uintptr_t)to_s);
- if (pcrel != NULL) {
- ptr = pcrel;
- /* Branch hints */
- if (ptr[0] == X86_CS || ptr[0] == X86_DS)
- ptr++;
- /* Conditional jumps */
- if (ptr[0] == X86_GROUP_0F)
- ptr++;
- /* 4-byte relative jump or call */
- *(uint32_t *)(ptr + 1 - (uintptr_t)from_s + (uintptr_t)to_s) +=
- ((uint32_t)(uintptr_t)from_s - (uint32_t)(uintptr_t)to_s);
- }
+ if (pcrel != NULL)
+ adjust_jumpoff(pcrel, from_s, to_s);
+
+#ifdef GPROF
+#ifdef i386
+#define MCOUNT_CALL_OFFSET 3
+#endif
+#ifdef __x86_64__
+#define MCOUNT_CALL_OFFSET 5
+#endif
+ /* Patch mcount call offset */
+ adjust_jumpoff((uint8_t *)from_s + MCOUNT_CALL_OFFSET, from_s, to_s);
+#endif
}
static inline void __unused