From owner-p4-projects@FreeBSD.ORG Thu Apr 24 23:51:52 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 24A5137B404; Thu, 24 Apr 2003 23:51:52 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C47D637B401 for ; Thu, 24 Apr 2003 23:51:51 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C79A43FD7 for ; Thu, 24 Apr 2003 23:51:51 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h3P6pp0U083201 for ; Thu, 24 Apr 2003 23:51:51 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h3P6poDR083191 for perforce@freebsd.org; Thu, 24 Apr 2003 23:51:50 -0700 (PDT) Date: Thu, 24 Apr 2003 23:51:50 -0700 (PDT) Message-Id: <200304250651.h3P6poDR083191@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 29677 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 06:51:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=29677 Change 29677 by peter@peter_daintree on 2003/04/24 23:51:26 now that the trapframe is suitably reordered, steal the code from sparc64 where it points argp at the trapframe when possible. Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#30 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#30 (text+ko) ==== @@ -653,8 +653,9 @@ int error; int narg; register_t args[8]; + register_t *argp; u_int code; - int syscallflag = 0; + int reg, regcnt; /* * note: PCPU_LAZY_INC() can only be used if we can afford @@ -671,6 +672,8 @@ } #endif + reg = 0; + regcnt = 6; sticks = td->td_sticks; td->td_frame = &frame; if (td->td_ucred != p->p_ucred) @@ -689,7 +692,8 @@ } else { if (code == SYS_syscall || code == SYS___syscall) { code = frame.tf_rdi; - syscallflag++; + reg++; + regcnt--; } } @@ -706,49 +710,25 @@ /* * copyin and the ktrsyscall()/ktrsysret() code is MP-aware */ - error = 0; - if (!syscallflag) { - if (narg != 0) { - /* XXX reorder trapframe so we can just copy the first 6 args */ - if (narg > 0) - args[0] = frame.tf_rdi; - if (narg > 1) - args[1] = frame.tf_rsi; - if (narg > 2) - args[2] = frame.tf_rdx; - if (narg > 3) - args[3] = frame.tf_rcx; - if (narg > 4) - args[4] = frame.tf_r8; - if (narg > 5) - args[5] = frame.tf_r9; - if (params != 0 && narg > 6) - error = copyin(params, (caddr_t)&args[6], - (u_int)((narg - 6) * sizeof(register_t))); - } + if (narg <= regcnt) { + argp = &frame.tf_rdi; + argp += reg; + error = 0; } else { - /* compensate for loss of 1 regparm */ - if (narg != 0) { - /* XXX reorder trapframe so we can just copy the first 6 args */ - if (narg > 0) - args[0] = frame.tf_rsi; - if (narg > 1) - args[1] = frame.tf_rdx; - if (narg > 2) - args[2] = frame.tf_rcx; - if (narg > 3) - args[3] = frame.tf_r8; - if (narg > 4) - args[4] = frame.tf_r9; - if (params != 0 && narg > 5) - error = copyin(params, (caddr_t)&args[5], - (u_int)((narg - 5) * sizeof(register_t))); - } + KASSERT(narg <= sizeof(args) / sizeof(args[0]), + ("Too many syscall arguments!")); + KASSERT(params != NULL, ("copyin args with no params!")); + argp = &frame.tf_rdi; + argp += reg; + bcopy(argp, args, sizeof(args[0]) * regcnt); + error = copyin(params, &args[regcnt], + (narg - regcnt) * sizeof(args[0])); + argp = &args[0]; } - + #ifdef KTRACE if (KTRPOINT(td, KTR_SYSCALL)) - ktrsyscall(code, narg, args); + ktrsyscall(code, narg, argp); #endif /* @@ -764,7 +744,7 @@ STOPEVENT(p, S_SCE, narg); - error = (*callp->sy_call)(td, args); + error = (*callp->sy_call)(td, argp); } switch (error) {