1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

UserspaceEmulator: Exclude special ranges from RangeAllocator

If we do not mark these ranges as reserved, RangeAllocator might later
give us addresses that overlap these, which then causes an assertion
failure in the SoftMMU.  This behavior led to recurring CI failures, and
sometimes made programs as simple as `/bin/true` fail.

Fixes "Crash 1" reported in #9104
This commit is contained in:
Daniel Bertalan 2021-12-24 22:54:26 +01:00 committed by Idan Horowitz
parent 979f300337
commit 4e1898df99
4 changed files with 20 additions and 3 deletions

View file

@ -1533,7 +1533,9 @@ u32 Emulator::virt$allocate_tls(FlatPtr initial_data, size_t size)
// TODO: This matches what Thread::make_thread_specific_region does. The kernel
// ends up allocating one more page. Figure out if this is intentional.
auto region_size = align_up_to(size, PAGE_SIZE) + PAGE_SIZE;
auto tcb_region = make<SimpleRegion>(0x20000000, region_size);
constexpr auto tls_location = VirtualAddress(0x20000000);
m_range_allocator.reserve_user_range(tls_location, region_size);
auto tcb_region = make<SimpleRegion>(tls_location.get(), region_size);
size_t offset = 0;
while (size - offset > 0) {