diff options
author | Andreas Kling <kling@serenityos.org> | 2022-12-30 23:14:28 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-01 15:14:35 +0100 |
commit | 1b4baaed56828558edbf880c7832c9093fd24543 (patch) | |
tree | 92657bb7d11bb92433a9e9395f73a232ada1bdbf /Kernel/Arch/x86_64 | |
parent | e3b9f78eb90403cb0effe683d8a1cbc4c7e0256b (diff) | |
download | serenity-1b4baaed56828558edbf880c7832c9093fd24543.zip |
Kernel/x86_64: *Restore* interrupt flag in page fault handler
If a page fault occurs while interrupts are disabled, we were wrongly
enabling interrupts right away in the page fault handler.
Instead, we should only do this if interrupts were enabled when the
page fault occurred.
Diffstat (limited to 'Kernel/Arch/x86_64')
-rw-r--r-- | Kernel/Arch/x86_64/Interrupts.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Kernel/Arch/x86_64/Interrupts.cpp b/Kernel/Arch/x86_64/Interrupts.cpp index 726c535b5a..7346163493 100644 --- a/Kernel/Arch/x86_64/Interrupts.cpp +++ b/Kernel/Arch/x86_64/Interrupts.cpp @@ -177,13 +177,16 @@ void page_fault_handler(TrapFrame* trap) { clac(); - // NOTE: Once we've extracted the faulting address from CR2, - // we can re-enable interrupts. auto fault_address = read_cr2(); - sti(); auto& regs = *trap->regs; + // NOTE: Once we've extracted the faulting address from CR2, we can re-enable interrupts. + // However, we only do this *if* they were enabled when the page fault occurred. + if (regs.flags() & 0x200) { + sti(); + } + if constexpr (PAGE_FAULT_DEBUG) { u32 fault_page_directory = read_cr3(); dbgln("CPU #{} ring {} {} page fault in PD={:#x}, {}{} {}", |