Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Apr 2003 15:31:16 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 29557 for review
Message-ID:  <200304232231.h3NMVGYv031661@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=29557

Change 29557 by peter@peter_daintree on 2003/04/23 15:31:09

	shameful hack for making __syscall(2) and syscall(2) work, since libc/sys/mmap.c
	uses it.  This will be cleaned up a lot when I reorder the trapframe.

Affected files ...

.. //depot/projects/hammer/sys/x86_64/x86_64/trap.c#28 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/x86_64/trap.c#28 (text+ko) ====

@@ -654,6 +654,7 @@
 	int narg;
 	register_t args[8];
 	u_int code;
+	int syscallflag = 0;
 
 	/*
 	 * note: PCPU_LAZY_INC() can only be used if we can afford
@@ -676,7 +677,7 @@
 		cred_update_thread(td);
 	if (p->p_flag & P_THREADED)
 		thread_user_enter(p, td);
-	params = (caddr_t)frame.tf_rsp + sizeof(long);
+	params = (caddr_t)frame.tf_rsp + sizeof(register_t);
 	code = frame.tf_rax;
 	orig_tf_rflags = frame.tf_rflags;
 
@@ -686,23 +687,9 @@
 		 */
 		(*p->p_sysent->sv_prepsyscall)(&frame, (int *)args, &code, &params);
 	} else {
-		/*
-		 * Need to check if this is a 32 bit or 64 bit syscall.
-		 * fuword is MP aware.
-		 */
-		if (code == SYS_syscall) {
-			/*
-			 * Code is first argument, followed by actual args.
-			 */
-			code = fuword(params);
-			params += sizeof(int);
-		} else if (code == SYS___syscall) {
-			/*
-			 * Like syscall, but code is a quad, so as to maintain
-			 * quad alignment for the rest of the arguments.
-			 */
-			code = fuword(params);
-			params += sizeof(quad_t);
+		if (code == SYS_syscall || code == SYS___syscall) {
+			code = frame.tf_rdi;
+			syscallflag++;
 		}
 	}
 
@@ -719,26 +706,45 @@
 	/*
 	 * copyin and the ktrsyscall()/ktrsysret() code is MP-aware
 	 */
-	if (params != NULL && narg != 0) {
-		error = 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 (narg > 6)
-			error = copyin(params, (caddr_t)&args[6],
-			    (u_int)((narg - 6) * sizeof(register_t)));
-	} else
-		error = 0;
+	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)));
+		}
+	} 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)));
+		}
+	}
 		
 #ifdef KTRACE
 	if (KTRPOINT(td, KTR_SYSCALL))



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