Source-Changes-HG archive

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

[src/netbsd-7-0]: src/sys/arch/sparc64/sparc64 Pull up following revision(s) ...



details:   https://anonhg.NetBSD.org/src/rev/8862e9e8eb16
branches:  netbsd-7-0
changeset: 801083:8862e9e8eb16
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Nov 16 13:39:47 2015 +0000

description:
Pull up following revision(s) (requested by martin in ticket #1028):
        sys/arch/sparc64/sparc64/locore.s: revision 1.386
        sys/arch/sparc64/sparc64/vm_machdep.c: revision 1.101
        sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.105
        sys/arch/sparc64/sparc64/netbsd32_machdep.c: revision 1.106
- Basically revert r1.246 of locore.s and r1.73 of vm_machdep.c:
        Remove special case handling for userland lwps from cpu_lwp_fork,
        instead do it in lwp_trampoline when we first return to userland.
  which was a stupid idea - since we did now set all fork child's %tstate
  (and thus %pstate when back in userland) to the current kernel's userland
  default. This meant we lost the address mask bit for 32bit processes and
  all memory model details for 64bit ones.
  Move it back to cpu_lwp_fork and fix the condition to only do it once when
  forking init.
- Fix kmem_free() size mismatch
- Convert siginfo to 32bit version before copying it out to 32bit userland.

diffstat:

 sys/arch/sparc64/sparc64/locore.s           |   8 +-------
 sys/arch/sparc64/sparc64/netbsd32_machdep.c |  14 +++++++++-----
 sys/arch/sparc64/sparc64/vm_machdep.c       |  12 ++++++++++--
 3 files changed, 20 insertions(+), 14 deletions(-)

diffs (121 lines):

diff -r 77fe63b6983d -r 8862e9e8eb16 sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Mon Nov 16 07:38:15 2015 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Mon Nov 16 13:39:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.369.2.2 2015/03/09 07:54:12 snj Exp $     */
+/*     $NetBSD: locore.s,v 1.369.2.2.2.1 2015/11/16 13:39:47 msaitoh Exp $     */
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -5764,12 +5764,6 @@
         mov    %l1, %o0
 
        /*
-        * Going to userland - set proper tstate in trap frame
-        */
-       set     (ASI_PRIMARY_NO_FAULT<<TSTATE_ASI_SHIFT)|((PSTATE_USER)<<TSTATE_PSTATE_SHIFT), %g1
-       stx     %g1, [%sp + CC64FSZ + STKB + TF_TSTATE]
-
-       /*
         * Here we finish up as in syscall, but simplified.
         */
        ba,a,pt %icc, return_from_trap
diff -r 77fe63b6983d -r 8862e9e8eb16 sys/arch/sparc64/sparc64/netbsd32_machdep.c
--- a/sys/arch/sparc64/sparc64/netbsd32_machdep.c       Mon Nov 16 07:38:15 2015 +0000
+++ b/sys/arch/sparc64/sparc64/netbsd32_machdep.c       Mon Nov 16 13:39:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.103 2014/03/07 22:51:27 nakayama Exp $  */
+/*     $NetBSD: netbsd32_machdep.c,v 1.103.8.1 2015/11/16 13:39:47 msaitoh Exp $       */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.103 2014/03/07 22:51:27 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.103.8.1 2015/11/16 13:39:47 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -319,6 +319,7 @@
        int sig = ksi->ksi_signo;
        ucontext32_t uc;
        struct sparc32_sigframe_siginfo *fp;
+       siginfo32_t si32;       
        netbsd32_intptr_t catcher;
        struct trapframe64 *tf = l->l_md.md_tf;
        struct rwindow32 *oldsp, *newsp;
@@ -339,15 +340,16 @@
        else
                fp = (struct sparc32_sigframe_siginfo *)oldsp;
        fp = (struct sparc32_sigframe_siginfo*)((u_long)(fp - 1) & ~7);
+
        /*
         * Build the signal context to be used by sigreturn.
         */
+       memset(&uc, 0, sizeof uc);
        uc.uc_flags = _UC_SIGMASK |
                ((l->l_sigstk.ss_flags & SS_ONSTACK)
                        ? _UC_SETSTACK : _UC_CLRSTACK);
        uc.uc_sigmask = *mask;
        uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
-       memset(&uc.uc_stack, 0, sizeof(uc.uc_stack));
 
        sendsig_reset(l, sig);
 
@@ -362,9 +364,10 @@
         */
        mutex_exit(p->p_lock);
        cpu_getmcontext32(l, &uc.uc_mcontext, &uc.uc_flags);
+       netbsd32_si_to_si32(&si32, (const siginfo_t *)&ksi->ksi_info);
        ucsz = (int)(intptr_t)&uc.__uc_pad - (int)(intptr_t)&uc;
        newsp = (struct rwindow32*)((intptr_t)fp - sizeof(struct frame32));
-       error = (copyout(&ksi->ksi_info, &fp->sf_si, sizeof ksi->ksi_info) ||
+       error = (copyout(&si32, &fp->sf_si, sizeof si32) ||
            copyout(&uc, &fp->sf_uc, ucsz) ||
            suword(&newsp->rw_in[6], (intptr_t)oldsp));
        mutex_enter(p->p_lock);
@@ -1327,7 +1330,8 @@
        error = cpu_setmcontext32(l, &uc->uc_mcontext, uc->uc_flags);
        KASSERT(error == 0);
 
-       kmem_free(uc, sizeof(ucontext32_t));
+       /* Note: we are freeing ucontext_t, not ucontext32_t. */
+       kmem_free(arg, sizeof(ucontext_t));
        userret(l, 0, 0);
 }
 
diff -r 77fe63b6983d -r 8862e9e8eb16 sys/arch/sparc64/sparc64/vm_machdep.c
--- a/sys/arch/sparc64/sparc64/vm_machdep.c     Mon Nov 16 07:38:15 2015 +0000
+++ b/sys/arch/sparc64/sparc64/vm_machdep.c     Mon Nov 16 13:39:47 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm_machdep.c,v 1.100 2013/09/15 16:04:16 martin Exp $ */
+/*     $NetBSD: vm_machdep.c,v 1.100.8.1 2015/11/16 13:39:47 msaitoh Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.100 2013/09/15 16:04:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.100.8.1 2015/11/16 13:39:47 msaitoh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -247,6 +247,14 @@
                tf2->tf_out[6] = (uint64_t)(u_long)stack + stacksize;
 
        /*
+        * Need to create a %tstate if we are forking our first userland
+        * process - in all other cases we inherit from the parent.
+        */
+       if (l2->l_proc->p_pid == 1)
+               tf2->tf_tstate = (ASI_PRIMARY_NO_FAULT<<TSTATE_ASI_SHIFT) |
+                   ((PSTATE_USER)<<TSTATE_PSTATE_SHIFT);
+
+       /*
         * Set return values in child mode and clear condition code,
         * in case we end up running a signal handler before returning
         * to userland.



Home | Main Index | Thread Index | Old Index