public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix ppc{32,64} longjmp
@ 2006-09-21 19:12 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2006-09-21 19:12 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers, Dwayne Grant McConnell, Steven Munroe

Hi!

Stack pointer demangling in ppc{32,64} longjmp leaves for one (ppc64; or a couple
(ppc32)) instruction(s) garbage in r1, which is bad if a signal comes in.
Fixed thusly:

2006-09-21  Jakub Jelinek  <jakub@redhat.com>

	[BZ #3225]
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h (PTR_MANGLE3,
	PTR_DEMANGLE3): Define.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h (PTR_MANGLE3,
	PTR_DEMANGLE3): Likewise.
	* sysdeps/powerpc/powerpc32/__longjmp-common.S (__longjmp): Use it.
	* sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S (__longjmp):
	Likewise.
	* sysdeps/powerpc/powerpc64/__longjmp-common.S (__longjmp): Likewise.

--- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h.jj	2006-01-02 11:39:05.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h	2006-09-21 17:46:56.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,1997-2003,2004,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1997-2003,2004,2005,2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -285,8 +285,12 @@
 	xor	reg,tmpreg,reg
 #  define PTR_MANGLE2(reg, tmpreg) \
 	xor	reg,tmpreg,reg
+#  define PTR_MANGLE3(destreg, reg, tmpreg) \
+	lwz	tmpreg,POINTER_GUARD(r2); \
+	xor	destreg,tmpreg,reg
 #  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
 #  define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
+#  define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
 # else
 #  define PTR_MANGLE(var) \
   (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
--- libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h.jj	2006-01-11 16:55:32.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h	2006-09-21 17:47:49.000000000 +0200
@@ -299,8 +299,12 @@
 	xor	reg,tmpreg,reg
 #  define PTR_MANGLE2(reg, tmpreg) \
 	xor	reg,tmpreg,reg
+#  define PTR_MANGLE3(destreg, reg, tmpreg) \
+	ld	tmpreg,POINTER_GUARD(r13); \
+	xor	destreg,tmpreg,reg
 #  define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
 #  define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
+#  define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
 # else
 #  define PTR_MANGLE(var) \
   (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
--- libc/sysdeps/powerpc/powerpc32/__longjmp-common.S.jj	2006-01-14 17:41:04.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc32/__longjmp-common.S	2006-09-21 18:03:21.000000000 +0200
@@ -31,7 +31,11 @@
 ENTRY (BP_SYM (__longjmp))
 	CHECK_BOUNDS_BOTH_WIDE_LIT (r3, r8, r9, JB_SIZE)
 
+#ifdef PTR_DEMANGLE
+	lwz r24,(JB_GPR1*4)(r3)
+#else
 	lwz r1,(JB_GPR1*4)(r3)
+#endif
 	lwz r0,(JB_LR*4)(r3)
 	lwz r14,((JB_GPRS+0)*4)(r3)
 	lwz r15,((JB_GPRS+1)*4)(r3)
@@ -41,8 +45,8 @@ ENTRY (BP_SYM (__longjmp))
 	lwz r19,((JB_GPRS+5)*4)(r3)
 	lwz r20,((JB_GPRS+6)*4)(r3)
 #ifdef PTR_DEMANGLE
-	PTR_DEMANGLE (r0, r25)
-	PTR_DEMANGLE2 (r1, r25)
+	PTR_DEMANGLE3 (r1, r24, r25)
+	PTR_DEMANGLE2 (r0, r25)
 #endif
 	mtlr r0
 	lwz r21,((JB_GPRS+7)*4)(r3)
--- libc/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S.jj	2006-01-14 17:41:04.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc32/fpu/__longjmp-common.S	2006-09-21 18:02:33.000000000 +0200
@@ -114,7 +114,11 @@ aligned_restore_vmx:
 	lvx	v31,0,r6
 L(no_vmx):
 #endif
+#ifdef PTR_DEMANGLE
+	lwz r24,(JB_GPR1*4)(r3)
+#else
 	lwz r1,(JB_GPR1*4)(r3)
+#endif
 	lwz r0,(JB_LR*4)(r3)
 	lwz r14,((JB_GPRS+0)*4)(r3)
 	lfd fp14,((JB_FPRS+0*2)*4)(r3)
@@ -131,8 +135,8 @@ L(no_vmx):
 	lwz r20,((JB_GPRS+6)*4)(r3)
 	lfd fp20,((JB_FPRS+6*2)*4)(r3)
 #ifdef PTR_DEMANGLE
-	PTR_DEMANGLE (r0, r25)
-	PTR_DEMANGLE2 (r1, r25)
+	PTR_DEMANGLE3 (r1, r24, r25)
+	PTR_DEMANGLE2 (r0, r25)
 #endif
 	mtlr r0
 	lwz r21,((JB_GPRS+7)*4)(r3)
--- libc/sysdeps/powerpc/powerpc64/__longjmp-common.S.jj	2006-01-14 17:41:04.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc64/__longjmp-common.S	2006-09-21 18:01:05.000000000 +0200
@@ -108,9 +108,11 @@ aligned_restore_vmx:
 	lvx	v31,0,r6
 L(no_vmx):
 #endif
-	ld r1,(JB_GPR1*8)(r3)
 #ifdef PTR_DEMANGLE
-	PTR_DEMANGLE (r1, r25)
+	ld r22,(JB_GPR1*8)(r3)
+	PTR_DEMANGLE3 (r1, r22, r25)
+#else
+	ld r1,(JB_GPR1*8)(r3)
 #endif
 	ld r2,(JB_GPR2*8)(r3)
 	ld r0,(JB_LR*8)(r3)

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-21 19:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-21 19:12 [PATCH] Fix ppc{32,64} longjmp Jakub Jelinek

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).