mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-21 22:45:45 +00:00
kernel/thread: Fix potential crashes introduced in 3bcf090d37
This amends cases where crashes can occur that were missed due to the odd way the previous code was set up (using 3DS memory regions that don't exist).
This commit is contained in:
parent
67b4326d93
commit
6f3a3ed8c5
3 changed files with 36 additions and 11 deletions
|
@ -339,6 +339,17 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
|
|||
tls_slots.emplace_back(0); // The page is completely available at the start
|
||||
available_page = tls_slots.size() - 1;
|
||||
available_slot = 0; // Use the first slot in the new page
|
||||
|
||||
// Allocate some memory from the end of the linear heap for this region.
|
||||
const size_t offset = thread->tls_memory->size();
|
||||
thread->tls_memory->insert(thread->tls_memory->end(), Memory::PAGE_SIZE, 0);
|
||||
|
||||
auto& vm_manager = owner_process->vm_manager;
|
||||
vm_manager.RefreshMemoryBlockMappings(thread->tls_memory.get());
|
||||
|
||||
vm_manager.MapMemoryBlock(Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE,
|
||||
thread->tls_memory, 0, Memory::PAGE_SIZE,
|
||||
MemoryState::ThreadLocal);
|
||||
}
|
||||
|
||||
// Mark the slot as used
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue