diff options
| author | 2020-02-27 19:12:41 -0400 | |
|---|---|---|
| committer | 2020-06-27 11:35:20 -0400 | |
| commit | 04e0f8776c26930d7dc8015e53914b11bf1929c1 (patch) | |
| tree | 4a8288d6bf8655a2ec0595fdc6d41a3037c5fcad /src/core/hle/kernel | |
| parent | SVC: Correct races on physical core switching. (diff) | |
| download | yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.gz yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.tar.xz yuzu-04e0f8776c26930d7dc8015e53914b11bf1929c1.zip | |
General: Add better safety for JIT use.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index 758fa8188..727d2e6cc 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -581,6 +581,7 @@ void Scheduler::SwitchContextStep2() { | |||
| 581 | 581 | ||
| 582 | if (new_thread) { | 582 | if (new_thread) { |
| 583 | new_thread->context_guard.lock(); | 583 | new_thread->context_guard.lock(); |
| 584 | cpu_core.Lock(); | ||
| 584 | ASSERT_MSG(new_thread->GetProcessorID() == s32(this->core_id), | 585 | ASSERT_MSG(new_thread->GetProcessorID() == s32(this->core_id), |
| 585 | "Thread must be assigned to this core."); | 586 | "Thread must be assigned to this core."); |
| 586 | ASSERT_MSG(new_thread->GetStatus() == ThreadStatus::Ready, | 587 | ASSERT_MSG(new_thread->GetStatus() == ThreadStatus::Ready, |
| @@ -601,6 +602,7 @@ void Scheduler::SwitchContextStep2() { | |||
| 601 | cpu_core.LoadContext(new_thread->GetContext64()); | 602 | cpu_core.LoadContext(new_thread->GetContext64()); |
| 602 | cpu_core.SetTlsAddress(new_thread->GetTLSAddress()); | 603 | cpu_core.SetTlsAddress(new_thread->GetTLSAddress()); |
| 603 | cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); | 604 | cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); |
| 605 | cpu_core.ClearExclusiveState(); | ||
| 604 | } | 606 | } |
| 605 | } else { | 607 | } else { |
| 606 | current_thread = nullptr; | 608 | current_thread = nullptr; |
| @@ -639,6 +641,7 @@ void Scheduler::SwitchContext() { | |||
| 639 | } | 641 | } |
| 640 | previous_thread->SetIsRunning(false); | 642 | previous_thread->SetIsRunning(false); |
| 641 | previous_thread->context_guard.unlock(); | 643 | previous_thread->context_guard.unlock(); |
| 644 | cpu_core.Unlock(); | ||
| 642 | } | 645 | } |
| 643 | 646 | ||
| 644 | std::shared_ptr<Common::Fiber> old_context; | 647 | std::shared_ptr<Common::Fiber> old_context; |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 1e6c60d78..b535593c7 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #include "common/alignment.h" | 11 | #include "common/alignment.h" |
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/fiber.h" | ||
| 13 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 14 | #include "common/microprofile.h" | 15 | #include "common/microprofile.h" |
| 15 | #include "common/string_util.h" | 16 | #include "common/string_util.h" |
| @@ -2468,7 +2469,10 @@ void Call(Core::System& system, u32 immediate) { | |||
| 2468 | } | 2469 | } |
| 2469 | auto& physical_core_2 = system.CurrentPhysicalCore(); | 2470 | auto& physical_core_2 = system.CurrentPhysicalCore(); |
| 2470 | if (physical_core.CoreIndex() != physical_core_2.CoreIndex()) { | 2471 | if (physical_core.CoreIndex() != physical_core_2.CoreIndex()) { |
| 2471 | physical_core.Stop(); | 2472 | LOG_CRITICAL(Kernel_SVC, "Rewinding"); |
| 2473 | auto* thread = physical_core_2.Scheduler().GetCurrentThread(); | ||
| 2474 | auto* host_context = thread->GetHostContext().get(); | ||
| 2475 | host_context->Rewind(); | ||
| 2472 | } | 2476 | } |
| 2473 | } | 2477 | } |
| 2474 | 2478 | ||