Index: sys/amd64/amd64/trap.c =================================================================== --- sys/amd64/amd64/trap.c +++ sys/amd64/amd64/trap.c @@ -999,15 +999,15 @@ else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; - KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!")); + KASSERT(sa->callp->sy_narg <= nitems(sa->args), + ("Too many syscall arguments!")); argp = &frame->tf_rdi; argp += reg; 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); 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)) return (error); } @@ -1037,10 +1037,10 @@ return (cpu_fetch_syscall_args_fallback(td, sa)); sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; - KASSERT(sa->narg <= nitems(sa->args), ("Too many syscall arguments!")); + KASSERT(sa->callp->sy_narg <= nitems(sa->args), + ("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)); memcpy(sa->args, &frame->tf_rdi, sizeof(sa->args[0]) * NARGREGS); Index: sys/amd64/cloudabi32/cloudabi32_sysvec.c =================================================================== --- sys/amd64/cloudabi32/cloudabi32_sysvec.c +++ sys/amd64/cloudabi32/cloudabi32_sysvec.c @@ -104,7 +104,6 @@ if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi32_sysent[sa->code]; - sa->narg = sa->callp->sy_narg; /* * Fetch system call arguments. @@ -117,7 +116,7 @@ * implementation used by 64-bit processes. */ 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) return (error); Index: sys/amd64/cloudabi64/cloudabi64_sysvec.c =================================================================== --- sys/amd64/cloudabi64/cloudabi64_sysvec.c +++ sys/amd64/cloudabi64/cloudabi64_sysvec.c @@ -101,7 +101,6 @@ if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi64_sysent[sa->code]; - sa->narg = sa->callp->sy_narg; /* Fetch system call arguments. */ sa->args[0] = frame->tf_rdi; Index: sys/amd64/ia32/ia32_syscall.c =================================================================== --- sys/amd64/ia32/ia32_syscall.c +++ sys/amd64/ia32/ia32_syscall.c @@ -180,15 +180,14 @@ sa->callp = &p->p_sysent->sv_table[0]; else 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, - (u_int)(sa->narg * sizeof(int))); + (u_int)(sa->callp->sy_narg * sizeof(int))); else error = 0; - for (i = 0; i < sa->narg; i++) + for (i = 0; i < sa->callp->sy_narg; i++) sa->args[i] = args[i]; if (error == 0) { Index: sys/amd64/include/proc.h =================================================================== --- sys/amd64/include/proc.h +++ sys/amd64/include/proc.h @@ -94,7 +94,6 @@ u_int code; struct sysent *callp; register_t args[8]; - int narg; }; #ifdef _KERNEL Index: sys/amd64/linux/linux_sysvec.c =================================================================== --- sys/amd64/linux/linux_sysvec.c +++ sys/amd64/linux/linux_sysvec.c @@ -198,7 +198,6 @@ sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1]; else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; td->td_retval[0] = 0; return (0); Index: sys/amd64/linux32/linux32_sysvec.c =================================================================== --- sys/amd64/linux32/linux32_sysvec.c +++ sys/amd64/linux32/linux32_sysvec.c @@ -662,7 +662,6 @@ sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1]; else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; td->td_retval[0] = 0; td->td_retval[1] = frame->tf_rdx; Index: sys/arm/arm/syscall.c =================================================================== --- sys/arm/arm/syscall.c +++ sys/arm/arm/syscall.c @@ -120,12 +120,12 @@ sa->callp = &p->p_sysent->sv_table[0]; else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; error = 0; 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 + - sa->nap, (sa->narg - sa->nap) * sizeof(register_t)); + sa->nap, (sa->callp->sy_narg - sa->nap) * + sizeof(register_t)); } if (error == 0) { td->td_retval[0] = 0; Index: sys/arm/cloudabi32/cloudabi32_sysvec.c =================================================================== --- sys/arm/cloudabi32/cloudabi32_sysvec.c +++ sys/arm/cloudabi32/cloudabi32_sysvec.c @@ -81,16 +81,15 @@ if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi32_sysent[sa->code]; - sa->narg = sa->callp->sy_narg; /* Fetch system call arguments from registers and the stack. */ sa->args[0] = frame->tf_r0; sa->args[1] = frame->tf_r1; sa->args[2] = frame->tf_r2; 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], - (sa->narg - 4) * sizeof(register_t)); + (sa->callp->sy_narg - 4) * sizeof(register_t)); if (error != 0) return (error); } Index: sys/arm/include/proc.h =================================================================== --- sys/arm/include/proc.h +++ sys/arm/include/proc.h @@ -82,7 +82,6 @@ u_int code; struct sysent *callp; register_t args[MAXARGS]; - int narg; u_int nap; } __aligned(8); Index: sys/arm64/arm64/elf32_machdep.c =================================================================== --- sys/arm64/arm64/elf32_machdep.c +++ sys/arm64/arm64/elf32_machdep.c @@ -156,7 +156,7 @@ struct proc *p; register_t *ap; struct syscall_args *sa; - int error, i, nap; + int error, i, nap, narg; unsigned int args[4]; nap = 4; @@ -181,15 +181,15 @@ else 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++) sa->args[i] = ap[i]; - if (sa->narg > nap) { - if ((sa->narg - nap) > nitems(args)) + if (narg > nap) { + if (narg - nap > nitems(args)) panic("Too many system call arguiments"); error = copyin((void *)td->td_frame->tf_x[13], args, - (sa->narg - nap) * sizeof(int)); - for (i = 0; i < (sa->narg - nap); i++) + (narg - nap) * sizeof(int)); + for (i = 0; i < (narg - nap); i++) sa->args[i + nap] = args[i]; } Index: sys/arm64/arm64/trap.c =================================================================== --- sys/arm64/arm64/trap.c +++ sys/arm64/arm64/trap.c @@ -124,7 +124,7 @@ struct syscall_args *sa; int nap; - nap = 8; + nap = MAXARGS; p = td->td_proc; ap = td->td_frame->tf_x; sa = &td->td_sa; @@ -141,10 +141,9 @@ else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; memcpy(sa->args, ap, nap * sizeof(register_t)); - if (sa->narg > nap) - panic("ARM64TODO: Could we have more than 8 args?"); + if (sa->callp->sy_narg > nap) + panic("ARM64TODO: Could we have more than %d args?", MAXARGS); td->td_retval[0] = 0; td->td_retval[1] = 0; Index: sys/arm64/cloudabi32/cloudabi32_sysvec.c =================================================================== --- sys/arm64/cloudabi32/cloudabi32_sysvec.c +++ sys/arm64/cloudabi32/cloudabi32_sysvec.c @@ -78,7 +78,6 @@ if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi32_sysent[sa->code]; - sa->narg = sa->callp->sy_narg; /* * Fetch system call arguments. @@ -91,7 +90,7 @@ * implementation used by 64-bit processes. */ 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) return (error); Index: sys/arm64/cloudabi64/cloudabi64_sysvec.c =================================================================== --- sys/arm64/cloudabi64/cloudabi64_sysvec.c +++ sys/arm64/cloudabi64/cloudabi64_sysvec.c @@ -81,7 +81,6 @@ if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi64_sysent[sa->code]; - sa->narg = sa->callp->sy_narg; /* Fetch system call arguments. */ for (i = 0; i < MAXARGS; i++) Index: sys/arm64/include/proc.h =================================================================== --- sys/arm64/include/proc.h +++ sys/arm64/include/proc.h @@ -51,7 +51,6 @@ u_int code; struct sysent *callp; register_t args[MAXARGS]; - int narg; }; #ifdef _KERNEL Index: sys/arm64/linux/linux_sysvec.c =================================================================== --- sys/arm64/linux/linux_sysvec.c +++ sys/arm64/linux/linux_sysvec.c @@ -126,10 +126,9 @@ else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; - if (sa->narg > 8) - panic("ARM64TODO: Could we have more than 8 args?"); - memcpy(sa->args, ap, 8 * sizeof(register_t)); + if (sa->callp->sy_narg > MAXARGS) + panic("ARM64TODO: Could we have more than %d args?", MAXARGS); + memcpy(sa->args, ap, MAXARGS * sizeof(register_t)); td->td_retval[0] = 0; return (0); Index: sys/i386/cloudabi32/cloudabi32_sysvec.c =================================================================== --- sys/i386/cloudabi32/cloudabi32_sysvec.c +++ sys/i386/cloudabi32/cloudabi32_sysvec.c @@ -99,11 +99,10 @@ if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) return (ENOSYS); sa->callp = &cloudabi32_sysent[sa->code]; - sa->narg = sa->callp->sy_narg; /* Fetch system call arguments from the stack. */ 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) return (error); Index: sys/i386/i386/trap.c =================================================================== --- sys/i386/i386/trap.c +++ sys/i386/i386/trap.c @@ -1084,11 +1084,10 @@ sa->callp = &p->p_sysent->sv_table[0]; else 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, - (u_int)(sa->narg * sizeof(uint32_t))); + (u_int)(sa->callp->sy_narg * sizeof(uint32_t))); else error = 0; Index: sys/i386/include/proc.h =================================================================== --- sys/i386/include/proc.h +++ sys/i386/include/proc.h @@ -66,7 +66,6 @@ u_int code; struct sysent *callp; register_t args[8]; - int narg; }; #ifdef _KERNEL Index: sys/i386/linux/linux_sysvec.c =================================================================== --- sys/i386/linux/linux_sysvec.c +++ sys/i386/linux/linux_sysvec.c @@ -784,7 +784,6 @@ sa->callp = &p->p_sysent->sv_table[p->p_sysent->sv_size - 1]; else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; td->td_retval[0] = 0; td->td_retval[1] = frame->tf_edx; Index: sys/kern/kern_thread.c =================================================================== --- sys/kern/kern_thread.c +++ sys/kern/kern_thread.c @@ -82,7 +82,7 @@ "struct thread KBI td_flags"); _Static_assert(offsetof(struct thread, td_pflags) == 0x104, "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"); _Static_assert(offsetof(struct thread, td_emuldata) == 0x6b0, "struct thread KBI td_emuldata"); @@ -102,9 +102,9 @@ "struct thread KBI td_flags"); _Static_assert(offsetof(struct thread, td_pflags) == 0xa0, "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"); -_Static_assert(offsetof(struct thread, td_emuldata) == 0x348, +_Static_assert(offsetof(struct thread, td_emuldata) == 0x344, "struct thread KBI td_emuldata"); _Static_assert(offsetof(struct proc, p_flag) == 0x68, "struct proc KBI p_flag"); Index: sys/kern/subr_syscall.c =================================================================== --- sys/kern/subr_syscall.c +++ sys/kern/subr_syscall.c @@ -79,7 +79,7 @@ error = (p->p_sysent->sv_fetch_syscall_args)(td); #ifdef KTRACE if (KTRPOINT(td, KTR_SYSCALL)) - ktrsyscall(sa->code, sa->narg, sa->args); + ktrsyscall(sa->code, sa->callp->sy_narg, sa->args); #endif KTR_START4(KTR_SYSC, "syscall", syscallname(p, sa->code), (uintptr_t)td, "pid:%d", td->td_proc->p_pid, "arg0:%p", sa->args[0], @@ -104,7 +104,7 @@ error = (p->p_sysent->sv_fetch_syscall_args)(td); #ifdef KTRACE if (KTRPOINT(td, KTR_SYSCALL)) - ktrsyscall(sa->code, sa->narg, sa->args); + ktrsyscall(sa->code, sa->callp->sy_narg, sa->args); #endif if (error != 0) { td->td_errno = error; Index: sys/kern/sys_process.c =================================================================== --- sys/kern/sys_process.c +++ sys/kern/sys_process.c @@ -925,7 +925,7 @@ break; } 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)); break; @@ -1246,7 +1246,7 @@ strcpy(pl->pl_tdname, td2->td_name); if ((td2->td_dbgflags & (TDB_SCE | TDB_SCX)) != 0) { 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 { pl->pl_syscall_code = 0; pl->pl_syscall_narg = 0; Index: sys/mips/include/proc.h =================================================================== --- sys/mips/include/proc.h +++ sys/mips/include/proc.h @@ -85,7 +85,6 @@ u_int code; struct sysent *callp; register_t args[8]; - int narg; struct trapframe *trapframe; }; Index: sys/mips/mips/trap.c =================================================================== --- sys/mips/mips/trap.c +++ sys/mips/mips/trap.c @@ -448,9 +448,7 @@ else sa->callp = &se->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; - - if (sa->narg > nsaved) { + if (sa->callp->sy_narg > nsaved) { #if defined(__mips_n32) || defined(__mips_n64) /* * XXX @@ -462,7 +460,7 @@ if (!SV_PROC_FLAG(td->td_proc, SV_ILP32)) #endif 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 #if (defined(__mips_n32) || defined(__mips_n64)) && defined(COMPAT_FREEBSD32) if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { @@ -470,7 +468,7 @@ int32_t arg; 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 + (4 + (i - nsaved)) * sizeof(int32_t)), (caddr_t)&arg, sizeof arg); @@ -482,7 +480,7 @@ #endif error = copyin((caddr_t)(intptr_t)(locr0->sp + 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) { locr0->v0 = error; locr0->a3 = 1; Index: sys/powerpc/include/proc.h =================================================================== --- sys/powerpc/include/proc.h +++ sys/powerpc/include/proc.h @@ -63,7 +63,6 @@ u_int code; struct sysent *callp; register_t args[10]; - int narg; }; #ifdef _KERNEL Index: sys/powerpc/powerpc/trap.c =================================================================== --- sys/powerpc/powerpc/trap.c +++ sys/powerpc/powerpc/trap.c @@ -639,7 +639,7 @@ struct syscall_args *sa; caddr_t params; size_t argsz; - int error, n, i; + int error, n, narg, i; p = td->td_proc; frame = td->td_frame; @@ -680,7 +680,7 @@ else 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)) { argsz = sizeof(uint32_t); @@ -695,17 +695,17 @@ sa->args[i] = ((u_register_t *)(params))[i]; } - if (sa->narg > n) + if (narg > n) error = copyin(MOREARGS(frame->fixreg[1]), sa->args + n, - (sa->narg - n) * argsz); + (narg - n) * argsz); else error = 0; #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 */ - for (i = sa->narg; i >= n; i--) + for (i = narg; i >= n; i--) sa->args[i] = ((uint32_t *)(&sa->args[n]))[i-n]; } #endif Index: sys/riscv/include/proc.h =================================================================== --- sys/riscv/include/proc.h +++ sys/riscv/include/proc.h @@ -50,7 +50,6 @@ u_int code; struct sysent *callp; register_t args[MAXARGS]; - int narg; }; #endif /* !_MACHINE_PROC_H_ */ Index: sys/riscv/riscv/trap.c =================================================================== --- sys/riscv/riscv/trap.c +++ sys/riscv/riscv/trap.c @@ -117,9 +117,8 @@ else sa->callp = &p->p_sysent->sv_table[sa->code]; - sa->narg = sa->callp->sy_narg; 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); td->td_retval[0] = 0;