summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-09-17 18:49:51 -0400
committerGravatar Lioncash2018-09-17 23:27:53 -0400
commitb6867602ca5accf84b5e1f9d4895b232c9448816 (patch)
tree1fa3c3b8972f6d795197fd6ad73afa0f0f982ba6 /src/core/hle/kernel/svc.cpp
parentMerge pull request #1311 from FernandoS27/fast-swizzle (diff)
downloadyuzu-b6867602ca5accf84b5e1f9d4895b232c9448816.tar.gz
yuzu-b6867602ca5accf84b5e1f9d4895b232c9448816.tar.xz
yuzu-b6867602ca5accf84b5e1f9d4895b232c9448816.zip
kernel/svc: Handle error cases for svcArbitrateLock() and svcArbitrateUnlock()
The kernel does the equivalent of the following check before proceeding: if (address + 0x8000000000 < 0x7FFFE00000) { return ERR_INVALID_MEMORY_STATE; } which is essentially what our IsKernelVirtualAddress() function does. So we should also be checking for this. The kernel also checks if the given input addresses are 4-byte aligned, however our Mutex::TryAcquire() and Mutex::Release() functions already handle this, so we don't need to add code for this case.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp8
1 files changed, 8 insertions, 0 deletions
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