summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-27 11:25:42 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:19 -0400
commitbd36eaf15d88c3875aba7032fe5124fbb150bd5d (patch)
treea6bad69cf31a39e0286d4cd14d404497ecfb9c42 /src
parentNVFlinger: Lock race condition between CPU, Host Timing, VSync. (diff)
downloadyuzu-bd36eaf15d88c3875aba7032fe5124fbb150bd5d.tar.gz
yuzu-bd36eaf15d88c3875aba7032fe5124fbb150bd5d.tar.xz
yuzu-bd36eaf15d88c3875aba7032fe5124fbb150bd5d.zip
SVC: Correct races on physical core switching.
Diffstat (limited to 'src')
-rw-r--r--src/core/cpu_manager.cpp11
-rw-r--r--src/core/hle/kernel/svc.cpp9
2 files changed, 10 insertions, 10 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 241971ff3..904aacd97 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -79,12 +79,13 @@ void CpuManager::RunGuestThread() {
79 sched.OnThreadStart(); 79 sched.OnThreadStart();
80 } 80 }
81 while (true) { 81 while (true) {
82 auto& physical_core = kernel.CurrentPhysicalCore(); 82 auto* physical_core = &kernel.CurrentPhysicalCore();
83 while (!physical_core.IsInterrupted()) { 83 while (!physical_core->IsInterrupted()) {
84 physical_core.Run(); 84 physical_core->Run();
85 physical_core = &kernel.CurrentPhysicalCore();
85 } 86 }
86 physical_core.ClearExclusive(); 87 physical_core->ClearExclusive();
87 auto& scheduler = physical_core.Scheduler(); 88 auto& scheduler = physical_core->Scheduler();
88 scheduler.TryDoContextSwitch(); 89 scheduler.TryDoContextSwitch();
89 } 90 }
90} 91}
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 279fe5888..1e6c60d78 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -2454,11 +2454,6 @@ void Call(Core::System& system, u32 immediate) {
2454 MICROPROFILE_SCOPE(Kernel_SVC); 2454 MICROPROFILE_SCOPE(Kernel_SVC);
2455 2455
2456 auto& physical_core = system.CurrentPhysicalCore(); 2456 auto& physical_core = system.CurrentPhysicalCore();
2457 if (physical_core.IsInterrupted()) {
2458 auto& sched = physical_core.Scheduler();
2459 sched.TryDoContextSwitch();
2460 }
2461 physical_core.ClearExclusive();
2462 2457
2463 const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate) 2458 const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate)
2464 : GetSVCInfo32(immediate); 2459 : GetSVCInfo32(immediate);
@@ -2471,6 +2466,10 @@ void Call(Core::System& system, u32 immediate) {
2471 } else { 2466 } else {
2472 LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate); 2467 LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate);
2473 } 2468 }
2469 auto& physical_core_2 = system.CurrentPhysicalCore();
2470 if (physical_core.CoreIndex() != physical_core_2.CoreIndex()) {
2471 physical_core.Stop();
2472 }
2474} 2473}
2475 2474
2476} // namespace Kernel::Svc 2475} // namespace Kernel::Svc