Kernel: GeneralAllocator and FixedWidth allocator invalidate TLB caches

We were getting random exceptions when reallocating same addressess and
this fixes that problem :)
This commit is contained in:
Bananymous 2023-06-11 15:57:48 +03:00
parent 1cf464d5c7
commit 3181ea7b4d
2 changed files with 6 additions and 1 deletions

View File

@ -196,6 +196,7 @@ namespace Kernel
page_vaddr = m_page_table.get_free_page(); page_vaddr = m_page_table.get_free_page();
m_page_table.map_page_at(page_paddr, page_vaddr, PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present); m_page_table.map_page_at(page_paddr, page_vaddr, PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present);
m_page_table.invalidate(page_vaddr);
} }
bool FixedWidthAllocator::allocate_page_if_needed(vaddr_t vaddr, uint8_t flags) bool FixedWidthAllocator::allocate_page_if_needed(vaddr_t vaddr, uint8_t flags)

View File

@ -43,7 +43,11 @@ namespace Kernel
allocation.address = m_page_table.get_free_contiguous_pages(needed_pages); allocation.address = m_page_table.get_free_contiguous_pages(needed_pages);
for (size_t i = 0; i < needed_pages; i++) for (size_t i = 0; i < needed_pages; i++)
m_page_table.map_page_at(allocation.pages[i], allocation.address + i * PAGE_SIZE, PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present); {
vaddr_t vaddr = allocation.address + i * PAGE_SIZE;
m_page_table.map_page_at(allocation.pages[i], vaddr, PageTable::Flags::UserSupervisor | PageTable::Flags::ReadWrite | PageTable::Flags::Present);
m_page_table.invalidate(vaddr);
}
MUST(m_allocations.push_back(BAN::move(allocation))); MUST(m_allocations.push_back(BAN::move(allocation)));
return allocation.address; return allocation.address;