diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2022-10-30 17:43:41 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2022-10-30 17:43:41 +0000 |
commit | 7fcf4a44c22344d228a55f6c66dbb6d37e637600 (patch) | |
tree | 65f839bf558694d11847f50dc841c622ec5d30e5 /sys/arch/macppc | |
parent | 3321c0c1f4711e353e9395028e6fd5d5739d39f2 (diff) |
Simplfity setregs() by passing it the ps_strings and switching
sys_execve() to return EJUSTRETURN.
setregs() is the MD routine used by sys_execve() to set up the
thread's trapframe and PCB such that, on 'return' to userspace, it
has the register values defined by the ABI and otherwise zero. It
had to set the syscall retval[] values previously because the normal
syscall return path overwrites a couple registers with the retval[]
values. By instead returning EJUSTRETURN that and some complexity
with program-counter handling on m88k and sparc64 goes away.
Also, give setregs() add a 'struct ps_strings *arginfo' argument
so powerpc, powerpc64, and sh can directly get argc/argv/envp
values for registers instead of copyin()ing the one in userspace.
Improvements from miod@ and millert@
Testing assistance miod@, kettenis@, and aoyama@
ok miod@ kettenis@
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r-- | sys/arch/macppc/macppc/machdep.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sys/arch/macppc/macppc/machdep.c b/sys/arch/macppc/macppc/machdep.c index c6f09bb9b9c..1406c18f36a 100644 --- a/sys/arch/macppc/macppc/machdep.c +++ b/sys/arch/macppc/macppc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.198 2022/10/21 22:42:36 gkoehler Exp $ */ +/* $OpenBSD: machdep.c,v 1.199 2022/10/30 17:43:39 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -418,24 +418,21 @@ consinit(void) */ void setregs(struct proc *p, struct exec_package *pack, u_long stack, - register_t *retval) + struct ps_strings *arginfo) { u_int32_t newstack; u_int32_t pargs; - u_int32_t args[4]; - struct trapframe *tf = trapframe(p); + pargs = -roundup(-stack + 8, 16); newstack = (u_int32_t)(pargs - 32); - copyin ((void *)p->p_p->ps_strings, &args, 0x10); - - bzero(tf, sizeof *tf); + memset(tf, 0, sizeof *tf); tf->fixreg[1] = newstack; - tf->fixreg[3] = retval[0] = args[1]; /* XXX */ - tf->fixreg[4] = retval[1] = args[0]; /* XXX */ - tf->fixreg[5] = args[2]; /* XXX */ - tf->fixreg[6] = args[3]; /* XXX */ + tf->fixreg[3] = arginfo->ps_nargvstr; + tf->fixreg[4] = (register_t)arginfo->ps_argvstr; + tf->fixreg[5] = (register_t)arginfo->ps_envstr; + tf->fixreg[6] = arginfo->ps_nenvstr; tf->srr0 = pack->ep_entry; tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT; p->p_addr->u_pcb.pcb_flags = 0; |