Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Centralized shared part of child_return() into MI part



details:   https://anonhg.NetBSD.org/src/rev/d74b147398b5
branches:  trunk
changeset: 998061:d74b147398b5
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Apr 06 11:54:19 2019 +0000

description:
Centralized shared part of child_return() into MI part

Add a new function md_child_return() for MD specific bits only.

New child_return() is now part of MI and central code that handles
uniformly tracing code (KTR and ptrace(2)).

Synchronize value passed to ktrsysret() among ports to SYS_fork. This is
a traditional value and accessing p_lflag to check for PL_PPWAIT shall
use locking against proc_lock. Returning SYS_fork vs SYS_vfork still isn't
correct enough as there are more entry points to forking code. Instead of
making it too good, just settle with plain SYS_fork for all ports.

diffstat:

 sys/arch/aarch64/aarch64/syscall.c   |  10 +++-------
 sys/arch/alpha/alpha/syscall.c       |  21 +++------------------
 sys/arch/arm/arm/syscall.c           |  21 +++------------------
 sys/arch/hppa/hppa/trap.c            |   9 +++------
 sys/arch/ia64/ia64/syscall.c         |  24 +++---------------------
 sys/arch/m68k/m68k/m68k_syscall.c    |   8 +++-----
 sys/arch/mips/mips/trap.c            |   8 +++-----
 sys/arch/powerpc/powerpc/syscall.c   |  22 +++-------------------
 sys/arch/riscv/riscv/riscv_machdep.c |  18 ++----------------
 sys/arch/sh3/sh3/vm_machdep.c        |   8 +++-----
 sys/arch/sparc/sparc/syscall.c       |  21 +++------------------
 sys/arch/sparc64/sparc64/syscall.c   |  20 +++-----------------
 sys/arch/usermode/usermode/syscall.c |   9 +++------
 sys/arch/vax/vax/syscall.c           |  20 +++-----------------
 sys/arch/x86/x86/syscall.c           |  20 +++-----------------
 sys/kern/kern_fork.c                 |  32 ++++++++++++++++++++++++++++++--
 sys/sys/proc.h                       |   3 ++-
 17 files changed, 76 insertions(+), 198 deletions(-)

diffs (truncated from 717 to 300 lines):

diff -r febd9f47959a -r d74b147398b5 sys/arch/aarch64/aarch64/syscall.c
--- a/sys/arch/aarch64/aarch64/syscall.c        Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/aarch64/aarch64/syscall.c        Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.4 2019/03/01 02:40:01 mrg Exp $  */
+/*     $NetBSD: syscall.c,v 1.5 2019/04/06 11:54:19 kamil Exp $        */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
 #define EMULNAME(x)    (x)
 #define EMULNAMEU(x)   (x)
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.4 2019/03/01 02:40:01 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.5 2019/04/06 11:54:19 kamil Exp $");
 
 void
 cpu_spawn_return(struct lwp *l)
@@ -71,18 +71,14 @@
 }
 
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
-       struct lwp * const l = arg;
        struct trapframe * const tf = l->l_md.md_utf;
 
        tf->tf_reg[0] = 0;
        tf->tf_reg[1] = 1;
        tf->tf_spsr &= ~NZCV_C;
        l->l_md.md_cpacr = CPACR_FPEN_NONE;
-
-       ktrsysret(SYS_fork, 0, 0);
-       /* Profiling? XXX */
 }
 #endif
 
diff -r febd9f47959a -r d74b147398b5 sys/arch/alpha/alpha/syscall.c
--- a/sys/arch/alpha/alpha/syscall.c    Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/alpha/alpha/syscall.c    Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.43 2019/04/03 08:07:59 kamil Exp $ */
+/* $NetBSD: syscall.c,v 1.44 2019/04/06 11:54:19 kamil Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -89,7 +89,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.43 2019/04/03 08:07:59 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.44 2019/04/06 11:54:19 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -218,28 +218,13 @@
  * Process the tail end of a fork() for the child.
  */
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
-       struct lwp * const l = arg;
-       struct proc *p = l->l_proc;
-
-       if (p->p_slflag & PSL_TRACED) {
-               mutex_enter(p->p_lock);
-               p->p_xsig = SIGTRAP;
-               p->p_sigctx.ps_faked = true; // XXX
-               p->p_sigctx.ps_info._signo = p->p_xsig;
-               p->p_sigctx.ps_info._code = TRAP_CHLD;
-               sigswitch(0, SIGTRAP, true);
-               // XXX ktrpoint(KTR_PSIG)
-               mutex_exit(p->p_lock);
-       }
 
        /*
         * Return values in the frame set by cpu_lwp_fork().
         */
-
        userret(l);
-       ktrsysret(SYS_fork, 0, 0);
 }
 
 /*
diff -r febd9f47959a -r d74b147398b5 sys/arch/arm/arm/syscall.c
--- a/sys/arch/arm/arm/syscall.c        Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/arm/arm/syscall.c        Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.66 2019/04/03 08:07:59 kamil Exp $       */
+/*     $NetBSD: syscall.c,v 1.67 2019/04/06 11:54:20 kamil Exp $       */
 
 /*-
  * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.66 2019/04/03 08:07:59 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.67 2019/04/06 11:54:20 kamil Exp $");
 
 #include <sys/cpu.h>
 #include <sys/device.h>
@@ -284,29 +284,14 @@
 }
 
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
-       lwp_t * const l = arg;
-       struct proc *p = l->l_proc;
-
-       if (p->p_slflag & PSL_TRACED) {
-               mutex_enter(p->p_lock);
-               p->p_xsig = SIGTRAP;
-               p->p_sigctx.ps_faked = true; // XXX
-               p->p_sigctx.ps_info._signo = p->p_xsig;
-               p->p_sigctx.ps_info._code = TRAP_CHLD;
-               sigswitch(0, SIGTRAP, true);
-               // XXX ktrpoint(KTR_PSIG)
-               mutex_exit(p->p_lock);
-       }
-
        struct trapframe * const tf = lwp_trapframe(l);
 
        tf->tf_r0 = 0;
        tf->tf_spsr &= ~PSR_C_bit;      /* carry bit */
 
        userret(l);
-       ktrsysret(SYS_fork, 0, 0);
 }
 
 /*
diff -r febd9f47959a -r d74b147398b5 sys/arch/hppa/hppa/trap.c
--- a/sys/arch/hppa/hppa/trap.c Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/hppa/hppa/trap.c Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.109 2019/04/06 03:06:25 thorpej Exp $       */
+/*     $NetBSD: trap.c,v 1.110 2019/04/06 11:54:20 kamil Exp $ */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.109 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.110 2019/04/06 11:54:20 kamil Exp $");
 
 /* #define INTRDEBUG */
 /* #define TRAPDEBUG */
@@ -977,16 +977,13 @@
 }
 
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
-       struct lwp *l = arg;
-
        /*
         * Return values in the frame set by cpu_lwp_fork().
         */
 
        userret(l, l->l_md.md_regs->tf_iioq_head, 0);
-       ktrsysret(SYS_fork, 0, 0);
 #ifdef DEBUG
        frame_sanity_check(__func__, __LINE__, 0, l->l_md.md_regs, l);
 #endif /* DEBUG */
diff -r febd9f47959a -r d74b147398b5 sys/arch/ia64/ia64/syscall.c
--- a/sys/arch/ia64/ia64/syscall.c      Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/ia64/ia64/syscall.c      Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.8 2019/04/03 08:07:59 kamil Exp $ */
+/* $NetBSD: syscall.c,v 1.9 2019/04/06 11:54:20 kamil Exp $ */
 
 /*
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.8 2019/04/03 08:07:59 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.9 2019/04/06 11:54:20 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,27 +76,9 @@
  * Process the tail end of a fork() for the child.
  */
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
        panic("XXX %s: not implemented\n", __func__);
-
-#ifdef notyet
-       struct lwp *l = arg;
-       struct proc *p = l->l_proc;
-
-       if (p->p_slflag & PSL_TRACED) {
-               mutex_enter(p->p_lock);
-               p->p_xsig = SIGTRAP;
-               p->p_sigctx.ps_faked = true; // XXX
-               p->p_sigctx.ps_info._signo = p->p_xsig;
-               p->p_sigctx.ps_info._code = TRAP_CHLD;
-               sigswitch(0, SIGTRAP, true);
-               // XXX ktrpoint(KTR_PSIG)
-               mutex_exit(p->p_lock);
-       }
-#endif
-
-       return;
 }
 
 /*
diff -r febd9f47959a -r d74b147398b5 sys/arch/m68k/m68k/m68k_syscall.c
--- a/sys/arch/m68k/m68k/m68k_syscall.c Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/m68k/m68k/m68k_syscall.c Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: m68k_syscall.c,v 1.53 2019/04/06 03:06:26 thorpej Exp $        */
+/*     $NetBSD: m68k_syscall.c,v 1.54 2019/04/06 11:54:20 kamil Exp $  */
 
 /*-
  * Portions Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.53 2019/04/06 03:06:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m68k_syscall.c,v 1.54 2019/04/06 11:54:20 kamil Exp $");
 
 #include "opt_execfmt.h"
 #include "opt_compat_netbsd.h"
@@ -403,9 +403,8 @@
 }
 
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
-       struct lwp *l = arg;
        /* See cpu_lwp_fork() */
        struct frame *f = (struct frame *)l->l_md.md_regs;
 
@@ -414,7 +413,6 @@
        f->f_format = FMT0;
 
        machine_userret(l, f, 0);
-       ktrsysret(SYS_fork, 0, 0);
 }
 
 /*
diff -r febd9f47959a -r d74b147398b5 sys/arch/mips/mips/trap.c
--- a/sys/arch/mips/mips/trap.c Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/mips/mips/trap.c Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.248 2019/04/06 03:06:26 thorpej Exp $       */
+/*     $NetBSD: trap.c,v 1.249 2019/04/06 11:54:20 kamil Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.248 2019/04/06 03:06:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.249 2019/04/06 11:54:20 kamil Exp $");
 
 #include "opt_cputype.h"       /* which mips CPU levels do we support? */
 #include "opt_ddb.h"
@@ -125,16 +125,14 @@
  * which will be called the very first time when child gets running.
  */
 void
-child_return(void *arg)
+md_child_return(struct lwp *l)
 {
-       struct lwp *l = arg;
        struct trapframe *utf = l->l_md.md_utf;
 
        utf->tf_regs[_R_V0] = 0;
        utf->tf_regs[_R_V1] = 1;
        utf->tf_regs[_R_A3] = 0;
        userret(l);
-       ktrsysret(SYS_fork, 0, 0);
 }
 
 #ifdef MIPS3_PLUS
diff -r febd9f47959a -r d74b147398b5 sys/arch/powerpc/powerpc/syscall.c
--- a/sys/arch/powerpc/powerpc/syscall.c        Sat Apr 06 11:49:53 2019 +0000
+++ b/sys/arch/powerpc/powerpc/syscall.c        Sat Apr 06 11:54:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.54 2019/04/03 08:08:00 kamil Exp $       */
+/*     $NetBSD: syscall.c,v 1.55 2019/04/06 11:54:20 kamil Exp $       */
 
 /*
  * Copyright (C) 2002 Matt Thomas



Home | Main Index | Thread Index | Old Index