aboutsummaryrefslogtreecommitdiff
path: root/x86_64/locore.S
diff options
context:
space:
mode:
authorLuca Dariz <luca@orpolo.org>2023-07-29 19:45:14 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-08-04 23:34:18 +0200
commit8b29b18fda413928c32473475ca51aa05c52db18 (patch)
treee3dca31b5321ae00d7c88b5dc6a78161622fcbeb /x86_64/locore.S
parentbdcafee412ab6eec58f6b315e16e57fe3dad002f (diff)
downloadgnumach-8b29b18fda413928c32473475ca51aa05c52db18.tar.gz
gnumach-8b29b18fda413928c32473475ca51aa05c52db18.tar.bz2
gnumach-8b29b18fda413928c32473475ca51aa05c52db18.zip
x86_64: install emergency handler for double fault
* i386/i386/idt.c: add selector for the interrupt-specific stack * i386/i386/ktss.c: configure ist1 to use a dedicated stack * i386/i386/trap.c: add double fault handler, which just prints the state and panics. There is not much else to do in this case but it's useful for troubleshooting * x86_64/idt_inittab.S: allow to specify an interrupt stack for custom handlers * x86_64/locore.S: add double fault handler Message-Id: <20230729174514.1145656-1-luca@orpolo.org>
Diffstat (limited to 'x86_64/locore.S')
-rw-r--r--x86_64/locore.S15
1 files changed, 15 insertions, 0 deletions
diff --git a/x86_64/locore.S b/x86_64/locore.S
index 2938e430..16b0dde5 100644
--- a/x86_64/locore.S
+++ b/x86_64/locore.S
@@ -345,6 +345,21 @@ ENTRY(start_timer)
*
*/
+/* Try to save/show some information when a double fault happens
+ * We can't recover to a working state, so if we have a debugger wait for it,
+ * otherwise reset */
+ENTRY(t_dbl_fault)
+ INT_FIX
+ cli /* disable interrupts that might corrupt the state*/
+ pusha
+ movq %cr2,%rax
+ movq %rax,R_CR2-R_R15(%rsp) /* CR2 might contain the faulting address */
+ subq $48,%rsp // FIXME remove when segments are cleaned up
+ movq %rsp,%rdi /* pass the saved state */
+ call handle_double_fault
+ jmp cpu_shutdown /* reset */
+END(t_dbl_fault)
+
/*
* General protection or segment-not-present fault.
* Check for a GP/NP fault in the kernel_return