Fix execve(2) and *setregs() interfaces so emulations can set registers in a

more correct way.  (See tech-kern.)
This commit is contained in:
mycroft 1997-09-11 23:01:44 +00:00
parent 5388cd2717
commit 16a8787248
25 changed files with 71 additions and 102 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.84 1997/09/02 18:54:28 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/11 23:01:44 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.84 1997/09/02 18:54:28 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.85 1997/09/11 23:01:44 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1467,11 +1467,10 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
* Set registers on exec.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct trapframe *tfp = p->p_md.md_tf;
extern struct proc *fpcurproc;
@ -1509,8 +1508,6 @@ setregs(p, pack, stack, retval)
p->p_md.md_flags &= ~MDP_FPUSED;
if (fpcurproc == p)
fpcurproc = NULL;
retval[0] = retval[1] = 0;
}
void
@ -1695,18 +1692,17 @@ delay(n)
#if defined(COMPAT_OSF1) || 1 /* XXX */
void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
u_long, register_t *));
u_long));
void
cpu_exec_ecoff_setregs(p, epp, stack, retval)
cpu_exec_ecoff_setregs(p, epp, stack)
struct proc *p;
struct exec_package *epp;
u_long stack;
register_t *retval;
{
struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr;
setregs(p, epp, stack, retval);
setregs(p, epp, stack);
p->p_md.md_tf->tf_regs[FRAME_GP] = execp->a.gp_value;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.95 1997/08/27 18:31:17 is Exp $ */
/* $NetBSD: machdep.c,v 1.96 1997/09/11 23:01:48 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -468,11 +468,10 @@ again:
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct frame *frame = (struct frame *)p->p_md.md_regs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.24 1997/07/31 02:59:06 mark Exp $ */
/* $NetBSD: machdep.c,v 1.25 1997/09/11 23:01:52 mycroft Exp $ */
/*
* Copyright (c) 1994-1996 Mark Brinicombe.
@ -2570,11 +2570,10 @@ setleds(led)
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
register struct trapframe *tf;
@ -2598,8 +2597,6 @@ setregs(p, pack, stack, retval)
tf->tf_spsr = PSR_USR32_MODE;
p->p_addr->u_pcb.pcb_flags = 0;
retval[1] = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.50 1997/07/15 06:49:56 leo Exp $ */
/* $NetBSD: machdep.c,v 1.51 1997/09/11 23:01:55 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -380,11 +380,10 @@ again:
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct frame *frame = (struct frame *)p->p_md.md_regs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_machdep.c,v 1.13 1997/04/27 21:38:57 thorpej Exp $ */
/* $NetBSD: hpux_machdep.c,v 1.14 1997/09/11 23:01:57 mycroft Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Jason R. Thorpe. All rights reserved.
@ -685,11 +685,10 @@ hpux_sys_sigreturn(p, v, retval)
* XXX Should clear registers except sp, pc.
*/
void
hpux_setregs(p, pack, stack, retval)
hpux_setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct frame *frame = (struct frame *)p->p_md.md_regs;
@ -704,9 +703,9 @@ hpux_setregs(p, pack, stack, retval)
p->p_md.md_flags &= ~MDP_HPUXMMAP;
frame->f_regs[A0] = 0; /* not 68010 (bit 31), no FPA (30) */
retval[0] = 0; /* no float card */
frame->f_regs[D0] = 0; /* no float card */
if (fputype)
retval[1] = 1; /* yes 68881 */
frame->f_regs[D1] = 1; /* yes 68881 */
else
retval[1] = 0; /* no 68881 */
frame->f_regs[D1] = 0; /* no 68881 */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.94 1997/06/12 15:46:29 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.95 1997/09/11 23:02:00 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -439,11 +439,10 @@ allocsys(v)
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct frame *frame = (struct frame *)p->p_md.md_regs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.250 1997/09/05 01:44:42 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.251 1997/09/11 23:02:02 mycroft Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@ -1282,11 +1282,10 @@ dumpsys()
* Clear registers on exec
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
register struct pcb *pcb = &p->p_addr->u_pcb;
register struct trapframe *tf;
@ -1317,8 +1316,6 @@ setregs(p, pack, stack, retval)
tf->tf_eflags = PSL_USERSET;
tf->tf_esp = stack;
tf->tf_ss = LSEL(LUDATA_SEL, SEL_UPL);
retval[1] = 0;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.160 1997/09/10 03:43:48 scottr Exp $ */
/* $NetBSD: machdep.c,v 1.161 1997/09/11 23:02:05 mycroft Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@ -525,25 +525,22 @@ void via_shutdown __P((void));
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, sp, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long sp;
register_t *retval;
u_long stack;
{
struct frame *frame;
struct frame *frame = (struct frame *)p->p_md.md_regs;
frame = (struct frame *) p->p_md.md_regs;
frame->f_pc = pack->ep_entry & ~1;
frame->f_regs[SP] = sp;
frame->f_regs[SP] = stack;
frame->f_regs[A2] = (int) PS_STRINGS;
/* restore a null state frame */
p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
if (fputype) {
if (fputype)
m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
}
}
int waittime = -1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu_exec.c,v 1.13 1997/07/19 09:54:33 jonathan Exp $ */
/* $NetBSD: cpu_exec.c,v 1.14 1997/09/11 23:02:09 mycroft Exp $ */
/*
* Copyright (c) 1992, 1993
@ -135,15 +135,14 @@ cpu_exec_aout_makecmds(p, epp)
extern struct emul emul_ultrix;
void
cpu_exec_ecoff_setregs(p, epp, stack, retval)
cpu_exec_ecoff_setregs(p, epp, stack)
struct proc *p;
struct exec_package *epp;
u_long stack;
register_t *retval;
{
struct ecoff_exechdr *execp = (struct ecoff_exechdr *)epp->ep_hdr;
setregs(p, epp, stack, retval);
setregs(p, epp, stack);
p->p_md.md_regs[GP] = execp->a.gp_value;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mips_machdep.c,v 1.19 1997/08/09 19:06:45 jonathan Exp $ */
/* $NetBSD: mips_machdep.c,v 1.20 1997/09/11 23:02:10 mycroft Exp $ */
/*
* Copyright 1996 The Board of Trustees of The Leland Stanford
@ -405,11 +405,10 @@ cpu_identify()
* code by the MIPS elf abi).
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
extern struct proc *fpcurproc;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.21 1997/06/12 15:46:37 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.22 1997/09/11 23:02:12 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -510,11 +510,10 @@ allocsys(v)
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct frame *frame = (struct frame *)p->p_md.md_regs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.10 1997/06/12 15:46:44 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.11 1997/09/11 23:02:17 mycroft Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -523,11 +523,10 @@ consinit()
* Set set up registers on exec.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct trapframe *tf = trapframe(p);
struct ps_strings arginfo;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.66 1997/06/12 15:46:39 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.67 1997/09/11 23:02:14 mycroft Exp $ */
/*-
* Copyright (c) 1996 Matthias Pfaller.
@ -865,11 +865,10 @@ err:
* Clear registers on exec
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct reg *r = p->p_md.md_regs;
struct pcb *pcbp = &p->p_addr->u_pcb;
@ -886,8 +885,6 @@ setregs(p, pack, stack, retval)
pcbp->pcb_fsr = FPC_UEN;
bzero(pcbp->pcb_freg, sizeof(pcbp->pcb_freg));
retval[1] = 0;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.10 1997/06/12 15:46:44 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.11 1997/09/11 23:02:17 mycroft Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -523,11 +523,10 @@ consinit()
* Set set up registers on exec.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct trapframe *tf = trapframe(p);
struct ps_strings arginfo;

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.83 1997/07/29 10:04:44 fair Exp $ */
/* $NetBSD: machdep.c,v 1.84 1997/09/11 23:02:19 mycroft Exp $ */
/*
* Copyright (c) 1992, 1993
@ -374,11 +374,10 @@ allocsys(v)
*/
/* ARGSUSED */
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
register struct trapframe *tf = p->p_md.md_tf;
register struct fpstate *fs;
@ -413,7 +412,6 @@ setregs(p, pack, stack, retval)
tf->tf_global[2] = tf->tf_global[7] = tf->tf_npc;
stack -= sizeof(struct rwindow);
tf->tf_out[6] = stack;
retval[1] = 0;
}
#ifdef DEBUG

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.96 1997/08/12 16:52:12 gwr Exp $ */
/* $NetBSD: machdep.c,v 1.97 1997/09/11 23:02:22 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -384,11 +384,10 @@ cpu_startup()
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
@ -398,9 +397,9 @@ setregs(p, pack, stack, retval)
/* restore a null state frame */
p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
if (fputype) {
if (fputype)
m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
}
p->p_md.md_flags = 0;
/* XXX - HPUX sigcode hack would go here... */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.18 1997/06/12 15:46:50 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.19 1997/09/11 23:02:24 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -387,11 +387,10 @@ cpu_startup()
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
@ -401,9 +400,9 @@ setregs(p, pack, stack, retval)
/* restore a null state frame */
p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
if (fputype) {
if (fputype)
m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
}
p->p_md.md_flags = 0;
/* XXX - HPUX sigcode hack would go here... */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.18 1997/06/12 15:46:50 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.19 1997/09/11 23:02:24 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -387,11 +387,10 @@ cpu_startup()
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
@ -401,9 +400,9 @@ setregs(p, pack, stack, retval)
/* restore a null state frame */
p->p_addr->u_pcb.pcb_fpregs.fpf_null = 0;
if (fputype) {
if (fputype)
m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
}
p->p_md.md_flags = 0;
/* XXX - HPUX sigcode hack would go here... */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.28 1997/07/28 21:48:33 ragge Exp $ */
/* $NetBSD: trap.c,v 1.29 1997/09/11 23:02:26 mycroft Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -374,18 +374,16 @@ if(p){
}
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t retval[2];
{
struct trapframe *exptr;
exptr = p->p_addr->u_pcb.framep;
exptr->pc = pack->ep_entry + 2;
exptr->sp = stack;
retval[0] = retval[1] = 0;
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.13 1997/06/12 15:46:54 mrg Exp $ */
/* $NetBSD: machdep.c,v 1.14 1997/09/11 23:02:29 mycroft Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -390,11 +390,10 @@ again:
* but would break init; should be fixed soon.
*/
void
setregs(p, pack, stack, retval)
setregs(p, pack, stack)
register struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct frame *frame = (struct frame *)p->p_md.md_regs;

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_misc.c,v 1.11 1996/10/13 00:46:53 christos Exp $ */
/* $NetBSD: osf1_misc.c,v 1.12 1997/09/11 23:02:30 mycroft Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
@ -56,7 +56,7 @@ extern int scdebug;
extern struct sysent osf1_sysent[];
extern char *osf1_syscallnames[];
extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
u_long, register_t *));
u_long));
extern char sigcode[], esigcode[];

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_main.c,v 1.101 1997/06/14 04:18:34 thorpej Exp $ */
/* $NetBSD: init_main.c,v 1.102 1997/09/11 23:02:33 mycroft Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
@ -533,7 +533,8 @@ start_init(p)
* Now try to exec the program. If can't for any reason
* other than it doesn't exist, complain.
*/
if ((error = sys_execve(p, &args, retval)) == 0)
error = sys_execve(p, &args, retval);
if (error == 0 || error == EJUSTRETURN)
return;
if (error != ENOENT)
printf("exec %s: error %d\n", path, error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.84 1997/05/08 16:20:07 mycroft Exp $ */
/* $NetBSD: kern_exec.c,v 1.85 1997/09/11 23:02:32 mycroft Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -472,7 +472,7 @@ sys_execve(p, v, retval)
vrele(pack.ep_vp);
/* setup new registers and do misc. setup. */
(*pack.ep_emul->e_setregs)(p, &pack, (u_long) stack, retval);
(*pack.ep_emul->e_setregs)(p, &pack, (u_long) stack);
if (p->p_flag & P_TRACED)
psignal(p, SIGTRAP);
@ -484,7 +484,8 @@ sys_execve(p, v, retval)
if (KTRPOINT(p, KTR_EMUL))
ktremul(p->p_tracep, p->p_emul->e_name);
#endif
return 0;
return (EJUSTRETURN);
bad:
/* free the vmspace-creation commands, and release their references */

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.h,v 1.64 1997/05/17 16:13:24 mycroft Exp $ */
/* $NetBSD: exec.h,v 1.65 1997/09/11 23:02:35 mycroft Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@ -170,7 +170,7 @@ int vmcmd_map_zero __P((struct proc *, struct exec_vmcmd *));
void *copyargs __P((struct exec_package *, struct ps_strings *,
void *, void *));
void setregs __P((struct proc *, struct exec_package *,
u_long, register_t *));
u_long));
int check_exec __P((struct proc *, struct exec_package *));
#ifdef DEBUG

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.50 1997/07/06 12:32:39 fvdl Exp $ */
/* $NetBSD: proc.h,v 1.51 1997/09/11 23:02:36 mycroft Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -89,7 +89,7 @@ struct emul {
void *, void *));
/* Set registers before execution */
void (*e_setregs) __P((struct proc *, struct exec_package *,
u_long, register_t *));
u_long));
char *e_sigcode; /* Start of sigcode */
char *e_esigcode; /* End of sigcode */
};