1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

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
parent d98edb3171
commit d99901660d
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()));