diff options
| author | 2017-08-23 18:17:44 -0600 | |
|---|---|---|
| committer | 2017-08-23 18:17:44 -0600 | |
| commit | 61442d6afba2f7528ddf3bbee64e8c2d86a4f4a8 (patch) | |
| tree | b4b16a86d9959e14c01e43f68400342d7224c5a8 /src/core/memory.cpp | |
| parent | Merge pull request #2893 from Subv/not_schedule_main_thread (diff) | |
| parent | Kernel/Memory: Acquire the global HLE lock when a memory read/write operation... (diff) | |
| download | yuzu-61442d6afba2f7528ddf3bbee64e8c2d86a4f4a8.tar.gz yuzu-61442d6afba2f7528ddf3bbee64e8c2d86a4f4a8.tar.xz yuzu-61442d6afba2f7528ddf3bbee64e8c2d86a4f4a8.zip | |
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 65649d9d7..a3c5f4a9d 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/hle/kernel/process.h" | 11 | #include "core/hle/kernel/process.h" |
| 12 | #include "core/hle/lock.h" | ||
| 12 | #include "core/memory.h" | 13 | #include "core/memory.h" |
| 13 | #include "core/memory_setup.h" | 14 | #include "core/memory_setup.h" |
| 14 | #include "core/mmio.h" | 15 | #include "core/mmio.h" |
| @@ -181,6 +182,9 @@ T Read(const VAddr vaddr) { | |||
| 181 | return value; | 182 | return value; |
| 182 | } | 183 | } |
| 183 | 184 | ||
| 185 | // The memory access might do an MMIO or cached access, so we have to lock the HLE kernel state | ||
| 186 | std::lock_guard<std::mutex> lock(HLE::g_hle_lock); | ||
| 187 | |||
| 184 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 188 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 185 | switch (type) { | 189 | switch (type) { |
| 186 | case PageType::Unmapped: | 190 | case PageType::Unmapped: |
| @@ -219,6 +223,9 @@ void Write(const VAddr vaddr, const T data) { | |||
| 219 | return; | 223 | return; |
| 220 | } | 224 | } |
| 221 | 225 | ||
| 226 | // The memory access might do an MMIO or cached access, so we have to lock the HLE kernel state | ||
| 227 | std::lock_guard<std::mutex> lock(HLE::g_hle_lock); | ||
| 228 | |||
| 222 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; | 229 | PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; |
| 223 | switch (type) { | 230 | switch (type) { |
| 224 | case PageType::Unmapped: | 231 | case PageType::Unmapped: |
| @@ -746,4 +753,4 @@ boost::optional<VAddr> PhysicalToVirtualAddress(const PAddr addr) { | |||
| 746 | return boost::none; | 753 | return boost::none; |
| 747 | } | 754 | } |
| 748 | 755 | ||
| 749 | } // namespace | 756 | } // namespace Memory |