summaryrefslogtreecommitdiff
path: root/Kernel/VM/RangeAllocator.cpp
AgeCommit message (Collapse)Author
2020-11-11Kernel: Add locks around RangeAllocatorTom
We need to keep multiple processors from changing it at the same time.
2020-08-30Kernel: Unbreak building with extra debug macros, part 2Ben Wiederhake
2020-08-02AK: Fix overflow and mixed-signedness issues in binary_search() (#2961)Muhammad Zahalqa
2020-07-26Refactor: Change the AK::binary_search signature to use AK::Span.asynts
2020-03-08AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)Andreas Kling
Use this instead of uintptr_t throughout the codebase. This makes it possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-03-02Kernel: Use klog() instead of kprintf()Liav A
Also, duplicate data in dbg() and klog() calls were removed. In addition, leakage of virtual address to kernel log is prevented. This is done by replacing kprintf() calls to dbg() calls with the leaked data instead. Also, other kprintf() calls were replaced with klog().
2020-02-27RangeAllocator: Use dbg() instead of dbgprintf()Liav A
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-19Kernel: Refuse to allocate 0 bytes of virtual address spaceAndreas Kling
2020-02-16Kernel+LibC: Allow sys$mmap() callers to specify address alignmentAndreas Kling
This is exposed via the non-standard serenity_mmap() call in userspace.
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-10Kernel: Remove more <LibBareMetal/Output/kstdio.h> includesAndreas Kling
2020-02-09Kernel: Apply changes to use LibBareMetal definitionsLiav A
2020-01-30Kernel: Add some sanity assertions in RangeAllocator::deallocate()Andreas Kling
We should never end up deallocating an empty range, or a range that ends before it begins.
2020-01-19Kernel: Oops, fix bad sort order of available VM rangesAndreas Kling
This made the allocator perform worse, so here's another second off of the Kernel/Process.cpp compile time from a simple bugfix! (31s to 30s)
2020-01-19Kernel: Optimize VM range deallocation a bitAndreas Kling
Previously, when deallocating a range of VM, we would sort and merge the range list. This was quite slow for large processes. This patch optimizes VM deallocation in the following ways: - Use binary search instead of linear scan to find the place to insert the deallocated range. - Insert at the right place immediately, removing the need to sort. - Merge the inserted range with any adjacent range(s) in-line instead of doing a separate merge pass into a list copy. - Add Traits<Range> to inform Vector that Range objects are trivial and can be moved using memmove(). I've also added an assertion that deallocated ranges are actually part of the RangeAllocator's initial address range. I've benchmarked this using g++ to compile Kernel/Process.cpp. With these changes, compilation goes from ~41 sec to ~35 sec.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-17Kernel: Add a random offset to the base of the per-process VM allocatorAndreas Kling
This is not ASLR, but it does de-trivialize exploiting the ELF loader which would previously always parse executables at 0x01001000 in every single exec(). I've taken advantage of this multiple times in my own toy exploits and it's starting to feel cheesy. :^)
2019-09-30Kernel: Make it possible to turn off VM guard pages at compile timeAndreas Kling
This might be useful for debugging since guard pages introduce a fair amount of noise in the virtual address space.
2019-09-22Kernel: Pad virtual address space allocations with guard pagesAndreas Kling
Put one unused page on each side of VM allocations to make invalid accesses more likely to generate crashes. Note that we will not add this guard padding for mmap() at a specific memory address, only to "mmap it anywhere" requests.
2019-06-07Kernel: Rename LinearAddress => VirtualAddress.Andreas Kling
2019-06-07Kernel: Run clang-format on everything.Andreas Kling
2019-05-22Kernel: Forked children should inherit their RangeAllocator by copy.Andreas Kling
Otherwise we'll start handing out addresses that are very likely already in use by existing ranges.
2019-05-18Kernel: Remove some RangeAllocator debug spam.Andreas Kling
2019-05-17Kernel: Use a RangeAllocator for kernel-only virtual space allocation too.Andreas Kling
2019-05-17Kernel: Implement a simple virtual address range allocator.Andreas Kling
This replaces the previous virtual address allocator which was basically just "m_next_address += size;" With this in place, virtual addresses can get reused, which cuts down on the number of page tables created. When we implement ASLR some day, we'll probably have to do page table deallocation, but for now page tables are only deallocated once the process dies.