diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 231897509a36..1155eaa83701 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -841,11 +841,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, idle, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, * Reset registers to default values on exec. */ void -exec_setregs(td, entry, stack, ps_strings) - struct thread *td; - u_long entry; - u_long stack; - u_long ps_strings; +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; @@ -863,7 +859,7 @@ exec_setregs(td, entry, stack, ps_strings) pcb->pcb_full_iret = 1; bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_rip = entry; + regs->tf_rip = imgp->entry_addr; regs->tf_rsp = ((stack - 8) & ~0xFul) + 8; regs->tf_rdi = stack; /* argv */ regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T); diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c index 10ec641bc61d..a4293c89a3b1 100644 --- a/sys/amd64/ia32/ia32_signal.c +++ b/sys/amd64/ia32/ia32_signal.c @@ -701,11 +701,7 @@ freebsd32_sigreturn(td, uap) * Clear registers on exec */ void -ia32_setregs(td, entry, stack, ps_strings) - struct thread *td; - u_long entry; - u_long stack; - u_long ps_strings; +ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; @@ -721,12 +717,12 @@ ia32_setregs(td, entry, stack, ps_strings) pcb->pcb_initial_fpucw = __INITIAL_FPUCW_I386__; bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_rip = entry; + regs->tf_rip = imgp->entry_addr; regs->tf_rsp = stack; regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T); regs->tf_ss = _udatasel; regs->tf_cs = _ucode32sel; - regs->tf_rbx = ps_strings; + regs->tf_rbx = imgp->ps_strings; regs->tf_ds = _udatasel; regs->tf_es = _udatasel; regs->tf_fs = _ufssel; diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index d967ad70113f..06f1e979e33a 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -124,8 +124,8 @@ static register_t *linux_copyout_strings(struct image_params *imgp); static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params); static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); -static void exec_linux_setregs(struct thread *td, u_long entry, - u_long stack, u_long ps_strings); +static void exec_linux_setregs(struct thread *td, + struct image_params *imgp, u_long stack); static void linux32_fixlimit(struct rlimit *rl, int which); static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel); @@ -828,11 +828,7 @@ exec_linux_imgact_try(struct image_params *imgp) * XXX copied from ia32_signal.c. */ static void -exec_linux_setregs(td, entry, stack, ps_strings) - struct thread *td; - u_long entry; - u_long stack; - u_long ps_strings; +exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; @@ -852,7 +848,7 @@ exec_linux_setregs(td, entry, stack, ps_strings) pcb->pcb_initial_fpucw = __LINUX_NPXCW__; bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_rip = entry; + regs->tf_rip = imgp->entry_addr; regs->tf_rsp = stack; regs->tf_rflags = PSL_USER | (regs->tf_rflags & PSL_T); regs->tf_gs = _ugssel; @@ -862,7 +858,7 @@ exec_linux_setregs(td, entry, stack, ps_strings) regs->tf_ss = _udatasel; regs->tf_flags = TF_HASSEGS; regs->tf_cs = _ucode32sel; - regs->tf_rbx = ps_strings; + regs->tf_rbx = imgp->ps_strings; td->td_pcb->pcb_full_iret = 1; load_cr0(rcr0() | CR0_MP | CR0_TS); fpstate_drop(td); diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index 49af8e2cdf48..088d2257cee9 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -516,15 +516,15 @@ spinlock_exit(void) * Clear registers on exec */ void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf = td->td_frame; memset(tf, 0, sizeof(*tf)); tf->tf_usr_sp = stack; - tf->tf_usr_lr = entry; + tf->tf_usr_lr = imgp->entry_addr; tf->tf_svc_lr = 0x77777777; - tf->tf_pc = entry; + tf->tf_pc = imgp->entry_addr; tf->tf_spsr = PSR_USR32_MODE; } diff --git a/sys/compat/ia32/ia32_signal.h b/sys/compat/ia32/ia32_signal.h index 6ebb0defc634..9daa8d52293f 100644 --- a/sys/compat/ia32/ia32_signal.h +++ b/sys/compat/ia32/ia32_signal.h @@ -185,5 +185,5 @@ extern char freebsd4_ia32_sigcode[]; extern int sz_ia32_sigcode; extern int sz_freebsd4_ia32_sigcode; extern void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *); -extern void ia32_setregs(struct thread *td, u_long entry, u_long stack, - u_long ps_strings); +extern void ia32_setregs(struct thread *td, struct image_params *imgp, + u_long stack); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 1ef94ead8c5f..695b656f21b8 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1461,11 +1461,7 @@ SYSCTL_PROC(_machdep, OID_AUTO, idle, CTLTYPE_STRING | CTLFLAG_RW, 0, 0, * Reset registers to default values on exec. */ void -exec_setregs(td, entry, stack, ps_strings) - struct thread *td; - u_long entry; - u_long stack; - u_long ps_strings; +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; @@ -1481,7 +1477,7 @@ exec_setregs(td, entry, stack, ps_strings) mtx_unlock_spin(&dt_lock); bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_eip = entry; + regs->tf_eip = imgp->entry_addr; regs->tf_esp = stack; regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T); regs->tf_ss = _udatasel; @@ -1491,7 +1487,7 @@ exec_setregs(td, entry, stack, ps_strings) regs->tf_cs = _ucodesel; /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */ - regs->tf_ebx = ps_strings; + regs->tf_ebx = imgp->ps_strings; /* * Reset the hardware debug registers if they were in use. diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 069b5bb85722..3f0c6f4100e6 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -105,8 +105,8 @@ static int elf_linux_fixup(register_t **stack_base, static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params); static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask); -static void exec_linux_setregs(struct thread *td, u_long entry, - u_long stack, u_long ps_strings); +static void exec_linux_setregs(struct thread *td, + struct image_params *imgp, u_long stack); static register_t *linux_copyout_strings(struct image_params *imgp); static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel); @@ -927,12 +927,11 @@ exec_linux_imgact_try(struct image_params *imgp) * override the exec_setregs default(s) here. */ static void -exec_linux_setregs(struct thread *td, u_long entry, - u_long stack, u_long ps_strings) +exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct pcb *pcb = td->td_pcb; - exec_setregs(td, entry, stack, ps_strings); + exec_setregs(td, imgp, stack); /* Linux sets %gs to 0, we default to _udatasel */ pcb->pcb_gs = 0; diff --git a/sys/ia64/ia32/ia32_signal.c b/sys/ia64/ia32/ia32_signal.c index a981c8444cde..e5eee411ccdd 100644 --- a/sys/ia64/ia32/ia32_signal.c +++ b/sys/ia64/ia32/ia32_signal.c @@ -120,7 +120,7 @@ freebsd32_sigreturn(struct thread *td, struct freebsd32_sigreturn_args *uap) void -ia32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf = td->td_frame; vm_offset_t gdt, ldt; @@ -129,7 +129,7 @@ ia32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) struct segment_descriptor desc; struct vmspace *vmspace = td->td_proc->p_vmspace; - exec_setregs(td, entry, stack, ps_strings); + exec_setregs(td, imgp, stack); /* Non-syscall frames are cleared by exec_setregs() */ if (tf->tf_flags & FRAME_SYSCALL) { diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index ec3d612ebaca..9f47a9a18035 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -1328,7 +1328,7 @@ set_mcontext(struct thread *td, const mcontext_t *mc) * Clear registers on exec. */ void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf; uint64_t *ksttop, *kst; @@ -1366,7 +1366,7 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) *kst-- = 0; if (((uintptr_t)kst & 0x1ff) == 0x1f8) *kst-- = 0; - *kst-- = ps_strings; + *kst-- = imgp->ps_strings; if (((uintptr_t)kst & 0x1ff) == 0x1f8) *kst-- = 0; *kst = stack; @@ -1385,7 +1385,7 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) suword((caddr_t)tf->tf_special.bspstore - 8, 0); } - tf->tf_special.iip = entry; + tf->tf_special.iip = imgp->entry_addr; tf->tf_special.sp = (stack & ~15) - 16; tf->tf_special.rsc = 0xf; tf->tf_special.fpsr = IA64_FPSR_DEFAULT; diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index c7a4358270ae..17a0ac61865b 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -799,11 +799,10 @@ do_execve(td, args, mac_p) /* Set values passed into the program in registers. */ if (p->p_sysent->sv_setregs) - (*p->p_sysent->sv_setregs)(td, imgp->entry_addr, - (u_long)(uintptr_t)stack_base, imgp->ps_strings); + (*p->p_sysent->sv_setregs)(td, imgp, + (u_long)(uintptr_t)stack_base); else - exec_setregs(td, imgp->entry_addr, - (u_long)(uintptr_t)stack_base, imgp->ps_strings); + exec_setregs(td, imgp, (u_long)(uintptr_t)stack_base); vfs_mark_atime(imgp->vp, td->td_ucred); diff --git a/sys/mips/mips/pm_machdep.c b/sys/mips/mips/pm_machdep.c index 712763b1020b..03867b0a8390 100644 --- a/sys/mips/mips/pm_machdep.c +++ b/sys/mips/mips/pm_machdep.c @@ -472,7 +472,7 @@ set_fpregs(struct thread *td, struct fpreg *fpregs) * code by the MIPS elf abi). */ void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { bzero((caddr_t)td->td_frame, sizeof(struct trapframe)); @@ -481,8 +481,8 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) * Make sp 64-bit aligned. */ td->td_frame->sp = ((register_t) stack) & ~(sizeof(__int64_t) - 1); - td->td_frame->pc = entry & ~3; - td->td_frame->t9 = entry & ~3; /* abicall req */ + td->td_frame->pc = imgp->entry_addr & ~3; + td->td_frame->t9 = imgp->entry_addr & ~3; /* abicall req */ #if 0 // td->td_frame->sr = SR_KSU_USER | SR_EXL | SR_INT_ENAB; //? td->td_frame->sr |= idle_mask & ALL_INT_MASK; @@ -511,7 +511,7 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) td->td_frame->a0 = (register_t) stack; td->td_frame->a1 = 0; td->td_frame->a2 = 0; - td->td_frame->a3 = (register_t)ps_strings; + td->td_frame->a3 = (register_t)imgp->ps_strings; td->td_md.md_flags &= ~MDTD_FPUSED; if (PCPU_GET(fpcurthread) == td) diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index f17874820b01..f470b5ef5efe 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1172,11 +1172,7 @@ void (*cpu_idle_hook)(void) = cpu_idle_default; * Reset registers to default values on exec. */ void -exec_setregs(td, entry, stack, ps_strings) - struct thread *td; - u_long entry; - u_long stack; - u_long ps_strings; +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *regs = td->td_frame; struct pcb *pcb = td->td_pcb; @@ -1192,7 +1188,7 @@ exec_setregs(td, entry, stack, ps_strings) mtx_unlock_spin(&dt_lock); bzero((char *)regs, sizeof(struct trapframe)); - regs->tf_eip = entry; + regs->tf_eip = imgp->entry_addr; regs->tf_esp = stack; regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T); regs->tf_ss = _udatasel; @@ -1202,7 +1198,7 @@ exec_setregs(td, entry, stack, ps_strings) regs->tf_cs = _ucodesel; /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */ - regs->tf_ebx = ps_strings; + regs->tf_ebx = imgp->ps_strings; /* * Reset the hardware debug registers if they were in use. diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c index a9cf051b57fd..49aae27cfe62 100644 --- a/sys/powerpc/aim/machdep.c +++ b/sys/powerpc/aim/machdep.c @@ -951,7 +951,7 @@ cpu_idle_wakeup(int cpu) * Set set up registers on exec. */ void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf; struct ps_strings arginfo; @@ -995,7 +995,7 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) tf->fixreg[7] = 0; /* termination vector */ tf->fixreg[8] = (register_t)PS_STRINGS; /* NetBSD extension */ - tf->srr0 = entry; + tf->srr0 = imgp->entry_addr; tf->srr1 = PSL_MBO | PSL_USERSET | PSL_FE_DFLT; td->td_pcb->pcb_flags = 0; } diff --git a/sys/powerpc/booke/machdep.c b/sys/powerpc/booke/machdep.c index e9a0099497cd..8a53b7355f97 100644 --- a/sys/powerpc/booke/machdep.c +++ b/sys/powerpc/booke/machdep.c @@ -509,7 +509,7 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz) /* Set set up registers on exec. */ void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf; struct ps_strings arginfo; @@ -553,7 +553,7 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) tf->fixreg[7] = 0; /* termination vector */ tf->fixreg[8] = (register_t)PS_STRINGS; /* NetBSD extension */ - tf->srr0 = entry; + tf->srr0 = imgp->entry_addr; tf->srr1 = PSL_USERSET; td->td_pcb->pcb_flags = 0; } diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index 9eab20fce39d..a020fb8038fe 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -969,7 +969,7 @@ ptrace_clear_single_step(struct thread *td) } void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf; struct pcb *pcb; @@ -992,8 +992,8 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) tf->tf_out[0] = stack; tf->tf_out[3] = p->p_sysent->sv_psstrings; tf->tf_out[6] = sp - SPOFF - sizeof(struct frame); - tf->tf_tnpc = entry + 4; - tf->tf_tpc = entry; + tf->tf_tnpc = imgp->entry_addr + 4; + tf->tf_tpc = imgp->entry_addr; tf->tf_tstate = TSTATE_IE | TSTATE_PEF | TSTATE_MM_TSO; td->td_retval[0] = tf->tf_out[0]; diff --git a/sys/sun4v/sun4v/machdep.c b/sys/sun4v/sun4v/machdep.c index 3913d35ca02a..e14eebd9f8c3 100644 --- a/sys/sun4v/sun4v/machdep.c +++ b/sys/sun4v/sun4v/machdep.c @@ -869,7 +869,7 @@ ptrace_clear_single_step(struct thread *td) } void -exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) +exec_setregs(struct thread *td, struct image_params *imgp, u_long stack) { struct trapframe *tf; struct pcb *pcb; @@ -897,8 +897,8 @@ exec_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings) tf->tf_out[3] = p->p_sysent->sv_psstrings; tf->tf_out[6] = sp - SPOFF - sizeof(struct frame); - tf->tf_tnpc = entry + 4; - tf->tf_tpc = entry; + tf->tf_tnpc = imgp->entry_addr + 4; + tf->tf_tpc = imgp->entry_addr; tf->tf_tstate = TSTATE_IE | TSTATE_PEF | TSTATE_MM_TSO; td->td_retval[0] = tf->tf_out[0]; diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index 79b389ebe381..86984f6cafb6 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -80,7 +80,7 @@ struct thread; int exec_check_permissions(struct image_params *); register_t *exec_copyout_strings(struct image_params *); int exec_new_vmspace(struct image_params *, struct sysentvec *); -void exec_setregs(struct thread *, u_long, u_long, u_long); +void exec_setregs(struct thread *, struct image_params *, u_long); int exec_shell_imgact(struct image_params *); int exec_copyin_args(struct image_args *, char *, enum uio_seg, char **, char **); diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 707c00bc444f..c3a19d82d16c 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -98,7 +98,8 @@ struct sysentvec { vm_offset_t sv_psstrings; /* PS_STRINGS */ int sv_stackprot; /* vm protection for stack */ register_t *(*sv_copyout_strings)(struct image_params *); - void (*sv_setregs)(struct thread *, u_long, u_long, u_long); + void (*sv_setregs)(struct thread *, struct image_params *, + u_long); void (*sv_fixlimit)(struct rlimit *, int); u_long *sv_maxssiz; u_int sv_flags;