Index: sys/mips/include/proc.h =================================================================== --- sys/mips/include/proc.h +++ sys/mips/include/proc.h @@ -81,11 +81,11 @@ size_t md_tls_tcb_offset; /* TCB offset */ }; +#define MAXARGS 8 struct syscall_args { u_int code; struct sysent *callp; - register_t args[8]; - struct trapframe *trapframe; + register_t args[MAXARGS]; }; #ifdef __mips_n64 Index: sys/mips/mips/trap.c =================================================================== --- sys/mips/mips/trap.c +++ sys/mips/mips/trap.c @@ -349,9 +349,9 @@ bzero(sa->args, sizeof(sa->args)); /* compute next PC after syscall instruction */ - td->td_pcb->pcb_tpc = sa->trapframe->pc; /* Remember if restart */ - if (DELAYBRANCH(sa->trapframe->cause)) /* Check BD bit */ - locr0->pc = MipsEmulateBranch(locr0, sa->trapframe->pc, 0, 0); + td->td_pcb->pcb_tpc = locr0->pc; /* Remember if restart */ + if (DELAYBRANCH(locr0->cause)) /* Check BD bit */ + locr0->pc = MipsEmulateBranch(locr0, locr0->pc, 0, 0); else locr0->pc += sizeof(int); sa->code = locr0->v0; @@ -781,7 +781,6 @@ case T_SYSCALL + T_USER: { - td->td_sa.trapframe = trapframe; syscallenter(td); #if !defined(SMP) && (defined(DDB) || defined(DEBUG)) Index: sys/riscv/riscv/trap.c =================================================================== --- sys/riscv/riscv/trap.c +++ sys/riscv/riscv/trap.c @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef KDB #include #endif @@ -106,12 +107,6 @@ sa->code = td->td_frame->tf_t[0]; - if (__predict_false(sa->code == SYS_syscall || sa->code == SYS___syscall)) { - sa->code = *ap++; - } else { - *dst_ap++ = *ap++; - } - if (__predict_false(sa->code >= p->p_sysent->sv_size)) sa->callp = &p->p_sysent->sv_table[0]; else @@ -120,7 +115,13 @@ KASSERT(sa->callp->sy_narg <= nitems(sa->args), ("Syscall %d takes too many arguments", sa->code)); - memcpy(dst_ap, ap, (NARGREG - 1) * sizeof(register_t)); + if (__predict_false(sa->callp->sy_call == (sy_call_t *)nosys) && + (sa->code == SYS_syscall || sa->code == SYS___syscall)) { + sa->code = *ap++; + memcpy(dst_ap, ap, (NARGREG - 1) * sizeof(register_t)); + } else { + memcpy(dst_ap, ap, NARGREG * sizeof(register_t)); + } td->td_retval[0] = 0; td->td_retval[1] = 0;