Handle %gs/%fs restore from appropriate pcb->pcb_{gs,fs}offset
properly, during userland exit. When either is loaded with a new
selector in the kernel, the base address offsets are reset, and have
to be reloaded.
In a xen pv container, this is done via hypercalls rather than
rdmsr/wrmsr. We break out xen_set_proc() into kernel stack switch and
just the tls switch via xen_load_tls(). This takes care of the ring #3
component of the %gs/%fs restore before exit to userland.
%gs is slightly special in that the kernel per-cpu base offset is
stored in the hidden offset register of %gs, in addition to the
userland context. Additionally, xen takes care of the 'swapgs'
operation when a user/kernel transition occurs. What all this means is
that the exit path needs to reload the current *kernel* %gs offset
when %gs is reloaded for userland, in addition to the userland
offset. This kernel offset is assumed to be the per-cpu structure for
the specific cpu on which the transition to userland is
happening. Since we don't have access to the per-cpu msr where this
information is saved, we take the slighly circuitous and presumptive
route of obtaining the cpu number on which we are running before
resetting %gs, and then using this information to find the appropriate
offset value.
Approved by: gibbs@ (implicit)