Commit graph

17 commits

Author SHA1 Message Date
Liav A 5ff318cf3a Kernel: Remove i686 support 2022-12-28 11:53:41 +01:00
Andreas Kling dc9d2c1b10 Kernel: Wrap RegionTree objects in SpinlockProtected
This makes locking them much more straightforward, and we can remove
a bunch of confusing use of AddressSpace::m_lock. That lock will also
be converted to use of SpinlockProtected in a subsequent patch.
2022-08-24 14:57:51 +02:00
Tim Schumacher 71f2c342c4 Kernel: Limit free space between randomized memory allocations 2022-04-21 13:16:56 +02:00
Andreas Kling f8d798b667 Kernel: Move allocate_unbacked_region_anywhere() to MemoryManager
This didn't need to be in RegionTree, and since it's specific to kernel
VM anyway, let's move it to MemoryManager.
2022-04-05 13:45:10 +02:00
Andreas Kling e0da8da657 Kernel: Move create_identity_mapped_region() to MemoryManager
This had no business being in RegionTree, since RegionTree doesn't track
identity-mapped regions anyway. (We allow *any* address to be identity
mapped, not just the ones that are part of the RegionTree's range.)
2022-04-05 13:45:10 +02:00
Andreas Kling cfb61cbd54 Kernel: Add RegionTree::find_region_containing(address or range)
Let's encapsulate looking up regions so clients don't have to dig into
RegionTree internals.
2022-04-05 12:23:47 +02:00
Andreas Kling da7ea2556e Kernel: Add RegionTree::remove(Region&)
This allows clients to remove a region from the tree without reaching
into the RegionTree internals.
2022-04-05 11:57:53 +02:00
Idan Horowitz 30e6b313b4 Kernel: Remove false condition in RegionTree::allocate_range_specific
Since find_largest_not_above returns the highest region that is below
the end of the request range, no region after it can intersect with it.
2022-04-04 00:16:11 +02:00
Andreas Kling db75bab493 Kernel: Actually fix accidental overlaps in allocate_range_specific()
Thanks to Idan for spotting this! :^)
2022-04-03 23:58:57 +02:00
Andreas Kling 9765f9f67e Kernel: Fix accidental overlaps in RegionTree::allocate_range_specific()
Thanks to Idan for spotting this! :^)
2022-04-03 23:07:29 +02:00
Andreas Kling 92dfcdb6b1 Kenrel: Update a dmesgln() to say "RegionTree" instead of old class name 2022-04-03 22:00:19 +02:00
Andreas Kling 8b01789ec4 Kernel: Improve RegionTree's internal helper function names
It's a bit nicer if functions that allocate ranges have some kind of
name that includes both "allocate" and "range". :^)
2022-04-03 21:56:16 +02:00
Andreas Kling 858b196c59 Kernel: Unbreak ASLR in the new RegionTree world
Functions that allocate and/or place a Region now take a parameter
that tells it whether to randomize unspecified addresses.
2022-04-03 21:51:58 +02:00
Andreas Kling 07f3d09c55 Kernel: Make VM allocation atomic for userspace regions
This patch move AddressSpace (the per-process memory manager) to using
the new atomic "place" APIs in RegionTree as well, just like we did for
MemoryManager in the previous commit.

This required updating quite a few places where VM allocation and
actually committing a Region object to the AddressSpace were separated
by other code.

All you have to do now is call into AddressSpace once and it'll take
care of everything for you.
2022-04-03 21:51:58 +02:00
Andreas Kling e852a69a06 LibWeb: Make VM allocation atomic for kernel regions
Instead of first allocating the VM range, and then inserting a region
with that range into the MM region tree, we now do both things in a
single atomic operation:

    - RegionTree::place_anywhere(Region&, size, alignment)
    - RegionTree::place_specifically(Region&, address, size)

To reduce the number of things we do while locking the region tree,
we also require callers to provide a constructed Region object.
2022-04-03 21:51:58 +02:00
Andreas Kling e8f543c390 Kernel: Use intrusive RegionTree solution for kernel regions as well
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-03 21:51:58 +02:00
Andreas Kling ffe2e77eba Kernel: Add Memory::RegionTree to share code between AddressSpace and MM
RegionTree holds an IntrusiveRedBlackTree of Region objects and vends a
set of APIs for allocating memory ranges.

It's used by AddressSpace at the moment, and will be used by MM soon.
2022-04-03 21:51:58 +02:00