diff options
Diffstat (limited to 'src/core/hle/kernel/process.cpp')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index f337f626f..a8e3098ca 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -127,7 +127,7 @@ void Process::Run(VAddr entry_point, s32 main_thread_priority, u32 stack_size) { | |||
| 127 | // TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part | 127 | // TODO(bunnei): This is heap area that should be allocated by the kernel and not mapped as part |
| 128 | // of the user address space. | 128 | // of the user address space. |
| 129 | vm_manager | 129 | vm_manager |
| 130 | .MapMemoryBlock(Memory::STACK_AREA_VADDR_END - stack_size, | 130 | .MapMemoryBlock(vm_manager.GetTLSIORegionEndAddress() - stack_size, |
| 131 | std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size, | 131 | std::make_shared<std::vector<u8>>(stack_size, 0), 0, stack_size, |
| 132 | MemoryState::Mapped) | 132 | MemoryState::Mapped) |
| 133 | .Unwrap(); | 133 | .Unwrap(); |
| @@ -193,6 +193,7 @@ static std::tuple<std::size_t, std::size_t, bool> FindFreeThreadLocalSlot( | |||
| 193 | 193 | ||
| 194 | VAddr Process::MarkNextAvailableTLSSlotAsUsed(Thread& thread) { | 194 | VAddr Process::MarkNextAvailableTLSSlotAsUsed(Thread& thread) { |
| 195 | auto [available_page, available_slot, needs_allocation] = FindFreeThreadLocalSlot(tls_slots); | 195 | auto [available_page, available_slot, needs_allocation] = FindFreeThreadLocalSlot(tls_slots); |
| 196 | const VAddr tls_begin = vm_manager.GetTLSIORegionBaseAddress(); | ||
| 196 | 197 | ||
| 197 | if (needs_allocation) { | 198 | if (needs_allocation) { |
| 198 | tls_slots.emplace_back(0); // The page is completely available at the start | 199 | tls_slots.emplace_back(0); // The page is completely available at the start |
| @@ -205,18 +206,17 @@ VAddr Process::MarkNextAvailableTLSSlotAsUsed(Thread& thread) { | |||
| 205 | 206 | ||
| 206 | vm_manager.RefreshMemoryBlockMappings(tls_memory.get()); | 207 | vm_manager.RefreshMemoryBlockMappings(tls_memory.get()); |
| 207 | 208 | ||
| 208 | vm_manager.MapMemoryBlock(Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE, | 209 | vm_manager.MapMemoryBlock(tls_begin + available_page * Memory::PAGE_SIZE, tls_memory, 0, |
| 209 | tls_memory, 0, Memory::PAGE_SIZE, MemoryState::ThreadLocal); | 210 | Memory::PAGE_SIZE, MemoryState::ThreadLocal); |
| 210 | } | 211 | } |
| 211 | 212 | ||
| 212 | tls_slots[available_page].set(available_slot); | 213 | tls_slots[available_page].set(available_slot); |
| 213 | 214 | ||
| 214 | return Memory::TLS_AREA_VADDR + available_page * Memory::PAGE_SIZE + | 215 | return tls_begin + available_page * Memory::PAGE_SIZE + available_slot * Memory::TLS_ENTRY_SIZE; |
| 215 | available_slot * Memory::TLS_ENTRY_SIZE; | ||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | void Process::FreeTLSSlot(VAddr tls_address) { | 218 | void Process::FreeTLSSlot(VAddr tls_address) { |
| 219 | const VAddr tls_base = tls_address - Memory::TLS_AREA_VADDR; | 219 | const VAddr tls_base = tls_address - vm_manager.GetTLSIORegionBaseAddress(); |
| 220 | const VAddr tls_page = tls_base / Memory::PAGE_SIZE; | 220 | const VAddr tls_page = tls_base / Memory::PAGE_SIZE; |
| 221 | const VAddr tls_slot = (tls_base % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; | 221 | const VAddr tls_slot = (tls_base % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; |
| 222 | 222 | ||
| @@ -240,8 +240,8 @@ void Process::LoadModule(SharedPtr<CodeSet> module_, VAddr base_addr) { | |||
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { | 242 | ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { |
| 243 | if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || | 243 | if (target < vm_manager.GetHeapRegionBaseAddress() || |
| 244 | target + size < target) { | 244 | target + size > vm_manager.GetHeapRegionEndAddress() || target + size < target) { |
| 245 | return ERR_INVALID_ADDRESS; | 245 | return ERR_INVALID_ADDRESS; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| @@ -276,8 +276,8 @@ ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission per | |||
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | ResultCode Process::HeapFree(VAddr target, u32 size) { | 278 | ResultCode Process::HeapFree(VAddr target, u32 size) { |
| 279 | if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || | 279 | if (target < vm_manager.GetHeapRegionBaseAddress() || |
| 280 | target + size < target) { | 280 | target + size > vm_manager.GetHeapRegionEndAddress() || target + size < target) { |
| 281 | return ERR_INVALID_ADDRESS; | 281 | return ERR_INVALID_ADDRESS; |
| 282 | } | 282 | } |
| 283 | 283 | ||