Date: Tue, 30 Apr 2013 05:39:43 +0000 (UTC) From: "Cherry G. Mathew" <cherry@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r250091 - projects/amd64_xen_pv/sys/amd64/xen Message-ID: <201304300539.r3U5dhtP073451@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304300539.r3U5dhtP073451>