1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

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.
This commit is contained in:
Andreas Kling 2022-04-05 12:40:31 +02:00
parent e0da8da657
commit f8d798b667
5 changed files with 9 additions and 10 deletions

View file

@ -354,7 +354,7 @@ struct KmallocGlobalData {
void enable_expansion()
{
// FIXME: This range can be much bigger on 64-bit, but we need to figure something out for 32-bit.
auto reserved_region = MUST(MM.region_tree().allocate_unbacked_anywhere(64 * MiB, 1 * MiB));
auto reserved_region = MUST(MM.allocate_unbacked_region_anywhere(64 * MiB, 1 * MiB));
expansion_data = KmallocGlobalData::ExpansionData {
.virtual_range = reserved_region->range(),

View file

@ -1242,4 +1242,11 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::create_identity_mapped_reg
return region;
}
ErrorOr<NonnullOwnPtr<Region>> MemoryManager::allocate_unbacked_region_anywhere(size_t size, size_t alignment)
{
auto region = TRY(Region::create_unbacked());
TRY(m_region_tree.place_anywhere(*region, RandomizeVirtualAddress::No, size, alignment));
return region;
}
}

View file

@ -188,6 +188,7 @@ public:
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(PhysicalAddress, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region_with_vmobject(VMObject&, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes);
ErrorOr<NonnullOwnPtr<Region>> allocate_unbacked_region_anywhere(size_t size, size_t alignment);
ErrorOr<NonnullOwnPtr<Region>> create_identity_mapped_region(PhysicalAddress, size_t);
struct SystemMemoryInfo {

View file

@ -129,13 +129,6 @@ ErrorOr<VirtualRange> RegionTree::allocate_range_randomized(size_t size, size_t
return allocate_range_anywhere(size, alignment);
}
ErrorOr<NonnullOwnPtr<Region>> RegionTree::allocate_unbacked_anywhere(size_t size, size_t alignment)
{
auto region = TRY(Region::create_unbacked());
TRY(place_anywhere(*region, RandomizeVirtualAddress::No, size, alignment));
return region;
}
ErrorOr<void> RegionTree::place_anywhere(Region& region, RandomizeVirtualAddress randomize_virtual_address, size_t size, size_t alignment)
{
SpinlockLocker locker(m_lock);

View file

@ -40,8 +40,6 @@ public:
VirtualRange total_range() const { return m_total_range; }
ErrorOr<NonnullOwnPtr<Region>> allocate_unbacked_anywhere(size_t size, size_t alignment = PAGE_SIZE);
ErrorOr<void> place_anywhere(Region&, RandomizeVirtualAddress, size_t size, size_t alignment = PAGE_SIZE);
ErrorOr<void> place_specifically(Region&, VirtualRange const&);