sparc64: Fix syscall restart, for real...

The change I put into copy_thread() just papered over the real
problem.

When we are looking to see if we should do a syscall restart, when
deliverying a signal, we should only interpret the syscall return
value as an error if the carry condition code(s) are set.

Otherwise it's a success return.

Also, sigreturn paths should do a pt_regs_clear_trap_type().

It turns out that doing a syscall restart when returning from a fork()
does and should happen, from time to time.  Even if copy_thread()
returns success, copy_process() can still unwind and signal
-ERESTARTNOINTR in the parent.

Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
index f2d88d8..45d6bf6 100644
--- a/arch/sparc64/kernel/signal.c
+++ b/arch/sparc64/kernel/signal.c
@@ -332,6 +332,9 @@
 	regs->tpc = tpc;
 	regs->tnpc = tnpc;
 
+	/* Prevent syscall restart.  */
+	pt_regs_clear_trap_type(regs);
+
 	sigdelsetmask(&set, ~_BLOCKABLE);
 	spin_lock_irq(&current->sighand->siglock);
 	current->blocked = set;
@@ -515,7 +518,8 @@
 	siginfo_t info;
 	int signr;
 	
-	if (pt_regs_is_syscall(regs)) {
+	if (pt_regs_is_syscall(regs) &&
+	    (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) {
 		pt_regs_clear_trap_type(regs);
 		cookie.restart_syscall = 1;
 	} else