Resolved page faults from user stacks
This commit is contained in:
parent
6c13fdc801
commit
72885190e9
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -55,6 +55,11 @@ bool AddressSpace::HandlePageFault(uint64_t vaddr) {
|
|||
#if K_VMAS_DEBUG
|
||||
dbgln("[VMAS] Page Fault!");
|
||||
#endif
|
||||
if (user_stacks_.IsValidStack(vaddr)) {
|
||||
MapPage(cr3_, vaddr, phys_mem::AllocatePage());
|
||||
return true;
|
||||
}
|
||||
|
||||
MemoryMapping* mapping = GetMemoryMappingForAddr(vaddr);
|
||||
if (mapping == nullptr) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue