Subject: Re: armv6 - Thread and process ID registers
To: Matt Thomas <>
From: Richard Earnshaw <>
List: port-arm
Date: 07/10/2007 00:00:58
On Mon, 2007-07-09 at 15:17 -0700, Matt Thomas wrote:
> Richard Earnshaw wrote:
> > I think the user-space registers can be hidden/disabled if we don't want
> > to support them immediately.  We should do this if we can't guarantee to
> > save/restore the value on context switches at this time.
> Didn't find a bit to do that.

Sigh... You're right.  I must have mis-remembered :-)

> >> For the user readonly register, I would also keep that in mdlwp and restore it 
> >> in cf_context_switch.  But I'm not sure what user space would make it.  I'd 
> >> allow a user to store a value in it via sysarch(ARM_SET_USERID, value).
> >>
> > 
> > Linux uses it (or is it the R/W one?) for Thread local storage (and gcc
> > has a TLS usage model to use it for that).
> TLS support seemed the most probable use.  Thought about that after I sent the 
> mail.  For platforms that don't support it, should we emulate the MRC for it
> or rely on the user code doing the right thing?

Emulating is expensive and won't work from Thumb (well, Thumb-1) code.
I think a syscall or the Linux approach would be better.

Linux does this by mapping a special bit of kernel memory in at a WKA
(well known address) that can return the value directly (blx <reg> to
the WKA and it returns the value in r0).  It's fairly efficient, but
definitely hacky (especially some of the games that are needed if you
then want an MP system when the CP15 register isn't available).