Bug 130355

Summary: [kernel] i386_set_fsbase() doesn't seem to set %fs for 32-bit process under 7.1/amd64
Product: Base System Reporter: Gary Byers <gb>
Component: amd64Assignee: freebsd-amd64 (Nobody) <amd64>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 7.1-RELEASE   
Hardware: Any   
OS: Any   

Description Gary Byers 2009-01-11 00:40:05 UTC
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.

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.
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.)
Comment 1 Gary Byers 2009-01-12 06:03:18 UTC
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.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2009-01-12 08:58:22 UTC
State Changed
From-To: open->closed

Closed at submitter's request.