Subject: Re: Use of TSS
To: None <bde@kralizec.zeta.org.au, mycroft@duality.gnu.ai.mit.edu>
From: Bruce Evans <bde@kralizec.zeta.org.au>
List: port-i386
Date: 11/22/1993 01:17:36
>   (SS)	// h/w switch would also wasting switching a zillion segment
>	   // regs and the LDT

>Actually, this is necessary to support user-settable LDTs.

It's always possible to load the LDTs and then the segment regs
directly.  Then context switches between processes that don't change
their LDT can be fast.

I don't really care about taking a little longer for context
switches.  I'm more interested in minimising overhead for traps,
syscalls and interrupts.  It might be possible to avoid switching
%ds and %es as follows: make user %ds == kernel %ds (etc.) and
depend on page-level protection for everything (page-level protection
currently has some holes, at least in my kernel).  If the user
doesn't have a user-settable LDT, then the user can never change
%ds to a segment with more privilege or a different base, so the
worst that can happen is a trap when the kernel uses it.  trap()
can reload %ds = kernel %ds and return.  This method is already
used to avoid reloading %gs, at least in my kernel.

Supporting user-settable LDT's might waste about 1/4 of the benefit
of not switching %ds and %es in tests like
"if (!proc->has_weird_segs) goto over_load_segregs;".  Perhaps the
tests can be combined with ones for whether trap() or a function
like subyte() has clobbered %gs, so that the kernel can restore
weird %gs's with no additional overhead for non-weird %gs's.

Bruce

------------------------------------------------------------------------------