summaryrefslogtreecommitdiff
path: root/Kernel/Process.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-07 15:50:44 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-07 15:55:36 +0200
commitec6bceaa0876f00c0ea6eb585f5527a842210747 (patch)
treef1478f01e04972c05cec55ac92df5f631c252574 /Kernel/Process.h
parentbcfdf9ffa7c17f5f080b5a45d17497be7d1a28f9 (diff)
downloadserenity-ec6bceaa0876f00c0ea6eb585f5527a842210747.zip
Kernel: Support thread-local storage
This patch adds support for TLS according to the x86 System V ABI. Each thread gets a thread-specific memory region, and the GS segment register always points _to a pointer_ to the thread-specific memory. In other words, to access thread-local variables, userspace programs start by dereferencing the pointer at [gs:0]. The Process keeps a master copy of the TLS segment that new threads should use, and when a new thread is created, they get a copy of it. It's basically whatever the PT_TLS program header in the ELF says.
Diffstat (limited to 'Kernel/Process.h')
-rw-r--r--Kernel/Process.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h
index e3beb925ab..36cbbfec06 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -369,6 +369,10 @@ private:
RefPtr<ProcessTracer> m_tracer;
OwnPtr<ELFLoader> m_elf_loader;
+ RefPtr<Region> m_master_tls_region;
+ size_t m_master_tls_size { 0 };
+ size_t m_master_tls_alignment { 0 };
+
Lock m_big_lock { "Process" };
u64 m_alarm_deadline { 0 };