kernel/x86_64: Avoid kernel panics when a page fault occurs in a userspace thread

This commit is contained in:
apio 2023-03-07 21:06:04 +01:00
parent ca85a69442
commit e30eec4213
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -31,7 +31,7 @@ void FPData::save()
void FPData::restore()
{
if(!m_already_saved) return;
if (!m_already_saved) return;
asm volatile("fxrstor (%0)" : : "r"(m_data));
}
@ -64,6 +64,13 @@ void decode_page_fault_error_code(u64 code)
decode_page_fault_error_code(regs->error);
if (!is_in_kernel(regs))
{
// FIXME: Kill this process with SIGSEGV once we have signals and all that.
kerrorln("Current task %zu was terminated because of a page fault", Scheduler::current()->id);
kernel_exit();
}
CPU::print_stack_trace_at(regs);
CPU::efficient_halt();