Module Name: src
Committed By: kamil
Date: Sat Apr 6 11:54:21 UTC 2019
Modified Files:
src/sys/arch/aarch64/aarch64: syscall.c
src/sys/arch/alpha/alpha: syscall.c
src/sys/arch/arm/arm: syscall.c
src/sys/arch/hppa/hppa: trap.c
src/sys/arch/ia64/ia64: syscall.c
src/sys/arch/m68k/m68k: m68k_syscall.c
src/sys/arch/mips/mips: trap.c
src/sys/arch/powerpc/powerpc: syscall.c
src/sys/arch/riscv/riscv: riscv_machdep.c
src/sys/arch/sh3/sh3: vm_machdep.c
src/sys/arch/sparc/sparc: syscall.c
src/sys/arch/sparc64/sparc64: syscall.c
src/sys/arch/usermode/usermode: syscall.c
src/sys/arch/vax/vax: syscall.c
src/sys/arch/x86/x86: syscall.c
src/sys/kern: kern_fork.c
src/sys/sys: proc.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/syscall.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/alpha/alpha/syscall.c
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/arm/arm/syscall.c
cvs rdiff -u -r1.109 -r1.110 src/sys/arch/hppa/hppa/trap.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/ia64/ia64/syscall.c
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/m68k/m68k/m68k_syscall.c
cvs rdiff -u -r1.248 -r1.249 src/sys/arch/mips/mips/trap.c
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/powerpc/powerpc/syscall.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/riscv/riscv_machdep.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/sh3/sh3/vm_machdep.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/sparc/sparc/syscall.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/sparc64/sparc64/syscall.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/usermode/usermode/syscall.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/vax/vax/syscall.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/x86/syscall.c
cvs rdiff -u -r1.207 -r1.208 src/sys/kern/kern_fork.c
cvs rdiff -u -r1.351 -r1.352 src/sys/sys/proc.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/aarch64/aarch64/syscall.c
diff -u src/sys/arch/aarch64/aarch64/syscall.c:1.4 src/sys/arch/aarch64/aarch64/syscall.c:1.5
--- src/sys/arch/aarch64/aarch64/syscall.c:1.4 Fri Mar 1 02:40:01 2019
+++ src/sys/arch/aarch64/aarch64/syscall.c Sat Apr 6 11:54:19 2019
@@ -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 @@ cpu_spawn_return(struct lwp *l)
}
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
Index: src/sys/arch/alpha/alpha/syscall.c
diff -u src/sys/arch/alpha/alpha/syscall.c:1.43 src/sys/arch/alpha/alpha/syscall.c:1.44
--- src/sys/arch/alpha/alpha/syscall.c:1.43 Wed Apr 3 08:07:59 2019
+++ src/sys/arch/alpha/alpha/syscall.c Sat Apr 6 11:54:19 2019
@@ -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 @@ syscall(struct lwp *l, uint64_t code, st
* 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);
}
/*
Index: src/sys/arch/arm/arm/syscall.c
diff -u src/sys/arch/arm/arm/syscall.c:1.66 src/sys/arch/arm/arm/syscall.c:1.67
--- src/sys/arch/arm/arm/syscall.c:1.66 Wed Apr 3 08:07:59 2019
+++ src/sys/arch/arm/arm/syscall.c Sat Apr 6 11:54:20 2019
@@ -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 @@ syscall(struct trapframe *tf, lwp_t *l,
}
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);
}
/*
Index: src/sys/arch/hppa/hppa/trap.c
diff -u src/sys/arch/hppa/hppa/trap.c:1.109 src/sys/arch/hppa/hppa/trap.c:1.110
--- src/sys/arch/hppa/hppa/trap.c:1.109 Sat Apr 6 03:06:25 2019
+++ src/sys/arch/hppa/hppa/trap.c Sat Apr 6 11:54:20 2019
@@ -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 @@ do_onfault:
}
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 */
Index: src/sys/arch/ia64/ia64/syscall.c
diff -u src/sys/arch/ia64/ia64/syscall.c:1.8 src/sys/arch/ia64/ia64/syscall.c:1.9
--- src/sys/arch/ia64/ia64/syscall.c:1.8 Wed Apr 3 08:07:59 2019
+++ src/sys/arch/ia64/ia64/syscall.c Sat Apr 6 11:54:20 2019
@@ -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 @@ syscall_fancy(struct lwp *l, u_int64_t c
* 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;
}
/*
Index: src/sys/arch/m68k/m68k/m68k_syscall.c
diff -u src/sys/arch/m68k/m68k/m68k_syscall.c:1.53 src/sys/arch/m68k/m68k/m68k_syscall.c:1.54
--- src/sys/arch/m68k/m68k/m68k_syscall.c:1.53 Sat Apr 6 03:06:26 2019
+++ src/sys/arch/m68k/m68k/m68k_syscall.c Sat Apr 6 11:54:20 2019
@@ -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 @@ out:
}
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 @@ child_return(void *arg)
f->f_format = FMT0;
machine_userret(l, f, 0);
- ktrsysret(SYS_fork, 0, 0);
}
/*
Index: src/sys/arch/mips/mips/trap.c
diff -u src/sys/arch/mips/mips/trap.c:1.248 src/sys/arch/mips/mips/trap.c:1.249
--- src/sys/arch/mips/mips/trap.c:1.248 Sat Apr 6 03:06:26 2019
+++ src/sys/arch/mips/mips/trap.c Sat Apr 6 11:54:20 2019
@@ -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 @@ void ast(void);
* 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
Index: src/sys/arch/powerpc/powerpc/syscall.c
diff -u src/sys/arch/powerpc/powerpc/syscall.c:1.54 src/sys/arch/powerpc/powerpc/syscall.c:1.55
--- src/sys/arch/powerpc/powerpc/syscall.c:1.54 Wed Apr 3 08:08:00 2019
+++ src/sys/arch/powerpc/powerpc/syscall.c Sat Apr 6 11:54:20 2019
@@ -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
@@ -61,25 +61,11 @@
#define EMULNAME(x) (x)
#define EMULNAMEU(x) (x)
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.54 2019/04/03 08:08:00 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.55 2019/04/06 11:54:20 kamil Exp $");
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);
- }
-
struct trapframe * const tf = l->l_md.md_utf;
tf->tf_fixreg[FIRSTARG] = 0;
@@ -87,8 +73,6 @@ child_return(void *arg)
tf->tf_cr &= ~0x10000000;
tf->tf_srr1 &= ~(PSL_FP|PSL_VEC); /* Disable FP & AltiVec, as we can't
be them. */
- ktrsysret(SYS_fork, 0, 0);
- /* Profiling? XXX */
}
#endif
Index: src/sys/arch/riscv/riscv/riscv_machdep.c
diff -u src/sys/arch/riscv/riscv/riscv_machdep.c:1.3 src/sys/arch/riscv/riscv/riscv_machdep.c:1.4
--- src/sys/arch/riscv/riscv/riscv_machdep.c:1.3 Wed Apr 3 08:08:00 2019
+++ src/sys/arch/riscv/riscv/riscv_machdep.c Sat Apr 6 11:54:20 2019
@@ -31,7 +31,7 @@
#include "opt_modular.h"
-__RCSID("$NetBSD: riscv_machdep.c,v 1.3 2019/04/03 08:08:00 kamil Exp $");
+__RCSID("$NetBSD: riscv_machdep.c,v 1.4 2019/04/06 11:54:20 kamil Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -116,27 +116,13 @@ setregs(struct lwp *l, struct exec_packa
}
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;
- 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);
- }
tf->tf_a0 = 0;
tf->tf_a1 = 1;
tf->tf_sr &= ~SR_EF; /* Disable FP as we can't be them. */
- ktrsysret(SYS_fork, 0, 0);
}
void
Index: src/sys/arch/sh3/sh3/vm_machdep.c
diff -u src/sys/arch/sh3/sh3/vm_machdep.c:1.79 src/sys/arch/sh3/sh3/vm_machdep.c:1.80
--- src/sys/arch/sh3/sh3/vm_machdep.c:1.79 Sat Apr 6 03:06:27 2019
+++ src/sys/arch/sh3/sh3/vm_machdep.c Sat Apr 6 11:54:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.79 2019/04/06 03:06:27 thorpej Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.80 2019/04/06 11:54:20 kamil Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.79 2019/04/06 03:06:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.80 2019/04/06 11:54:20 kamil Exp $");
#include "opt_kstack_debug.h"
@@ -239,16 +239,14 @@ sh3_setup_uarea(struct lwp *l)
* When this function returns, new lwp returns to user mode.
*/
void
-child_return(void *arg)
+md_child_return(struct lwp *l)
{
- struct lwp *l = arg;
struct trapframe *tf = l->l_md.md_regs;
tf->tf_r0 = 0; /* fork(2) returns 0 in child */
tf->tf_ssr |= PSL_TBIT; /* syscall succeeded */
userret(l);
- ktrsysret(SYS_fork, 0, 0);
}
/*
Index: src/sys/arch/sparc/sparc/syscall.c
diff -u src/sys/arch/sparc/sparc/syscall.c:1.30 src/sys/arch/sparc/sparc/syscall.c:1.31
--- src/sys/arch/sparc/sparc/syscall.c:1.30 Wed Apr 3 08:08:00 2019
+++ src/sys/arch/sparc/sparc/syscall.c Sat Apr 6 11:54:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.30 2019/04/03 08:08:00 kamil Exp $ */
+/* $NetBSD: syscall.c,v 1.31 2019/04/06 11:54:20 kamil Exp $ */
/*
* Copyright (c) 1996
@@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.30 2019/04/03 08:08:00 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.31 2019/04/06 11:54:20 kamil Exp $");
#include "opt_sparc_arch.h"
#include "opt_multiprocessor.h"
@@ -283,28 +283,13 @@ syscall(register_t code, struct trapfram
* Process the tail end of a fork() for the child.
*/
void
-child_return(void *arg)
+md_child_return(struct lwp *l)
{
- 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);
- }
/*
* Return values in the frame set by cpu_lwp_fork().
*/
userret(l, l->l_md.md_tf->tf_pc, 0);
- ktrsysret((l->l_proc->p_lflag & PL_PPWAIT) ? SYS_vfork : SYS_fork,
- 0, 0);
}
/*
Index: src/sys/arch/sparc64/sparc64/syscall.c
diff -u src/sys/arch/sparc64/sparc64/syscall.c:1.47 src/sys/arch/sparc64/sparc64/syscall.c:1.48
--- src/sys/arch/sparc64/sparc64/syscall.c:1.47 Wed Apr 3 08:08:00 2019
+++ src/sys/arch/sparc64/sparc64/syscall.c Sat Apr 6 11:54:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.47 2019/04/03 08:08:00 kamil Exp $ */
+/* $NetBSD: syscall.c,v 1.48 2019/04/06 11:54:20 kamil Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.47 2019/04/03 08:08:00 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.48 2019/04/06 11:54:20 kamil Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -365,27 +365,13 @@ syscall(struct trapframe64 *tf, register
* Process the tail end of a fork() for the child.
*/
void
-child_return(void *arg)
+md_child_return(struct lwp *l)
{
- 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);
- }
/*
* Return values in the frame set by cpu_lwp_fork().
*/
userret(l, l->l_md.md_tf->tf_pc, 0);
- ktrsysret((l->l_proc->p_lflag & PL_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
}
/*
Index: src/sys/arch/usermode/usermode/syscall.c
diff -u src/sys/arch/usermode/usermode/syscall.c:1.24 src/sys/arch/usermode/usermode/syscall.c:1.25
--- src/sys/arch/usermode/usermode/syscall.c:1.24 Wed Jun 26 15:11:30 2013
+++ src/sys/arch/usermode/usermode/syscall.c Sat Apr 6 11:54:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.24 2013/06/26 15:11:30 matt Exp $ */
+/* $NetBSD: syscall.c,v 1.25 2019/04/06 11:54:21 kamil Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.24 2013/06/26 15:11:30 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.25 2019/04/06 11:54:21 kamil Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -46,9 +46,8 @@ __KERNEL_RCSID(0, "$NetBSD: syscall.c,v
#include <machine/machdep.h>
void
-child_return(void *arg)
+md_child_return(struct lwp *l)
{
- lwp_t *l = arg;
register_t rval[2];
struct pcb *pcb = lwp_getpcb(l);
ucontext_t *ucp = &pcb->pcb_userret_ucp;
@@ -60,7 +59,6 @@ child_return(void *arg)
aprint_debug("child return! lwp %p\n", l);
userret(l);
- ktrsysret(SYS_fork, 0, 0);
}
/*
@@ -235,4 +233,3 @@ return;
thunk_printf("=> %s: %d, (%"PRIx32", %"PRIx32")\n",
errstr, error, (uint) (rval[0]), (uint) (rval[1]));
}
-
Index: src/sys/arch/vax/vax/syscall.c
diff -u src/sys/arch/vax/vax/syscall.c:1.25 src/sys/arch/vax/vax/syscall.c:1.26
--- src/sys/arch/vax/vax/syscall.c:1.25 Wed Apr 3 08:08:00 2019
+++ src/sys/arch/vax/vax/syscall.c Sat Apr 6 11:54:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.25 2019/04/03 08:08:00 kamil Exp $ */
+/* $NetBSD: syscall.c,v 1.26 2019/04/06 11:54:21 kamil Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -28,7 +28,7 @@
/* All bugs are subject to removal without further notice */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.25 2019/04/03 08:08:00 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.26 2019/04/06 11:54:21 kamil Exp $");
#include "opt_multiprocessor.h"
@@ -129,24 +129,10 @@ bad:
}
void
-child_return(void *arg)
+md_child_return(struct lwp *l)
{
- 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);
- }
userret(l, l->l_md.md_utf, 0);
- ktrsysret(SYS_fork, 0, 0);
}
/*
Index: src/sys/arch/x86/x86/syscall.c
diff -u src/sys/arch/x86/x86/syscall.c:1.17 src/sys/arch/x86/x86/syscall.c:1.18
--- src/sys/arch/x86/x86/syscall.c:1.17 Wed Apr 3 08:08:00 2019
+++ src/sys/arch/x86/x86/syscall.c Sat Apr 6 11:54:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.17 2019/04/03 08:08:00 kamil Exp $ */
+/* $NetBSD: syscall.c,v 1.18 2019/04/06 11:54:21 kamil Exp $ */
/*-
* Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.17 2019/04/03 08:08:00 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.18 2019/04/06 11:54:21 kamil Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -57,28 +57,14 @@ void syscall_intern(struct proc *);
static void syscall(struct trapframe *);
void
-child_return(void *arg)
+md_child_return(struct lwp *l)
{
- struct lwp *l = arg;
struct trapframe *tf = l->l_md.md_regs;
- 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);
- }
X86_TF_RAX(tf) = 0;
X86_TF_RFLAGS(tf) &= ~PSL_C;
userret(l);
- ktrsysret(SYS_fork, 0, 0);
}
/*
Index: src/sys/kern/kern_fork.c
diff -u src/sys/kern/kern_fork.c:1.207 src/sys/kern/kern_fork.c:1.208
--- src/sys/kern/kern_fork.c:1.207 Fri Apr 5 21:41:18 2019
+++ src/sys/kern/kern_fork.c Sat Apr 6 11:54:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_fork.c,v 1.207 2019/04/05 21:41:18 kamil Exp $ */
+/* $NetBSD: kern_fork.c,v 1.208 2019/04/06 11:54:21 kamil Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.207 2019/04/05 21:41:18 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.208 2019/04/06 11:54:21 kamil Exp $");
#include "opt_ktrace.h"
#include "opt_dtrace.h"
@@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_fork.c,
#include <sys/ktrace.h>
#include <sys/sched.h>
#include <sys/signalvar.h>
+#include <sys/syscall.h>
#include <sys/kauth.h>
#include <sys/atomic.h>
#include <sys/syscallargs.h>
@@ -610,3 +611,30 @@ fork1(struct lwp *l1, int flags, int exi
return 0;
}
+
+void
+child_return(void *arg)
+{
+ 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);
+ }
+
+ md_child_return(l);
+
+ /*
+ * Return SYS_fork for all fork types, including vfork(2) and clone(2).
+ *
+ * This approach simplifies the code and avoids extra locking.
+ */
+ ktrsysret(SYS_fork, 0, 0);
+}
Index: src/sys/sys/proc.h
diff -u src/sys/sys/proc.h:1.351 src/sys/sys/proc.h:1.352
--- src/sys/sys/proc.h:1.351 Fri Mar 1 03:03:19 2019
+++ src/sys/sys/proc.h Sat Apr 6 11:54:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.351 2019/03/01 03:03:19 christos Exp $ */
+/* $NetBSD: proc.h,v 1.352 2019/04/06 11:54:21 kamil Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -536,6 +536,7 @@ void cpu_spawn_return(struct lwp*);
void syscall_intern(struct proc *);
#endif
+void md_child_return(struct lwp *);
void child_return(void *);
int proc_isunder(struct proc *, struct lwp *);