kern: write cpu tick differential to tls +0x108 on thread switch

This commit is contained in:
Michael Scire
2025-11-11 10:50:17 -07:00
committed by SciresM
parent 18bb1fdea0
commit e36051359c
3 changed files with 13 additions and 3 deletions

View File

@@ -270,7 +270,13 @@ namespace ams::kern {
m_current_thread = next_thread;
/* Set the new Thread Local region. */
cpu::SwitchThreadLocalRegion(GetInteger(next_thread->GetThreadLocalRegionAddress()));
const auto tls_address = GetInteger(next_thread->GetThreadLocalRegionAddress());
cpu::SwitchThreadLocalRegion(tls_address);
/* Update the thread's cpu time differential in TLS, if relevant. */
if (tls_address != 0) {
static_cast<ams::svc::ThreadLocalRegion *>(next_thread->GetThreadLocalRegionHeapAddress())->thread_cpu_time = next_thread->GetCpuTime() - cur_tick;
}
}
void KScheduler::ClearPreviousThread(KThread *thread) {