summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2017-07-21 07:34:47 +0200
committerSubv <subv2112@gmail.com>2017-08-22 16:30:58 +0200
commitf484927ed03a1943a83f8781e598e07c056cc82a (patch)
tree86ef2b76879c87f80a99e4031138bcdc39b921c6
parentKernel/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). (diff)
downloadyuzu-f484927ed03a1943a83f8781e598e07c056cc82a.tar
yuzu-f484927ed03a1943a83f8781e598e07c056cc82a.tar.gz
yuzu-f484927ed03a1943a83f8781e598e07c056cc82a.tar.bz2
yuzu-f484927ed03a1943a83f8781e598e07c056cc82a.tar.lz
yuzu-f484927ed03a1943a83f8781e598e07c056cc82a.tar.xz
yuzu-f484927ed03a1943a83f8781e598e07c056cc82a.tar.zst
yuzu-f484927ed03a1943a83f8781e598e07c056cc82a.zip
-rw-r--r--src/core/memory.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 9024f4922..72cbf2ec7 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"
@@ -187,6 +188,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:
@@ -226,6 +230,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:
@@ -722,4 +729,4 @@ VAddr PhysicalToVirtualAddress(const PAddr addr) {
return addr | 0x80000000;
}
-} // namespace
+} // namespace Memory