Resolved page faults from user stacks

This commit is contained in:
Drew Galbraith 2023-06-12 23:28:23 -07:00
parent 6c13fdc801
commit 72885190e9
3 changed files with 19 additions and 0 deletions

View file

@ -21,3 +21,14 @@ void UserStackManager::FreeUserStack(uint64_t stack_ptr) {
freed_stacks_++;
dbgln("%u freed user stacks", freed_stacks_);
}
bool UserStackManager::IsValidStack(uint64_t vaddr) {
if (vaddr < next_stack_ || vaddr > (kStackMax - 0x1000)) {
return false;
}
// Checks if the address is in the first page of the stack.
if (vaddr & 0xFF000) {
return true;
}
return false;
}

View file

@ -20,6 +20,9 @@ class UserStackManager {
uint64_t NewUserStack();
void FreeUserStack(uint64_t stack_ptr);
// Used to check if we should page in this address.
bool IsValidStack(uint64_t vaddr);
private:
const uint64_t kStackMax = 0x00008000'00000000;
const uint64_t kStackMin = 0x00007FF0'00000000;