kernel: Preserve kernel threads' page directories when they differ from the regular kernel page directory
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-06-17 00:49:31 +02:00
parent c2cdb861c9
commit 7a78609a85
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -233,9 +233,11 @@ namespace Scheduler
{ {
switch_context(old_thread, new_thread, regs); switch_context(old_thread, new_thread, regs);
if (!old_thread->is_kernel) old_thread->fp_data.save(); if (!old_thread->is_kernel) old_thread->fp_data.save();
if (old_thread->is_kernel && MMU::get_page_directory() != MMU::kernel_page_directory())
old_thread->directory = MMU::get_page_directory();
if (new_thread->directory) MMU::switch_page_directory(new_thread->directory);
if (!new_thread->is_kernel) if (!new_thread->is_kernel)
{ {
MMU::switch_page_directory(new_thread->directory);
CPU::switch_kernel_stack(new_thread->kernel_stack.top()); CPU::switch_kernel_stack(new_thread->kernel_stack.top());
new_thread->fp_data.restore(); new_thread->fp_data.restore();
} }