sparc64/140523: sparc {set, swap}context calls trash TLS register %g7

Nathaniel Filardo nwf at cs.jhu.edu
Fri Nov 13 09:00:13 UTC 2009


>Number:         140523
>Category:       sparc64
>Synopsis:       sparc {set,swap}context calls trash TLS register %g7
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-sparc64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 13 09:00:07 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Nathaniel Filardo
>Release:        9.0-CURRENT
>Organization:
>Environment:
FreeBSD hydra.priv.oc.ietfng.org 9.0-CURRENT FreeBSD 9.0-CURRENT #12: Mon Oct 26 02:37:54 EDT 2009     root at hydra.priv.oc.ietfng.org:/systank/obj/systank/src/sys/NWFKERN  sparc64

>Description:
The FreeBSD sparc64 implementation of {set,swap}context() will trash the Thread Local Storage register (%g7), making migration of contexts across threads unsafe.  This breaks plan9port, at least.

The same problem existed in Linux; see http://sourceware.org/bugzilla/show_bug.cgi?id=6577 for my report there.
>How-To-Repeat:
Attempt to setcontext() in one pthread the result of getcontext() in another thread.  Suddenly pthread_self() will return as if running on the other thread.
>Fix:
Don't restore %g7 from the stored context.

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


More information about the freebsd-sparc64 mailing list