cvs commit: src/sys/i386/i386 genassym.c machdep.c mp_machdep.c
swtch.s sys_machdep.c src/sys/i386/include pcb.h pcpu.h segments.h
sysarch.h
Peter Wemm
peter at overcee.wemm.org
Wed Apr 13 16:32:16 PDT 2005
On Wed, Apr 13, 2005 at 10:57:17PM +0000, Peter Wemm wrote:
> peter 2005-04-13 22:57:17 UTC
>
> FreeBSD src repository
>
> Modified files:
> sys/i386/i386 genassym.c machdep.c mp_machdep.c swtch.s
> sys_machdep.c
> sys/i386/include pcb.h pcpu.h segments.h sysarch.h
> Log:
> Change the segment limits to 4GB, we set the user accessible bit on all
> of the kernel address space already. Intel recommend this anyway, because
> using a non-4GB limit adds an additional clock cycle to address generation.
> We were able to install 4GB segments into the LDT, so any limits we imposed
> on %cs and %ds were academic anyway. More importantly, this allows us to
> make a page in the kernel readable to user applications, for holding things
> like the signal trampoline and other fun things.
>
> Move the user %cs/%ds segments from the LDT to the GDT. There was no good
> reason for them to be there anyway. The old LDT entries are still there
> but we can now relax the restriction that prevented users from emptying
> the default LDT entries.
>
> Putting user and kernel %cs and %ds together allows us to access the fast
> sysenter/sysexit/syscall/sysret instructions. syscall/sysret in particular
> require that the user/kernel segments be laid out this way. Reserve a slot
> specifically for NDIS while here.
>
> Create two user controllable slots in the GDT that are context switched
> with the (kernel) thread. This allows user applications to set two
> user privilige selectors to arbitary values. Create
> i386_set_fsbase(void *base) and friends. (get/set, fs/gs). For i386,
> %gs is used by tls and the thread libraries and this means that user
> processes no longer have to have the cost of having a custom LDT, and
> we will no longer to do a ldt switch when activating a kthread/ithread in
> the usual case any more.
>
> In other words, we can now set the base address for %fs and %gs to arbitary
> addresses without the pain of messing with ldt segments.
Please note that I have not tested this with SMP yet, but I am 99.9% sure
that it will work.
I have a bunch of patches for userland that will use this stuff. It does
fall back to the old ldt method if you boot a kernel.old, so it should be
safe to commit these shortly. I have patches for ld.so, libc and libpthread.
I have not tried libthr yet.
-Peter
More information about the cvs-src
mailing list