]> git.lizzy.rs Git - plan9front.git/commitdiff
pc64: fix note handling
authorcinap_lenrek <cinap_lenrek@felloff.net>
Thu, 6 Feb 2014 21:43:33 +0000 (22:43 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Thu, 6 Feb 2014 21:43:33 +0000 (22:43 +0100)
sys/src/9/kw/syscall.c
sys/src/9/omap4/trap.c
sys/src/9/pc/trap.c
sys/src/9/pc64/fns.h
sys/src/9/pc64/l.s
sys/src/9/pc64/trap.c

index fc148dee9589b4d8a5921d5cf53a6c161e8efcb3..8ef7a0edf74e6f3edf275866d77056ce83708d48 100644 (file)
@@ -261,7 +261,7 @@ syscall(Ureg* ureg)
        up->psstate = 0;
 
        if(scallnr == NOTED)
-               noted(ureg, up->s.args[0]);
+               noted(ureg, *((ulong*)up->s.args));
 
        splhi();
        if(scallnr != RFORK && (up->procctl || up->nnote))
index 26de7ac8dec06e7940c2e1c5e797354ebd034b00..50450855ab2e1b446a3de6a7e1ed6353b99ab89e 100644 (file)
@@ -370,7 +370,7 @@ syscall(Ureg *ureg)
        up->psstate = nil;
 
        if(scall == NOTED)
-               noted(ureg, up->s.args[0]);
+               noted(ureg, *((ulong*)up->s.args));
        if(scall != RFORK && (up->procctl || up->nnote)){
                splhi();
                notify(ureg);
index cf85bcad69f8010fa78b0b23fbd0ae97862d84ef..fbc6aef2c5ce926832083a87420253d1c47a6b53 100644 (file)
@@ -799,7 +799,7 @@ syscall(Ureg* ureg)
        up->psstate = 0;
 
        if(scallnr == NOTED)
-               noted(ureg, up->s.args[0]);
+               noted(ureg, *((ulong*)up->s.args));
 
        if(scallnr!=RFORK && (up->procctl || up->nnote)){
                splhi();
index 5586d1aa511283276e48fa57c72ec0f3909f96b2..47c3acf7ad46a59b887b37ea58f1eb1fd0a50689 100644 (file)
@@ -104,6 +104,7 @@ uintptr     *mmuwalk(uintptr*, uintptr, int, int);
 int    mtrr(uvlong, uvlong, char *);
 void   mtrrclock(void);
 int    mtrrprint(char *, long);
+void   noteret(void);
 uchar  nvramread(int);
 void   nvramwrite(int, uchar);
 void   outb(int, int);
index e1eb310b13746028e96097dc83330f279e0dea32..e0038a1d6f2cfcdb8988572ce54fb3fe13ceff6d 100644 (file)
@@ -737,6 +737,10 @@ TEXT forkret(SB), 1, $-4
 
        BYTE $0x48; SYSRET                      /* SYSRETQ */
 
+TEXT noteret(SB), 1, $-4
+       CLI
+       JMP _intrestore
+
 /*
  * Interrupt/exception handling.
  */
@@ -786,6 +790,7 @@ _intrnested:
        PUSHQ   SP
        CALL    trap(SB)
 
+_intrestore:
        POPQ    AX
 
        POPQ    AX
index a83fe2f3f560b869ea2bdc89e2541ffa710e7df5..41a8c4978595f33c5d1444caa5ac34af8992d1e9 100644 (file)
@@ -758,8 +758,19 @@ syscall(Ureg* ureg)
        up->insyscall = 0;
        up->psstate = 0;
 
-       if(scallnr == NOTED)
-               noted(ureg, up->s.args[0]);
+       if(scallnr == NOTED){
+               noted(ureg, *((ulong*)up->s.args));
+
+               /*
+                * normally, syscall() returns to forkret()
+                * not restoring general registers when going
+                * to userspace. to completely restore the
+                * interrupted context, we have to return thru
+                * noteret(). we override return pc to jump to
+                * to it when returning form syscall()
+                */
+               ((void**)&ureg)[-1] = (void*)noteret;
+       }
 
        if(scallnr!=RFORK && (up->procctl || up->nnote)){
                splhi();
@@ -904,7 +915,7 @@ if(0) print("%s %lud: noted %#p %#p\n",
                        pprint("suicide: trap in noted\n");
                        pexit("Suicide", 0);
                }
-               up->ureg = (Ureg*)(*(ulong*)(oureg-BY2WD));
+               up->ureg = (Ureg*)(*(uintptr*)(oureg-BY2WD));
                qunlock(&up->debug);
                break;