Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: [netbsd-5] src



> Module Name:  src
> Committed By: snj
> Date:         Mon Feb  2 03:06:13 UTC 2009
> 
> Modified Files:
>       src/common/lib/libc/arch/i386/atomic [netbsd-5]: atomic.S
>       src/sys/arch/x86/include [netbsd-5]: cpufunc.h
>       src/sys/arch/x86/x86 [netbsd-5]: cpu.c identcpu.c patch.c
> 
> Log Message:
> Pull up following revision(s) (requested by ad in ticket #343):
>       common/lib/libc/arch/i386/atomic/atomic.S: revision 1.14
>       sys/arch/x86/include/cpufunc.h: revision 1.9
>       sys/arch/x86/x86/identcpu.c: revision 1.12
>       sys/arch/x86/x86/cpu.c: revision 1.60
>       sys/arch/x86/x86/patch.c: revision 1.15
> PR kern/40213 my i386 machine can't boot because of tsc
> - Patch in atomic_cas_64() twice. The first patch is early and makes it
>   the MP-atomic version available if we have cmpxchg8b. The second patch
>   strips the lock prefix if ncpu==1.
> - Fix the i486 atomic_cas_64() to not unconditionally enable interrupts.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -r1.13 -r1.13.4.1 src/common/lib/libc/arch/i386/atomic/atomic.S
> cvs rdiff -r1.8 -r1.8.10.1 src/sys/arch/x86/include/cpufunc.h
> cvs rdiff -r1.57.4.1 -r1.57.4.2 src/sys/arch/x86/x86/cpu.c
> cvs rdiff -r1.10 -r1.10.4.1 src/sys/arch/x86/x86/identcpu.c
> cvs rdiff -r1.14 -r1.14.4.1 src/sys/arch/x86/x86/patch.c

In addition to the previously mailed problem that x86_patch() is nop
except the first call, above change also makes profile kernel won't
boot (it panics due to patch size mismatch).  Appended diff is against
netbsd-5 branch.

enami.

Index: common/lib/libc/arch/i386/atomic/atomic.S
===================================================================
RCS file: /cvsroot/src/common/lib/libc/arch/i386/atomic/atomic.S,v
retrieving revision 1.13.4.1
diff -u -r1.13.4.1 atomic.S
--- common/lib/libc/arch/i386/atomic/atomic.S   2 Feb 2009 03:06:12 -0000       
1.13.4.1
+++ common/lib/libc/arch/i386/atomic/atomic.S   7 Feb 2009 21:23:46 -0000
@@ -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: sys/arch/amd64/amd64/spl.S
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/amd64/spl.S,v
retrieving revision 1.20
diff -u -r1.20 spl.S
--- sys/arch/amd64/amd64/spl.S  1 Jul 2008 18:49:20 -0000       1.20
+++ sys/arch/amd64/amd64/spl.S  7 Feb 2009 21:25:36 -0000
@@ -209,6 +209,10 @@
        nop
        nop
        .align  16
+#ifdef GPROF
+       nop
+       .align  16
+#endif
 LABEL(spllower_end)
 
 #endif /* !XEN */
Index: sys/arch/x86/x86/patch.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/patch.c,v
retrieving revision 1.14.4.1
diff -u -r1.14.4.1 patch.c
--- sys/arch/x86/x86/patch.c    2 Feb 2009 03:06:12 -0000       1.14.4.1
+++ sys/arch/x86/x86/patch.c    7 Feb 2009 21:25:54 -0000
@@ -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


Home | Main Index | Thread Index | Old Index