summaryrefslogtreecommitdiff
path: root/Kernel/Memory/PageDirectory.cpp
AgeCommit message (Collapse)Author
2022-10-17Kernel: Move InterruptDisabler out of Arch directoryTimon Kruiper
The code in this file is not architecture specific, so it can be moved to the base Kernel directory.
2022-08-24Kernel: Don't take MM lock in ~PageDirectory()Andreas Kling
We don't need the MM lock to unregister a PageDirectory from the CR3 map. This is already protected by the CR3 map's own lock.
2022-08-22Kernel: Stop taking MM lock while using regular quickmapsAndreas Kling
You're still required to disable interrupts though, as the mappings are per-CPU. This exposed the fact that our CR3 lookup map is insufficiently protected (but we'll address that in a separate commit.)
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-07-14Kernel+Userland: Rename prefix of user_physical => physicalLiav A
There's no such supervisor pages concept, so there's no need to call physical pages with the "user_physical" prefix anymore.
2022-04-03Kernel: Use intrusive RegionTree solution for kernel regions as wellAndreas Kling
This patch ports MemoryManager to RegionTree as well. The biggest difference between this and the userspace code is that kernel regions are owned by extant OwnPtr<Region> objects spread around the kernel, while userspace regions are owned by the AddressSpace itself. For kernelspace, there are a couple of situations where we need to make large VM reservations that never get backed by regular VMObjects (for example the kernel image reservation, or the big kmalloc range.) Since we can't make a VM reservation without a Region object anymore, this patch adds a way to create unbacked Region objects that can be used for this exact purpose. They have no internal VMObject.)
2022-04-03Kernel: Use AddressSpace region tree for range allocationAndreas Kling
This patch stops using VirtualRangeAllocator in AddressSpace and instead looks for holes in the region tree when allocating VM space. There are many benefits: - VirtualRangeAllocator is non-intrusive and would call kmalloc/kfree when used. This new solution is allocation-free. This was a source of unpleasant MM/kmalloc deadlocks. - We consolidate authority on what the address space looks like in a single place. Previously, we had both the range allocator *and* the region tree both being used to determine if an address was valid. Now there is only the region tree. - Deallocation of VM when splitting regions is no longer complicated, as we don't need to keep two separate trees in sync.
2022-04-02Kernel: Make MemoryManager compile on aarch64James Mintram
2022-04-02Kernel: Make PageDirectory.cpp compile on aarch64James Mintram
2022-03-23Kernel: Use the whole kernel PD range when randomizing the KASLR offsetIdan Horowitz
Now that we reclaim the memory range that is created by KASLR before the start of the kernel image, there's no need to be conservative with the KASLR offset.
2022-03-22Kernel: Use the pre-image kernel memory range introduced by KASLRIdan Horowitz
This ensures we don't just waste the memory range between the default base load address and the actual load address that was shifted by the KASLR offset.
2022-03-17Kernel: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-01-28Kernel: Convert MemoryManager::allocate_user_physical_page to ErrorOrIdan Horowitz
This allows is to use the TRY macro at the call sites, instead of using clunky null checks.
2022-01-16Kernel: Don't access directory table of uninitialized PageDirectorycreator1creeper1
PageDirectory gets initialized step-by-step in PageDirectory::try_create_for_userspace(). This initialization may fail anywhere in this function - for example, we may not be able to allocate a directory table, in which case PageDirectory::try_create_for_userspace() will return a null pointer. We recognize this condition and early-return ENOMEM. However, at this point, we need to correctly destruct the only partially initialized PageDirectory. Previously, PageDirectory::~PageDirectory() would assume that the object it was destructing was always fully initialized. It now uses the new helper PageDirectory::is_cr3_initialized() to correctly recognize when the directory table was not yet initialized. This helper checks if the pointer to the directory table is null. Only if it is not null does the destructor try to fetch the directory table using PageDirectory::cr3().
2022-01-15Kernel: Always remove PageDirectories from the cr3 map on destructionIdan Horowitz
Previously we would only remove them from the map if they were attached to an AddressSpace, even though we would always add them to the map on construction. This results in an assertion failure on destruction if the page directory was never attached to an AddressSpace. (for example, on an allocation failure of said AddressSpace)
2021-12-22Kernel: Move userspace virtual address range base to 0x10000Idan Horowitz
Now that the shared bottom 2 MiB virtual address mappings are gone userspace can use lower virtual addresses.
2021-12-22Kernel: Don't share the bottom 2 MiB of kernel mappings with processesIdan Horowitz
Now that the last 2 users of these mappings (the Prekernel and the APIC ap boot environment) were removed, these are no longer used.
2021-11-18Kernel: Make VirtualRangeAllocator setup functions propagate errorsAndreas Kling
If an internal allocation failure occurs while setting up a new VRA, we'll now propagate the error to our caller instead of panicking.
2021-11-08Kernel: Replace KResult and KResultOr<T> with Error and ErrorOr<T>Andreas Kling
We now use AK::Error and AK::ErrorOr<T> in both kernel and userspace! This was a slightly tedious refactoring that took a long time, so it's not unlikely that some bugs crept in. Nevertheless, it does pass basic functionality testing, and it's just real nice to finally see the same pattern in all contexts. :^)
2021-09-10AK+Kernel: Reduce the number of template parameters of IntrusiveRBTreeAli Mohammad Pur
This makes the user-facing type only take the node member pointer, and lets the compiler figure out the other needed types from that.
2021-09-08Kernel: Use an IntrusiveRedBlackTree for storing the cr3 mappingsIdan Horowitz
This ensures we don't allocate when intializing the PageDirectory.
2021-09-05Kernel: Unbreak x86_64 build (PageDirectory)Andreas Kling
2021-09-05Kernel: Tidy up Memory::AddressSpace constructionAndreas Kling
- Return KResultOr<T> in places - Propagate errors - Use TRY()
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-08Everywhere: Replace AK::Singleton => SingletonAndreas Kling
2021-08-06Kernel: Make identity mapping mechanism used during AP boot non-genericAndreas Kling
When booting AP's, we identity map a region at 0x8000 while doing the initial bringup sequence. This is the only thing in the kernel that requires an identity mapping, yet we had a bunch of generic API's and a dedicated VirtualRangeAllocator in every PageDirectory for this purpose. This patch simplifies the situation by moving the identity mapping logic to the AP boot code and removing the generic API's.
2021-08-06Kernel: Rename Range => VirtualRangeAndreas Kling
...and also RangeAllocator => VirtualRangeAllocator. This clarifies that the ranges we're dealing with are *virtual* memory ranges and not anything else.
2021-08-06Kernel: Move Kernel/Memory/ code into Kernel::Memory namespaceAndreas Kling
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.