aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@xensource.com>2007-07-17 21:37:06 -0400
committerJeremy Fitzhardinge <jeremy@goop.org>2007-07-18 11:47:44 -0400
commit8b84ad942b534f8faeb34b68f0f7277ea375fed0 (patch)
tree911472add5b9068a95a77215a70dac63edf6202e /arch/i386
parentd66bf8fcf3fce058a1cd164a7c8ee6093fdf039c (diff)
xen: hack to prevent bad segment register reload
The hypervisor saves and restores the segment registers as part of the state is saves while context switching. If, during a context switch, the next process doesn't use the TLS segments, it invalidates the GDT entry, causing the segment register reload to fault. This fault effectively doubles the cost of a context switch. This patch is a band-aid workaround which clears the usermode %gs after it has been saved for the previous process, but before it gets reloaded for the next, and it avoids having the hypervisor attempt to erroneously reload it. Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/xen/enlighten.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/i386/xen/enlighten.c b/arch/i386/xen/enlighten.c
index 031dc1dcf819..42756771b8eb 100644
--- a/arch/i386/xen/enlighten.c
+++ b/arch/i386/xen/enlighten.c
@@ -291,6 +291,18 @@ static void xen_load_tls(struct thread_struct *t, unsigned int cpu)
291 load_TLS_descriptor(t, cpu, 2); 291 load_TLS_descriptor(t, cpu, 2);
292 292
293 xen_mc_issue(PARAVIRT_LAZY_CPU); 293 xen_mc_issue(PARAVIRT_LAZY_CPU);
294
295 /*
296 * XXX sleazy hack: If we're being called in a lazy-cpu zone,
297 * it means we're in a context switch, and %gs has just been
298 * saved. This means we can zero it out to prevent faults on
299 * exit from the hypervisor if the next process has no %gs.
300 * Either way, it has been saved, and the new value will get
301 * loaded properly. This will go away as soon as Xen has been
302 * modified to not save/restore %gs for normal hypercalls.
303 */
304 if (xen_get_lazy_mode() == PARAVIRT_LAZY_CPU)
305 loadsegment(gs, 0);
294} 306}
295 307
296static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum, 308static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum,