[Linux-ia64] IMPORTANT glibc fix

From: David Mosberger <davidm_at_napali.hpl.hp.com>
Date: 2003-03-28 12:06:08
The patch below was just applied to the CVS glibc.  Since it fixes an
important bug, I'd highly recommend for distributors to also apply the
patch to their currently shipping version of glibc.

	--david

--------------------------------------------------------------------
From: David Mosberger <davidm@linux.hpl.hp.com>
Sender: libc-hacker-owner@sources.redhat.com
To: libc-hacker@sources.redhat.com
Subject: ia64: unat restoration fixes for setjmp() & getcontext()
Date: Thu, 27 Mar 2003 11:40:03 -0800
Reply-To: davidm@hpl.hp.com

The ia64 versions of __sigsetjmp() and getcontext() failed to restore
ar.unat before returning.  Patch below should fix that.

	--david

2003-03-27  David Mosberger  <davidm@hpl.hp.com>

	* sysdeps/unix/sysv/linux/ia64/getcontext.S: Restore caller's
	ar.unat before returning.  Add missing .mem.offset directives
	to ensure file gets assembled without warnings.

	* sysdeps/unix/sysv/linux/ia64/setjmp.S: Ditto.

Index: sysdeps/unix/sysv/linux/ia64/setjmp.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/ia64/setjmp.S,v
retrieving revision 1.7 diff -u -r1.7 setjmp.S ---
sysdeps/unix/sysv/linux/ia64/setjmp.S 31 Dec 2002 20:37:30 -0000 1.7
+++ sysdeps/unix/sysv/linux/ia64/setjmp.S 27 Mar 2003 18:05:14 -0000
@@ -87,21 +87,22 @@
 ENTRY(__sigsetjmp)
 	.prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
 	alloc loc1=ar.pfs,2,2,2,0
+	.save ar.unat, r16
 	mov r16=ar.unat
 	;;
 	mov r17=ar.fpsr
 	mov r2=in0
 	add r3=8,in0
 	;;
-	st8.spill.nta [r2]=sp,16	// r12 (sp)
-	st8.spill.nta [r3]=gp,16	// r1 (gp)
+.mem.offset 8,0;	st8.spill.nta [r2]=sp,16	// r12 (sp)
+.mem.offset 0,0;	st8.spill.nta [r3]=gp,16	// r1 (gp)
 	;;
 	st8.nta [r2]=r16,16		// save caller's unat
 	st8.nta [r3]=r17,16		// save fpsr
 	add r8=0xa0,in0
 	;;
-	st8.spill.nta [r2]=r4,16	// r4
-	st8.spill.nta [r3]=r5,16	// r5
+.mem.offset 8,0;	st8.spill.nta [r2]=r4,16	// r4
+.mem.offset 0,0;	st8.spill.nta [r3]=r5,16	// r5
 	add r9=0xb0,in0
 	;;
 	stf.spill.nta [r8]=f2,32
@@ -143,8 +144,8 @@
 	stf.spill.nta [r8]=f30
 	stf.spill.nta [r9]=f31
 
-	st8.spill.nta [r2]=r6,16	// r6
-	st8.spill.nta [r3]=r7,16	// r7
+.mem.offset 8,0;	st8.spill.nta [r2]=r6,16	// r6
+.mem.offset 0,0;	st8.spill.nta [r3]=r7,16	// r7
 	;;
 	mov r23=ar.bsp
 	mov r25=ar.unat
@@ -170,9 +171,10 @@
 	st8.nta [r3]=in0		// &__jmp_buf
 	br.call.dpnt.few rp=__sigjmp_save
 .ret0:					// force a new bundle ::q
-	mov r8=0
+	mov.m ar.unat=r16		// restore caller's unat
 	mov rp=loc0
 	mov ar.pfs=loc1
+	mov r8=0
 	ret
 END(__sigsetjmp)
 
Index: sysdeps/unix/sysv/linux/ia64/getcontext.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/ia64/getcontext.S,v
retrieving revision 1.6 diff -u -r1.6 getcontext.S ---
sysdeps/unix/sysv/linux/ia64/getcontext.S 9 Oct 2002 09:57:46 -0000
1.6 +++ sysdeps/unix/sysv/linux/ia64/getcontext.S 27 Mar 2003 19:33:04
-0000 @@ -34,6 +34,7 @@
   other than the PRESERVED state.  */
 
 ENTRY(__getcontext)
+	.prologue
 	alloc r16 = ar.pfs, 1, 0, 3, 0
 
 	// sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask):
@@ -53,7 +54,9 @@
 	add r2 = SC_GR+1*8, r32
 	;;
 	mov.m rBSP = ar.bsp
+	.save ar.unat, rUNAT
 	mov.m rUNAT = ar.unat
+	.body
 	add r3 = SC_GR+4*8, r32
 	;;
 
@@ -65,8 +68,8 @@
 .mem.offset 8,0; st8.spill [r3] = r6, 48
 	and rTMP = ~0x3, rRSC
 	;;
-	st8.spill [r2] = r7, (SC_FR+2*16-(SC_GR+7*8))
-	st8.spill [r3] = sp, (SC_FR+3*16-(SC_GR+12*8))
+.mem.offset 0,0; st8.spill [r2] = r7, (SC_FR+2*16-(SC_GR+7*8))
+.mem.offset 8,0; st8.spill [r3] = sp, (SC_FR+3*16-(SC_GR+12*8))
 	;;
 	mov.m ar.rsc = rTMP 		// put RSE into enforced lazy mode
 	mov.m rNAT = ar.unat
@@ -119,8 +122,8 @@
 	stf.spill [r3] = f31, 32
 	mov rB1 = b1
 	;; + mov ar.unat = rUNAT // we're done spilling integer regs;
restore caller's UNaT
 	add r2 = SC_NAT, r32
-	nop 0
 	add r3 = SC_BSP, r32
 	;;
 	st8 [r2] = rNAT, (SC_RNAT-SC_NAT)
Received on Thu Mar 27 17:07:41 2003

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:12 EST