diff options
author | Timon Kruiper <timonkruiper@gmail.com> | 2023-02-15 19:49:37 +0100 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-02-15 22:53:19 +0100 |
commit | cfd73e5d9f71f3bb1882bd999acef4c461b8e18d (patch) | |
tree | 894e8ba93fa31d992acf47ec2bc1cd55465d01c0 /Kernel/Arch/aarch64 | |
parent | 7d0917f50b189db55cbf21641f608be76a6c6abc (diff) | |
download | serenity-cfd73e5d9f71f3bb1882bd999acef4c461b8e18d.zip |
Kernel/aarch64: Implement Thread Local Storage
This commit adds Processor::set_thread_specific_data, and this function
is used to factor out architecture specific implementation of setting
the thread specific data. This function is implemented for
aarch64 and x86_64, and the callsites are changed to use this function
instead.
Diffstat (limited to 'Kernel/Arch/aarch64')
-rw-r--r-- | Kernel/Arch/aarch64/ASM_wrapper.h | 5 | ||||
-rw-r--r-- | Kernel/Arch/aarch64/Processor.cpp | 7 | ||||
-rw-r--r-- | Kernel/Arch/aarch64/Processor.h | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/Kernel/Arch/aarch64/ASM_wrapper.h b/Kernel/Arch/aarch64/ASM_wrapper.h index ccf207c1bc..9bb7a7ac99 100644 --- a/Kernel/Arch/aarch64/ASM_wrapper.h +++ b/Kernel/Arch/aarch64/ASM_wrapper.h @@ -37,6 +37,11 @@ inline void set_sp_el1(FlatPtr sp_el1) asm("msr sp_el1, %[value]" ::[value] "r"(sp_el1)); } +inline void set_tpidr_el0(FlatPtr tpidr_el0) +{ + asm("msr tpidr_el0, %[value]" ::[value] "r"(tpidr_el0)); +} + inline void flush() { asm("dsb ish"); diff --git a/Kernel/Arch/aarch64/Processor.cpp b/Kernel/Arch/aarch64/Processor.cpp index 811b05995e..699bad1689 100644 --- a/Kernel/Arch/aarch64/Processor.cpp +++ b/Kernel/Arch/aarch64/Processor.cpp @@ -454,6 +454,8 @@ extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread) to_thread->set_cpu(Processor::current().id()); + Processor::set_thread_specific_data(to_thread->thread_specific_data()); + auto in_critical = to_thread->saved_critical(); VERIFY(in_critical > 0); Processor::restore_critical(in_critical); @@ -466,4 +468,9 @@ StringView Processor::platform_string() return "aarch64"sv; } +void Processor::set_thread_specific_data(VirtualAddress thread_specific_data) +{ + Aarch64::Asm::set_tpidr_el0(thread_specific_data.get()); +} + } diff --git a/Kernel/Arch/aarch64/Processor.h b/Kernel/Arch/aarch64/Processor.h index 57b55152bf..2baaec99c5 100644 --- a/Kernel/Arch/aarch64/Processor.h +++ b/Kernel/Arch/aarch64/Processor.h @@ -279,6 +279,8 @@ public: static StringView platform_string(); + static void set_thread_specific_data(VirtualAddress thread_specific_data); + private: Processor(Processor const&) = delete; |