summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-21 04:03:22 -0400
committerIan Moffett <ian@osmora.org>2025-08-21 04:03:22 -0400
commit47f23523bfb864342ea2a95cd95df02fa8095885 (patch)
treefe73b9d6b4710b4d95611bbbed29a23e9a822a89 /sys/arch/amd64
parent2231410363d1ff97f0b22556cc656ad5880db5cf (diff)
kernel/amd64: Use seperate stack for double faults
This commit gives the double fault handling context a dedicated kernel stack to ensure it has a clean space to vomit up a trapframe into without encountering too many issues besides the inevitable panic to the user's despair and distress. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/machdep.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 1a07cb5..5fb006c 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -127,20 +127,28 @@ static void
setup_vectors(struct cpu_info *ci)
{
union tss_stack scstack;
+ union tss_stack dfstack;
/* Try to allocate a syscall stack */
if (tss_alloc_stack(&scstack, DEFAULT_PAGESIZE) != 0) {
panic("failed to allocate syscall stack\n");
}
+ /* Try to allocate a double fault stack */
+ if (tss_alloc_stack(&dfstack, DEFAULT_PAGESIZE) != 0) {
+ panic("failed to allocate double fault stack\n");
+ }
+
tss_update_ist(ci, scstack, IST_SYSCALL);
+ tss_update_ist(ci, dfstack, IST_DBFLT);
+
idt_set_desc(0x0, IDT_TRAP_GATE, ISR(arith_err), 0);
idt_set_desc(0x2, IDT_TRAP_GATE, ISR(nmi), 0);
idt_set_desc(0x3, IDT_TRAP_GATE, ISR(breakpoint_handler), 0);
idt_set_desc(0x4, IDT_TRAP_GATE, ISR(overflow), 0);
idt_set_desc(0x5, IDT_TRAP_GATE, ISR(bound_range), 0);
idt_set_desc(0x6, IDT_TRAP_GATE, ISR(invl_op), 0);
- idt_set_desc(0x8, IDT_TRAP_GATE, ISR(double_fault), 0);
+ idt_set_desc(0x8, IDT_TRAP_GATE, ISR(double_fault), IST_DBFLT);
idt_set_desc(0xA, IDT_TRAP_GATE, ISR(invl_tss), 0);
idt_set_desc(0xB, IDT_TRAP_GATE, ISR(segnp), 0);
idt_set_desc(0xC, IDT_TRAP_GATE, ISR(ss_fault), 0);