[PATCH] Retrieval of TLS pointer via RDHWR

Robert Millan rmh at debian.org
Wed Dec 8 17:04:44 UTC 2010


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.

-- 
Robert Millan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rdhwr.diff
Type: text/x-patch
Size: 1510 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-mips/attachments/20101208/43f0e8f7/rdhwr.bin


More information about the freebsd-mips mailing list