Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2020 18:46:14 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366456 - head/sys/arm64/arm64
Message-ID:  <202010051846.095IkEqo017716@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Mon Oct  5 18:46:14 2020
New Revision: 366456
URL: https://svnweb.freebsd.org/changeset/base/366456

Log:
  Tweak arm64's cpu_fetch_syscall_args().  This should make it possible
  for the compiler to inline the memcpy().
  
  Reviewed by:	andrew
  Sponsored by:	DARPA
  Differential Revision:	https://reviews.freebsd.org/D26629

Modified:
  head/sys/arm64/arm64/trap.c

Modified: head/sys/arm64/arm64/trap.c
==============================================================================
--- head/sys/arm64/arm64/trap.c	Mon Oct  5 18:45:32 2020	(r366455)
+++ head/sys/arm64/arm64/trap.c	Mon Oct  5 18:46:14 2020	(r366456)
@@ -123,30 +123,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 = MAXARGS;
 	p = td->td_proc;
-	ap = td->td_frame->tf_x;
 	sa = &td->td_sa;
+	ap = td->td_frame->tf_x;
+	dst_ap = &sa->args[0];
 
 	sa->code = td->td_frame->tf_x[8];
 
-	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("ARM64TODO: Could we have more than %d args?", MAXARGS);
+	KASSERT(sa->callp->sy_narg <= nitems(sa->args),
+	    ("Syscall %d takes too many arguments", sa->code));
+
+	memcpy(dst_ap, ap, (MAXARGS - 1) * sizeof(register_t));
 
 	td->td_retval[0] = 0;
 	td->td_retval[1] = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010051846.095IkEqo017716>