PERFORCE change 29677 for review

Peter Wemm peter at FreeBSD.org
Thu Apr 24 23:51:53 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=29677

Change 29677 by peter at 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) {


More information about the p4-projects mailing list