[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-tech-kern
Subject:    Re: Some issues with x86's TLS [amd64: USER_LDT (and wine)]
From:       Maxime Villard <max () m00nbsd ! net>
Date:       2017-02-12 20:33:22
Message-ID: fe621c4c-31f6-6810-5a94-f47f0dfc4719 () m00nbsd ! net
[Download RAW message or body]

Le 12/02/2017 à 20:21, Joerg Sonnenberger a écrit :
> On Sun, Feb 12, 2017 at 08:07:06PM +0100, Maxime Villard wrote:
>> I see only two ways of fixing all of that:
>>  - change amd64 so that it saves/restores fsgs like i386.
>
> This is not desirable since it moves the cost from
> one-per-context-switch to once-per-return-to-userland.

Yes, indeed, I know it is heavy but that's the only consistent solution I could
think of back then.

> That said, for USER_LDT it will likely need a branch in the return-to-userland
> code to do a second pass for FS/GS reload for 32bit processes.

Yes, I also thought about something similar - if the lwp is 32bit, restore on
exit and not on context switch. However I (mistakenly) thought there would be no
way to retrieve lwp information in INTRFASTEXIT. In fact there is.

I have written this patch [1] on the fly, without testing it yet. There is a
necessary three-instruction overhead, even on 64bit lwps. Note that a change
is also needed for T_NMI, but the handler is wrong anyway and I intend to switch
back to the original ZTRAP(T_NMI).

[1] http://m00nbsd.net/garbage/ldt/fastexit.diff
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic