Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: fs register



On Thu, Dec 05, 2013 at 09:20:25PM +0100, Edgar Fu? wrote:
> EF> What does NetBSD/amd64 use the fs register for?
> JS> TLS base register.
> Amongst the dozens of expansions of "TLS", I suppose it's Thread Local 
> Storage 
> here? I suppose then neither 0 nor 0x17 are valid values, then?
> I don't have much of a clue of 80x86; why does %fs:0 work for 0 and fault 
> for 0x17?

%fs is hard and difficult in amd64.
The %fs segment override causes an offset be added to the virtual address.
But, since you can add a 64bit offset (well signed 48bit actually) the
offset doesn't come from the 'segment' table (as does would for i386)
but from a special register.

This makes the kernel code to save and restore it somewhat complex
since the value of %fs and the offset have to be saved and restored
separately.

IIRC both setting are reading the offset are priviledged instructions.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index