Source-Changes-HG archive

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

[src/netbsd-7]: src Pull up following revision(s) (requested by chs in ticket...



details:   https://anonhg.NetBSD.org/src/rev/1513f493c093
branches:  netbsd-7
changeset: 798763:1513f493c093
user:      snj <snj%NetBSD.org@localhost>
date:      Wed Dec 31 06:51:08 2014 +0000

description:
Pull up following revision(s) (requested by chs in ticket #364):
        lib/libc/tls/tls.c: revision 1.8
        libexec/ld.elf_so/tls.c: revision 1.10
        sys/arch/powerpc/include/types.h: revision 1.50
        sys/arch/powerpc/powerpc/sig_machdep.c: revision 1.44
fix powerpc TLS problems by removing the hacks for PPC EABI.
the kernel no longer treats R2 specially and its use as
the TLS register is now handled entirely in userland.

diffstat:

 lib/libc/tls/tls.c                     |  13 ++-----------
 libexec/ld.elf_so/tls.c                |  11 ++---------
 sys/arch/powerpc/include/types.h       |   3 ++-
 sys/arch/powerpc/powerpc/sig_machdep.c |  28 +++++++++++++---------------
 4 files changed, 19 insertions(+), 36 deletions(-)

diffs (150 lines):

diff -r 283603a352b5 -r 1513f493c093 lib/libc/tls/tls.c
--- a/lib/libc/tls/tls.c        Wed Dec 31 06:44:00 2014 +0000
+++ b/lib/libc/tls/tls.c        Wed Dec 31 06:51:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tls.c,v 1.7 2013/08/19 22:14:37 matt Exp $     */
+/*     $NetBSD: tls.c,v 1.7.4.1 2014/12/31 06:51:08 snj Exp $  */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.7 2013/08/19 22:14:37 matt Exp $");
+__RCSID("$NetBSD: tls.c,v 1.7.4.1 2014/12/31 06:51:08 snj Exp $");
 
 #include "namespace.h"
 
@@ -155,15 +155,6 @@
        struct tls_tcb *tcb;
 
        if (&rtld_DYNAMIC != NULL) {
-#ifdef __powerpc__
-               /*
-                * Old powerpc crt0's are going to overwrite r2 so we need to
-                * restore it but only do so if the saved value isn't NULL (if
-                * it is NULL, ld.elf_so doesn't have the matching change).
-                */
-               if ((tcb = _lwp_getprivate()) != NULL)
-                       __lwp_settcb(tcb);
-#endif
                return;
        }
 
diff -r 283603a352b5 -r 1513f493c093 libexec/ld.elf_so/tls.c
--- a/libexec/ld.elf_so/tls.c   Wed Dec 31 06:44:00 2014 +0000
+++ b/libexec/ld.elf_so/tls.c   Wed Dec 31 06:51:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tls.c,v 1.9 2013/10/21 19:14:15 joerg Exp $    */
+/*     $NetBSD: tls.c,v 1.9.4.1 2014/12/31 06:51:08 snj Exp $  */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.9 2013/10/21 19:14:15 joerg Exp $");
+__RCSID("$NetBSD: tls.c,v 1.9.4.1 2014/12/31 06:51:08 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/ucontext.h>
@@ -106,13 +106,6 @@
        tcb = _rtld_tls_allocate_locked();
 #ifdef __HAVE___LWP_SETTCB
        __lwp_settcb(tcb);
-#ifdef __powerpc__
-       /*
-        * Save the tcb pointer so that libc can retrieve it.  Older
-        * crt0 will obliterate r2 so there is code in libc to restore it.
-        */
-       _lwp_setprivate(tcb);
-#endif
 #else
        _lwp_setprivate(tcb);
 #endif
diff -r 283603a352b5 -r 1513f493c093 sys/arch/powerpc/include/types.h
--- a/sys/arch/powerpc/include/types.h  Wed Dec 31 06:44:00 2014 +0000
+++ b/sys/arch/powerpc/include/types.h  Wed Dec 31 06:51:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: types.h,v 1.49 2014/03/18 18:20:41 riastradh Exp $     */
+/*     $NetBSD: types.h,v 1.49.4.1 2014/12/31 06:51:08 snj Exp $       */
 
 /*-
  * Copyright (C) 1995 Wolfgang Solfrank.
@@ -81,6 +81,7 @@
 #ifdef _LP64
 #define        __HAVE_ATOMIC64_OPS
 #endif
+#define        __HAVE_CPU_LWP_SETPRIVATE
 #define        __HAVE_COMMON___TLS_GET_ADDR
 #define        __HAVE___LWP_GETTCB_FAST
 #define        __HAVE___LWP_SETTCB
diff -r 283603a352b5 -r 1513f493c093 sys/arch/powerpc/powerpc/sig_machdep.c
--- a/sys/arch/powerpc/powerpc/sig_machdep.c    Wed Dec 31 06:44:00 2014 +0000
+++ b/sys/arch/powerpc/powerpc/sig_machdep.c    Wed Dec 31 06:51:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.43 2012/09/11 00:15:19 matt Exp $    */
+/*     $NetBSD: sig_machdep.c,v 1.43.14.1 2014/12/31 06:51:08 snj Exp $        */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.43 2012/09/11 00:15:19 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.43.14.1 2014/12/31 06:51:08 snj Exp $");
 
 #include "opt_ppcarch.h"
 #include "opt_altivec.h"
@@ -43,6 +43,7 @@
 #include <sys/syscallargs.h>
 #include <sys/systm.h>
 #include <sys/ucontext.h>
+#include <sys/cpu.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -172,8 +173,7 @@
 #endif
 
        *flagp |= _UC_CPU;
-       if (gr[_REG_R2] == (uintptr_t)l->l_private)
-               *flagp |= _UC_TLSBASE;
+       *flagp |= _UC_TLSBASE;
 
 #ifdef PPC_HAVE_FPU
        /* Save FPU context, if any. */
@@ -231,17 +231,6 @@
 #ifdef PPC_OEA
                tf->tf_mq = gr[_REG_MQ];
 #endif
-               /*
-                * If R2 contains the TLS base, make sure to update l->l_private.
-                * If not, restore R2 from l->l_private if not null.  Since setcontext
-                * existed before the TCB code, a static program could expect R2 to
-                * the small data pointer.
-                */
-               if (flags & _UC_TLSBASE) {
-                       l->l_private = (void *) tf->tf_fixreg[_REG_R2];
-               } else if (l->l_private) {
-                       tf->tf_fixreg[_REG_R2] = (uintptr_t)l->l_private;
-               }
        }
 
 #ifdef PPC_HAVE_FPU
@@ -264,3 +253,12 @@
 
        return (0);
 }
+
+int
+cpu_lwp_setprivate(lwp_t *l, void *addr)
+{
+       struct trapframe * const tf = l->l_md.md_utf;
+
+       tf->tf_fixreg[_REG_R2] = (register_t)addr;
+       return 0;
+}



Home | Main Index | Thread Index | Old Index