Browse Source

Use registers for syscall arguments.

Tested and working. I've removed the memmove from user stack.
And of course the need to ever do okaddr. This is really going
to clean up Go system call code.

Change-Id: If9efd4cfe2fbbcf169acd0914ffea0de5b121059
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-on: http://nxm.coreboot.org/review/417
Tested-by: Jenkins QA
Reviewed-by: Akshat Kumar <seed@mail.nanosouffle.net>
Ronald G. Minnich 11 years ago
parent
commit
7f0053edd8
3 changed files with 14 additions and 10 deletions
  1. 2 0
      sys/src/nxm/k10/l64syscall.s
  2. 7 5
      sys/src/nxm/k10/syscall.c
  3. 5 5
      util/mksys.go

+ 2 - 0
sys/src/nxm/k10/l64syscall.s

@@ -156,10 +156,12 @@ TEXT syscallentry(SB), 1, $-4
 
 	SUBQ	$(18*8), SP			/* unsaved registers */
 	/* register arguments */
+	/* saved in the order in which they are used. */
 	MOVQ	DI, (5*8)(SP)
 	MOVQ	SI, (4*8)(SP)
 	MOVQ	DX, (3*8)(SP)
 	MOVQ	R10, (9*8)(SP)
+	MOVQ	R8, (7*8)(SP)
 
 	MOVW	$SSEL(SiUDS, SsRPL3), (15*8+0)(SP)
 	MOVW	ES, (15*8+2)(SP)

+ 7 - 5
sys/src/nxm/k10/syscall.c

@@ -258,7 +258,7 @@ syscall(int badscallnr, Ureg* ureg)
 {
 	unsigned int scallnr = (u8int) badscallnr;
 	char *e;
-	uintptr	sp;
+	uintptr	sp, *args;
 	int s;
 	vlong startns, stopns;
 	Ar0 ar0;
@@ -313,10 +313,12 @@ syscall(int badscallnr, Ureg* ureg)
 			error(Ebadarg);
 		}
 
-		if(sp < (USTKTOP-BIGPGSZ) || sp > (USTKTOP-sizeof(up->arg)-BY2SE))
-			validaddr(UINT2PTR(sp), sizeof(up->arg)+BY2SE, 0);
-
-		memmove(up->arg, UINT2PTR(sp+BY2SE), sizeof(up->arg));
+		args = (uintptr *)up->arg;
+		args[0] = ureg->di;
+		args[1] = ureg->si;
+		args[2] = ureg->dx;
+		args[3] = ureg->r10;
+		args[4] = ureg->r8;
 		up->psstate = systab[scallnr].n;
 
 		systab[scallnr].f(&ar0, (va_list)up->arg);

+ 5 - 5
util/mksys.go

@@ -38,11 +38,11 @@ func main(){
 		 * rather than the worst case.
 		 */
 		ass = ass + "\tMOVQ $0xc000,AX\n"
-		ass = ass + "\tMOVQ a1+0x8(FP), DI\n"
-		ass = ass + "\tMOVQ a2+0x10(FP), SI\n"
-		ass = ass + "\tMOVQ a3+0x18(FP), DX\n"
-		ass = ass + "\tMOVQ a4+0x20(FP), R10\n"
-		ass = ass + "\tMOVQ a5+0x28(FP), R8\n"
+		ass = ass + "\tMOVQ a0+0x0(FP), DI\n"
+		ass = ass + "\tMOVQ a1+0x8(FP), SI\n"
+		ass = ass + "\tMOVQ a2+0x10(FP), DX\n"
+		ass = ass + "\tMOVQ a3+0x18(FP), R10\n"
+		ass = ass + "\tMOVQ a4+0x20(FP), R8\n"
 
 		ass = ass + "\tSYSCALL\n\tRET\n"
 		err = ioutil.WriteFile(filename, []byte(ass), 0666)