From nobody@FreeBSD.org  Sun Jan 11 00:35:14 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 61C38106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Jan 2009 00:35:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 4FA6F8FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Jan 2009 00:35:14 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n0B0ZDwq089906
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Jan 2009 00:35:13 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n0B0ZDX5089905;
	Sun, 11 Jan 2009 00:35:13 GMT
	(envelope-from nobody)
Message-Id: <200901110035.n0B0ZDX5089905@www.freebsd.org>
Date: Sun, 11 Jan 2009 00:35:13 GMT
From: Gary Byers <gb@clozure.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: i386_set_fsbase() doesn't seem to set %fs for 32-bit process under 7.1/amd64
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         130355
>Category:       amd64
>Synopsis:       [kernel] 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:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 11 00:40:05 UTC 2009
>Closed-Date:    Mon Jan 12 08:58:40 UTC 2009
>Last-Modified:  Mon Jan 12 08:58:40 UTC 2009
>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:

From: Gary Byers <gb@clozure.com>
To: bug-followup@FreeBSD.org, gb@clozure.com
Cc:  
Subject: Re: amd64/130355: [kernel] i386_set_fsbase() doesn't seem to set
 %fs for 32-bit process under 7.1/amd64
Date: Sun, 11 Jan 2009 23:03:18 -0700

 My claim that i386_set_fsbase() changed the value of %fs when used on other 
 amd64 kernels was incorrect.  As far as I can tell, there's no 7.1 kernel 
 bug here.
 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Mon Jan 12 08:58:22 UTC 2009 
State-Changed-Why:  
Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=130355 
>Unformatted:
