Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead.
Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26458
This commit is contained in:
parent
c4390e6da6
commit
1e2521ffae
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366205
@ -999,15 +999,15 @@ cpu_fetch_syscall_args_fallback(struct thread *td, struct syscall_args *sa)
|
|||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
KASSERT(sa->callp->sy_narg <= nitems(sa->args),
|
||||||
KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!"));
|
("Too many syscall arguments!"));
|
||||||
argp = &frame->tf_rdi;
|
argp = &frame->tf_rdi;
|
||||||
argp += reg;
|
argp += reg;
|
||||||
memcpy(sa->args, argp, sizeof(sa->args[0]) * NARGREGS);
|
memcpy(sa->args, argp, sizeof(sa->args[0]) * NARGREGS);
|
||||||
if (sa->narg > regcnt) {
|
if (sa->callp->sy_narg > regcnt) {
|
||||||
params = (caddr_t)frame->tf_rsp + sizeof(register_t);
|
params = (caddr_t)frame->tf_rsp + sizeof(register_t);
|
||||||
error = copyin(params, &sa->args[regcnt],
|
error = copyin(params, &sa->args[regcnt],
|
||||||
(sa->narg - regcnt) * sizeof(sa->args[0]));
|
(sa->callp->sy_narg - regcnt) * sizeof(sa->args[0]));
|
||||||
if (__predict_false(error != 0))
|
if (__predict_false(error != 0))
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
@ -1037,10 +1037,10 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
return (cpu_fetch_syscall_args_fallback(td, sa));
|
return (cpu_fetch_syscall_args_fallback(td, sa));
|
||||||
|
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
KASSERT(sa->callp->sy_narg <= nitems(sa->args),
|
||||||
KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!"));
|
("Too many syscall arguments!"));
|
||||||
|
|
||||||
if (__predict_false(sa->narg > NARGREGS))
|
if (__predict_false(sa->callp->sy_narg > NARGREGS))
|
||||||
return (cpu_fetch_syscall_args_fallback(td, sa));
|
return (cpu_fetch_syscall_args_fallback(td, sa));
|
||||||
|
|
||||||
memcpy(sa->args, &frame->tf_rdi, sizeof(sa->args[0]) * NARGREGS);
|
memcpy(sa->args, &frame->tf_rdi, sizeof(sa->args[0]) * NARGREGS);
|
||||||
|
@ -104,7 +104,6 @@ cloudabi32_fetch_syscall_args(struct thread *td)
|
|||||||
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
||||||
return (ENOSYS);
|
return (ENOSYS);
|
||||||
sa->callp = &cloudabi32_sysent[sa->code];
|
sa->callp = &cloudabi32_sysent[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch system call arguments.
|
* Fetch system call arguments.
|
||||||
@ -117,7 +116,7 @@ cloudabi32_fetch_syscall_args(struct thread *td)
|
|||||||
* implementation used by 64-bit processes.
|
* implementation used by 64-bit processes.
|
||||||
*/
|
*/
|
||||||
error = copyin((void *)frame->tf_rcx, sa->args,
|
error = copyin((void *)frame->tf_rcx, sa->args,
|
||||||
sa->narg * sizeof(sa->args[0]));
|
sa->callp->sy_narg * sizeof(sa->args[0]));
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ cloudabi64_fetch_syscall_args(struct thread *td)
|
|||||||
if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL)
|
if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL)
|
||||||
return (ENOSYS);
|
return (ENOSYS);
|
||||||
sa->callp = &cloudabi64_sysent[sa->code];
|
sa->callp = &cloudabi64_sysent[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
/* Fetch system call arguments. */
|
/* Fetch system call arguments. */
|
||||||
sa->args[0] = frame->tf_rdi;
|
sa->args[0] = frame->tf_rdi;
|
||||||
|
@ -180,15 +180,14 @@ ia32_fetch_syscall_args(struct thread *td)
|
|||||||
sa->callp = &p->p_sysent->sv_table[0];
|
sa->callp = &p->p_sysent->sv_table[0];
|
||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
if (params != NULL && sa->narg != 0)
|
if (params != NULL && sa->callp->sy_narg != 0)
|
||||||
error = copyin(params, (caddr_t)args,
|
error = copyin(params, (caddr_t)args,
|
||||||
(u_int)(sa->narg * sizeof(int)));
|
(u_int)(sa->callp->sy_narg * sizeof(int)));
|
||||||
else
|
else
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
for (i = 0; i < sa->narg; i++)
|
for (i = 0; i < sa->callp->sy_narg; i++)
|
||||||
sa->args[i] = args[i];
|
sa->args[i] = args[i];
|
||||||
|
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
|
@ -94,7 +94,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[8];
|
register_t args[8];
|
||||||
int narg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
@ -198,7 +198,6 @@ linux_fetch_syscall_args(struct thread *td)
|
|||||||
sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1];
|
sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1];
|
||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -662,7 +662,6 @@ linux32_fetch_syscall_args(struct thread *td)
|
|||||||
sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1];
|
sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1];
|
||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
td->td_retval[1] = frame->tf_rdx;
|
td->td_retval[1] = frame->tf_rdx;
|
||||||
|
@ -120,12 +120,12 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
sa->callp = &p->p_sysent->sv_table[0];
|
sa->callp = &p->p_sysent->sv_table[0];
|
||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
error = 0;
|
error = 0;
|
||||||
memcpy(sa->args, ap, sa->nap * sizeof(register_t));
|
memcpy(sa->args, ap, sa->nap * sizeof(register_t));
|
||||||
if (sa->narg > sa->nap) {
|
if (sa->callp->sy_narg > sa->nap) {
|
||||||
error = copyin((void *)td->td_frame->tf_usr_sp, sa->args +
|
error = copyin((void *)td->td_frame->tf_usr_sp, sa->args +
|
||||||
sa->nap, (sa->narg - sa->nap) * sizeof(register_t));
|
sa->nap, (sa->callp->sy_narg - sa->nap) *
|
||||||
|
sizeof(register_t));
|
||||||
}
|
}
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
|
@ -81,16 +81,15 @@ cloudabi32_fetch_syscall_args(struct thread *td)
|
|||||||
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
||||||
return (ENOSYS);
|
return (ENOSYS);
|
||||||
sa->callp = &cloudabi32_sysent[sa->code];
|
sa->callp = &cloudabi32_sysent[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
/* Fetch system call arguments from registers and the stack. */
|
/* Fetch system call arguments from registers and the stack. */
|
||||||
sa->args[0] = frame->tf_r0;
|
sa->args[0] = frame->tf_r0;
|
||||||
sa->args[1] = frame->tf_r1;
|
sa->args[1] = frame->tf_r1;
|
||||||
sa->args[2] = frame->tf_r2;
|
sa->args[2] = frame->tf_r2;
|
||||||
sa->args[3] = frame->tf_r3;
|
sa->args[3] = frame->tf_r3;
|
||||||
if (sa->narg > 4) {
|
if (sa->callp->sy_narg > 4) {
|
||||||
error = copyin((void *)td->td_frame->tf_usr_sp, &sa->args[4],
|
error = copyin((void *)td->td_frame->tf_usr_sp, &sa->args[4],
|
||||||
(sa->narg - 4) * sizeof(register_t));
|
(sa->callp->sy_narg - 4) * sizeof(register_t));
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[MAXARGS];
|
register_t args[MAXARGS];
|
||||||
int narg;
|
|
||||||
u_int nap;
|
u_int nap;
|
||||||
} __aligned(8);
|
} __aligned(8);
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ freebsd32_fetch_syscall_args(struct thread *td)
|
|||||||
struct proc *p;
|
struct proc *p;
|
||||||
register_t *ap;
|
register_t *ap;
|
||||||
struct syscall_args *sa;
|
struct syscall_args *sa;
|
||||||
int error, i, nap;
|
int error, i, nap, narg;
|
||||||
unsigned int args[4];
|
unsigned int args[4];
|
||||||
|
|
||||||
nap = 4;
|
nap = 4;
|
||||||
@ -181,15 +181,15 @@ freebsd32_fetch_syscall_args(struct thread *td)
|
|||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
narg = sa->callp->sy_narg;
|
||||||
for (i = 0; i < nap; i++)
|
for (i = 0; i < nap; i++)
|
||||||
sa->args[i] = ap[i];
|
sa->args[i] = ap[i];
|
||||||
if (sa->narg > nap) {
|
if (narg > nap) {
|
||||||
if ((sa->narg - nap) > nitems(args))
|
if (narg - nap > nitems(args))
|
||||||
panic("Too many system call arguiments");
|
panic("Too many system call arguiments");
|
||||||
error = copyin((void *)td->td_frame->tf_x[13], args,
|
error = copyin((void *)td->td_frame->tf_x[13], args,
|
||||||
(sa->narg - nap) * sizeof(int));
|
(narg - nap) * sizeof(int));
|
||||||
for (i = 0; i < (sa->narg - nap); i++)
|
for (i = 0; i < (narg - nap); i++)
|
||||||
sa->args[i + nap] = args[i];
|
sa->args[i + nap] = args[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
struct syscall_args *sa;
|
struct syscall_args *sa;
|
||||||
int nap;
|
int nap;
|
||||||
|
|
||||||
nap = 8;
|
nap = MAXARGS;
|
||||||
p = td->td_proc;
|
p = td->td_proc;
|
||||||
ap = td->td_frame->tf_x;
|
ap = td->td_frame->tf_x;
|
||||||
sa = &td->td_sa;
|
sa = &td->td_sa;
|
||||||
@ -144,10 +144,9 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
memcpy(sa->args, ap, nap * sizeof(register_t));
|
memcpy(sa->args, ap, nap * sizeof(register_t));
|
||||||
if (sa->narg > nap)
|
if (sa->callp->sy_narg > nap)
|
||||||
panic("ARM64TODO: Could we have more than 8 args?");
|
panic("ARM64TODO: Could we have more than %d args?", MAXARGS);
|
||||||
|
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
td->td_retval[1] = 0;
|
td->td_retval[1] = 0;
|
||||||
|
@ -78,7 +78,6 @@ cloudabi32_fetch_syscall_args(struct thread *td)
|
|||||||
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
||||||
return (ENOSYS);
|
return (ENOSYS);
|
||||||
sa->callp = &cloudabi32_sysent[sa->code];
|
sa->callp = &cloudabi32_sysent[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fetch system call arguments.
|
* Fetch system call arguments.
|
||||||
@ -91,7 +90,7 @@ cloudabi32_fetch_syscall_args(struct thread *td)
|
|||||||
* implementation used by 64-bit processes.
|
* implementation used by 64-bit processes.
|
||||||
*/
|
*/
|
||||||
error = copyin((void *)frame->tf_x[2], sa->args,
|
error = copyin((void *)frame->tf_x[2], sa->args,
|
||||||
sa->narg * sizeof(sa->args[0]));
|
sa->callp->sy_narg * sizeof(sa->args[0]));
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ cloudabi64_fetch_syscall_args(struct thread *td)
|
|||||||
if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL)
|
if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL)
|
||||||
return (ENOSYS);
|
return (ENOSYS);
|
||||||
sa->callp = &cloudabi64_sysent[sa->code];
|
sa->callp = &cloudabi64_sysent[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
/* Fetch system call arguments. */
|
/* Fetch system call arguments. */
|
||||||
for (i = 0; i < MAXARGS; i++)
|
for (i = 0; i < MAXARGS; i++)
|
||||||
|
@ -51,7 +51,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[MAXARGS];
|
register_t args[MAXARGS];
|
||||||
int narg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
@ -126,10 +126,9 @@ linux_fetch_syscall_args(struct thread *td)
|
|||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
if (sa->callp->sy_narg > MAXARGS)
|
||||||
if (sa->narg > 8)
|
panic("ARM64TODO: Could we have more than %d args?", MAXARGS);
|
||||||
panic("ARM64TODO: Could we have more than 8 args?");
|
memcpy(sa->args, ap, MAXARGS * sizeof(register_t));
|
||||||
memcpy(sa->args, ap, 8 * sizeof(register_t));
|
|
||||||
|
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -99,11 +99,10 @@ cloudabi32_fetch_syscall_args(struct thread *td)
|
|||||||
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
||||||
return (ENOSYS);
|
return (ENOSYS);
|
||||||
sa->callp = &cloudabi32_sysent[sa->code];
|
sa->callp = &cloudabi32_sysent[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
/* Fetch system call arguments from the stack. */
|
/* Fetch system call arguments from the stack. */
|
||||||
error = copyin((void *)(frame->tf_esp + 4), sa->args,
|
error = copyin((void *)(frame->tf_esp + 4), sa->args,
|
||||||
sa->narg * sizeof(sa->args[0]));
|
sa->callp->sy_narg * sizeof(sa->args[0]));
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
@ -1084,11 +1084,10 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
sa->callp = &p->p_sysent->sv_table[0];
|
sa->callp = &p->p_sysent->sv_table[0];
|
||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
if (params != NULL && sa->narg != 0)
|
if (params != NULL && sa->callp->sy_narg != 0)
|
||||||
error = copyin(params, (caddr_t)sa->args,
|
error = copyin(params, (caddr_t)sa->args,
|
||||||
(u_int)(sa->narg * sizeof(uint32_t)));
|
(u_int)(sa->callp->sy_narg * sizeof(uint32_t)));
|
||||||
else
|
else
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[8];
|
register_t args[8];
|
||||||
int narg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
@ -784,7 +784,6 @@ linux_fetch_syscall_args(struct thread *td)
|
|||||||
sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1];
|
sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1];
|
||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
|
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
td->td_retval[1] = frame->tf_edx;
|
td->td_retval[1] = frame->tf_edx;
|
||||||
|
@ -82,7 +82,7 @@ _Static_assert(offsetof(struct thread, td_flags) == 0xfc,
|
|||||||
"struct thread KBI td_flags");
|
"struct thread KBI td_flags");
|
||||||
_Static_assert(offsetof(struct thread, td_pflags) == 0x104,
|
_Static_assert(offsetof(struct thread, td_pflags) == 0x104,
|
||||||
"struct thread KBI td_pflags");
|
"struct thread KBI td_pflags");
|
||||||
_Static_assert(offsetof(struct thread, td_frame) == 0x4a8,
|
_Static_assert(offsetof(struct thread, td_frame) == 0x4a0,
|
||||||
"struct thread KBI td_frame");
|
"struct thread KBI td_frame");
|
||||||
_Static_assert(offsetof(struct thread, td_emuldata) == 0x6b0,
|
_Static_assert(offsetof(struct thread, td_emuldata) == 0x6b0,
|
||||||
"struct thread KBI td_emuldata");
|
"struct thread KBI td_emuldata");
|
||||||
@ -102,9 +102,9 @@ _Static_assert(offsetof(struct thread, td_flags) == 0x98,
|
|||||||
"struct thread KBI td_flags");
|
"struct thread KBI td_flags");
|
||||||
_Static_assert(offsetof(struct thread, td_pflags) == 0xa0,
|
_Static_assert(offsetof(struct thread, td_pflags) == 0xa0,
|
||||||
"struct thread KBI td_pflags");
|
"struct thread KBI td_pflags");
|
||||||
_Static_assert(offsetof(struct thread, td_frame) == 0x304,
|
_Static_assert(offsetof(struct thread, td_frame) == 0x300,
|
||||||
"struct thread KBI td_frame");
|
"struct thread KBI td_frame");
|
||||||
_Static_assert(offsetof(struct thread, td_emuldata) == 0x348,
|
_Static_assert(offsetof(struct thread, td_emuldata) == 0x344,
|
||||||
"struct thread KBI td_emuldata");
|
"struct thread KBI td_emuldata");
|
||||||
_Static_assert(offsetof(struct proc, p_flag) == 0x68,
|
_Static_assert(offsetof(struct proc, p_flag) == 0x68,
|
||||||
"struct proc KBI p_flag");
|
"struct proc KBI p_flag");
|
||||||
|
@ -79,7 +79,7 @@ syscallenter(struct thread *td)
|
|||||||
error = (p->p_sysent->sv_fetch_syscall_args)(td);
|
error = (p->p_sysent->sv_fetch_syscall_args)(td);
|
||||||
#ifdef KTRACE
|
#ifdef KTRACE
|
||||||
if (KTRPOINT(td, KTR_SYSCALL))
|
if (KTRPOINT(td, KTR_SYSCALL))
|
||||||
ktrsyscall(sa->code, sa->narg, sa->args);
|
ktrsyscall(sa->code, sa->callp->sy_narg, sa->args);
|
||||||
#endif
|
#endif
|
||||||
KTR_START4(KTR_SYSC, "syscall", syscallname(p, sa->code),
|
KTR_START4(KTR_SYSC, "syscall", syscallname(p, sa->code),
|
||||||
(uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0],
|
(uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0],
|
||||||
@ -104,7 +104,7 @@ syscallenter(struct thread *td)
|
|||||||
error = (p->p_sysent->sv_fetch_syscall_args)(td);
|
error = (p->p_sysent->sv_fetch_syscall_args)(td);
|
||||||
#ifdef KTRACE
|
#ifdef KTRACE
|
||||||
if (KTRPOINT(td, KTR_SYSCALL))
|
if (KTRPOINT(td, KTR_SYSCALL))
|
||||||
ktrsyscall(sa->code, sa->narg, sa->args);
|
ktrsyscall(sa->code, sa->callp->sy_narg, sa->args);
|
||||||
#endif
|
#endif
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
td->td_errno = error;
|
td->td_errno = error;
|
||||||
|
@ -925,7 +925,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bzero(addr, sizeof(td2->td_sa.args));
|
bzero(addr, sizeof(td2->td_sa.args));
|
||||||
bcopy(td2->td_sa.args, addr, td2->td_sa.narg *
|
bcopy(td2->td_sa.args, addr, td2->td_sa.callp->sy_narg *
|
||||||
sizeof(register_t));
|
sizeof(register_t));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1246,7 +1246,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
|||||||
strcpy(pl->pl_tdname, td2->td_name);
|
strcpy(pl->pl_tdname, td2->td_name);
|
||||||
if ((td2->td_dbgflags & (TDB_SCE | TDB_SCX)) != 0) {
|
if ((td2->td_dbgflags & (TDB_SCE | TDB_SCX)) != 0) {
|
||||||
pl->pl_syscall_code = td2->td_sa.code;
|
pl->pl_syscall_code = td2->td_sa.code;
|
||||||
pl->pl_syscall_narg = td2->td_sa.narg;
|
pl->pl_syscall_narg = td2->td_sa.callp->sy_narg;
|
||||||
} else {
|
} else {
|
||||||
pl->pl_syscall_code = 0;
|
pl->pl_syscall_code = 0;
|
||||||
pl->pl_syscall_narg = 0;
|
pl->pl_syscall_narg = 0;
|
||||||
|
@ -85,7 +85,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[8];
|
register_t args[8];
|
||||||
int narg;
|
|
||||||
struct trapframe *trapframe;
|
struct trapframe *trapframe;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -448,9 +448,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
else
|
else
|
||||||
sa->callp = &se->sv_table[sa->code];
|
sa->callp = &se->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
if (sa->callp->sy_narg > nsaved) {
|
||||||
|
|
||||||
if (sa->narg > nsaved) {
|
|
||||||
#if defined(__mips_n32) || defined(__mips_n64)
|
#if defined(__mips_n32) || defined(__mips_n64)
|
||||||
/*
|
/*
|
||||||
* XXX
|
* XXX
|
||||||
@ -462,7 +460,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
if (!SV_PROC_FLAG(td->td_proc, SV_ILP32))
|
if (!SV_PROC_FLAG(td->td_proc, SV_ILP32))
|
||||||
#endif
|
#endif
|
||||||
printf("SYSCALL #%u pid:%u, narg (%u) > nsaved (%u).\n",
|
printf("SYSCALL #%u pid:%u, narg (%u) > nsaved (%u).\n",
|
||||||
sa->code, td->td_proc->p_pid, sa->narg, nsaved);
|
sa->code, td->td_proc->p_pid, sa->callp->sy_narg, nsaved);
|
||||||
#endif
|
#endif
|
||||||
#if (defined(__mips_n32) || defined(__mips_n64)) && defined(COMPAT_FREEBSD32)
|
#if (defined(__mips_n32) || defined(__mips_n64)) && defined(COMPAT_FREEBSD32)
|
||||||
if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
|
if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
|
||||||
@ -470,7 +468,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
int32_t arg;
|
int32_t arg;
|
||||||
|
|
||||||
error = 0; /* XXX GCC is awful. */
|
error = 0; /* XXX GCC is awful. */
|
||||||
for (i = nsaved; i < sa->narg; i++) {
|
for (i = nsaved; i < sa->callp->sy_narg; i++) {
|
||||||
error = copyin((caddr_t)(intptr_t)(locr0->sp +
|
error = copyin((caddr_t)(intptr_t)(locr0->sp +
|
||||||
(4 + (i - nsaved)) * sizeof(int32_t)),
|
(4 + (i - nsaved)) * sizeof(int32_t)),
|
||||||
(caddr_t)&arg, sizeof arg);
|
(caddr_t)&arg, sizeof arg);
|
||||||
@ -482,7 +480,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
#endif
|
#endif
|
||||||
error = copyin((caddr_t)(intptr_t)(locr0->sp +
|
error = copyin((caddr_t)(intptr_t)(locr0->sp +
|
||||||
4 * sizeof(register_t)), (caddr_t)&sa->args[nsaved],
|
4 * sizeof(register_t)), (caddr_t)&sa->args[nsaved],
|
||||||
(u_int)(sa->narg - nsaved) * sizeof(register_t));
|
(u_int)(sa->callp->sy_narg - nsaved) * sizeof(register_t));
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
locr0->v0 = error;
|
locr0->v0 = error;
|
||||||
locr0->a3 = 1;
|
locr0->a3 = 1;
|
||||||
|
@ -63,7 +63,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[10];
|
register_t args[10];
|
||||||
int narg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
@ -639,7 +639,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
struct syscall_args *sa;
|
struct syscall_args *sa;
|
||||||
caddr_t params;
|
caddr_t params;
|
||||||
size_t argsz;
|
size_t argsz;
|
||||||
int error, n, i;
|
int error, n, narg, i;
|
||||||
|
|
||||||
p = td->td_proc;
|
p = td->td_proc;
|
||||||
frame = td->td_frame;
|
frame = td->td_frame;
|
||||||
@ -680,7 +680,7 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
narg = sa->callp->sy_narg;
|
||||||
|
|
||||||
if (SV_PROC_FLAG(p, SV_ILP32)) {
|
if (SV_PROC_FLAG(p, SV_ILP32)) {
|
||||||
argsz = sizeof(uint32_t);
|
argsz = sizeof(uint32_t);
|
||||||
@ -695,17 +695,17 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
sa->args[i] = ((u_register_t *)(params))[i];
|
sa->args[i] = ((u_register_t *)(params))[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sa->narg > n)
|
if (narg > n)
|
||||||
error = copyin(MOREARGS(frame->fixreg[1]), sa->args + n,
|
error = copyin(MOREARGS(frame->fixreg[1]), sa->args + n,
|
||||||
(sa->narg - n) * argsz);
|
(narg - n) * argsz);
|
||||||
else
|
else
|
||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
#ifdef __powerpc64__
|
#ifdef __powerpc64__
|
||||||
if (SV_PROC_FLAG(p, SV_ILP32) && sa->narg > n) {
|
if (SV_PROC_FLAG(p, SV_ILP32) && narg > n) {
|
||||||
/* Expand the size of arguments copied from the stack */
|
/* Expand the size of arguments copied from the stack */
|
||||||
|
|
||||||
for (i = sa->narg; i >= n; i--)
|
for (i = narg; i >= n; i--)
|
||||||
sa->args[i] = ((uint32_t *)(&sa->args[n]))[i-n];
|
sa->args[i] = ((uint32_t *)(&sa->args[n]))[i-n];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,7 +50,6 @@ struct syscall_args {
|
|||||||
u_int code;
|
u_int code;
|
||||||
struct sysent *callp;
|
struct sysent *callp;
|
||||||
register_t args[MAXARGS];
|
register_t args[MAXARGS];
|
||||||
int narg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !_MACHINE_PROC_H_ */
|
#endif /* !_MACHINE_PROC_H_ */
|
||||||
|
@ -117,9 +117,8 @@ cpu_fetch_syscall_args(struct thread *td)
|
|||||||
else
|
else
|
||||||
sa->callp = &p->p_sysent->sv_table[sa->code];
|
sa->callp = &p->p_sysent->sv_table[sa->code];
|
||||||
|
|
||||||
sa->narg = sa->callp->sy_narg;
|
|
||||||
memcpy(sa->args, ap, nap * sizeof(register_t));
|
memcpy(sa->args, ap, nap * sizeof(register_t));
|
||||||
if (sa->narg > nap)
|
if (sa->callp->sy_narg > nap)
|
||||||
panic("TODO: Could we have more then %d args?", NARGREG);
|
panic("TODO: Could we have more then %d args?", NARGREG);
|
||||||
|
|
||||||
td->td_retval[0] = 0;
|
td->td_retval[0] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user