summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorchs <chs@NetBSD.org>2014-12-14 23:49:17 +0000
committerchs <chs@NetBSD.org>2014-12-14 23:49:17 +0000
commitcc618d93e77dfbaac3b7e7e04a01eeac8fd4e63f (patch)
tree5a6257f8a070bb2d0a79f94050ba9b68a1a323d1 /sys
parent5550f0634311889b2b774b801881bed8d0f4eb4c (diff)
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 (limited to 'sys')
-rw-r--r--sys/arch/powerpc/include/types.h3
-rw-r--r--sys/arch/powerpc/powerpc/sig_machdep.c28
2 files changed, 15 insertions, 16 deletions
diff --git a/sys/arch/powerpc/include/types.h b/sys/arch/powerpc/include/types.h
index 4deeeab8c68..c5313a0ea57 100644
--- a/sys/arch/powerpc/include/types.h
+++ b/sys/arch/powerpc/include/types.h
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.49 2014/03/18 18:20:41 riastradh Exp $ */
+/* $NetBSD: types.h,v 1.50 2014/12/14 23:49:17 chs Exp $ */
/*-
* Copyright (C) 1995 Wolfgang Solfrank.
@@ -81,6 +81,7 @@ typedef volatile int __cpu_simple_lock_t;
#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 --git a/sys/arch/powerpc/powerpc/sig_machdep.c b/sys/arch/powerpc/powerpc/sig_machdep.c
index e3441cdae01..0ec57594370 100644
--- a/sys/arch/powerpc/powerpc/sig_machdep.c
+++ b/sys/arch/powerpc/powerpc/sig_machdep.c
@@ -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.44 2014/12/14 23:49:17 chs 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.44 2014/12/14 23:49:17 chs Exp $");
#include "opt_ppcarch.h"
#include "opt_altivec.h"
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.43 2012/09/11 00:15:19 matt Exp $"
#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 @@ cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flagp)
#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 @@ cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
#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 @@ cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
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;
+}