[PATCH] Retrieval of TLS pointer via RDHWR
Oleksandr Tymoshenko
gonzo at freebsd.org
Thu Feb 9 22:41:11 UTC 2012
On 08/12/2010 8:34 AM, Robert Millan 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.
Hi Robert,
It's a shame that it took a year to commit this patch :( but finally it
made it to SVN. I modified it a little bit to be more universal and
MIPS64-compatible.
More information about the freebsd-mips
mailing list