From: guenther Date: Wed, 2 Nov 2022 07:20:07 +0000 (+0000) Subject: Clean up more ancient history: since 2015 the libc stubs for X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f11c99e6d0b54f18ffdc3fbb4b56e58af88a433f;p=openbsd Clean up more ancient history: since 2015 the libc stubs for fork/vfork/__tfork haven't cared about the second return register. So, stop setting retval[1] in kern_fork.c and stop setting the second return register in the MD child_return() routines. With the above, we have no multi-register return values on LP64, so stop touching that register in the trapframe on those archs. testing miod@ and aoyama@ ok miod@ --- diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index 3541c81d488..a0379b92e52 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.103 2022/08/29 06:08:03 jsg Exp $ */ +/* $OpenBSD: trap.c,v 1.104 2022/11/02 07:20:07 guenther Exp $ */ /* $NetBSD: trap.c,v 1.52 2000/05/24 16:48:33 thorpej Exp $ */ /*- @@ -569,7 +569,6 @@ syscall(code, framep) switch (error) { case 0: framep->tf_regs[FRAME_V0] = rval[0]; - framep->tf_regs[FRAME_A4] = rval[1]; framep->tf_regs[FRAME_A3] = 0; break; case ERESTART: @@ -604,7 +603,6 @@ child_return(arg) * Return values in the frame set by cpu_fork(). */ framep->tf_regs[FRAME_V0] = 0; - framep->tf_regs[FRAME_A4] = 0; framep->tf_regs[FRAME_A3] = 0; KERNEL_UNLOCK(); diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 334502b2e3f..53707fbc99c 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.90 2021/12/09 00:26:11 guenther Exp $ */ +/* $OpenBSD: trap.c,v 1.91 2022/11/02 07:20:07 guenther Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -580,14 +580,13 @@ syscall(struct trapframe *frame) } rval[0] = 0; - rval[1] = frame->tf_rdx; + rval[1] = 0; error = mi_syscall(p, code, callp, argp, rval); switch (error) { case 0: frame->tf_rax = rval[0]; - frame->tf_rdx = rval[1]; frame->tf_rflags &= ~PSL_C; /* carry bit */ break; case ERESTART: @@ -614,7 +613,6 @@ child_return(void *arg) struct trapframe *tf = p->p_md.md_regs; tf->tf_rax = 0; - tf->tf_rdx = 1; tf->tf_rflags &= ~PSL_C; KERNEL_UNLOCK(); diff --git a/sys/arch/arm64/arm64/syscall.c b/sys/arch/arm64/arm64/syscall.c index e30e6fd0671..84653fe0f58 100644 --- a/sys/arch/arm64/arm64/syscall.c +++ b/sys/arch/arm64/arm64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.10 2022/01/01 18:52:36 kettenis Exp $ */ +/* $OpenBSD: syscall.c,v 1.11 2022/11/02 07:20:08 guenther Exp $ */ /* * Copyright (c) 2015 Dale Rahn * @@ -82,15 +82,13 @@ svc_handler(trapframe_t *frame) } rval[0] = 0; - rval[1] = frame->tf_x[1]; + rval[1] = 0; error = mi_syscall(p, code, callp, args, rval); switch (error) { case 0: frame->tf_x[0] = rval[0]; - frame->tf_x[1] = rval[1]; - frame->tf_spsr &= ~PSR_C; /* carry bit */ break; @@ -122,7 +120,6 @@ child_return(void *arg) struct trapframe *frame = p->p_addr->u_pcb.pcb_tf; frame->tf_x[0] = 0; - frame->tf_x[1] = 1; frame->tf_spsr &= ~PSR_C; /* carry bit */ KERNEL_UNLOCK(); diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index d5080df7e3e..da735f48308 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.158 2022/08/12 17:19:52 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.159 2022/11/02 07:20:07 guenther Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -641,7 +641,6 @@ child_return(void *arg) * Set up return value registers as libc:fork() expects */ tf->tf_ret0 = 0; - tf->tf_ret1 = 1; /* ischild */ tf->tf_t1 = 0; /* errno */ KERNEL_UNLOCK(); diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index b1956c8ef49..d2937dbc415 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.122 2022/08/12 08:31:06 jsg Exp $ */ +/* $OpenBSD: trap.c,v 1.123 2022/11/02 07:20:07 guenther Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -1397,7 +1397,6 @@ child_return(arg) tf = (struct trapframe *)USER_REGS(p); tf->tf_r[2] = 0; - tf->tf_r[3] = 0; tf->tf_epsr &= ~PSR_C; /* skip br instruction as in syscall() */ #ifdef M88100 diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index f4a06919cae..d044afd73e5 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.160 2022/10/07 14:59:39 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.161 2022/11/02 07:20:08 guenther Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -477,7 +477,7 @@ fault_common_no_miss: } rval[0] = 0; - rval[1] = locr0->v1; + rval[1] = 0; #if defined(DDB) || defined(DEBUG) trapdebug[TRAPSIZE * ci->ci_cpuid + (trppos[ci->ci_cpuid] == 0 ? @@ -489,7 +489,6 @@ fault_common_no_miss: switch (error) { case 0: locr0->v0 = rval[0]; - locr0->v1 = rval[1]; locr0->a3 = 0; break; @@ -839,7 +838,6 @@ child_return(void *arg) trapframe = p->p_md.md_regs; trapframe->v0 = 0; - trapframe->v1 = 1; trapframe->a3 = 0; KERNEL_UNLOCK(); diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index da68970686b..6c7e433e44d 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.126 2022/10/22 00:58:56 gkoehler Exp $ */ +/* $OpenBSD: trap.c,v 1.127 2022/11/02 07:20:07 guenther Exp $ */ /* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */ /* @@ -563,7 +563,6 @@ child_return(void *arg) tf->fixreg[0] = 0; tf->fixreg[FIRSTARG] = 0; - tf->fixreg[FIRSTARG + 1] = 1; tf->cr &= ~0x10000000; /* Disable FPU, VECT, as we can't be fpuproc */ tf->srr1 &= ~(PSL_FP|PSL_VEC); diff --git a/sys/arch/powerpc64/powerpc64/syscall.c b/sys/arch/powerpc64/powerpc64/syscall.c index 95fb92b5915..d47076d1824 100644 --- a/sys/arch/powerpc64/powerpc64/syscall.c +++ b/sys/arch/powerpc64/powerpc64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.8 2021/12/09 00:26:11 guenther Exp $ */ +/* $OpenBSD: syscall.c,v 1.9 2022/11/02 07:20:08 guenther Exp $ */ /* * Copyright (c) 2015 Dale Rahn @@ -64,7 +64,7 @@ syscall(struct trapframe *frame) } rval[0] = 0; - rval[1] = frame->fixreg[4]; + rval[1] = 0; error = mi_syscall(p, code, callp, args, rval); @@ -72,7 +72,6 @@ syscall(struct trapframe *frame) case 0: frame->fixreg[0] = 0; frame->fixreg[3] = rval[0]; - frame->fixreg[4] = rval[1]; frame->cr &= ~0x10000000; break; @@ -102,7 +101,6 @@ child_return(void *arg) frame->fixreg[0] = 0; frame->fixreg[3] = 0; - frame->fixreg[4] = 1; frame->cr &= ~0x10000000; KERNEL_UNLOCK(); diff --git a/sys/arch/riscv64/riscv64/syscall.c b/sys/arch/riscv64/riscv64/syscall.c index 81685bfd608..1e1b2ce6ed5 100644 --- a/sys/arch/riscv64/riscv64/syscall.c +++ b/sys/arch/riscv64/riscv64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.12 2022/02/22 13:34:23 visa Exp $ */ +/* $OpenBSD: syscall.c,v 1.13 2022/11/02 07:20:08 guenther Exp $ */ /* * Copyright (c) 2020 Brian Bamsch @@ -84,14 +84,13 @@ svc_handler(trapframe_t *frame) } rval[0] = 0; - rval[1] = frame->tf_a[1]; + rval[1] = 0; error = mi_syscall(p, code, callp, args, rval); switch (error) { case 0: frame->tf_a[0] = rval[0]; - frame->tf_a[1] = rval[1]; frame->tf_t[0] = 0; /* syscall succeeded */ break; @@ -119,7 +118,6 @@ child_return(void *arg) struct trapframe *frame = process_frame(p); frame->tf_a[0] = 0; - frame->tf_a[1] = 1; frame->tf_t[0] = 0; /* no error */ KERNEL_UNLOCK(); diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index 540b0b48d72..8682eefb4be 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.111 2022/10/21 18:55:42 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.112 2022/11/02 07:20:08 guenther Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -1175,7 +1175,7 @@ syscall(struct trapframe *tf, register_t code, register_t pc) } rval[0] = 0; - rval[1] = tf->tf_out[1]; + rval[1] = 0; error = mi_syscall(p, code, callp, args, rval); @@ -1184,7 +1184,6 @@ syscall(struct trapframe *tf, register_t code, register_t pc) case 0: /* Note: fork() does not return here in the child */ tf->tf_out[0] = rval[0]; - tf->tf_out[1] = rval[1]; if (new) { /* jmp %g2 on success */ dest = tf->tf_global[2]; @@ -1247,7 +1246,6 @@ child_return(void *arg) * Return values in the frame set by cpu_fork(). */ tf->tf_out[0] = 0; - tf->tf_out[1] = 0; KERNEL_UNLOCK(); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 4c3b5d071f3..e02a40aa4a4 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.242 2022/08/14 01:58:27 jsg Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.243 2022/11/02 07:20:07 guenther Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -502,10 +502,8 @@ fork1(struct proc *curp, int flags, void (*func)(void *), void *arg, /* * Return child pid to parent process */ - if (retval != NULL) { - retval[0] = pr->ps_pid; - retval[1] = 0; - } + if (retval != NULL) + *retval = pr->ps_pid; return (0); } @@ -574,8 +572,7 @@ thread_fork(struct proc *curp, void *stack, void *tcb, pid_t *tidptr, /* * Return tid to parent thread and copy it out to userspace */ - retval[0] = tid = p->p_tid + THREAD_PID_OFFSET; - retval[1] = 0; + *retval = tid = p->p_tid + THREAD_PID_OFFSET; if (tidptr != NULL) { if (copyout(&tid, tidptr, sizeof(tid))) psignal(curp, SIGSEGV);