z80fixedbank: Always use the swapstack
authorAlan Cox <alan@linux.intel.com>
Fri, 19 Dec 2014 01:30:26 +0000 (01:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 19 Dec 2014 01:30:26 +0000 (01:30 +0000)
If we don't then when we call map_kernel after copying the udata back we
will scribble somewhere on the stack of the process. We could potentially
move the switch back to the point we've fixed up sp, but as we have a swap
stack we might as well use it.

If we get banked boxes without swap then it may be worth looking at the other
path for a lib/z80fixedbanknswap.s

Kernel/lib/z80fixedbank.s

index 5d8f71d..ea1c68e 100644 (file)
@@ -99,16 +99,21 @@ _switchin:
        add hl, de      ; process ptr
        pop de
 
+       ;
+       ;       Always use the swapstack, otherwise when we call map_kernel
+       ;       having copied the udata stash back to udata we will crap
+       ;       somewhere up the stackframe and it's then down to luck
+       ;       if those bytes are discarded or not.
+       ;
+       ;       Yes - this was a bitch to debug, please don't break it !
+       ;
+       ld sp, #_swapstack
+
         ld a, (hl)
 
        or a
        jr nz, not_swapped
 
-       ;
-       ;       We are still on the departing processes stack, which is
-       ;       fine for now.
-       ;
-       ld sp, #_swapstack
        push hl
        push de
        call _swapper