shithub: riscv

Download patch

ref: 9bdf602ebbdcfcb4baaeb17499a1f1f6865ddc61
parent: 9d8f5a14662f6500c21ac4fa0afd083fc9e2467a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 8 21:23:33 EST 2014

pc64: pass Ureg* argument in BP to userspace note handler

--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -851,11 +851,12 @@
 	sp -= BY2WD+ERRMAX;
 	memmove((char*)sp, up->note[0].msg, ERRMAX);
 	sp -= 3*BY2WD;
-	*(uintptr*)(sp+2*BY2WD) = sp+3*BY2WD;		/* arg 2 is string */
-	*(uintptr*)(sp+1*BY2WD) = (uintptr)up->ureg;	/* arg 1 is ureg* */
-	*(uintptr*)(sp+0*BY2WD) = 0;			/* arg 0 is pc */
+	((uintptr*)sp)[2] = sp + 3*BY2WD;	/* arg2 string */
+	((uintptr*)sp)[1] = (uintptr)up->ureg;	/* arg1 is ureg* */
+	((uintptr*)sp)[0] = 0;			/* arg0 is pc */
 	ureg->sp = sp;
 	ureg->pc = (uintptr)up->notify;
+	ureg->bp = (uintptr)up->ureg;		/* arg1 passed in RARG */
 	ureg->cs = UESEL;
 	ureg->ss = ureg->ds = ureg->es = UDSEL;
 	up->notified = 1;
@@ -920,7 +921,7 @@
 		break;
 
 	case NSAVE:
-		if(!okaddr(nureg->pc, BY2WD, 0)
+		if(!okaddr(nureg->pc, 1, 0)
 		|| !okaddr(nureg->sp, BY2WD, 0)){
 			qunlock(&up->debug);
 			pprint("suicide: trap in noted\n");
@@ -930,6 +931,7 @@
 		sp = oureg-4*BY2WD-ERRMAX;
 		splhi();
 		ureg->sp = sp;
+		ureg->bp = oureg;		/* arg 1 passed in RARG */
 		((uintptr*)sp)[1] = oureg;	/* arg 1 0(FP) is ureg* */
 		((uintptr*)sp)[0] = 0;		/* arg 0 is pc */
 		break;