aboutsummaryrefslogtreecommitdiff
path: root/sys/riscv
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2020-10-03 13:01:07 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2020-10-03 13:01:07 +0000
commitf7265157586a1fa983fb959824d5e701dcf4e4b5 (patch)
treeb9ae97b0ab87724b0353391417ef657b9605ee53 /sys/riscv
parent4658877815f78aea73353b288bec4076854430a3 (diff)
downloadsrc-f7265157586a1fa983fb959824d5e701dcf4e4b5.tar.gz
src-f7265157586a1fa983fb959824d5e701dcf4e4b5.zip
Optimize riscv's cpu_fetch_syscall_args(), making it possible
for the compiler to inline the memcpy. Reviewed by: arichardson, mhorne MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26528
Notes
Notes: svn path=/head/; revision=366392
Diffstat (limited to 'sys/riscv')
-rw-r--r--sys/riscv/riscv/trap.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c
index 6ea7f7d96d37..983e1062b5cb 100644
--- a/sys/riscv/riscv/trap.c
+++ b/sys/riscv/riscv/trap.c
@@ -96,30 +96,31 @@ int
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;