Skip to content

Commit d2886ab

Browse files
Andrew Boieandrewboie
Andrew Boie
authored andcommitted
x86: clear EFLAGS on double fault
In the event of a double fault, we do a HW task switch to a special _df_tss hardware task which resets the stack pointer to the interrupt stack and otherwise restores the main hardware task to a runnable state so that _df_handler_bottom() can run. However, we need to make sure that _df_handler_bottom() runs with interrupts locked, otherwise another IRQ could corrupt the interrupt stack resulting in undefined behavior. We have very little stack space to work with in this context, just zero it. It's a fatal error for the thread in any event. Fixes: #7291 Signed-off-by: Andrew Boie <[email protected]>
1 parent 1227b2f commit d2886ab

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

arch/x86/core/fatal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ static FUNC_NORETURN __used void _df_handler_top(void)
446446
_main_tss.ss = DATA_SEG;
447447
_main_tss.eip = (u32_t)_df_handler_bottom;
448448
_main_tss.cr3 = (u32_t)X86_MMU_PDPT;
449+
_main_tss.eflags = 0;
449450

450451
/* NT bit is set in EFLAGS so we will task switch back to _main_tss
451452
* and run _df_handler_bottom

0 commit comments

Comments
 (0)