Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jan 2009 00:35:13 GMT
From:      Gary Byers <gb@clozure.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   amd64/130355: i386_set_fsbase() doesn't seem to set %fs for 32-bit process under 7.1/amd64
Message-ID:  <200901110035.n0B0ZDX5089905@www.freebsd.org>
Resent-Message-ID: <200901110040.n0B0e55Q046291@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         130355
>Category:       amd64
>Synopsis:       i386_set_fsbase() doesn't seem to set %fs for 32-bit process under 7.1/amd64
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-amd64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 11 00:40:05 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Gary Byers
>Release:        7.1-RELEASE/amd64
>Organization:
Clozure Associates
>Environment:
FreeBSD f71.abq.clozure.com 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan  1 08:58:24 UTC 2009     root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
i386_set_fsbase(void *addr) has the effect of causing memory references relative to %fs to reference the linear address "addr"; part of this effect is achieved by loading a segment descriptor (GSEL(GUFS_SEL, SEL_UPL), which is generally = 0x13) into %fs on return from the sysarch syscall.

This works as expected on (at least) i386 versions of 6.4-RELEASE, 7.0-RELEASE, and 7.1-RELEASE and on amd64 versions of 6.4-RELEASE and 7.0-RELEASE, but on 7.1-RELEASE/amd64 the i386_set_fsbase() call returns 0 but %fs is unchanged on return and subsequent attempts to reference memory relative to %fs seem to be equivalent to references relative to address 0.
>How-To-Repeat:
Compile (in a 32-bit FreeBSD/i386 environment) a small program that uses i386_set_fsbase() and checks to ensure that %fs has changed on successful return from the call to i386_set_fsbase().  Run the program on i386 versions of FreeBSD (6.4, 7.0, 7.1) and on amd64 versions of 6.4 and 7.0 and note that %fs is changed by the syscall.  Run the program on 7.1-RELEASE/amd64 and note that it fails.

(I'm not really sure if I'm supposed to provide a simple test case on the web form that I'm using to report this; I can easily do so if requested.)

>Fix:
Unknown.  To the extent that I understand the issue, it seems to have to do with code that tries to ensure that the correct value is loaded into %fs on return from the syscall and on subsequent context switches; the code that actually sets the fsbase msr seems to be unchanged between the released versions of 7.0 and 7.1.


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901110035.n0B0ZDX5089905>