From af2ed201b1d4ede6fc9d4ba2a35b37b5425393c5 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 11 Dec 2018 18:06:08 +0000 Subject: [PATCH] thunked: fix stack handling bug in the pre-emption path --- Kernel/lowlevel-z80-thunked.s | 10 +++++++--- Kernel/platform-cromemco/kernel.def | 4 ++++ Kernel/platform-sam/kernel.def | 4 ++++ Kernel/platform-sc108/kernel.def | 3 +++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Kernel/lowlevel-z80-thunked.s b/Kernel/lowlevel-z80-thunked.s index efe65402..4ebdff65 100644 --- a/Kernel/lowlevel-z80-thunked.s +++ b/Kernel/lowlevel-z80-thunked.s @@ -86,7 +86,7 @@ _doexec: ld sp,hl ex de,hl ld de,#PROGLOAD - ld a,(U_DATA__U_PAGE+1) ; pass high page to trampoline + ld a,(U_DATA__U_PAGE+HIGHPAGE) ; pass high page to trampoline jp _platform_doexec ; jump into the low memory stub ; @@ -158,7 +158,7 @@ syscall_return: exx ; Return page for caller (may not be the page we can in on if we ; swapped - ld a,(U_DATA__U_PAGE+1) + ld a,(U_DATA__U_PAGE+HIGHPAGE) ret signal_path: ld h,a ; save signal number @@ -234,7 +234,7 @@ no_sig: xor a ld (_int_disabled),a ld e,a - ld a,(U_DATA__U_PAGE+1) + ld a,(U_DATA__U_PAGE+HIGHPAGE) intret: ret @@ -317,6 +317,10 @@ intret2: ; The istack was lost but that is ok as we saved the return onto the ; kernel stack, so when we finally ret we end up in the right place ld sp,#kstack_top - 2 ; saved return address + + ld hl,(U_DATA__U_SYSCALL_SP) + ld (istack_switched_sp),hl + ; Now continue on the interrupt return path ; looking for signals jr intsig diff --git a/Kernel/platform-cromemco/kernel.def b/Kernel/platform-cromemco/kernel.def index def2cec1..939d0b7b 100644 --- a/Kernel/platform-cromemco/kernel.def +++ b/Kernel/platform-cromemco/kernel.def @@ -21,3 +21,7 @@ CONFIG_SWAP .equ 0 .macro HIGH .area _COMMONMEM .endm + +; We only have a single page entry + +HIGHPAGE .equ 0 \ No newline at end of file diff --git a/Kernel/platform-sam/kernel.def b/Kernel/platform-sam/kernel.def index 50f075fa..d00b87bb 100644 --- a/Kernel/platform-sam/kernel.def +++ b/Kernel/platform-sam/kernel.def @@ -20,3 +20,7 @@ Z80_TYPE .equ 1 .macro HIGH .area _HIGH .endm + +; We keep the low and high bytes of the 32K map in the two adjacent bytes +; +HIGHPAGE .equ 1 \ No newline at end of file diff --git a/Kernel/platform-sc108/kernel.def b/Kernel/platform-sc108/kernel.def index 35fe066b..37a5db61 100644 --- a/Kernel/platform-sc108/kernel.def +++ b/Kernel/platform-sc108/kernel.def @@ -44,3 +44,6 @@ NBUFS .equ 4 .macro HIGH .area _COMMONMEM .endm + +HIGHPAGE .equ 0 ; We only have 1 page byte and the low page + ; isn't used -- 2.34.1