diff options
| author | James Rowe <jroweboy@gmail.com> | 2017-08-23 18:17:44 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-23 18:17:44 -0600 |
| commit | 35e185309b7d5a09f4149d9af7c8322d342157ca (patch) | |
| tree | b4b16a86d9959e14c01e43f68400342d7224c5a8 /src/core/memory.cpp | |
| parent | add21dee2f0a1b56adde8e8ca7b9d11593eeff4f (diff) | |
| parent | 36220f3873ec17733cc3ebfcd46495ee74881879 (diff) | |
Merge pull request #2839 from Subv/global_kernel_lock
Kernel/HLE: Use a mutex to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
Diffstat (limited to 'src/core/memory.cpp')
| -rw-r--r-- | src/core/memory.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 65649d9d76..a3c5f4a9d0 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -9,6 +9,7 @@ #include "common/logging/log.h" #include "common/swap.h" #include "core/hle/kernel/process.h" +#include "core/hle/lock.h" #include "core/memory.h" #include "core/memory_setup.h" #include "core/mmio.h" @@ -181,6 +182,9 @@ T Read(const VAddr vaddr) { return value; } + // The memory access might do an MMIO or cached access, so we have to lock the HLE kernel state + std::lock_guard<std::mutex> lock(HLE::g_hle_lock); + PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; switch (type) { case PageType::Unmapped: @@ -219,6 +223,9 @@ void Write(const VAddr vaddr, const T data) { return; } + // The memory access might do an MMIO or cached access, so we have to lock the HLE kernel state + std::lock_guard<std::mutex> lock(HLE::g_hle_lock); + PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; switch (type) { case PageType::Unmapped: @@ -746,4 +753,4 @@ boost::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) { return boost::none; } -} // namespace +} // namespace Memory |
