summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorB3n30 <bene_thomas@web.de>2017-09-15 22:41:45 +0200
committerGitHub <noreply@github.com>2017-09-15 22:41:45 +0200
commit813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6 (patch)
treedf43bf978de3b699a22650d3ff2a3ebb5d86b2de /src/core/hle/kernel/thread.cpp
parentMerge pull request #2915 from wwylele/font-archive-2 (diff)
parentCPU/Dynarmic: Disable the fast page-table access in dynarmic until it supports switching page tables at runtime. (diff)
downloadyuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.gz
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.bz2
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.lz
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.xz
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.zst
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.zip
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index b957c45dd..324415a36 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -171,6 +171,8 @@ static void SwitchContext(Thread* new_thread) {
// Cancel any outstanding wakeup events for this thread
CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle);
+ auto previous_process = Kernel::g_current_process;
+
current_thread = new_thread;
ready_queue.remove(new_thread->current_priority, new_thread);
@@ -178,8 +180,18 @@ static void SwitchContext(Thread* new_thread) {
Core::CPU().LoadContext(new_thread->context);
Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
+
+ if (previous_process != current_thread->owner_process) {
+ Kernel::g_current_process = current_thread->owner_process;
+ Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
+ // We have switched processes and thus, page tables, clear the instruction cache so we
+ // don't keep stale data from the previous process.
+ Core::CPU().ClearInstructionCache();
+ }
} else {
current_thread = nullptr;
+ // Note: We do not reset the current process and current page table when idling because
+ // technically we haven't changed processes, our threads are just paused.
}
}