Module Name: src
Committed By: chs
Date: Sat Jan 7 16:47:43 UTC 2012
Modified Files:
src/lib/libc/arch/vax/gen: _lwp.c
src/sys/arch/vax/include: mcontext.h
src/sys/arch/vax/vax: machdep.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/arch/vax/gen/_lwp.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/mcontext.h
cvs rdiff -u -r1.183 -r1.184 src/sys/arch/vax/vax/machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/arch/vax/gen/_lwp.c
diff -u src/lib/libc/arch/vax/gen/_lwp.c:1.1 src/lib/libc/arch/vax/gen/_lwp.c:1.2
--- src/lib/libc/arch/vax/gen/_lwp.c:1.1 Wed Jun 3 01:02:28 2009
+++ src/lib/libc/arch/vax/gen/_lwp.c Sat Jan 7 16:47:42 2012
@@ -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 @@ _lwp_makecontext(ucontext_t *u, void (*s
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;
}
Index: src/sys/arch/vax/include/mcontext.h
diff -u src/sys/arch/vax/include/mcontext.h:1.6 src/sys/arch/vax/include/mcontext.h:1.7
--- src/sys/arch/vax/include/mcontext.h:1.6 Tue Apr 12 18:24:28 2011
+++ src/sys/arch/vax/include/mcontext.h Sat Jan 7 16:47:42 2012
@@ -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 @@ typedef struct {
__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])
Index: src/sys/arch/vax/vax/machdep.c
diff -u src/sys/arch/vax/vax/machdep.c:1.183 src/sys/arch/vax/vax/machdep.c:1.184
--- src/sys/arch/vax/vax/machdep.c:1.183 Mon Dec 12 19:03:12 2011
+++ src/sys/arch/vax/vax/machdep.c Sat Jan 7 16:47:42 2012
@@ -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 @@ cpu_setmcontext(struct lwp *l, const mco
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;
}