Source-Changes-HG archive

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

[src/trunk]: src define _UC_TLSBASE and use it to pass the TLS pointer to set...



details:   https://anonhg.NetBSD.org/src/rev/bad201dd0c2a
branches:  trunk
changeset: 772532:bad201dd0c2a
user:      chs <chs%NetBSD.org@localhost>
date:      Sat Jan 07 16:47:42 2012 +0000

description:
define _UC_TLSBASE and use it to pass the TLS pointer to setcontext().
since there is no available space in ucontext_t on vax, pass the
TLS pointer on the stack referenced by the ucontext_t instead.
suggested by joerg.

diffstat:

 lib/libc/arch/vax/gen/_lwp.c    |  12 ++++++++++--
 sys/arch/vax/include/mcontext.h |   5 ++++-
 sys/arch/vax/vax/machdep.c      |  16 ++++++++++++++--
 3 files changed, 28 insertions(+), 5 deletions(-)

diffs (87 lines):

diff -r 99bdeb279577 -r bad201dd0c2a lib/libc/arch/vax/gen/_lwp.c
--- a/lib/libc/arch/vax/gen/_lwp.c      Sat Jan 07 16:12:30 2012 +0000
+++ b/lib/libc/arch/vax/gen/_lwp.c      Sat Jan 07 16:47:42 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.1 2009/06/03 01:02:28 christos Exp $        */
+/*     $NetBSD: _lwp.c,v 1.2 2012/01/07 16:47:42 chs Exp $     */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.1 2009/06/03 01:02:28 christos Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.2 2012/01/07 16:47:42 chs Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -76,4 +76,12 @@
        gr[_REG_SP] = (__greg_t)sp;
        gr[_REG_FP] = (__greg_t)sp;
        gr[_REG_PC] = (__greg_t)start + 2;
+
+       /*
+        * Push the TLS pointer onto the new stack also.
+        * The _UC_TLSBASE flag tells the kernel to pop it and use it.
+        */
+       *--sp = (intptr_t)private;
+       gr[_REG_SP] = (__greg_t)sp;
+       u->uc_flags |= _UC_TLSBASE;
 }
diff -r 99bdeb279577 -r bad201dd0c2a sys/arch/vax/include/mcontext.h
--- a/sys/arch/vax/include/mcontext.h   Sat Jan 07 16:12:30 2012 +0000
+++ b/sys/arch/vax/include/mcontext.h   Sat Jan 07 16:47:42 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mcontext.h,v 1.6 2011/04/12 18:24:28 matt Exp $        */
+/*     $NetBSD: mcontext.h,v 1.7 2012/01/07 16:47:42 chs Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -64,6 +64,9 @@
        __gregset_t     __gregs;        /* General Purpose Register set */
 } mcontext_t;
 
+/* Machine-dependent uc_flags */
+#define _UC_TLSBASE    0x00080000
+
 #define        _UC_MACHINE_SP(uc)      ((uc)->uc_mcontext.__gregs[_REG_SP])
 #define        _UC_MACHINE_PC(uc)      ((uc)->uc_mcontext.__gregs[_REG_PC])
 #define        _UC_MACHINE_INTRV(uc)   ((uc)->uc_mcontext.__gregs[_REG_R0])
diff -r 99bdeb279577 -r bad201dd0c2a sys/arch/vax/vax/machdep.c
--- a/sys/arch/vax/vax/machdep.c        Sat Jan 07 16:12:30 2012 +0000
+++ b/sys/arch/vax/vax/machdep.c        Sat Jan 07 16:47:42 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.183 2011/12/12 19:03:12 mrg Exp $     */
+/* $NetBSD: machdep.c,v 1.184 2012/01/07 16:47:42 chs Exp $     */
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.183 2011/12/12 19:03:12 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.184 2012/01/07 16:47:42 chs Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -719,6 +719,18 @@
        tf->tf_sp = gr[_REG_SP];
        tf->tf_pc = gr[_REG_PC];
        tf->tf_psl = gr[_REG_PSL];
+
+       if (flags & _UC_TLSBASE) {
+               void *tlsbase;
+               int error;
+
+               error = copyin((void *)tf->tf_sp, &tlsbase, sizeof(tlsbase));
+               if (error) {
+                       return error;
+               }
+               lwp_setprivate(l, tlsbase);
+               tf->tf_sp += sizeof(tlsbase);
+       }
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index