summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-09-18 14:25:00 -0400
committerGravatar GitHub2018-09-18 14:25:00 -0400
commit733c47623b98d873b58ce796b672b7b3d4081b0c (patch)
tree73b76702c2e562a6bcc1ae8cdddf55129cddac34 /src
parentMerge pull request #1344 from lioncash/arm (diff)
parentkernel/mutex: Replace ResultCode construction for invalid addresses with the ... (diff)
downloadyuzu-733c47623b98d873b58ce796b672b7b3d4081b0c.tar.gz
yuzu-733c47623b98d873b58ce796b672b7b3d4081b0c.tar.xz
yuzu-733c47623b98d873b58ce796b672b7b3d4081b0c.zip
Merge pull request #1343 from lioncash/mutex
kernel/svc: Handle invalid address cases within svcArbitrateLock() and svcArbitrateUnlock()
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/mutex.cpp4
-rw-r--r--src/core/hle/kernel/svc.cpp8
2 files changed, 10 insertions, 2 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 36bf0b677..51f4544be 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -62,7 +62,7 @@ ResultCode Mutex::TryAcquire(HandleTable& handle_table, VAddr address, Handle ho
62 Handle requesting_thread_handle) { 62 Handle requesting_thread_handle) {
63 // The mutex address must be 4-byte aligned 63 // The mutex address must be 4-byte aligned
64 if ((address % sizeof(u32)) != 0) { 64 if ((address % sizeof(u32)) != 0) {
65 return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidAddress); 65 return ERR_INVALID_ADDRESS;
66 } 66 }
67 67
68 SharedPtr<Thread> holding_thread = handle_table.Get<Thread>(holding_thread_handle); 68 SharedPtr<Thread> holding_thread = handle_table.Get<Thread>(holding_thread_handle);
@@ -100,7 +100,7 @@ ResultCode Mutex::TryAcquire(HandleTable& handle_table, VAddr address, Handle ho
100ResultCode Mutex::Release(VAddr address) { 100ResultCode Mutex::Release(VAddr address) {
101 // The mutex address must be 4-byte aligned 101 // The mutex address must be 4-byte aligned
102 if ((address % sizeof(u32)) != 0) { 102 if ((address % sizeof(u32)) != 0) {
103 return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidAddress); 103 return ERR_INVALID_ADDRESS;
104 } 104 }
105 105
106 auto [thread, num_waiters] = GetHighestPriorityMutexWaitingThread(GetCurrentThread(), address); 106 auto [thread, num_waiters] = GetHighestPriorityMutexWaitingThread(GetCurrentThread(), address);
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index c5c1697ee..371fc439e 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -280,6 +280,10 @@ static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
280 "requesting_current_thread_handle=0x{:08X}", 280 "requesting_current_thread_handle=0x{:08X}",
281 holding_thread_handle, mutex_addr, requesting_thread_handle); 281 holding_thread_handle, mutex_addr, requesting_thread_handle);
282 282
283 if (Memory::IsKernelVirtualAddress(mutex_addr)) {
284 return ERR_INVALID_ADDRESS_STATE;
285 }
286
283 auto& handle_table = Core::System::GetInstance().Kernel().HandleTable(); 287 auto& handle_table = Core::System::GetInstance().Kernel().HandleTable();
284 return Mutex::TryAcquire(handle_table, mutex_addr, holding_thread_handle, 288 return Mutex::TryAcquire(handle_table, mutex_addr, holding_thread_handle,
285 requesting_thread_handle); 289 requesting_thread_handle);
@@ -289,6 +293,10 @@ static ResultCode ArbitrateLock(Handle holding_thread_handle, VAddr mutex_addr,
289static ResultCode ArbitrateUnlock(VAddr mutex_addr) { 293static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
290 LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr); 294 LOG_TRACE(Kernel_SVC, "called mutex_addr=0x{:X}", mutex_addr);
291 295
296 if (Memory::IsKernelVirtualAddress(mutex_addr)) {
297 return ERR_INVALID_ADDRESS_STATE;
298 }
299
292 return Mutex::Release(mutex_addr); 300 return Mutex::Release(mutex_addr);
293} 301}
294 302