[parisc-linux-cvs] Patch to fix strace over fork bug

John Marvin jsm@udlkern.fc.hp.com
Fri, 30 Mar 2001 02:55:31 -0700 (MST)


Here's a patch that fixes the strace over fork bug. The problem is that
fork (and exec) can change sr3, and normally we restore sr4-sr7 from
sr3 upon syscall return. But the return path used by strace was
skipping over the code that does this. So the patch just moves the
code up before the test to determine whether or not to save registers.

John

--- entry.S.old	Fri Mar 30 01:07:59 2001
+++ entry.S	Fri Mar 30 02:20:09 2001
@@ -2132,6 +2132,18 @@ try_tbit:
 	depi	-1,7,1,%r20			   /* T bit */
 psw_setup:
 	STREG	%r20,TASK_PT_PSW(%r1)
+
+	/* Always store space registers, since sr3 can be changed (e.g. fork) */
+
+	mfsp    %sr3,%r25
+	STREG   %r25,TASK_PT_SR3(%r1)
+	STREG   %r25,TASK_PT_SR4(%r1)
+	STREG   %r25,TASK_PT_SR5(%r1)
+	STREG   %r25,TASK_PT_SR6(%r1)
+	STREG   %r25,TASK_PT_SR7(%r1)
+	STREG   %r25,TASK_PT_IASQ0(%r1)
+	STREG   %r25,TASK_PT_IASQ1(%r1)
+
 	/* XXX W bit??? */
 	/* Now if old D bit is clear, it means we didn't save all registers
 	 * on syscall entry, so do that now.  This only happens on TRACEME
@@ -2151,14 +2163,6 @@ psw_setup:
 	STREG	%r2,TASK_PT_SR1(%r1)
 	mfsp	%sr2,%r2
 	STREG	%r2,TASK_PT_SR2(%r1)
-	mfsp	%sr3,%r2
-	STREG	%r2,TASK_PT_SR3(%r1)
-	STREG	%r2,TASK_PT_SR4(%r1)
-	STREG	%r2,TASK_PT_SR5(%r1)
-	STREG	%r2,TASK_PT_SR6(%r1)
-	STREG	%r2,TASK_PT_SR7(%r1)
-	STREG	%r2,TASK_PT_IASQ0(%r1)
-	STREG	%r2,TASK_PT_IASQ1(%r1)
 pt_regs_ok:
 	LDREG	TASK_PT_GR31(%r1),%r2
 	depi	3,31,2,%r2			   /* ensure return to user mode. */