Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Dec 2019 23:17:54 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355373 - in head/sys: amd64/amd64 amd64/cloudabi32 amd64/cloudabi64 amd64/ia32 amd64/linux amd64/linux32 arm/arm arm/cloudabi32 arm64/arm64 arm64/cloudabi32 arm64/cloudabi64 arm64/linu...
Message-ID:  <201912032317.xB3NHsjB022858@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Dec  3 23:17:54 2019
New Revision: 355373
URL: https://svnweb.freebsd.org/changeset/base/355373

Log:
  Use uintptr_t instead of register_t * for the stack base.
  
  - Use ustringp for the location of the argv and environment strings
    and allow destp to travel further down the stack for the stackgap
    and auxv regions.
  - Update the Linux copyout_strings variants to move destp down the
    stack as was done for the native ABIs in r263349.
  - Stop allocating a space for a stack gap in the Linux ABIs.  This
    used to hold translated system call arguments, but hasn't been used
    since r159992.
  
  Reviewed by:	kib
  Tested on:	md64 (amd64, i386, linux64), i386 (i386, linux)
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D22501

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  head/sys/amd64/ia32/ia32_signal.c
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/arm/arm/machdep.c
  head/sys/arm/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/arm64/elf32_machdep.c
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
  head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  head/sys/arm64/linux/linux_sysvec.c
  head/sys/compat/cloudabi32/cloudabi32_module.c
  head/sys/compat/cloudabi32/cloudabi32_util.h
  head/sys/compat/cloudabi64/cloudabi64_module.c
  head/sys/compat/cloudabi64/cloudabi64_util.h
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/compat/freebsd32/freebsd32_util.h
  head/sys/compat/ia32/ia32_signal.h
  head/sys/i386/cloudabi32/cloudabi32_sysvec.c
  head/sys/i386/i386/machdep.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/kern/imgact_aout.c
  head/sys/kern/imgact_elf.c
  head/sys/kern/kern_exec.c
  head/sys/mips/mips/freebsd32_machdep.c
  head/sys/mips/mips/pm_machdep.c
  head/sys/powerpc/include/reg.h
  head/sys/powerpc/powerpc/elf64_machdep.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/riscv/riscv/machdep.c
  head/sys/sparc64/sparc64/machdep.c
  head/sys/sys/imgact.h
  head/sys/sys/imgact_elf.h
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/amd64/amd64/machdep.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -577,7 +577,7 @@ freebsd4_sigreturn(struct thread *td, struct freebsd4_
  * Reset registers to default values on exec.
  */
 void
-exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
 {
 	struct trapframe *regs;
 	struct pcb *pcb;

Modified: head/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/amd64/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/amd64/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -53,7 +53,7 @@ extern struct sysent cloudabi32_sysent[];
 extern unsigned long ia32_maxssiz;
 
 static int
-cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
+cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp)
 {
 	int error;
 	uint32_t args[2];
@@ -73,16 +73,16 @@ cloudabi32_fixup_tcb(register_t **stack_base, struct i
 	 * refer to the auxiliary vector, which is stored right after
 	 * the TCB.
 	 */
-	args[0] = (uintptr_t)*stack_base;
-	args[1] = (uintptr_t)*stack_base +
+	args[0] = *stack_base;
+	args[1] = *stack_base +
 	    roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
-	*stack_base -= howmany(sizeof(args), sizeof(register_t));
-	return (copyout(args, *stack_base, sizeof(args)));
+	*stack_base -= roundup2(sizeof(args), sizeof(register_t));
+	return (copyout(args, (void *)*stack_base, sizeof(args)));
 }
 
 static void
 cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
-    unsigned long stack)
+    uintptr_t stack)
 {
 
 	ia32_setregs(td, imgp, stack);

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==============================================================================
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -48,7 +48,7 @@ extern const char *cloudabi64_syscallnames[];
 extern struct sysent cloudabi64_sysent[];
 
 static int
-cloudabi64_fixup_tcb(register_t **stack_base, struct image_params *imgp)
+cloudabi64_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp)
 {
 	int error;
 	register_t tcbptr;
@@ -64,12 +64,13 @@ cloudabi64_fixup_tcb(register_t **stack_base, struct i
 	 * containing a pointer to the TCB. %fs base will point to this.
 	 */
 	tcbptr = (register_t)*stack_base;
-	return (copyout(&tcbptr, --*stack_base, sizeof(tcbptr)));
+	*stack_base -= sizeof(tcbptr);
+	return (copyout(&tcbptr, (void *)*stack_base, sizeof(tcbptr)));
 }
 
 static void
 cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
-    unsigned long stack)
+    uintptr_t stack)
 {
 	struct trapframe *regs;
 

Modified: head/sys/amd64/ia32/ia32_signal.c
==============================================================================
--- head/sys/amd64/ia32/ia32_signal.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/amd64/ia32/ia32_signal.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -936,7 +936,7 @@ freebsd32_sigreturn(td, uap)
  * Clear registers on exec
  */
 void
-ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+ia32_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
 {
 	struct trapframe *regs;
 	struct pcb *pcb;

Modified: head/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- head/sys/amd64/linux/linux_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/amd64/linux/linux_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -97,8 +97,8 @@ extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
 static int	linux_copyout_strings(struct image_params *imgp,
-		    register_t **stack_base);
-static int	linux_fixup_elf(register_t **stack_base,
+		    uintptr_t *stack_base);
+static int	linux_fixup_elf(uintptr_t *stack_base,
 		    struct image_params *iparams);
 static bool	linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static void	linux_vdso_install(void *param);
@@ -106,7 +106,7 @@ static void	linux_vdso_deinstall(void *param);
 static void	linux_set_syscall_retval(struct thread *td, int error);
 static int	linux_fetch_syscall_args(struct thread *td);
 static void	linux_exec_setregs(struct thread *td, struct image_params *imgp,
-		    u_long stack);
+		    uintptr_t stack);
 static int	linux_vsyscall(struct thread *td);
 
 #define LINUX_T_UNKNOWN  255
@@ -224,7 +224,7 @@ linux_set_syscall_retval(struct thread *td, int error)
 }
 
 static int
-linux_copyout_auxargs(struct image_params *imgp, u_long *base)
+linux_copyout_auxargs(struct image_params *imgp, uintptr_t *base)
 {
 	Elf_Auxargs *args;
 	Elf_Auxinfo *argarray, *pos;
@@ -274,7 +274,7 @@ linux_copyout_auxargs(struct image_params *imgp, u_lon
 }
 
 static int
-linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
+linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp)
 {
 	Elf_Addr *base;
 
@@ -283,7 +283,7 @@ linux_fixup_elf(register_t **stack_base, struct image_
 	if (suword(base, (uint64_t)imgp->args->argc) == -1)
 		return (EFAULT);
 
-	*stack_base = (register_t *)base;
+	*stack_base = (uintptr_t)base;
 	return (0);
 }
 
@@ -293,11 +293,12 @@ linux_fixup_elf(register_t **stack_base, struct image_
  * as the initial stack pointer.
  */
 static int
-linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
+linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 {
 	int argc, envc, error;
 	char **vectp;
-	char *stringp, *destp;
+	char *stringp;
+	uintptr_t destp, ustringp;
 	struct ps_strings *arginfo;
 	char canary[LINUX_AT_RANDOM_LEN];
 	size_t execpath_len;
@@ -311,43 +312,45 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	p = imgp->proc;
 	arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
-	destp = (caddr_t)arginfo - SPARE_USRSPACE -
-	    roundup(sizeof(canary), sizeof(char *)) -
-	    roundup(execpath_len, sizeof(char *)) -
-	    roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
+	destp = (uintptr_t)arginfo;
 
 	if (execpath_len != 0) {
-		imgp->execpathp = (uintptr_t)arginfo - execpath_len;
-		error = copyout(imgp->execpath, (void *)imgp->execpathp,
-		    execpath_len);
+		destp -= execpath_len;
+		destp = rounddown2(destp, sizeof(void *));
+		imgp->execpathp = destp;
+		error = copyout(imgp->execpath, (void *)destp, execpath_len);
 		if (error != 0)
 			return (error);
 	}
 
 	/* Prepare the canary for SSP. */
 	arc4rand(canary, sizeof(canary), 0);
-	imgp->canary = (uintptr_t)arginfo -
-	    roundup(execpath_len, sizeof(char *)) -
-	    roundup(sizeof(canary), sizeof(char *));
-	error = copyout(canary, (void *)imgp->canary, sizeof(canary));
+	destp -= roundup(sizeof(canary), sizeof(void *));
+	imgp->canary = destp;
+	error = copyout(canary, (void *)destp, sizeof(canary));
 	if (error != 0)
 		return (error);
 
-	vectp = (char **)destp;
+	/* Allocate room for the argument and environment strings. */
+	destp -= ARG_MAX - imgp->args->stringspace;
+	destp = rounddown2(destp, sizeof(void *));
+	ustringp = destp;
 
 	/*
 	 * Starting with 2.24, glibc depends on a 16-byte stack alignment.
 	 * One "long argc" will be prepended later.
 	 */
-	vectp = (char **)((((uintptr_t)vectp + 8) & ~0xF) - 8);
+	if (destp % 16 == 0)
+		destp -= 8;
 
 	if (imgp->auxargs) {
-		error = imgp->sysent->sv_copyout_auxargs(imgp,
-		    (u_long *)&vectp);
+		error = imgp->sysent->sv_copyout_auxargs(imgp, &destp);
 		if (error != 0)
 			return (error);
 	}
 
+	vectp = (char **)destp;
+
 	/*
 	 * Allocate room for the argv[] and env vectors including the
 	 * terminating NULL pointers.
@@ -355,14 +358,15 @@ linux_copyout_strings(struct image_params *imgp, regis
 	vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
 
 	/* vectp also becomes our initial stack base. */
-	*stack_base = (register_t *)vectp;
+	*stack_base = (uintptr_t)vectp;
 
 	stringp = imgp->args->begin_argv;
 	argc = imgp->args->argc;
 	envc = imgp->args->envc;
 
 	/* Copy out strings - arguments and environment. */
-	error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
+	error = copyout(stringp, (void *)ustringp,
+	    ARG_MAX - imgp->args->stringspace);
 	if (error != 0)
 		return (error);
 
@@ -373,11 +377,11 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	/* Fill in argument portion of vector table. */
 	for (; argc > 0; --argc) {
-		if (suword(vectp++, (long)(intptr_t)destp) != 0)
+		if (suword(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* A null vector table pointer separates the argp's from the envp's. */
@@ -390,11 +394,11 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	/* Fill in environment portion of vector table. */
 	for (; envc > 0; --envc) {
-		if (suword(vectp++, (long)(intptr_t)destp) != 0)
+		if (suword(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* The end of the vector table is a null pointer. */
@@ -408,7 +412,8 @@ linux_copyout_strings(struct image_params *imgp, regis
  * Reset registers to default values on exec.
  */
 static void
-linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+linux_exec_setregs(struct thread *td, struct image_params *imgp,
+    uintptr_t stack)
 {
 	struct trapframe *regs;
 	struct pcb *pcb;

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/amd64/linux32/linux32_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -101,13 +101,13 @@ extern struct sysent linux32_sysent[LINUX32_SYS_MAXSYS
 
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
-static int	linux_fixup_elf(register_t **stack_base,
+static int	linux_fixup_elf(uintptr_t *stack_base,
 		    struct image_params *iparams);
 static int	linux_copyout_strings(struct image_params *imgp,
-		    register_t **stack_base);
+		    uintptr_t *stack_base);
 static void     linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
 static void	linux_exec_setregs(struct thread *td,
-				   struct image_params *imgp, u_long stack);
+				   struct image_params *imgp, uintptr_t stack);
 static void	linux32_fixlimit(struct rlimit *rl, int which);
 static bool	linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static void	linux_vdso_install(void *param);
@@ -246,7 +246,7 @@ linux_copyout_auxargs(struct image_params *imgp, u_lon
 }
 
 static int
-linux_fixup_elf(register_t **stack_base, struct image_params *imgp)
+linux_fixup_elf(uintptr_t *stack_base, struct image_params *imgp)
 {
 	Elf32_Addr *base;
 
@@ -254,7 +254,7 @@ linux_fixup_elf(register_t **stack_base, struct image_
 	base--;
 	if (suword32(base, (uint32_t)imgp->args->argc) == -1)
 		return (EFAULT);
-	*stack_base = (register_t *)base;
+	*stack_base = (uintptr_t)base;
 	return (0);
 }
 
@@ -677,7 +677,8 @@ linux32_fetch_syscall_args(struct thread *td)
  * XXX copied from ia32_signal.c.
  */
 static void
-linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+linux_exec_setregs(struct thread *td, struct image_params *imgp,
+    uintptr_t stack)
 {
 	struct trapframe *regs = td->td_frame;
 	struct pcb *pcb = td->td_pcb;
@@ -721,11 +722,12 @@ linux_exec_setregs(struct thread *td, struct image_par
  * XXX copied from ia32_sysvec.c.
  */
 static int
-linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
+linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 {
 	int argc, envc, error;
 	u_int32_t *vectp;
-	char *stringp, *destp;
+	char *stringp;
+	uintptr_t destp, ustringp;
 	struct linux32_ps_strings *arginfo;
 	char canary[LINUX_AT_RANDOM_LEN];
 	size_t execpath_len;
@@ -737,36 +739,38 @@ linux_copyout_strings(struct image_params *imgp, regis
 		execpath_len = 0;
 
 	arginfo = (struct linux32_ps_strings *)LINUX32_PS_STRINGS;
-	destp =	(caddr_t)arginfo - SPARE_USRSPACE -
-	    roundup(sizeof(canary), sizeof(char *)) -
-	    roundup(execpath_len, sizeof(char *)) -
-	    roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
+	destp = (uintptr_t)arginfo;
 
 	if (execpath_len != 0) {
-		imgp->execpathp = (uintptr_t)arginfo - execpath_len;
-		error = copyout(imgp->execpath, (void *)imgp->execpathp,
-		    execpath_len);
+		destp -= execpath_len;
+		destp = rounddown2(destp, sizeof(void *));
+		imgp->execpathp = destp;
+		error = copyout(imgp->execpath, (void *)destp, execpath_len);
 		if (error != 0)
 			return (error);
 	}
 
 	/* Prepare the canary for SSP. */
 	arc4rand(canary, sizeof(canary), 0);
-	imgp->canary = (uintptr_t)arginfo -
-	    roundup(execpath_len, sizeof(char *)) -
-	    roundup(sizeof(canary), sizeof(char *));
-	error = copyout(canary, (void *)imgp->canary, sizeof(canary));
+	destp -= roundup(sizeof(canary), sizeof(void *));
+	imgp->canary = destp;
+	error = copyout(canary, (void *)destp, sizeof(canary));
 	if (error != 0)
 		return (error);
 
-	vectp = (uint32_t *)destp;
+	/* Allocate room for the argument and environment strings. */
+	destp -= ARG_MAX - imgp->args->stringspace;
+	destp = rounddown2(destp, sizeof(void *));
+	ustringp = destp;
+
 	if (imgp->auxargs) {
-		error = imgp->sysent->sv_copyout_auxargs(imgp,
-		    (u_long *)&vectp);
+		error = imgp->sysent->sv_copyout_auxargs(imgp, &destp);
 		if (error != 0)
 			return (error);
 	}
 
+	vectp = (uint32_t *)destp;
+
 	/*
 	 * Allocate room for the argv[] and env vectors including the
 	 * terminating NULL pointers.
@@ -774,13 +778,15 @@ linux_copyout_strings(struct image_params *imgp, regis
 	vectp -= imgp->args->argc + 1 + imgp->args->envc + 1;
 
 	/* vectp also becomes our initial stack base. */
-	*stack_base = (register_t *)vectp;
+	*stack_base = (uintptr_t)vectp;
 
 	stringp = imgp->args->begin_argv;
 	argc = imgp->args->argc;
 	envc = imgp->args->envc;
+
 	/* Copy out strings - arguments and environment. */
-	error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
+	error = copyout(stringp, (void *)ustringp,
+	    ARG_MAX - imgp->args->stringspace);
 	if (error != 0)
 		return (error);
 
@@ -791,11 +797,11 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	/* Fill in argument portion of vector table. */
 	for (; argc > 0; --argc) {
-		if (suword32(vectp++, (uint32_t)(intptr_t)destp) != 0)
+		if (suword32(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* A null vector table pointer separates the argp's from the envp's. */
@@ -808,11 +814,11 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	/* Fill in environment portion of vector table. */
 	for (; envc > 0; --envc) {
-		if (suword32(vectp++, (uint32_t)(intptr_t)destp) != 0)
+		if (suword32(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* The end of the vector table is a null pointer. */

Modified: head/sys/arm/arm/machdep.c
==============================================================================
--- head/sys/arm/arm/machdep.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm/arm/machdep.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -412,7 +412,7 @@ spinlock_exit(void)
  * Clear registers on exec
  */
 void
-exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
 {
 	struct trapframe *tf = td->td_frame;
 

Modified: head/sys/arm/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/arm/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -49,7 +49,7 @@ extern struct sysent cloudabi32_sysent[];
 
 static void
 cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
-    unsigned long stack)
+    uintptr_t stack)
 {
 	struct trapframe *regs;
 

Modified: head/sys/arm64/arm64/elf32_machdep.c
==============================================================================
--- head/sys/arm64/arm64/elf32_machdep.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm64/arm64/elf32_machdep.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -232,7 +232,7 @@ freebsd32_set_syscall_retval(struct thread *td, int er
 
 static void
 freebsd32_setregs(struct thread *td, struct image_params *imgp,
-   u_long stack)
+   uintptr_t stack)
 {
 	struct trapframe *tf = td->td_frame;
 

Modified: head/sys/arm64/arm64/machdep.c
==============================================================================
--- head/sys/arm64/arm64/machdep.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm64/arm64/machdep.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -436,7 +436,7 @@ ptrace_clear_single_step(struct thread *td)
 }
 
 void
-exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
 {
 	struct trapframe *tf = td->td_frame;
 

Modified: head/sys/arm64/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/arm64/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm64/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -49,7 +49,7 @@ extern struct sysent cloudabi32_sysent[];
 
 static void
 cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
-    unsigned long stack)
+    uintptr_t stack)
 {
 	struct trapframe *regs;
 

Modified: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==============================================================================
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -49,7 +49,7 @@ extern struct sysent cloudabi64_sysent[];
 
 static void
 cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp,
-    unsigned long stack)
+    uintptr_t stack)
 {
 	struct trapframe *regs;
 

Modified: head/sys/arm64/linux/linux_sysvec.c
==============================================================================
--- head/sys/arm64/linux/linux_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/arm64/linux/linux_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -70,8 +70,8 @@ extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
 static int	linux_copyout_strings(struct image_params *imgp,
-		    register_t **stack_base);
-static int	linux_elf_fixup(register_t **stack_base,
+		    uintptr_t *stack_base);
+static int	linux_elf_fixup(uintptr_t *stack_base,
 		    struct image_params *iparams);
 static bool	linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static void	linux_vdso_install(const void *param);
@@ -79,7 +79,7 @@ static void	linux_vdso_deinstall(const void *param);
 static void	linux_set_syscall_retval(struct thread *td, int error);
 static int	linux_fetch_syscall_args(struct thread *td);
 static void	linux_exec_setregs(struct thread *td, struct image_params *imgp,
-		    u_long stack);
+		    uintptr_t stack);
 static int	linux_vsyscall(struct thread *td);
 
 /* DTrace init */
@@ -143,7 +143,7 @@ linux_set_syscall_retval(struct thread *td, int error)
 }
 
 static int
-linux_copyout_auxargs(struct image_params *imgp, u_long *base)
+linux_copyout_auxargs(struct image_params *imgp, uintptr_t *base)
 {
 	Elf_Auxargs *args;
 	Elf_Auxinfo *argarray, *pos;
@@ -198,7 +198,7 @@ linux_copyout_auxargs(struct image_params *imgp, u_lon
 }
 
 static int
-linux_elf_fixup(register_t **stack_base, struct image_params *imgp)
+linux_elf_fixup(uintptr_t *stack_base, struct image_params *imgp)
 {
 
 	LIN_SDT_PROBE0(sysvec, linux_elf_fixup, todo);
@@ -213,10 +213,11 @@ linux_elf_fixup(register_t **stack_base, struct image_
  * LINUXTODO: deduplicate against other linuxulator archs
  */
 static int
-linux_copyout_strings(struct image_params *imgp, register_t **stack_base)
+linux_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 {
 	char **vectp;
-	char *stringp, *destp;
+	char *stringp;
+	uintptr_t *destp, *ustringp;
 	struct ps_strings *arginfo;
 	char canary[LINUX_AT_RANDOM_LEN];
 	size_t execpath_len;
@@ -231,36 +232,38 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	p = imgp->proc;
 	arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
-	destp = (caddr_t)arginfo - SPARE_USRSPACE -
-	    roundup(sizeof(canary), sizeof(char *)) -
-	    roundup(execpath_len, sizeof(char *)) -
-	    roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
+	destp = (uintptr_t)arginfo;
 
 	if (execpath_len != 0) {
-		imgp->execpathp = (uintptr_t)arginfo - execpath_len;
-		error = copyout(imgp->execpath, (void *)imgp->execpathp,
-		    execpath_len);
+		destp -= execpath_len;
+		destp = rounddown2(destp, sizeof(void *));
+		imgp->execpathp = destp;
+		error = copyout(imgp->execpath, (void *)destp, execpath_len);
 		if (error != 0)
 			return (error);
 	}
 
 	/* Prepare the canary for SSP. */
 	arc4rand(canary, sizeof(canary), 0);
-	imgp->canary = (uintptr_t)arginfo -
-	    roundup(execpath_len, sizeof(char *)) -
-	    roundup(sizeof(canary), sizeof(char *));
-	error = copyout(canary, (void *)imgp->canary, sizeof(canary));
+	destp -= roundup(sizeof(canary), sizeof(void *));
+	imgp->canary = destp;
+	error = copyout(canary, (void *)destp, sizeof(canary));
 	if (error != 0)
 		return (error);
 
-	vectp = (char **)destp;
+	/* Allocate room for the argument and environment strings. */
+	destp -= ARG_MAX - imgp->args->stringspace;
+	destp = rounddown2(destp, sizeof(void *));
+	ustringp = destp;
+
 	if (imgp->auxargs) {
-		error = imgp->sysent->sv_copyout_auxargs(imgp,
-		    (u_long *)&vectp);
+		error = imgp->sysent->sv_copyout_auxargs(imgp, &destp);
 		if (error != 0)
 			return (error);
 	}
 
+	vectp = (char **)destp;
+
 	/*
 	 * Allocate room for argc and the argv[] and env vectors including the
 	 * terminating NULL pointers.
@@ -269,14 +272,15 @@ linux_copyout_strings(struct image_params *imgp, regis
 	vectp = (char **)STACKALIGN(vectp);
 
 	/* vectp also becomes our initial stack base. */
-	*stack_base = (register_t *)vectp;
+	*stack_base = (uintptr_t)vectp;
 
 	stringp = imgp->args->begin_argv;
 	argc = imgp->args->argc;
 	envc = imgp->args->envc;
 
 	/* Copy out strings - arguments and environment. */
-	error = copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
+	error = copyout(stringp, (void *)ustringp,
+	    ARG_MAX - imgp->args->stringspace);
 	if (error != 0)
 		return (error);
 
@@ -290,11 +294,11 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	/* Fill in argument portion of vector table. */
 	for (; argc > 0; --argc) {
-		if (suword(vectp++, (long)(intptr_t)destp) != 0)
+		if (suword(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* A null vector table pointer separates the argp's from the envp's. */
@@ -307,11 +311,11 @@ linux_copyout_strings(struct image_params *imgp, regis
 
 	/* Fill in environment portion of vector table. */
 	for (; envc > 0; --envc) {
-		if (suword(vectp++, (long)(intptr_t)destp) != 0)
+		if (suword(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* The end of the vector table is a null pointer. */
@@ -325,7 +329,8 @@ linux_copyout_strings(struct image_params *imgp, regis
  * Reset registers to default values on exec.
  */
 static void
-linux_exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+linux_exec_setregs(struct thread *td, struct image_params *imgp,
+    uintptr_t stack)
 {
 	struct trapframe *regs = td->td_frame;
 

Modified: head/sys/compat/cloudabi32/cloudabi32_module.c
==============================================================================
--- head/sys/compat/cloudabi32/cloudabi32_module.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/cloudabi32/cloudabi32_module.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -46,7 +46,7 @@ extern char _binary_cloudabi32_vdso_o_start[];
 extern char _binary_cloudabi32_vdso_o_end[];
 
 int
-cloudabi32_copyout_strings(struct image_params *imgp, register_t **stack_base)
+cloudabi32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 {
 	struct image_args *args;
 	uintptr_t begin;
@@ -56,12 +56,12 @@ cloudabi32_copyout_strings(struct image_params *imgp, 
 	args = imgp->args;
 	len = exec_args_get_begin_envv(args) - args->begin_argv;
 	begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t));
-	*stack_base = (register_t *)begin;
+	*stack_base = begin;
 	return (copyout(args->begin_argv, (void *)begin, len));
 }
 
 int
-cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
+cloudabi32_fixup(uintptr_t *stack_base, struct image_params *imgp)
 {
 	char canarybuf[64], pidbuf[16];
 	Elf32_Auxargs *args;
@@ -79,12 +79,12 @@ cloudabi32_fixup(register_t **stack_base, struct image
 	td = curthread;
 	td->td_proc->p_osrel = __FreeBSD_version;
 
-	argdata = *stack_base;
+	argdata = (void *)*stack_base;
 
 	/* Store canary for stack smashing protection. */
 	arc4rand(canarybuf, sizeof(canarybuf), 0);
-	*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
-	canary = *stack_base;
+	*stack_base -= roundup(sizeof(canarybuf), sizeof(register_t));
+	canary = (void *)*stack_base;
 	error = copyout(canarybuf, canary, sizeof(canarybuf));
 	if (error != 0)
 		return (error);
@@ -97,8 +97,8 @@ cloudabi32_fixup(register_t **stack_base, struct image
 	arc4rand(pidbuf, sizeof(pidbuf), 0);
 	pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
 	pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
-	*stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
-	pid = *stack_base;
+	*stack_base -= roundup(sizeof(pidbuf), sizeof(register_t));
+	pid = (void *)*stack_base;
 	error = copyout(pidbuf, pid, sizeof(pidbuf));
 	if (error != 0)
 		return (error);
@@ -135,13 +135,13 @@ cloudabi32_fixup(register_t **stack_base, struct image
 #undef PTR
 		{ .a_type = CLOUDABI_AT_NULL },
 	};
-	*stack_base -= howmany(sizeof(auxv), sizeof(register_t));
-	error = copyout(auxv, *stack_base, sizeof(auxv));
+	*stack_base -= roundup(sizeof(auxv), sizeof(register_t));
+	error = copyout(auxv, (void *)*stack_base, sizeof(auxv));
 	if (error != 0)
 		return (error);
 
 	/* Reserve space for storing the TCB. */
-	*stack_base -= howmany(sizeof(cloudabi32_tcb_t), sizeof(register_t));
+	*stack_base -= roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
 	return (0);
 }
 

Modified: head/sys/compat/cloudabi32/cloudabi32_util.h
==============================================================================
--- head/sys/compat/cloudabi32/cloudabi32_util.h	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/cloudabi32/cloudabi32_util.h	Tue Dec  3 23:17:54 2019	(r355373)
@@ -42,8 +42,8 @@ extern Elf32_Brandinfo cloudabi32_brand;
 #define	TO_PTR(x)	((void *)(uintptr_t)(x))
 
 /* Stack initialization during process execution. */
-int	cloudabi32_copyout_strings(struct image_params *, register_t **);
-int	cloudabi32_fixup(register_t **, struct image_params *);
+int	cloudabi32_copyout_strings(struct image_params *, uintptr_t *);
+int	cloudabi32_fixup(uintptr_t *, struct image_params *);
 
 int	cloudabi32_thread_setregs(struct thread *,
     const cloudabi32_threadattr_t *, uint32_t);

Modified: head/sys/compat/cloudabi64/cloudabi64_module.c
==============================================================================
--- head/sys/compat/cloudabi64/cloudabi64_module.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/cloudabi64/cloudabi64_module.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -46,7 +46,7 @@ extern char _binary_cloudabi64_vdso_o_start[];
 extern char _binary_cloudabi64_vdso_o_end[];
 
 int
-cloudabi64_copyout_strings(struct image_params *imgp, register_t **stack_base)
+cloudabi64_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 {
 	struct image_args *args;
 	uintptr_t begin;
@@ -56,12 +56,12 @@ cloudabi64_copyout_strings(struct image_params *imgp, 
 	args = imgp->args;
 	len = exec_args_get_begin_envv(args) - args->begin_argv;
 	begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t));
-	*stack_base = (register_t *)begin;
+	*stack_base = begin;
 	return (copyout(args->begin_argv, (void *)begin, len));
 }
 
 int
-cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
+cloudabi64_fixup(uintptr_t *stack_base, struct image_params *imgp)
 {
 	char canarybuf[64], pidbuf[16];
 	Elf64_Auxargs *args;
@@ -79,12 +79,12 @@ cloudabi64_fixup(register_t **stack_base, struct image
 	td = curthread;
 	td->td_proc->p_osrel = __FreeBSD_version;
 
-	argdata = *stack_base;
+	argdata = (void *)*stack_base;
 
 	/* Store canary for stack smashing protection. */
 	arc4rand(canarybuf, sizeof(canarybuf), 0);
-	*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
-	canary = *stack_base;
+	*stack_base -= roundup(sizeof(canarybuf), sizeof(register_t));
+	canary = (void *)*stack_base;
 	error = copyout(canarybuf, canary, sizeof(canarybuf));
 	if (error != 0)
 		return (error);
@@ -97,8 +97,8 @@ cloudabi64_fixup(register_t **stack_base, struct image
 	arc4rand(pidbuf, sizeof(pidbuf), 0);
 	pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
 	pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
-	*stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
-	pid = *stack_base;
+	*stack_base -= roundup(sizeof(pidbuf), sizeof(register_t));
+	pid = (void *)*stack_base;
 	error = copyout(pidbuf, pid, sizeof(pidbuf));
 	if (error != 0)
 		return (error);
@@ -135,13 +135,13 @@ cloudabi64_fixup(register_t **stack_base, struct image
 #undef PTR
 		{ .a_type = CLOUDABI_AT_NULL },
 	};
-	*stack_base -= howmany(sizeof(auxv), sizeof(register_t));
-	error = copyout(auxv, *stack_base, sizeof(auxv));
+	*stack_base -= roundup(sizeof(auxv), sizeof(register_t));
+	error = copyout(auxv, (void *)*stack_base, sizeof(auxv));
 	if (error != 0)
 		return (error);
 
 	/* Reserve space for storing the TCB. */
-	*stack_base -= howmany(sizeof(cloudabi64_tcb_t), sizeof(register_t));
+	*stack_base -= roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t));
 	return (0);
 }
 

Modified: head/sys/compat/cloudabi64/cloudabi64_util.h
==============================================================================
--- head/sys/compat/cloudabi64/cloudabi64_util.h	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/cloudabi64/cloudabi64_util.h	Tue Dec  3 23:17:54 2019	(r355373)
@@ -42,8 +42,8 @@ extern Elf64_Brandinfo cloudabi64_brand;
 #define	TO_PTR(x)	((void *)(uintptr_t)(x))
 
 /* Stack initialization during process execution. */
-int	cloudabi64_copyout_strings(struct image_params *, register_t **);
-int	cloudabi64_fixup(register_t **, struct image_params *);
+int	cloudabi64_copyout_strings(struct image_params *, uintptr_t *);
+int	cloudabi64_fixup(uintptr_t *, struct image_params *);
 
 int	cloudabi64_thread_setregs(struct thread *,
     const cloudabi64_threadattr_t *, uint64_t);

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/freebsd32/freebsd32_misc.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -3120,12 +3120,12 @@ syscall32_helper_unregister(struct syscall_helper_data
 }
 
 int
-freebsd32_copyout_strings(struct image_params *imgp, register_t **stack_base)
+freebsd32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base)
 {
 	int argc, envc, i;
 	u_int32_t *vectp;
 	char *stringp;
-	uintptr_t destp;
+	uintptr_t destp, ustringp;
 	struct freebsd32_ps_strings *arginfo;
 	char canary[sizeof(long) * 8];
 	int32_t pagesizes32[MAXPAGESIZES];
@@ -3195,20 +3195,24 @@ freebsd32_copyout_strings(struct image_params *imgp, r
 		return (error);
 	imgp->pagesizeslen = sizeof(pagesizes32);
 
+	/*
+	 * Allocate room for the argument and environment strings.
+	 */
 	destp -= ARG_MAX - imgp->args->stringspace;
 	destp = rounddown2(destp, sizeof(uint32_t));
+	ustringp = destp;
 
-	vectp = (uint32_t *)destp;
 	if (imgp->sysent->sv_stackgap != NULL)
-		imgp->sysent->sv_stackgap(imgp, (u_long *)&vectp);
+		imgp->sysent->sv_stackgap(imgp, &destp);
 
 	if (imgp->auxargs) {
-		error = imgp->sysent->sv_copyout_auxargs(imgp,
-		    (u_long *)&vectp);
+		error = imgp->sysent->sv_copyout_auxargs(imgp, &destp);
 		if (error != 0)
 			return (error);
 	}
 
+	vectp = (uint32_t *)destp;
+
 	/*
 	 * Allocate room for the argv[] and env vectors including the
 	 * terminating NULL pointers.
@@ -3218,7 +3222,7 @@ freebsd32_copyout_strings(struct image_params *imgp, r
 	/*
 	 * vectp also becomes our initial stack base
 	 */
-	*stack_base = (register_t *)vectp;
+	*stack_base = (uintptr_t)vectp;
 
 	stringp = imgp->args->begin_argv;
 	argc = imgp->args->argc;
@@ -3226,7 +3230,7 @@ freebsd32_copyout_strings(struct image_params *imgp, r
 	/*
 	 * Copy out strings - arguments and environment.
 	 */
-	error = copyout(stringp, (void *)destp,
+	error = copyout(stringp, (void *)ustringp,
 	    ARG_MAX - imgp->args->stringspace);
 	if (error != 0)
 		return (error);
@@ -3242,11 +3246,11 @@ freebsd32_copyout_strings(struct image_params *imgp, r
 	 * Fill in argument portion of vector table.
 	 */
 	for (; argc > 0; --argc) {
-		if (suword32(vectp++, (u_int32_t)(intptr_t)destp) != 0)
+		if (suword32(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* a null vector table pointer separates the argp's from the envp's */
@@ -3261,11 +3265,11 @@ freebsd32_copyout_strings(struct image_params *imgp, r
 	 * Fill in environment portion of vector table.
 	 */
 	for (; envc > 0; --envc) {
-		if (suword32(vectp++, (u_int32_t)(intptr_t)destp) != 0)
+		if (suword32(vectp++, ustringp) != 0)
 			return (EFAULT);
 		while (*stringp++ != 0)
-			destp++;
-		destp++;
+			ustringp++;
+		ustringp++;
 	}
 
 	/* end of vector table is a null pointer */

Modified: head/sys/compat/freebsd32/freebsd32_util.h
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_util.h	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/freebsd32/freebsd32_util.h	Tue Dec  3 23:17:54 2019	(r355373)
@@ -113,7 +113,7 @@ int    syscall32_helper_unregister(struct syscall_help
 struct iovec32;
 struct rusage32;
 int	freebsd32_copyout_strings(struct image_params *imgp,
-	    register_t **stack_base);
+	    uintptr_t *stack_base);
 int	freebsd32_copyiniov(struct iovec32 *iovp, u_int iovcnt,
 	    struct iovec **iov, int error);
 void	freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32);

Modified: head/sys/compat/ia32/ia32_signal.h
==============================================================================
--- head/sys/compat/ia32/ia32_signal.h	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/compat/ia32/ia32_signal.h	Tue Dec  3 23:17:54 2019	(r355373)
@@ -206,7 +206,7 @@ extern int sz_ia32_osigcode;
 extern int sz_lcall_tramp;
 void ia32_sendsig(sig_t, struct ksiginfo *, sigset_t *);
 void ia32_setregs(struct thread *td, struct image_params *imgp,
-    u_long stack);
+    uintptr_t stack);
 int setup_lcall_gate(void);
 
 #endif

Modified: head/sys/i386/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- head/sys/i386/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/i386/cloudabi32/cloudabi32_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -48,7 +48,7 @@ extern const char *cloudabi32_syscallnames[];
 extern struct sysent cloudabi32_sysent[];
 
 static int
-cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
+cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp)
 {
 	int error;
 	uint32_t args[2];
@@ -68,16 +68,16 @@ cloudabi32_fixup_tcb(register_t **stack_base, struct i
 	 * refer to the auxiliary vector, which is stored right after
 	 * the TCB.
 	 */
-	args[0] = (uintptr_t)*stack_base;
-	args[1] = (uintptr_t)*stack_base +
+	args[0] = *stack_base;
+	args[1] = *stack_base +
 	    roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
-	*stack_base -= howmany(sizeof(args), sizeof(register_t));
-	return (copyout(args, *stack_base, sizeof(args)));
+	*stack_base -= roundup(sizeof(args), sizeof(register_t));
+	return (copyout(args, (void *)*stack_base, sizeof(args)));
 }
 
 static void
 cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
-    unsigned long stack)
+    uintptr_t stack)
 {
 
 	exec_setregs(td, imgp, stack);

Modified: head/sys/i386/i386/machdep.c
==============================================================================
--- head/sys/i386/i386/machdep.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/i386/i386/machdep.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -1124,7 +1124,7 @@ setup_priv_lcall_gate(struct proc *p)
  * Reset registers to default values on exec.
  */
 void
-exec_setregs(struct thread *td, struct image_params *imgp, u_long stack)
+exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack)
 {
 	struct trapframe *regs;
 	struct pcb *pcb;

Modified: head/sys/i386/linux/linux_sysvec.c
==============================================================================
--- head/sys/i386/linux/linux_sysvec.c	Tue Dec  3 23:11:40 2019	(r355372)
+++ head/sys/i386/linux/linux_sysvec.c	Tue Dec  3 23:17:54 2019	(r355373)
@@ -88,15 +88,15 @@ extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL
 
 SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
 
-static int	linux_fixup(register_t **stack_base,
+static int	linux_fixup(uintptr_t *stack_base,
 		    struct image_params *iparams);
-static int	linux_fixup_elf(register_t **stack_base,
+static int	linux_fixup_elf(uintptr_t *stack_base,
 		    struct image_params *iparams);
 static void     linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
 static void	linux_exec_setregs(struct thread *td,
-		    struct image_params *imgp, u_long stack);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912032317.xB3NHsjB022858>