Date: Wed, 10 Oct 2007 15:33:05 +0200 From: Tijl Coosemans <tijl@ulyssis.org> To: Mihai =?utf-8?q?Don=C8=9Bu?= <mihai.dontu@gmail.com> Cc: freebsd-emulation@freebsd.org, freebsd-questions@freebsd.org, Jung-uk Kim <jkim@freebsd.org> Subject: Re: amd64_set_gsbase() Message-ID: <200710101533.06287.tijl@ulyssis.org> In-Reply-To: <200710090348.52036.mihai.dontu@gmail.com> References: <200710082135.58099.mihai.dontu@gmail.com> <200710081841.35968.jkim@FreeBSD.org> <200710090348.52036.mihai.dontu@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 09 October 2007 02:48:51 Mihai Don=C8=9Bu wrote: > I have *one* more question: maybe I don't fully understand the hole > BASE thing, but since the FreeBSD kernel does not preserve %gs and > %fs, what is the purpose of amd64_set_XXbase()? The %fs, %gs registers and fsbase and gsbase MSRs are separate registers. When you write %gs:offset, you actually get (gsbase+offset), so the actual value of %gs doesn't matter. There are two ways to set gsbase. One is by using the privileged instruction wrmsr to set gsbase directly (full 64bit base address), which is what amd64_set_gsbase() exposes to userland. The other is by loading a descriptor selector in %gs in which case gsbase will be set to the base address (only 32bit base address) of a descriptor entry in either the GDT or LDT. To get back to what you are trying to do, because %gs isn't preserved, I think you should avoid writing to it and instead strictly use amd64_set_gsbase(). But from what you've written, I'm guessing you're already doing this, so the next thing to try is to create threads with PTHREAD_SCOPE_SYSTEM or use libthr instead of libpthread, because if I'm not mistaken, PTHREAD_SCOPE_PROCESS in libpthread doesn't preserve gsbase either.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710101533.06287.tijl>