Page MenuHomeFreeBSD

D26528.id77812.diff
No OneTemporary

D26528.id77812.diff

Index: head/sys/riscv/riscv/trap.c
===================================================================
--- head/sys/riscv/riscv/trap.c
+++ head/sys/riscv/riscv/trap.c
@@ -96,30 +96,31 @@
cpu_fetch_syscall_args(struct thread *td)
{
struct proc *p;
- register_t *ap;
+ register_t *ap, *dst_ap;
struct syscall_args *sa;
- int nap;
- nap = NARGREG;
p = td->td_proc;
sa = &td->td_sa;
ap = &td->td_frame->tf_a[0];
+ dst_ap = &sa->args[0];
sa->code = td->td_frame->tf_t[0];
- if (sa->code == SYS_syscall || sa->code == SYS___syscall) {
+ if (__predict_false(sa->code == SYS_syscall || sa->code == SYS___syscall)) {
sa->code = *ap++;
- nap--;
+ } else {
+ *dst_ap++ = *ap++;
}
- if (sa->code >= p->p_sysent->sv_size)
+ if (__predict_false(sa->code >= p->p_sysent->sv_size))
sa->callp = &p->p_sysent->sv_table[0];
else
sa->callp = &p->p_sysent->sv_table[sa->code];
- memcpy(sa->args, ap, nap * sizeof(register_t));
- if (sa->callp->sy_narg > nap)
- panic("TODO: Could we have more then %d args?", NARGREG);
+ 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));
td->td_retval[0] = 0;
td->td_retval[1] = 0;

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 22, 5:51 PM (3 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24044839
Default Alt Text
D26528.id77812.diff (1 KB)

Event Timeline