ladybird/Kernel/Memory
Andreas Kling 24ecf1d021 Kernel: Remove redundant hash map of page tables in PageDirectory
The purpose of the PageDirectory::m_page_tables map was really just
to act as ref-counting storage for PhysicalPage objects that were
being used for the directory's page tables.

However, this was basically redundant, since we can find the physical
address of each page table from the page directory, and we can find the
PhysicalPage object from MemoryManager::get_physical_page_entry().
So if we just manually ref() and unref() the pages when they go in and
out of the directory, we no longer need PageDirectory::m_page_tables!

Not only does this remove a bunch of kmalloc() traffic, it also solves
a race condition that would occur when lazily adding a new page table
to a directory:

Previously, when MemoryManager::ensure_pte() would call HashMap::set()
to insert the new page table into m_page_tables, if the HashMap had to
grow its internal storage, it would call kmalloc(). If that kmalloc()
would need to perform heap expansion, it would end up calling
ensure_pte() again, which would clobber the page directory mapping used
by the outer invocation of ensure_pte().

The net result of the above bug would be that any invocation of
MemoryManager::ensure_pte() could erroneously return a pointer into
a kernel page table instead of the correct one!

This whole problem goes away when we remove the HashMap, as ensure_pte()
no longer does anything that allocates from the heap.
2022-01-10 16:22:37 +01:00
..
AddressSpace.cpp Kernel: Add implied auto qualifiers in Memory 2022-01-09 23:29:57 -08:00
AddressSpace.h Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
AllocationStrategy.h Kernel: Rename Kernel/VM/ to Kernel/Memory/ 2021-08-06 14:05:58 +02:00
AnonymousVMObject.cpp Kernel: Add implied auto qualifiers in Memory 2022-01-09 23:29:57 -08:00
AnonymousVMObject.h Kernel: Mark private members of SharedCommittedCowPages as private 2021-11-14 22:52:35 +01:00
InodeVMObject.cpp Kernel: Rename ScopedSpinlock => SpinlockLocker 2021-08-22 03:34:10 +02:00
InodeVMObject.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
MappedROM.h Kernel: Fix possible buffer overrun when scanning a MappedROM 2022-01-04 17:46:36 +00:00
MemoryManager.cpp Kernel: Remove redundant hash map of page tables in PageDirectory 2022-01-10 16:22:37 +01:00
MemoryManager.h Kernel: Remove redundant hash map of page tables in PageDirectory 2022-01-10 16:22:37 +01:00
PageDirectory.cpp Kernel: Move userspace virtual address range base to 0x10000 2021-12-22 00:02:36 -08:00
PageDirectory.h Kernel: Remove redundant hash map of page tables in PageDirectory 2022-01-10 16:22:37 +01:00
PageFaultResponse.h Kernel: Rename Kernel/VM/ to Kernel/Memory/ 2021-08-06 14:05:58 +02:00
PhysicalPage.cpp Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalPage.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
PhysicalRegion.cpp Kernel: Initialize PhysicalRegion::m_large_zones, remove m_small_zones 2021-12-22 13:29:31 -08:00
PhysicalRegion.h Kernel: Remove the kmalloc_eternal heap :^) 2021-12-28 21:02:38 +01:00
PhysicalZone.cpp Kernel: Add implied auto qualifiers in Memory 2022-01-09 23:29:57 -08:00
PhysicalZone.h Kernel: Remove the kmalloc_eternal heap :^) 2021-12-28 21:02:38 +01:00
PrivateInodeVMObject.cpp Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
PrivateInodeVMObject.h Everywhere: Remove unused AK/Bitmap includes 2021-11-10 14:39:42 +01:00
Region.cpp Kernel: Don't relock MM lock for every page when remapping region 2022-01-10 16:22:37 +01:00
Region.h Kernel: Remove old SlabAllocator :^) 2021-12-26 21:22:59 +01:00
RingBuffer.cpp Kernel: Propagate overflow errors from Memory::page_round_up 2021-12-28 23:08:50 +01:00
RingBuffer.h Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T> 2021-11-08 01:10:53 +01:00
ScatterGatherList.cpp Kernel: Propagate overflow errors from Memory::page_round_up 2021-12-28 23:08:50 +01:00
ScatterGatherList.h Kernel: Move Kernel/Memory/ code into Kernel::Memory namespace 2021-08-06 14:05:58 +02:00
ScopedAddressSpaceSwitcher.cpp Kernel: Access MemoryManager static functions statically 2021-10-02 18:16:15 +02:00
ScopedAddressSpaceSwitcher.h Kernel: Rename ProcessPagingScope => ScopedAddressSpaceSwitcher 2021-09-06 18:56:51 +02:00
SharedInodeVMObject.cpp Kernel: Don't rewrite the whole file on sys$msync 2021-12-01 09:47:46 +01:00
SharedInodeVMObject.h Kernel: Don't rewrite the whole file on sys$msync 2021-12-01 09:47:46 +01:00
TypedMapping.h Kernel: Propagate overflow errors from Memory::page_round_up 2021-12-28 23:08:50 +01:00
VirtualRange.cpp Kernel: Propagate overflow errors from Memory::page_round_up 2021-12-28 23:08:50 +01:00
VirtualRange.h AK: Convert AK::Format formatting helpers to returning ErrorOr<void> 2021-11-17 00:21:13 +01:00
VirtualRangeAllocator.cpp Kernel: Return EEXIST in VirtualRangeAllocator::try_allocate_specific() 2021-12-23 23:08:10 +01:00
VirtualRangeAllocator.h Kernel: Make VirtualRangeAllocator setup functions propagate errors 2021-11-18 21:11:30 +01:00
VMObject.cpp AK+Everywhere: Make FixedArray OOM-safe 2022-01-08 22:54:05 +01:00
VMObject.h Kernel: Support Mutex Protected lists in ListedRefCounted 2021-12-29 12:04:15 +01:00