summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-03 20:45:39 -0400
committerGravatar Lioncash2018-08-03 23:49:10 -0400
commite93fa7f2cccfaaf655f62a0627e002676800a44d (patch)
tree3c54d3fc5af88d887123897e0c69b7dd54e2601e /src/core/hle/kernel/thread.cpp
parentMerge pull request #908 from lioncash/memory (diff)
downloadyuzu-e93fa7f2cccfaaf655f62a0627e002676800a44d.tar.gz
yuzu-e93fa7f2cccfaaf655f62a0627e002676800a44d.tar.xz
yuzu-e93fa7f2cccfaaf655f62a0627e002676800a44d.zip
kernel/thread: Fix potential crashes introduced in 26de4bb521b1ace7af76eff4f6956cb23ac0d58c
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).
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index ea9554cbb..b9022feae 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -339,6 +339,17 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
339 tls_slots.emplace_back(0); // The page is completely available at the start 339 tls_slots.emplace_back(0); // The page is completely available at the start
340 available_page = tls_slots.size() - 1; 340 available_page = tls_slots.size() - 1;
341 available_slot = 0; // Use the first slot in the new page 341 available_slot = 0; // Use the first slot in the new page
342
343 // Allocate some memory from the end of the linear heap for this region.
344 const size_t offset = thread->tls_memory->size();
345 thread->tls_memory->insert(thread->tls_memory->end(), Memory::PAGE_SIZE, 0);
346
347 auto& vm_manager = owner_process->vm_manager;
348 vm_manager.RefreshMemoryBlockMappings(thread->tls_memory.get());
349
350 vm_manager.MapMemoryBlock(Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE,
351 thread->tls_memory, 0, Memory::PAGE_SIZE,
352 MemoryState::ThreadLocal);
342 } 353 }
343 354
344 // Mark the slot as used 355 // Mark the slot as used