diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-07-03 00:25:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-04 01:07:28 +0200 |
commit | c51b49a8cb8901eb36860718495cccf2d5f05eea (patch) | |
tree | a69b64f3d852f57901ac5962b2bb45c46e89dc32 | |
parent | 04a912f68fa6e0fa529e480e74d12e287a62c850 (diff) | |
download | serenity-c51b49a8cb8901eb36860718495cccf2d5f05eea.zip |
Kernel: Implement TLS support for x86_64
-rw-r--r-- | Kernel/Arch/x86/common/Processor.cpp | 3 | ||||
-rw-r--r-- | Kernel/Syscalls/mmap.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Kernel/Arch/x86/common/Processor.cpp b/Kernel/Arch/x86/common/Processor.cpp index 90a2b3af3b..263cb6803b 100644 --- a/Kernel/Arch/x86/common/Processor.cpp +++ b/Kernel/Arch/x86/common/Processor.cpp @@ -1214,6 +1214,9 @@ extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread) auto& tls_descriptor = processor.get_gdt_entry(GDT_SELECTOR_TLS); tls_descriptor.set_base(to_thread->thread_specific_data()); tls_descriptor.set_limit(to_thread->thread_specific_region_size()); +#else + MSR fs_base_msr(MSR_FS_BASE); + fs_base_msr.set(to_thread->thread_specific_data().get()); #endif if (from_regs.cr3 != to_regs.cr3) diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index 3a44c41b1c..cc6cc1fa1f 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -6,6 +6,7 @@ */ #include <Kernel/Arch/x86/InterruptDisabler.h> +#include <Kernel/Arch/x86/MSR.h> #include <Kernel/Arch/x86/SmapDisabler.h> #include <Kernel/FileSystem/FileDescription.h> #include <Kernel/PerformanceEventBuffer.h> @@ -618,7 +619,8 @@ KResultOr<FlatPtr> Process::sys$allocate_tls(Userspace<const char*> initial_data tls_descriptor.set_base(main_thread->thread_specific_data()); tls_descriptor.set_limit(main_thread->thread_specific_region_size()); #else - dbgln("FIXME: Not setting FS_BASE for process."); + MSR fs_base_msr(MSR_FS_BASE); + fs_base_msr.set(main_thread->thread_specific_data().get()); #endif return m_master_tls_region.unsafe_ptr()->vaddr().get(); |