1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:27:45 +00:00

UserspaceEmulator: Implement a proper VM allocator

This patch brings Kernel::RangeAllocator to UserspaceEmulator in a
slightly simplified form.

It supports the basic three allocation types needed by virt$mmap():
allocate_anywhere, allocate_specific, and allocate_randomized.

Porting virt$mmap() and virt$munmap() to use the allocator makes
UE work correctly once again. :^)
This commit is contained in:
Andreas Kling 2021-02-06 23:08:51 +01:00
parent 9dacd7c0ec
commit 89483a9408
10 changed files with 438 additions and 36 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,6 +27,7 @@
#pragma once
#include "MallocTracer.h"
#include "RangeAllocator.h"
#include "Report.h"
#include "SoftCPU.h"
#include "SoftMMU.h"
@ -174,7 +175,6 @@ private:
int virt$sendfd(int, int);
int virt$msyscall(FlatPtr);
FlatPtr allocate_vm(size_t size, size_t alignment);
bool find_malloc_symbols(const MmapRegion& libc_text);
void dispatch_one_pending_signal();
@ -213,6 +213,8 @@ private:
};
HashMap<String, CachedELF> m_dynamic_library_cache;
RangeAllocator m_range_allocator;
};
ALWAYS_INLINE bool Emulator::is_in_malloc_or_free() const