[parisc-linux-cvs] patch to fix trashed space registers in signal handling

John Marvin jsm@udlkern.fc.hp.com
Fri, 13 Apr 2001 08:19:00 -0600 (MDT)


This patch fixes a bug where we haven't saved the space registers if
a signal is taken while in user space (and the process isn't traced).
Currently we don't store the space registers in the sigcontext structure,
and I don't see this as a reason to start. As far as I'm concerned we
don't support the user changing space register values, so we just set
them to proper values in this case. That'll teach em not to mess with
the space registers. :-)

John

--- entry.S.old	Fri Apr 13 05:12:04 2001
+++ entry.S	Fri Apr 13 07:52:33 2001
@@ -647,6 +647,26 @@ syscall_exit_rfi:
 	depi	3,31,2,%r19
 	STREG	%r19,PT_IAOQ1(%r16)
 
+	/*
+	 * If we aren't being traced, we never saved space registers
+	 * (we don't store them in the sigcontext), so set them
+	 * to "proper" values now (otherwise we'll wind up restoring
+	 * whatever was last stored in the task structure, which might
+	 * be inconsistant if an interrupt occured while on the gateway
+	 * page) Note that we may be "trashing" values the user put in
+	 * them, but we don't support the the user changing them.
+	 */
+
+	STREG   %r0,PT_SR2(%r16)
+	mfsp    %sr3,%r19
+	STREG   %r19,PT_SR0(%r16)
+	STREG   %r19,PT_SR1(%r16)
+	STREG   %r19,PT_SR3(%r16)
+	STREG   %r19,PT_SR4(%r16)
+	STREG   %r19,PT_SR5(%r16)
+	STREG   %r19,PT_SR6(%r16)
+	STREG   %r19,PT_SR7(%r16)
+
 intr_return:
 
 	/* Check for software interrupts */