public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/6577] New: SPARC64 get/setcontext smashes TLS
@ 2008-05-28 23:46 nwfilardo at gmail dot com
  2008-07-31 16:45 ` [Bug nptl/6577] " drepper at redhat dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: nwfilardo at gmail dot com @ 2008-05-28 23:46 UTC (permalink / raw)
  To: glibc-bugs

(I'm not sure that this is libc's fault so apologies in advance if this is 
noise and should be redirected.  Please don't hesitate to ask for additional 
information; I'm not sure what else I should provide.)

Doing a setcontext() on Linux/SPARC64 (kernel 2.6.26-rc4) using glibc 2.7 
(Debian build 2.7-11) also writes over %g7, which is used to store the TLS 
pointer for pthread_self() (see libc/nptl/sysdeps/sparc/tls.h).  This breaks 
plan9port's libthread but it will show up any time threads exchange or pool 
contexts.

I've worked around it by manually setting uc_mcontext.mc_gregs[REG_G7] to 
pthread_self() before calling setcontext; if this is the correct fix, it would 
seem that setcontext() should be doing that itself.

Thanks for your time.

-- 
           Summary: SPARC64 get/setcontext smashes TLS
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: nwfilardo at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: sparc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=6577

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/6577] SPARC64 get/setcontext smashes TLS
  2008-05-28 23:46 [Bug nptl/6577] New: SPARC64 get/setcontext smashes TLS nwfilardo at gmail dot com
@ 2008-07-31 16:45 ` drepper at redhat dot com
  2008-07-31 17:19 ` jakub at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2008-07-31 16:45 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|drepper at redhat dot com   |jakub at redhat dot com
             Status|NEW                         |ASSIGNED


http://sourceware.org/bugzilla/show_bug.cgi?id=6577

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/6577] SPARC64 get/setcontext smashes TLS
  2008-05-28 23:46 [Bug nptl/6577] New: SPARC64 get/setcontext smashes TLS nwfilardo at gmail dot com
  2008-07-31 16:45 ` [Bug nptl/6577] " drepper at redhat dot com
@ 2008-07-31 17:19 ` jakub at redhat dot com
  2008-08-01  3:43 ` davem at davemloft dot net
  2008-08-13  7:01 ` drepper at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at redhat dot com @ 2008-07-31 17:19 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2008-07-31 17:18 -------
I'd say the kernel setcontext 0x16f trap shouldn't change %g7, Dave, do you
agree?  Of course glibc can store %g7 to the setcontext structure before doing
ta 0x6f too, but that means the context has to be modified by setcontext.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davem at davemloft dot net


http://sourceware.org/bugzilla/show_bug.cgi?id=6577

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/6577] SPARC64 get/setcontext smashes TLS
  2008-05-28 23:46 [Bug nptl/6577] New: SPARC64 get/setcontext smashes TLS nwfilardo at gmail dot com
  2008-07-31 16:45 ` [Bug nptl/6577] " drepper at redhat dot com
  2008-07-31 17:19 ` jakub at redhat dot com
@ 2008-08-01  3:43 ` davem at davemloft dot net
  2008-08-13  7:01 ` drepper at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: davem at davemloft dot net @ 2008-08-01  3:43 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From davem at davemloft dot net  2008-08-01 03:42 -------
Subject: Re:  SPARC64 get/setcontext smashes TLS

From: "jakub at redhat dot com" <sourceware-bugzilla@sourceware.org>
Date: 31 Jul 2008 17:18:35 -0000

> I'd say the kernel setcontext 0x16f trap shouldn't change %g7, Dave, do you
> agree?  Of course glibc can store %g7 to the setcontext structure before doing
> ta 0x6f too, but that means the context has to be modified by setcontext.

I agree, therefore I'll commit the following patch upstream.

sparc64: Do not clobber %g7 in setcontext() trap.

That's the userland thread register, so we should never try to change
it like this.

Based upon glibc bug nptl/6577 and suggestions by Jakub Jelinek.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc64/kernel/signal.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
index d1b8445..ca5a6ae 100644
--- a/arch/sparc64/kernel/signal.c
+++ b/arch/sparc64/kernel/signal.c
@@ -2,7 +2,7 @@
  *  arch/sparc64/kernel/signal.c
  *
  *  Copyright (C) 1991, 1992  Linus Torvalds
- *  Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
+ *  Copyright (C) 1995, 2008 David S. Miller (davem@davemloft.net)
  *  Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  *  Copyright (C) 1997 Eddie C. Dost   (ecd@skynet.be)
  *  Copyright (C) 1997,1998 Jakub Jelinek   (jj@sunsite.mff.cuni.cz)
@@ -91,7 +91,9 @@ asmlinkage void sparc64_set_context(struct pt_regs *regs)
 	err |= __get_user(regs->u_regs[UREG_G4], (&(*grp)[MC_G4]));
 	err |= __get_user(regs->u_regs[UREG_G5], (&(*grp)[MC_G5]));
 	err |= __get_user(regs->u_regs[UREG_G6], (&(*grp)[MC_G6]));
-	err |= __get_user(regs->u_regs[UREG_G7], (&(*grp)[MC_G7]));
+
+	/* Skip %g7 as that's the thread register in userspace.  */
+
 	err |= __get_user(regs->u_regs[UREG_I0], (&(*grp)[MC_O0]));
 	err |= __get_user(regs->u_regs[UREG_I1], (&(*grp)[MC_O1]));
 	err |= __get_user(regs->u_regs[UREG_I2], (&(*grp)[MC_O2]));


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=6577

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug nptl/6577] SPARC64 get/setcontext smashes TLS
  2008-05-28 23:46 [Bug nptl/6577] New: SPARC64 get/setcontext smashes TLS nwfilardo at gmail dot com
                   ` (2 preceding siblings ...)
  2008-08-01  3:43 ` davem at davemloft dot net
@ 2008-08-13  7:01 ` drepper at redhat dot com
  3 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2008-08-13  7:01 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2008-08-13 07:00 -------
Not a libc problem, this is fixed in the kernel.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID


http://sourceware.org/bugzilla/show_bug.cgi?id=6577

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-08-13  7:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-28 23:46 [Bug nptl/6577] New: SPARC64 get/setcontext smashes TLS nwfilardo at gmail dot com
2008-07-31 16:45 ` [Bug nptl/6577] " drepper at redhat dot com
2008-07-31 17:19 ` jakub at redhat dot com
2008-08-01  3:43 ` davem at davemloft dot net
2008-08-13  7:01 ` drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).