1
0
Fork 0
forked from suyu/suyu

SVC: Correct races on physical core switching.

This commit is contained in:
Fernando Sahmkow 2020-02-27 11:25:42 -04:00
parent cc3aa95926
commit bd36eaf15d
2 changed files with 10 additions and 10 deletions

View file

@ -79,12 +79,13 @@ void CpuManager::RunGuestThread() {
sched.OnThreadStart(); sched.OnThreadStart();
} }
while (true) { while (true) {
auto& physical_core = kernel.CurrentPhysicalCore(); auto* physical_core = &kernel.CurrentPhysicalCore();
while (!physical_core.IsInterrupted()) { while (!physical_core->IsInterrupted()) {
physical_core.Run(); physical_core->Run();
physical_core = &kernel.CurrentPhysicalCore();
} }
physical_core.ClearExclusive(); physical_core->ClearExclusive();
auto& scheduler = physical_core.Scheduler(); auto& scheduler = physical_core->Scheduler();
scheduler.TryDoContextSwitch(); scheduler.TryDoContextSwitch();
} }
} }

View file

@ -2454,11 +2454,6 @@ void Call(Core::System& system, u32 immediate) {
MICROPROFILE_SCOPE(Kernel_SVC); MICROPROFILE_SCOPE(Kernel_SVC);
auto& physical_core = system.CurrentPhysicalCore(); auto& physical_core = system.CurrentPhysicalCore();
if (physical_core.IsInterrupted()) {
auto& sched = physical_core.Scheduler();
sched.TryDoContextSwitch();
}
physical_core.ClearExclusive();
const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate) const FunctionDef* info = system.CurrentProcess()->Is64BitProcess() ? GetSVCInfo64(immediate)
: GetSVCInfo32(immediate); : GetSVCInfo32(immediate);
@ -2471,6 +2466,10 @@ void Call(Core::System& system, u32 immediate) {
} else { } else {
LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate); LOG_CRITICAL(Kernel_SVC, "Unknown SVC function 0x{:X}", immediate);
} }
auto& physical_core_2 = system.CurrentPhysicalCore();
if (physical_core.CoreIndex() != physical_core_2.CoreIndex()) {
physical_core.Stop();
}
} }
} // namespace Kernel::Svc } // namespace Kernel::Svc