From 4d89b8656ae7c0815b09699e4a6feaa9f209410e Mon Sep 17 00:00:00 2001 From: julianb0 Date: Tue, 9 Jul 2019 20:02:36 +0200 Subject: [PATCH] it's a trap! --- ka/sys/intr/common.k | 22 +++++++++------------- vm/dv/CPUDEV | 10 +++++----- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/ka/sys/intr/common.k b/ka/sys/intr/common.k index b0d059f..1c46a4c 100644 --- a/ka/sys/intr/common.k +++ b/ka/sys/intr/common.k @@ -2,23 +2,19 @@ ; See the LICENSE file in the project root for more information. TrapHandlers.prolog: - sub rsp, rbp, 56 - mov q[rbp-8], r10 - mov q[rbp-16], r11 - mov q[rbp-24], r12 - mov q[rbp-32], r13 - mov q[rbp-40], r14 - mov q[rbp-48], r15 + sub rsp, rbp, 32 + mov q[rbp-8], r11 + mov q[rbp-16], r12 + mov q[rbp-24], r13 + cmp q[rsp], r13 + crash.z jmp rax ; go back TrapHandlers.epilog: - mov r10, q[rbp-8] - mov r11, q[rbp-16] - mov r12, q[rbp-24] - mov r13, q[rbp-32] - mov r14, q[rbp-40] - mov r15, q[rbp-48] + mov r11, q[rbp-8] + mov r12, q[rbp-16] + mov r13, q[rbp-24] mov ax0, r11 call IDT.DoneHandling diff --git a/vm/dv/CPUDEV b/vm/dv/CPUDEV index 616ae8e..b312e4d 100644 --- a/vm/dv/CPUDEV +++ b/vm/dv/CPUDEV @@ -61,12 +61,12 @@ When called, a handler will receive the number of the E/I it is handling in R10, and its own RFRAME ID in R11. (in particular, if exception #25 happens and there are no handler for it, the handler #0 that will be called will receive '25' in R10, and '0' in R11). R11 is the value that must be passed to the 'initdone' iocall. -The handler will also receive the previous RFRAME ID in R12, the previous RIP in R15 and the -previous RPC in R14. R13's content is meaningful only to the processor. +The handler will also receive the previous RFRAME ID in R12. +R13 is also modified but its value is meaningful only to the processor. -To return from an E/I, *after* having called 'idtdone', the handler must simply restore -R10-R15's values to what they were when the handler started executing, and then use -the 'IRET' instruction. +To return from an E/I, *after* having called 'idtdone' (using the value originally in R11), +the handler must simply restore R12's and R13's values to what they were when the handler +started executing, and then use the 'IRET' instruction. Clearing the interrupt flag prevents (and queues) maskable hardware interrupts