From owner-freebsd-emulation@FreeBSD.ORG Tue Jan 23 22:43:55 2007 Return-Path: X-Original-To: freebsd-emulation@freebsd.org Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1A61B16A402; Tue, 23 Jan 2007 22:43:55 +0000 (UTC) (envelope-from tijl@ulyssis.org) Received: from rusty.kulnet.kuleuven.ac.be (rusty.kulnet.kuleuven.ac.be [134.58.240.42]) by mx1.freebsd.org (Postfix) with ESMTP id A7E7D13C455; Tue, 23 Jan 2007 22:43:54 +0000 (UTC) (envelope-from tijl@ulyssis.org) Received: from localhost (localhost [127.0.0.1]) by rusty.kulnet.kuleuven.ac.be (Postfix) with ESMTP id 7AC1B1D7491; Tue, 23 Jan 2007 23:43:53 +0100 (CET) Received: from smtp02.kuleuven.be (lepidus.kulnet.kuleuven.ac.be [134.58.240.72]) by rusty.kulnet.kuleuven.ac.be (Postfix) with ESMTP id 43AB11D7950; Tue, 23 Jan 2007 23:43:52 +0100 (CET) Received: from kalimero.kotnet.org (kalimero.kotnet.org [10.4.16.222]) by smtp02.kuleuven.be (Postfix) with ESMTP id 187442CA9C8; Tue, 23 Jan 2007 23:43:49 +0100 (CET) Received: from kalimero.kotnet.org (kalimero.kotnet.org [127.0.0.1]) by kalimero.kotnet.org (8.13.8/8.13.8) with ESMTP id l0NMhmlB009780; Tue, 23 Jan 2007 23:43:48 +0100 (CET) (envelope-from tijl@ulyssis.org) From: Tijl Coosemans To: freebsd-emulation@freebsd.org Date: Tue, 23 Jan 2007 23:43:45 +0100 User-Agent: KMail/1.9.5 References: <790a9fff0701211041j1176d00gd6dd75d0989cf4ec@mail.gmail.com> <200701232113.50766.tijl@ulyssis.org> <200701231555.57521.jkim@FreeBSD.org> In-Reply-To: <200701231555.57521.jkim@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701232343.47316.tijl@ulyssis.org> X-Virus-Scanned: by KULeuven Antivirus Cluster Cc: Jung-uk Kim Subject: Re: linuxolator: tls_test results amd64 X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2007 22:43:55 -0000 On Tuesday 23 January 2007 21:55, Jung-uk Kim wrote: > On Tuesday 23 January 2007 03:13 pm, Tijl Coosemans wrote: > > On Tuesday 23 January 2007 20:00, Jung-uk Kim wrote: > > > Second problem is MSR_KGSBASE is scrubbed by something during > > > context switch, i.e., it becomes 0 some times. > > > > You mean: > > > > *kernel sets gsbase and switches back to user mode > > *user program does things > > Yes. BTW, glibc seems to use movw instead of movl to load %gs. I > don't know if that makes difference, though. It may have some > effect when glibc is built with -mtls-direct-seg-refs flag. Need > confirmation. I think there's no difference between movw and movl. The first stores a 16 bit value in %gs, the second stores the lower 16 bits of a 32 bit value. That flag is interesting, but I think it only relates to using %gs after it has been set up for tls. > > *back in kernel mode, save gsbase into pcb and it appears to be 0 > > now? > > Saved pcb_gsbase seems always correct. MSR_KGSBASE is not, which is > supposedly swapped with MSR_GSBASE via swapgs. Maybe I am confused, > or maybe my CPU is too old (it's C0 stepping and I know there are > some segmentation issues with the revision) but that's what I see. I > need more time for testing (or resting?). Ok, I understand why pcb_gsbase is always correct. It is never written to except for cpu_set_user_tls, i386_set_gsbase and set_thread_area. cpu_switch only reads from it to restore gsbase. At least, that's what cpu_switch does in case of 64 bit programs, not 32 bit it seems. Why is that? Why is there a jmp on line 186 in sys/amd64/amd64/cpu_switch.S?