aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/cloudabi32/cloudabi32_module.c22
-rw-r--r--sys/compat/cloudabi32/cloudabi32_util.h4
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c22
-rw-r--r--sys/compat/cloudabi64/cloudabi64_util.h4
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c32
-rw-r--r--sys/compat/freebsd32/freebsd32_util.h2
-rw-r--r--sys/compat/ia32/ia32_signal.h2
7 files changed, 46 insertions, 42 deletions
diff --git a/sys/compat/cloudabi32/cloudabi32_module.c b/sys/compat/cloudabi32/cloudabi32_module.c
index 9170e49eda30..3463101193a5 100644
--- a/sys/compat/cloudabi32/cloudabi32_module.c
+++ b/sys/compat/cloudabi32/cloudabi32_module.c
@@ -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, 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
-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_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 @@ cloudabi32_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 @@ cloudabi32_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(cloudabi32_tcb_t), sizeof(register_t));
+ *stack_base -= roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
return (0);
}
diff --git a/sys/compat/cloudabi32/cloudabi32_util.h b/sys/compat/cloudabi32/cloudabi32_util.h
index 1661854a30f8..917356468311 100644
--- a/sys/compat/cloudabi32/cloudabi32_util.h
+++ b/sys/compat/cloudabi32/cloudabi32_util.h
@@ -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);
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);
}
diff --git a/sys/compat/cloudabi64/cloudabi64_util.h b/sys/compat/cloudabi64/cloudabi64_util.h
index 59e93b37b1b6..27088392c75a 100644
--- a/sys/compat/cloudabi64/cloudabi64_util.h
+++ b/sys/compat/cloudabi64/cloudabi64_util.h
@@ -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);
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 395e4e4a3668..d7fda7834ff7 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -3120,12 +3120,12 @@ syscall32_helper_unregister(struct syscall_helper_data *sd)
}
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, register_t **stack_base)
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, register_t **stack_base)
/*
* 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, register_t **stack_base)
/*
* 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, register_t **stack_base)
* 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, register_t **stack_base)
* 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 */
diff --git a/sys/compat/freebsd32/freebsd32_util.h b/sys/compat/freebsd32/freebsd32_util.h
index 4da7c7029b6b..a66038d4d36a 100644
--- a/sys/compat/freebsd32/freebsd32_util.h
+++ b/sys/compat/freebsd32/freebsd32_util.h
@@ -113,7 +113,7 @@ int syscall32_helper_unregister(struct syscall_helper_data *sd);
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);
diff --git a/sys/compat/ia32/ia32_signal.h b/sys/compat/ia32/ia32_signal.h
index ec8702971ef0..3546363122c6 100644
--- a/sys/compat/ia32/ia32_signal.h
+++ b/sys/compat/ia32/ia32_signal.h
@@ -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