From owner-freebsd-emulation@FreeBSD.ORG Sun Jan 21 23:01:28 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 0728316A401; Sun, 21 Jan 2007 23:01:28 +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 9093113C44C; Sun, 21 Jan 2007 23:01:27 +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 8660D1D77DE; Mon, 22 Jan 2007 00:01:26 +0100 (CET) Received: from smtps01 (octavianus.kulnet.kuleuven.ac.be [134.58.240.71]) by rusty.kulnet.kuleuven.ac.be (Postfix) with ESMTP id 9C5E91D771B; Mon, 22 Jan 2007 00:01:25 +0100 (CET) Received: from kalimero.kotnet.org (kalimero.kotnet.org [10.4.16.222]) by smtps01 (Postfix) with ESMTP id E45322E68CC; Mon, 22 Jan 2007 00:01:24 +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 l0LN1NYV031256; Mon, 22 Jan 2007 00:01:23 +0100 (CET) (envelope-from tijl@ulyssis.org) From: Tijl Coosemans To: freebsd-emulation@freebsd.org Date: Mon, 22 Jan 2007 00:01:19 +0100 User-Agent: KMail/1.9.5 References: <790a9fff0701211041j1176d00gd6dd75d0989cf4ec@mail.gmail.com> <20070121185445.GA88090@stud.fit.vutbr.cz> In-Reply-To: <20070121185445.GA88090@stud.fit.vutbr.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701220001.22404.tijl@ulyssis.org> X-Virus-Scanned: by KULeuven Antivirus Cluster Cc: jkim@freebsd.org 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: Sun, 21 Jan 2007 23:01:28 -0000 On Sunday 21 January 2007 19:54, Divacky Roman wrote: > On Sun, Jan 21, 2007 at 12:41:02PM -0600, Scot Hetzel wrote: > > Divacky Roman asked me to update my sources to the latest P4 patches > > and run the tls_test program. Below are the results: > > > > hp010 / # ./tls_test > > > > doing 1st set_thread_area(): > > ====> got GDT selector: 0x0 --- TEST PASSED. > > > > reading first byte of [0x00000000] TLS: > > ====> 123 --- TEST PASSED. > > > > doing 2nd set_thread_area(): > > ====> got GDT selector: 0x4 --- TEST PASSED. > > context-switching once ... > > > > reading first byte of 4K [0x0804aca0] TLS: > > Segmentation fault (core dumped) > > this means that we are able to set up the TLS for the very first > time but not any other time. > > can someone explain this? > > the tls_test program is at > > www.stud.fit.vutbr.cz/~xdivac02/tls_test.c I don't have an amd64 box, so I can only guess, but I think it's your test that's bugged and not your tls implementation. Your test uses FS and your tls implementation uses GS and while they each point to the same GDT entry they don't end up pointing to the same addresses because your tls implementation doesn't touch the GDT entry at all. It simply (and correctly as far as I can tell) changes the upper 32 bits of GS (using wrmsr). So what you should change in your test I believe, is remove the initseg() function and every use of it and in __readseg() and __writeseg() use gs instead of fs. http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/x86-64_overview.pdf page 43, Special Treatment of FS and GS segments