Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Apr 2012 22:46:40 +0000 (UTC)
From:      "Cherry G. Mathew" <cherry@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r234114 - projects/amd64_xen_pv/sys/amd64/xen
Message-ID:  <201204102246.q3AMkeWK043738@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cherry
Date: Tue Apr 10 22:46:40 2012
New Revision: 234114
URL: http://svn.freebsd.org/changeset/base/234114

Log:
  Reload the tls registers after the new GDT has been loaded.
  
  Approved by:	gibbs (implicit)

Modified:
  projects/amd64_xen_pv/sys/amd64/xen/machdep.c

Modified: projects/amd64_xen_pv/sys/amd64/xen/machdep.c
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/machdep.c	Tue Apr 10 22:14:49 2012	(r234113)
+++ projects/amd64_xen_pv/sys/amd64/xen/machdep.c	Tue Apr 10 22:46:40 2012	(r234114)
@@ -276,7 +276,12 @@ initxen(struct start_info *si)
 	physmem = si->nr_pages;
 	Maxmem = si->nr_pages + 1;
 
-	/* setup kernel tls registers. pcpu needs them */
+	/* 
+	 * Setup kernel tls registers. pcpu needs them, and other
+	 * parts of the early startup path use pcpu variables before
+	 * we have loaded the new Global Descriptor Table.
+	 */
+
 	pc = &__pcpu[0];
 	HYPERVISOR_set_segment_base (SEGBASE_FS, 0);
 	HYPERVISOR_set_segment_base (SEGBASE_GS_KERNEL, (uint64_t) pc);
@@ -354,6 +359,14 @@ initxen(struct start_info *si)
 
 	lgdt(NULL); /* See: support.S */
 
+	/* 
+	 * Refresh kernel tls registers since we've blown them away
+	 * via new GDT load. pcpu needs them.
+	 */
+	HYPERVISOR_set_segment_base (SEGBASE_FS, 0);
+	HYPERVISOR_set_segment_base (SEGBASE_GS_KERNEL, (uint64_t) pc);
+	HYPERVISOR_set_segment_base (SEGBASE_GS_USER, (uint64_t) 0);
+
 	/* exception handling */
 	init_exception_table();
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204102246.q3AMkeWK043738>