diff options
| author | 2015-08-27 19:43:55 -0400 | |
|---|---|---|
| committer | 2015-08-27 19:43:55 -0400 | |
| commit | 2978b5fbc8fe7d5bd0824aa6a5c97cb5237e0305 (patch) | |
| tree | 1c9a5352790d3fea47582013ad5a160781f59cf8 /src/core | |
| parent | Merge pull request #1065 from yuriks/shader-fp (diff) | |
| parent | Kernel: Fix assertion failure when ControlMemory is called with size=0 (diff) | |
| download | yuzu-2978b5fbc8fe7d5bd0824aa6a5c97cb5237e0305.tar.gz yuzu-2978b5fbc8fe7d5bd0824aa6a5c97cb5237e0305.tar.xz yuzu-2978b5fbc8fe7d5bd0824aa6a5c97cb5237e0305.zip | |
Merge pull request #1075 from yuriks/ControlMem-fixes
Fix heap-management regressions
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.cpp | 27 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/apt/apt.cpp | 4 |
4 files changed, 37 insertions, 4 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 124047a53..6279a4bf8 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -174,6 +174,10 @@ ResultCode Process::HeapFree(VAddr target, u32 size) { | |||
| 174 | return ERR_INVALID_ADDRESS; | 174 | return ERR_INVALID_ADDRESS; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | if (size == 0) { | ||
| 178 | return RESULT_SUCCESS; | ||
| 179 | } | ||
| 180 | |||
| 177 | ResultCode result = vm_manager.UnmapRange(target, size); | 181 | ResultCode result = vm_manager.UnmapRange(target, size); |
| 178 | if (result.IsError()) return result; | 182 | if (result.IsError()) return result; |
| 179 | 183 | ||
| @@ -226,6 +230,10 @@ ResultCode Process::LinearFree(VAddr target, u32 size) { | |||
| 226 | return ERR_INVALID_ADDRESS; | 230 | return ERR_INVALID_ADDRESS; |
| 227 | } | 231 | } |
| 228 | 232 | ||
| 233 | if (size == 0) { | ||
| 234 | return RESULT_SUCCESS; | ||
| 235 | } | ||
| 236 | |||
| 229 | VAddr heap_end = GetLinearHeapBase() + (u32)linheap_memory->size(); | 237 | VAddr heap_end = GetLinearHeapBase() + (u32)linheap_memory->size(); |
| 230 | if (target + size > heap_end) { | 238 | if (target + size > heap_end) { |
| 231 | return ERR_INVALID_ADDRESS_STATE; | 239 | return ERR_INVALID_ADDRESS_STATE; |
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index 4137683b5..1f477664b 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -20,6 +20,7 @@ SharedPtr<SharedMemory> SharedMemory::Create(u32 size, MemoryPermission permissi | |||
| 20 | 20 | ||
| 21 | shared_memory->name = std::move(name); | 21 | shared_memory->name = std::move(name); |
| 22 | shared_memory->base_address = 0x0; | 22 | shared_memory->base_address = 0x0; |
| 23 | shared_memory->fixed_address = 0x0; | ||
| 23 | shared_memory->size = size; | 24 | shared_memory->size = size; |
| 24 | shared_memory->permissions = permissions; | 25 | shared_memory->permissions = permissions; |
| 25 | shared_memory->other_permissions = other_permissions; | 26 | shared_memory->other_permissions = other_permissions; |
| @@ -30,9 +31,31 @@ SharedPtr<SharedMemory> SharedMemory::Create(u32 size, MemoryPermission permissi | |||
| 30 | ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions, | 31 | ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions, |
| 31 | MemoryPermission other_permissions) { | 32 | MemoryPermission other_permissions) { |
| 32 | 33 | ||
| 34 | if (base_address != 0) { | ||
| 35 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s: already mapped at 0x%08X!", | ||
| 36 | GetObjectId(), address, name.c_str(), base_address); | ||
| 37 | // TODO: Verify error code with hardware | ||
| 38 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, | ||
| 39 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 40 | } | ||
| 41 | |||
| 42 | if (fixed_address != 0) { | ||
| 43 | if (address != 0 && address != fixed_address) { | ||
| 44 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s: fixed_addres is 0x%08X!", | ||
| 45 | GetObjectId(), address, name.c_str(), fixed_address); | ||
| 46 | // TODO: Verify error code with hardware | ||
| 47 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, | ||
| 48 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 49 | } | ||
| 50 | |||
| 51 | // HACK(yuriks): This is only here to support the APT shared font mapping right now. | ||
| 52 | // Later, this should actually map the memory block onto the address space. | ||
| 53 | return RESULT_SUCCESS; | ||
| 54 | } | ||
| 55 | |||
| 33 | if (address < Memory::SHARED_MEMORY_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) { | 56 | if (address < Memory::SHARED_MEMORY_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) { |
| 34 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X outside of shared mem bounds!", | 57 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s outside of shared mem bounds!", |
| 35 | GetObjectId(), address); | 58 | GetObjectId(), address, name.c_str()); |
| 36 | // TODO: Verify error code with hardware | 59 | // TODO: Verify error code with hardware |
| 37 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, | 60 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, |
| 38 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | 61 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); |
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 7a2922776..35b550d12 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h | |||
| @@ -61,6 +61,8 @@ public: | |||
| 61 | 61 | ||
| 62 | /// Address of shared memory block in the process. | 62 | /// Address of shared memory block in the process. |
| 63 | VAddr base_address; | 63 | VAddr base_address; |
| 64 | /// Fixed address to allow mapping to. Used for blocks created from the linear heap. | ||
| 65 | VAddr fixed_address; | ||
| 64 | /// Size of the memory block. Page-aligned. | 66 | /// Size of the memory block. Page-aligned. |
| 65 | u32 size; | 67 | u32 size; |
| 66 | /// Permission restrictions applied to the process which created the block. | 68 | /// Permission restrictions applied to the process which created the block. |
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 6a2fdea2b..ba66569b4 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp | |||
| @@ -78,8 +78,8 @@ void GetSharedFont(Service::Interface* self) { | |||
| 78 | if (shared_font != nullptr) { | 78 | if (shared_font != nullptr) { |
| 79 | // TODO(yuriks): This is a hack to keep this working right now even with our completely | 79 | // TODO(yuriks): This is a hack to keep this working right now even with our completely |
| 80 | // broken shared memory system. | 80 | // broken shared memory system. |
| 81 | shared_font_mem->base_address = SHARED_FONT_VADDR; | 81 | shared_font_mem->fixed_address = SHARED_FONT_VADDR; |
| 82 | Kernel::g_current_process->vm_manager.MapMemoryBlock(shared_font_mem->base_address, | 82 | Kernel::g_current_process->vm_manager.MapMemoryBlock(shared_font_mem->fixed_address, |
| 83 | shared_font, 0, shared_font_mem->size, Kernel::MemoryState::Shared); | 83 | shared_font, 0, shared_font_mem->size, Kernel::MemoryState::Shared); |
| 84 | 84 | ||
| 85 | cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2); | 85 | cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2); |