Subject: lib/26900: pthread should save/restore %fs resgister on i386
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <kent@NetBSD.org>
List: netbsd-bugs
Date: 09/10/2004 06:00:51
>Number:         26900
>Category:       lib
>Synopsis:       pthread should save/restore %fs resgister on i386
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 10 06:01:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     TAMURA Kent
>Release:        2.0G
>Organization:
>Environment:
NetBSD gabi-n.hauN.org 2.0G NetBSD 2.0G (GABI-N) #12: Tue Aug 10 17:09:19 JST 2004  kent@gabi-n
.hauN.org:/sys/arch/i386/compile/GABI-N i386

>Description:
With the current pthread implementation, a thread does not keep
the value of %fs register.  This behavior causes a serious
problem on Wine or PEACE because %fs register is used for
associating a thread and thread-dependent information in Windows.

>How-To-Repeat:

>Fix:
Index: _getsetc.S
===================================================================
RCS file: /cvsroot/src/lib/libpthread/arch/i386/_getsetc.S,v
retrieving revision 1.3
diff -u -u -r1.3 _getsetc.S
--- _getsetc.S	30 Oct 2003 13:56:37 -0000	1.3
+++ _getsetc.S	10 Sep 2004 06:00:08 -0000
@@ -40,6 +40,7 @@
 #undef SETC
 
 #define GETC \
+	movl	%fs,  (UC_REGS + _REG_FS * 4)(%ecx)	; \
 	movl	%edi,  (UC_REGS + _REG_EDI * 4)(%ecx)	; \
 	movl	%esi,  (UC_REGS + _REG_ESI * 4)(%ecx)	; \
 	movl	%ebp,  (UC_REGS + _REG_EBP * 4)(%ecx)	; \
@@ -55,6 +56,7 @@
 	jnc	1f					; \
 							; \
 	FPLOAD(%ecx)					; \
+	movl	(UC_REGS + _REG_FS * 4)(%ecx), %fs	; \
 	movl	(UC_REGS + _REG_EDI * 4)(%ecx), %edi	; \
 	movl	(UC_REGS + _REG_ESI * 4)(%ecx), %esi	; \
 	movl	(UC_REGS + _REG_EBP * 4)(%ecx), %ebp	; \

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