summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar B3n302017-09-15 22:41:45 +0200
committerGravatar GitHub2017-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 support... (diff)
downloadyuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.gz
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.tar.xz
yuzu-813837c5cf3e63a4ac08f4ec463bd2b2b87ab1c6.zip
Merge pull request #2842 from Subv/switchable_page_table
Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
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) {
171 // Cancel any outstanding wakeup events for this thread 171 // Cancel any outstanding wakeup events for this thread
172 CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle); 172 CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle);
173 173
174 auto previous_process = Kernel::g_current_process;
175
174 current_thread = new_thread; 176 current_thread = new_thread;
175 177
176 ready_queue.remove(new_thread->current_priority, new_thread); 178 ready_queue.remove(new_thread->current_priority, new_thread);
@@ -178,8 +180,18 @@ static void SwitchContext(Thread* new_thread) {
178 180
179 Core::CPU().LoadContext(new_thread->context); 181 Core::CPU().LoadContext(new_thread->context);
180 Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); 182 Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
183
184 if (previous_process != current_thread->owner_process) {
185 Kernel::g_current_process = current_thread->owner_process;
186 Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
187 // We have switched processes and thus, page tables, clear the instruction cache so we
188 // don't keep stale data from the previous process.
189 Core::CPU().ClearInstructionCache();
190 }
181 } else { 191 } else {
182 current_thread = nullptr; 192 current_thread = nullptr;
193 // Note: We do not reset the current process and current page table when idling because
194 // technically we haven't changed processes, our threads are just paused.
183 } 195 }
184} 196}
185 197