[PATCH] Retrieval of TLS pointer via RDHWR

Jayachandran C. jchandra at freebsd.org
Thu Dec 9 11:16:10 UTC 2010


On Wed, Dec 8, 2010 at 10:04 PM, Robert Millan <rmh at debian.org> wrote:
> This patch implements support for retrieving the TLS pointer via RDHWR
> instruction.
>
> It is implemented through emulation for platforms that don't provide
> this instruction natively (such as gxemul/malta).  Platforms that do
> provide it would need a separate patch.
>
> Reading register $29 with RDHWR is becoming the de-facto standard to
> implement TLS.  According to linux-mips wiki, MIPS Technologies has
> reserved hardware register $29 for ABI use.  Furthermore current GCC [1]
> makes the following assumptions:
> - RDHWR is natively available or otherwise emulated by the kernel
> - Register $29 holds the TLS pointer
>
> [1] gcc-4.4.4/gcc/config/mips/mips.md reads:
>
> ;; The TLS base pointer is accessed via "rdhwr $3, $29".  No current
> ;; MIPS architecture defines this register, and no current
> ;; implementation provides it; instead, any OS which supports TLS is
> ;; expected to trap and emulate this instruction.  rdhwr is part of the
> ;; MIPS 32r2 specification, but we use it on any architecture because
> ;; we expect it to be emulated.


I'm not sure that the freebsd mips toolchain supports the __thread
directive yet.  Were you able to test this from C?

Regards,
JC


More information about the freebsd-mips mailing list