1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

UserspaceEmulator: Make sure TLS allocation behavior matches kernel

This commit is contained in:
Gunnar Beutner 2021-05-03 01:30:53 +02:00 committed by Andreas Kling
parent 92cc8a47dd
commit e468bf08b1

View file

@ -1432,9 +1432,10 @@ int Emulator::virt$readlink(FlatPtr params_addr)
u32 Emulator::virt$allocate_tls(FlatPtr initial_data, size_t size)
{
// TODO: Why is this needed? without this, the loader overflows the bounds of the TLS region.
constexpr size_t TLS_SIZE_HACK = 8;
auto tcb_region = make<SimpleRegion>(0x20000000, size + TLS_SIZE_HACK);
// 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);
size_t offset = 0;
while (size - offset > 0) {