aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/cloudabi64/cloudabi64_module.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2019-12-03 23:17:54 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2019-12-03 23:17:54 +0000
commit31174518d2db4950b8bc8ab02e64cdb5e00d34c9 (patch)
tree2c830969197705d2f745734684051163c5b29ec5 /sys/compat/cloudabi64/cloudabi64_module.c
parentd00066a5f923073113bcb0213ca7a0a9a29b9561 (diff)
downloadsrc-31174518d2db4950b8bc8ab02e64cdb5e00d34c9.tar.gz
src-31174518d2db4950b8bc8ab02e64cdb5e00d34c9.zip
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
Notes
Notes: svn path=/head/; revision=355373
Diffstat (limited to 'sys/compat/cloudabi64/cloudabi64_module.c')
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c
index 7459b026d8ec..ed0c85b4aba5 100644
--- a/sys/compat/cloudabi64/cloudabi64_module.c
+++ b/sys/compat/cloudabi64/cloudabi64_module.c
@@ -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, register_t **stack_base)
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_params *imgp)
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_params *imgp)
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_params *imgp)
#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);
}