Skip to content

Commit e468bf0

Browse files
gunnarbeutnerawesomekling
authored andcommitted
UserspaceEmulator: Make sure TLS allocation behavior matches kernel
1 parent 92cc8a4 commit e468bf0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,9 +1432,10 @@ int Emulator::virt$readlink(FlatPtr params_addr)
14321432

14331433
u32 Emulator::virt$allocate_tls(FlatPtr initial_data, size_t size)
14341434
{
1435-
// TODO: Why is this needed? without this, the loader overflows the bounds of the TLS region.
1436-
constexpr size_t TLS_SIZE_HACK = 8;
1437-
auto tcb_region = make<SimpleRegion>(0x20000000, size + TLS_SIZE_HACK);
1435+
// TODO: This matches what Thread::make_thread_specific_region does. The kernel
1436+
// ends up allocating one more page. Figure out if this is intentional.
1437+
auto region_size = align_up_to(size, PAGE_SIZE) + PAGE_SIZE;
1438+
auto tcb_region = make<SimpleRegion>(0x20000000, region_size);
14381439

14391440
size_t offset = 0;
14401441
while (size - offset > 0) {

0 commit comments

Comments
 (0)