Set RSP0 on context switch

Previously we only set it on thread init which caused interrupts to
stomp on the stack of the most recently started thread, potentially
overwriting their cr3 and other variables and causing a crash.
This commit is contained in:
Drew Galbraith 2023-06-16 01:52:55 -07:00
parent e5da93757a
commit 4e328c2f7a
1 changed files with 2 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include "scheduler/scheduler.h"
#include "common/gdt.h"
#include "debug/debug.h"
#include "lib/linked_list.h"
#include "scheduler/process_manager.h"
@ -26,6 +27,7 @@ void Scheduler::SwapToCurrent(Thread& prev) {
}
current_thread_->SetState(Thread::RUNNING);
SetRsp0(current_thread_->Rsp0Start());
context_switch(prev.Rsp0Ptr(), current_thread_->Rsp0Ptr());
asm volatile("sti");