From owner-svn-src-projects@FreeBSD.ORG Tue Apr 30 05:39:43 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7D901BA4; Tue, 30 Apr 2013 05:39:43 +0000 (UTC) (envelope-from cherry@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6F9081C3B; Tue, 30 Apr 2013 05:39:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3U5dhCR073453; Tue, 30 Apr 2013 05:39:43 GMT (envelope-from cherry@svn.freebsd.org) Received: (from cherry@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3U5dhtP073451; Tue, 30 Apr 2013 05:39:43 GMT (envelope-from cherry@svn.freebsd.org) Message-Id: <201304300539.r3U5dhtP073451@svn.freebsd.org> From: "Cherry G. Mathew" Date: Tue, 30 Apr 2013 05:39:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r250091 - projects/amd64_xen_pv/sys/amd64/xen X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Apr 2013 05:39:43 -0000 Author: cherry Date: Tue Apr 30 05:39:42 2013 New Revision: 250091 URL: http://svnweb.freebsd.org/changeset/base/250091 Log: On Xen, %fs and %gs are set via hypercalls. We thus set the %fs and %gs selectors to 0 and ignore trapframe values on return to userspace. Userspace sets %fs via sysarch(2), and the kernel dtrt. Approved by: gibbs (implicit) Modified: projects/amd64_xen_pv/sys/amd64/xen/exception.S projects/amd64_xen_pv/sys/amd64/xen/machdep.c Modified: projects/amd64_xen_pv/sys/amd64/xen/exception.S ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/exception.S Tue Apr 30 05:32:07 2013 (r250090) +++ projects/amd64_xen_pv/sys/amd64/xen/exception.S Tue Apr 30 05:39:42 2013 (r250091) @@ -100,7 +100,8 @@ /* Save generic data segment registers to the stack */ #define SAVE_SEGMENT_REGS \ movw %es, TF_ES(%rsp) ; \ - movw %ds, TF_DS(%rsp) + movw %ds, TF_DS(%rsp) ; \ + movw %fs, TF_FS(%rsp) /* Restore generic data segment registers from the stack */ #define RESTORE_SEGMENT_REGS \ @@ -118,7 +119,7 @@ * [DS-GS,] is only saved for the failsafe callback. * * [ERRCODE], is optional, depending on the type of (hardware) exception. - * See: the "AMD64 Architecture Programmer's Manuel, Volume 2: + * See: the "AMD64 Architecture Programmer's Manual, Volume 2: * System Programming: Section 8.2 for individual error code * reporting status * @@ -241,8 +242,8 @@ ld_es: movw (TF_ES + 8)(%rsp,1), %es ; /* Save on previous frame */ ld_ds: movw (TF_DS + 8)(%rsp,1), %ds ; /* Save on previous frame */ -ld_fs: -ld_gs: +ld_fs: /* %fs == 0 and the per-proc base is updated via xen_set_proc() */ +ld_gs: /* XEN manages %gs (swapgs) */ ret /* The path below should not have been reached. */ Modified: projects/amd64_xen_pv/sys/amd64/xen/machdep.c ============================================================================== --- projects/amd64_xen_pv/sys/amd64/xen/machdep.c Tue Apr 30 05:32:07 2013 (r250090) +++ projects/amd64_xen_pv/sys/amd64/xen/machdep.c Tue Apr 30 05:39:42 2013 (r250091) @@ -413,7 +413,7 @@ initxen(struct start_info *si) memset(dump_avail, 0 , sizeof dump_avail); /* - * Setup kernel tls registers. pcpu needs them, and other + * Setup kernel PCPU base. pcpu needs them, and other * parts of the early startup path use pcpu variables before * we have loaded the new Global Descriptor Table. */ @@ -514,9 +514,7 @@ initxen(struct start_info *si) * 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); /* per cpu structures for cpu0 */ pcpu_init(pc, 0, sizeof(struct pcpu)); @@ -596,7 +594,10 @@ initxen(struct start_info *si) /* Load thread0 context */ load_ds(_udatasel); load_es(_udatasel); - load_fs(_ufssel); + load_fs(0); /* reset %fs to 0 before 64bit base load */ + HYPERVISOR_set_segment_base (SEGBASE_FS, 0); + HYPERVISOR_set_segment_base (SEGBASE_GS_USER_SEL, (uint64_t) 0); + HYPERVISOR_set_segment_base (SEGBASE_GS_USER, (uint64_t) 0); /* setup proc 0's pcb */ thread0.td_pcb->pcb_flags = 0; @@ -1378,15 +1379,13 @@ xen_set_proc(struct pcb *newpcb) USD_SETBASE(&gsd, newpcb->pcb_fsbase); xen_set_descriptor((vm_paddr_t)PCPU_GET(fs32p), (void *)&gsd); } - } else { - HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, - _ugssel); - HYPERVISOR_set_segment_base(SEGBASE_FS, - newpcb->pcb_fsbase); + 0); HYPERVISOR_set_segment_base(SEGBASE_GS_USER, newpcb->pcb_gsbase); + HYPERVISOR_set_segment_base(SEGBASE_FS, + newpcb->pcb_fsbase); } } }