summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-03-07 18:59:42 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:37 -0400
commitcd1c38be8d15d3caf52f566a9e8dc20504c61068 (patch)
tree2fed02ffd4f2151dfca14ddb33ef1939eaee2fba /src/core/hle/kernel
parentSVC: WaitSynchronization add Termination Pending Result. (diff)
downloadyuzu-cd1c38be8d15d3caf52f566a9e8dc20504c61068.tar.gz
yuzu-cd1c38be8d15d3caf52f566a9e8dc20504c61068.tar.xz
yuzu-cd1c38be8d15d3caf52f566a9e8dc20504c61068.zip
ARM/Memory: Correct Exclusive Monitor and Implement Exclusive Memory Writes.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp6
-rw-r--r--src/core/hle/kernel/mutex.cpp5
-rw-r--r--src/core/hle/kernel/svc.cpp2
-rw-r--r--src/core/hle/kernel/thread.cpp6
4 files changed, 10 insertions, 9 deletions
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index ebabde921..07acabc1d 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -90,7 +90,7 @@ ResultCode AddressArbiter::IncrementAndSignalToAddressIfEqual(VAddr address, s32
90 auto& monitor = system.Monitor(); 90 auto& monitor = system.Monitor();
91 u32 current_value; 91 u32 current_value;
92 do { 92 do {
93 monitor.SetExclusive(current_core, address); 93 monitor.SetExclusive32(current_core, address);
94 current_value = memory.Read32(address); 94 current_value = memory.Read32(address);
95 95
96 if (current_value != value) { 96 if (current_value != value) {
@@ -120,7 +120,7 @@ ResultCode AddressArbiter::ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr a
120 auto& monitor = system.Monitor(); 120 auto& monitor = system.Monitor();
121 s32 updated_value; 121 s32 updated_value;
122 do { 122 do {
123 monitor.SetExclusive(current_core, address); 123 monitor.SetExclusive32(current_core, address);
124 updated_value = memory.Read32(address); 124 updated_value = memory.Read32(address);
125 125
126 if (updated_value != value) { 126 if (updated_value != value) {
@@ -191,7 +191,7 @@ ResultCode AddressArbiter::WaitForAddressIfLessThan(VAddr address, s32 value, s6
191 const std::size_t current_core = system.CurrentCoreIndex(); 191 const std::size_t current_core = system.CurrentCoreIndex();
192 auto& monitor = system.Monitor(); 192 auto& monitor = system.Monitor();
193 do { 193 do {
194 monitor.SetExclusive(current_core, address); 194 monitor.SetExclusive32(current_core, address);
195 current_value = static_cast<s32>(memory.Read32(address)); 195 current_value = static_cast<s32>(memory.Read32(address));
196 if (should_decrement) { 196 if (should_decrement) {
197 decrement_value = current_value - 1; 197 decrement_value = current_value - 1;
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index ebe3f6050..16c95782a 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -10,6 +10,7 @@
10#include "common/logging/log.h" 10#include "common/logging/log.h"
11#include "core/core.h" 11#include "core/core.h"
12#include "core/arm/exclusive_monitor.h" 12#include "core/arm/exclusive_monitor.h"
13#include "core/core.h"
13#include "core/hle/kernel/errors.h" 14#include "core/hle/kernel/errors.h"
14#include "core/hle/kernel/handle_table.h" 15#include "core/hle/kernel/handle_table.h"
15#include "core/hle/kernel/kernel.h" 16#include "core/hle/kernel/kernel.h"
@@ -138,7 +139,7 @@ std::pair<ResultCode, std::shared_ptr<Thread>> Mutex::Unlock(std::shared_ptr<Thr
138 const std::size_t current_core = system.CurrentCoreIndex(); 139 const std::size_t current_core = system.CurrentCoreIndex();
139 if (new_owner == nullptr) { 140 if (new_owner == nullptr) {
140 do { 141 do {
141 monitor.SetExclusive(current_core, address); 142 monitor.SetExclusive32(current_core, address);
142 } while (!monitor.ExclusiveWrite32(current_core, address, 0)); 143 } while (!monitor.ExclusiveWrite32(current_core, address, 0));
143 return {RESULT_SUCCESS, nullptr}; 144 return {RESULT_SUCCESS, nullptr};
144 } 145 }
@@ -154,7 +155,7 @@ std::pair<ResultCode, std::shared_ptr<Thread>> Mutex::Unlock(std::shared_ptr<Thr
154 new_owner->ResumeFromWait(); 155 new_owner->ResumeFromWait();
155 156
156 do { 157 do {
157 monitor.SetExclusive(current_core, address); 158 monitor.SetExclusive32(current_core, address);
158 } while (!monitor.ExclusiveWrite32(current_core, address, mutex_value)); 159 } while (!monitor.ExclusiveWrite32(current_core, address, mutex_value));
159 return {RESULT_SUCCESS, new_owner}; 160 return {RESULT_SUCCESS, new_owner};
160} 161}
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index da2f90a1d..371beed0d 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1641,7 +1641,7 @@ static void SignalProcessWideKey(Core::System& system, VAddr condition_variable_
1641 u32 update_val = 0; 1641 u32 update_val = 0;
1642 const VAddr mutex_address = thread->GetMutexWaitAddress(); 1642 const VAddr mutex_address = thread->GetMutexWaitAddress();
1643 do { 1643 do {
1644 monitor.SetExclusive(current_core, mutex_address); 1644 monitor.SetExclusive32(current_core, mutex_address);
1645 1645
1646 // If the mutex is not yet acquired, acquire it. 1646 // If the mutex is not yet acquired, acquire it.
1647 mutex_val = memory.Read32(mutex_address); 1647 mutex_val = memory.Read32(mutex_address);
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index b99e3b7a5..51cc5dcca 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -236,7 +236,7 @@ ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadTy
236 ResetThreadContext64(thread->context_64, stack_top, entry_point, arg); 236 ResetThreadContext64(thread->context_64, stack_top, entry_point, arg);
237 } 237 }
238 thread->host_context = 238 thread->host_context =
239 std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); 239 std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter);
240 240
241 return MakeResult<std::shared_ptr<Thread>>(std::move(thread)); 241 return MakeResult<std::shared_ptr<Thread>>(std::move(thread));
242} 242}
@@ -412,12 +412,12 @@ ResultCode Thread::SetActivity(ThreadActivity value) {
412 } 412 }
413 413
414 if (value == ThreadActivity::Paused) { 414 if (value == ThreadActivity::Paused) {
415 if (pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag) != 0) { 415 if ((pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag)) != 0) {
416 return ERR_INVALID_STATE; 416 return ERR_INVALID_STATE;
417 } 417 }
418 AddSchedulingFlag(ThreadSchedFlags::ThreadPauseFlag); 418 AddSchedulingFlag(ThreadSchedFlags::ThreadPauseFlag);
419 } else { 419 } else {
420 if (pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag) == 0) { 420 if ((pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag)) == 0) {
421 return ERR_INVALID_STATE; 421 return ERR_INVALID_STATE;
422 } 422 }
423 RemoveSchedulingFlag(ThreadSchedFlags::ThreadPauseFlag); 423 RemoveSchedulingFlag(ThreadSchedFlags::ThreadPauseFlag);