On Sat, Feb 20, 2016 at 1:49 PM, Patrick Wildt <[email protected]> wrote:
> since ARMv6 the coprocessor provides special registers to store software
> defined values.  Those registers are:
>
>   * TPIDRURW -> kernel RW, user RW
>   * TPIDRURO -> kernel RW, user RO
>   * TPIDRPRW -> kernel RW
>
> TPIDRPRW is typically used to store the pointer to the curcpu struct,
> while TPIDRURO is used to point to the TCB.
>
> The following diff implements using TPIDRPRW to store and retrieve the
> curcpu struct pointer.  This will especially be helpful in future MP
> efforts.  I have guarded it for ARMv7 only, as that's the only hardware
> I have that supports it and I was able to test on.

I don't know arm, but of those choices that makes sense.


> If TCB_GET()'s only user is libpthread, then it could make sense to
> store the TCB pointer in TPIDRURO.  If it's possible that it's also
> used in ports, then the arm packages won't be compatible to
> armish/zaurus anymore.  But the TCB stuff is not part of this diff.

The userland bits in <machine/tcb.h> should match the platform's ABI
for the thread register.  The last time I tried to figure this out
from the arm ABI docs I wanted to stab someone, but I was hopefully
just looking at the wrong docs.  Looking at the bits in FreeBSD I see

static inline void
set_tls(void *tls)
{
        __asm __volatile("mcr p15, 0, %0, c13, c0, 3" : : "r" (tls));
}

so, uh, whichever register that sets is presumably the correct one for userland.

(What is it with the arm docs giving N names to registers without a
"here's the mapping" table splatted somewhere obvious?)


Philip Guenther

Reply via email to