forked from eden-emu/eden
		
	ARM/Memory: Correct Exclusive Monitor and Implement Exclusive Memory Writes.
This commit is contained in:
		
							parent
							
								
									535c542d84
								
							
						
					
					
						commit
						cd1c38be8d
					
				
					 12 changed files with 325 additions and 24 deletions
				
			
		|  | @ -90,7 +90,7 @@ ResultCode AddressArbiter::IncrementAndSignalToAddressIfEqual(VAddr address, s32 | |||
|     auto& monitor = system.Monitor(); | ||||
|     u32 current_value; | ||||
|     do { | ||||
|         monitor.SetExclusive(current_core, address); | ||||
|         monitor.SetExclusive32(current_core, address); | ||||
|         current_value = memory.Read32(address); | ||||
| 
 | ||||
|         if (current_value != value) { | ||||
|  | @ -120,7 +120,7 @@ ResultCode AddressArbiter::ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr a | |||
|     auto& monitor = system.Monitor(); | ||||
|     s32 updated_value; | ||||
|     do { | ||||
|         monitor.SetExclusive(current_core, address); | ||||
|         monitor.SetExclusive32(current_core, address); | ||||
|         updated_value = memory.Read32(address); | ||||
| 
 | ||||
|         if (updated_value != value) { | ||||
|  | @ -191,7 +191,7 @@ ResultCode AddressArbiter::WaitForAddressIfLessThan(VAddr address, s32 value, s6 | |||
|         const std::size_t current_core = system.CurrentCoreIndex(); | ||||
|         auto& monitor = system.Monitor(); | ||||
|         do { | ||||
|             monitor.SetExclusive(current_core, address); | ||||
|             monitor.SetExclusive32(current_core, address); | ||||
|             current_value = static_cast<s32>(memory.Read32(address)); | ||||
|             if (should_decrement) { | ||||
|                 decrement_value = current_value - 1; | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ | |||
| #include "common/logging/log.h" | ||||
| #include "core/core.h" | ||||
| #include "core/arm/exclusive_monitor.h" | ||||
| #include "core/core.h" | ||||
| #include "core/hle/kernel/errors.h" | ||||
| #include "core/hle/kernel/handle_table.h" | ||||
| #include "core/hle/kernel/kernel.h" | ||||
|  | @ -138,7 +139,7 @@ std::pair<ResultCode, std::shared_ptr<Thread>> Mutex::Unlock(std::shared_ptr<Thr | |||
|     const std::size_t current_core = system.CurrentCoreIndex(); | ||||
|     if (new_owner == nullptr) { | ||||
|         do { | ||||
|             monitor.SetExclusive(current_core, address); | ||||
|             monitor.SetExclusive32(current_core, address); | ||||
|         } while (!monitor.ExclusiveWrite32(current_core, address, 0)); | ||||
|         return {RESULT_SUCCESS, nullptr}; | ||||
|     } | ||||
|  | @ -154,7 +155,7 @@ std::pair<ResultCode, std::shared_ptr<Thread>> Mutex::Unlock(std::shared_ptr<Thr | |||
|     new_owner->ResumeFromWait(); | ||||
| 
 | ||||
|     do { | ||||
|         monitor.SetExclusive(current_core, address); | ||||
|         monitor.SetExclusive32(current_core, address); | ||||
|     } while (!monitor.ExclusiveWrite32(current_core, address, mutex_value)); | ||||
|     return {RESULT_SUCCESS, new_owner}; | ||||
| } | ||||
|  |  | |||
|  | @ -1641,7 +1641,7 @@ static void SignalProcessWideKey(Core::System& system, VAddr condition_variable_ | |||
|         u32 update_val = 0; | ||||
|         const VAddr mutex_address = thread->GetMutexWaitAddress(); | ||||
|         do { | ||||
|             monitor.SetExclusive(current_core, mutex_address); | ||||
|             monitor.SetExclusive32(current_core, mutex_address); | ||||
| 
 | ||||
|             // If the mutex is not yet acquired, acquire it.
 | ||||
|             mutex_val = memory.Read32(mutex_address); | ||||
|  |  | |||
|  | @ -236,7 +236,7 @@ ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadTy | |||
|         ResetThreadContext64(thread->context_64, stack_top, entry_point, arg); | ||||
|     } | ||||
|     thread->host_context = | ||||
|         std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); | ||||
|         std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); | ||||
| 
 | ||||
|     return MakeResult<std::shared_ptr<Thread>>(std::move(thread)); | ||||
| } | ||||
|  | @ -412,12 +412,12 @@ ResultCode Thread::SetActivity(ThreadActivity value) { | |||
|     } | ||||
| 
 | ||||
|     if (value == ThreadActivity::Paused) { | ||||
|         if (pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag) != 0) { | ||||
|         if ((pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag)) != 0) { | ||||
|             return ERR_INVALID_STATE; | ||||
|         } | ||||
|         AddSchedulingFlag(ThreadSchedFlags::ThreadPauseFlag); | ||||
|     } else { | ||||
|         if (pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag) == 0) { | ||||
|         if ((pausing_state & static_cast<u32>(ThreadSchedFlags::ThreadPauseFlag)) == 0) { | ||||
|             return ERR_INVALID_STATE; | ||||
|         } | ||||
|         RemoveSchedulingFlag(ThreadSchedFlags::ThreadPauseFlag); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fernando Sahmkow
						Fernando Sahmkow