From 604538ed62cb688d88c4b3f6a9fad72b1e0eb32e Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Wed, 15 Apr 2015 17:44:38 -0300 Subject: [PATCH] x86: Set interrupt handler for Double Fault exception This patch sets an interrupt handler for Double Fault exception during CPU initialization. In case such exception is raised, we halt the system. This way, we avoid the system to triple fault (due to an unhandled interrupt for instance), leaving no trace about what cause the triple fault. --- cpu/x86/cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cpu/x86/cpu.c b/cpu/x86/cpu.c index 9e4707856..d3e5fef84 100644 --- a/cpu/x86/cpu.c +++ b/cpu/x86/cpu.c @@ -30,10 +30,23 @@ #include "gdt.h" #include "idt.h" +#include "interrupt.h" +#include "helpers.h" +static void +double_fault_handler(struct interrupt_context context) +{ + halt(); +} +/*---------------------------------------------------------------------------*/ void cpu_init(void) { gdt_init(); idt_init(); + + /* Set an interrupt handler for Double Fault exception. This way, we avoid + * the system to triple fault, leaving no trace about what happened. + */ + SET_INTERRUPT_HANDLER(8, 1, double_fault_handler); }