Using Task gate for exceptions and IRQs handling
Posted: Wed Mar 06, 2013 4:12 am
Hi,
In my OS, every programs run in ring 0. So when an interrupt or exception is raised, the CPU will not change stack if I use Interrupt gate in IDT. This leads to some problems like:
Stack is near full -> Page fault -> Push current state to stack (in order to call handler) -> Stack overflow -> Double fault -> Push -> Triple fault -> die
or
Stack overflow -> Push current state -> Stack overflow -> Double fault -> ... -> die
Therefore, I am considering using Task gate to handle exceptions and IRQs, and this will remove stack pressure from interrupt for normal programs. But TSS switching has considerable overhead. Are there any other solutions?
In my OS, every programs run in ring 0. So when an interrupt or exception is raised, the CPU will not change stack if I use Interrupt gate in IDT. This leads to some problems like:
Stack is near full -> Page fault -> Push current state to stack (in order to call handler) -> Stack overflow -> Double fault -> Push -> Triple fault -> die
or
Stack overflow -> Push current state -> Stack overflow -> Double fault -> ... -> die
Therefore, I am considering using Task gate to handle exceptions and IRQs, and this will remove stack pressure from interrupt for normal programs. But TSS switching has considerable overhead. Are there any other solutions?