Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/powerpc in cpu_setmcontext(), do not update...



details:   https://anonhg.NetBSD.org/src/rev/6ec06e31fb7c
branches:  trunk
changeset: 822159:6ec06e31fb7c
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Mar 05 16:09:26 2017 +0000

description:
in cpu_setmcontext(), do not update the TLS register (r2) as part of _UC_CPU.
if _UC_TLSBASE is set, use lwp_setprivate() to update both r2 and the
common field in struct lwp.

diffstat:

 sys/arch/powerpc/powerpc/sig_machdep.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 97533c120129 -r 6ec06e31fb7c sys/arch/powerpc/powerpc/sig_machdep.c
--- a/sys/arch/powerpc/powerpc/sig_machdep.c    Sun Mar 05 16:08:23 2017 +0000
+++ b/sys/arch/powerpc/powerpc/sig_machdep.c    Sun Mar 05 16:09:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig_machdep.c,v 1.44 2014/12/14 23:49:17 chs Exp $     */
+/*     $NetBSD: sig_machdep.c,v 1.45 2017/03/05 16:09:26 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.44 2014/12/14 23:49:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sig_machdep.c,v 1.45 2017/03/05 16:09:26 chs Exp $");
 
 #include "opt_ppcarch.h"
 #include "opt_altivec.h"
@@ -216,10 +216,17 @@
                pcb->pcb_flags |= gr[_REG_MSR] & (PCB_FE0|PCB_FE1);
 #endif
 
+               /*
+                * R2 is the TLS register so avoid updating it here.
+                */
+
+               __greg_t save_r2 = tf->tf_fixreg[_REG_R2];
                (void)memcpy(&tf->tf_fixreg, gr, 32 * sizeof (gr[0]));
+               tf->tf_fixreg[_REG_R2] = save_r2;
                tf->tf_cr   = gr[_REG_CR];
                tf->tf_lr   = gr[_REG_LR];
                tf->tf_srr0 = gr[_REG_PC];
+
                /*
                 * Accept all user-settable bits without complaint;
                 * userland should not need to know the machine-specific
@@ -233,6 +240,9 @@
 #endif
        }
 
+       if (flags & _UC_TLSBASE)
+               lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_R2]);
+
 #ifdef PPC_HAVE_FPU
        /* Restore FPU context, if any. */
        if (flags & _UC_FPU)



Home | Main Index | Thread Index | Old Index