5 msgZFS deadlocks or panics
1 msgTCP Spurious RST, segment rejected
1 msghow to handle name clashes in linux/freebsd ker...
10 msgIs this reasonable ?
11 msg[PATCH] Machine Check Architecture on amd64
5 msgIssues with 'xl0' keeping link

Re: The relation between %fs and fs base
\ Jung-uk Kim (25 Jun 2007)
. \ jj shen (26 Jun 2007)

20 msg[head tinderbox] failure on amd64/amd64
27 msg[head tinderbox] failure on i386/pc98
1 msgZFS and Jails (dataset does not exist)
2 msgRE: unionfs and tmpfs?
1 msgbinutils/gas compilation problems on i386.
19 msgSilent gcc 4.2.0 loop optimization bug with -O2
3 msgProblem compiling -CURRENT/OpenSSL
6 msgKSE was Re: open/close/ioctl api change?
2 msgopen/close/ioctl api change?
4 msgZFS and gmirror
4 msgZFS questions
3 msgQ) lockf(flock?) on -current (amd64)
3 msgoptions IPI_PREEMPTION and PREEMPTION in 7.0 AMD64
Subject:Re: The relation between %fs and fs base
Group:Freebsd-current
From:jj shen
Date:26 Jun 2007


 
Hi,

I know that NPTL use %fs to access thread local data. It seems that when the
base address can be fitted in 32 bits, a GDT entry is used for better
performance and the selector is loaded to %fs; otherwise, if the base
address is larger than 0xffffffff, it is loaded to FS_BASE MSR and %fs is
set to zero.

I need to maintain these two kinds of TLS simultaneously (for system
simulation), but was confused with the %fs and fs base. Maybe, someone can
help me, at least my last two questions.

Thanks!

On 6/26/07, Jung-uk Kim <jkim> wrote:

> On Monday 25 June 2007 01:37 pm, jj shen wrote:
> > Hi,
> >
> > I want to access different TLS through both fs base and GDT
> > simultaneously. Let us call the two ways TLS_FSBASE and TLS_GDT
> > respectively.
> >
> > (1) Can I switch from TLS_FSBASE to TLS_GDT just by: "movl GDT_SEL,
> > %fs" (where GDT_SEL is the selector of GDT entry)?
> > Will this instruction destroy the content of the IA32_FS_BASE MSR?
> >
> > (2) When switching from TLS_GDT to TLS_FSBASE, can I just set %fs
> > to zero to indicate the fs base should be used, or must I invoke
> > the
> > *wrmsrl*instruction to reset IA32_FS_BASE once again?
> >
> > (3) What is the length of %fs? What I get by "movl %fs, %eax" in
> > %eax? In the programmer manual from AMD, it is said somewhere that
> > segment registers are still 16 bits as in x86, and it is also said
> > otherwhere that "segment loads into FS and GS load a standard
> > 32-bit base value in the hidden portion of the segment descriptor
> > register".
> >
> > (4) What is the content of %fs, a descriptor selector or a base
> > address smaller than 0xffffffff?
> > What is effect of "movl val, %fs", loading a GDT selector or a
> > 32-bit base address to %fs?
> > Seen from the citation above, I think *val *should be a 32-bit
> > base address; however seen from the implementation of Linux
> > *arch_prctl* system call, it is a GDT selector loaded into %fs.
>
> I don't know what you are trying to achieve but don't mess up with %fs
> and %gs on amd64 unless you are absolutely sure. It is deprecated
> and it won't work as you expected. The only way to get/set %fs and
> %gs properly on amd64 is via proper API, i.e., sysarch(2) with
> AMD64_{GET,SET}_{FS,GS}BASE. If you use the API, the MSR will be
> properly saved and restored while switching contexts. However, it is
> very much discouraged as the manual page says, e. g., it will cause
> serious problem if the application is threaded, etc. In fact, the
> API should be only used by threading libraries.
>
> Jung-uk Kim
>
_______________________________________________
freebsd-current mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe"


© 2004-2008 readlist.com