3 ms·
regardless of where you stash the state, if the kernel is responsible for preemptively changing threads, it needs to swap out the TLS pointer when it does so.
by convolvatron 8y ago
regardless of where you stash the state, if the kernel is responsible for preemptively changing threads, it needs to swap out the TLS pointer when it does so.
on the linker side - you're right, there isn't any fundamental reason why. but since traditionally the linker does address assignment for symbols, and TLS variables are general symbols/storage with an annotation...then it seems natural to extend it to allocate out of .tdata and .tbss for multiple objects.
- chrisseaton 8y agoHmm but the kernel doesn't need to know you're using a register for TLS. That's like saying that the kernel is involved in arithmetic because it needs to swap your temporary values in and out of registers that you're using on context switches.
- etaoins 8y agoYou can’t set FS/GS from user space on x64-64 until the FSGSBASE instructions were introduced in Ivy Bridge. The kernel only needs to be involved as its privilege is needed to set the register; the kernel doesn’t “know” that they’re being used for TLS.