Kernel/LibCore: Expose processor id where a thread last ran

This commit is contained in:
Tom 2020-06-27 22:36:15 -06:00 committed by Andreas Kling
commit d99901660d
Notes: sideshowbarker 2024-07-19 05:18:06 +09:00
5 changed files with 11 additions and 1 deletions

View file

@ -904,13 +904,16 @@ extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread)
set_fs(to_tss.fs);
set_gs(to_tss.gs);
auto& tls_descriptor = Processor::current().get_gdt_entry(GDT_SELECTOR_TLS);
auto& processor = Processor::current();
auto& tls_descriptor = processor.get_gdt_entry(GDT_SELECTOR_TLS);
tls_descriptor.set_base(to_thread->thread_specific_data().as_ptr());
tls_descriptor.set_limit(to_thread->thread_specific_region_size());
if (from_tss.cr3 != to_tss.cr3)
write_cr3(to_tss.cr3);
to_thread->set_cpu(processor.id());
asm volatile("fxrstor %0"
::"m"(to_thread->fpu_state()));