Kernel: Make userspace stack on-demand allocated

Also bump the hardlimit of stack size from 512 KiB->32 MiB. This still
feels quite low but is much better than before :D
This commit is contained in:
2025-08-07 02:49:02 +03:00
parent f5bbcc017c
commit 72f85dce2b
3 changed files with 14 additions and 4 deletions

View File

@@ -143,7 +143,7 @@ namespace Kernel
BAN::ErrorOr<bool> VirtualRange::allocate_page_for_demand_paging(vaddr_t vaddr)
{
ASSERT(contains(vaddr));
ASSERT(&PageTable::current() == &m_page_table);
vaddr &= PAGE_ADDR_MASK;
if (m_preallocated)
return false;
@@ -158,8 +158,11 @@ namespace Kernel
if (m_paddrs[index] == 0)
return BAN::Error::from_errno(ENOMEM);
PageTable::with_fast_page(m_paddrs[index], []{
memset(PageTable::fast_page_as_ptr(), 0x00, PAGE_SIZE);
});
m_page_table.map_page_at(m_paddrs[index], vaddr, m_flags);
memset(reinterpret_cast<void*>(vaddr), 0, PAGE_SIZE);
return true;
}