[Devel] [PATCH] ckpt/powerpc: handle syscall restart

Nathan Lynch ntl at pobox.com
Fri Feb 26 11:54:33 PST 2010


If a task is checkpointed while servicing a restartable system call
like nanosleep, we need to ensure that the syscall is restarted
appropriately after a checkpoint/restart cycle.  This gets
cr_tests/sleeptest passing on powerpc.

Signed-off-by: Nathan Lynch <ntl at pobox.com>
---
 arch/powerpc/kernel/checkpoint.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/checkpoint.c b/arch/powerpc/kernel/checkpoint.c
index 2634011..cd384df 100644
--- a/arch/powerpc/kernel/checkpoint.c
+++ b/arch/powerpc/kernel/checkpoint.c
@@ -307,6 +307,31 @@ static int restore_gprs(const struct ckpt_hdr_cpu *cpu_hdr,
 	regs->orig_gpr3 = cpu_hdr->orig_gpr3;
 
 	regs->msr = sanitize_msr(regs->msr);
+
+	/* The normal servicing of the freezer's fake signal is
+	 * short-circuited by checkpoint/restart.  See
+	 * arch/powerpc/kernel/signal.c::do_signal_pending().
+	 */
+	if (TRAP(regs) != 0x0C00)
+		goto out;
+	if (!(regs->ccr & 0x10000000))
+		goto out;
+
+	switch (regs->gpr[3]) {
+	case ERESTARTNOHAND:
+	case ERESTARTSYS:
+	case ERESTARTNOINTR:
+		regs->gpr[3] = regs->orig_gpr3;
+		break;
+	case ERESTART_RESTARTBLOCK:
+		regs->gpr[0] = __NR_restart_syscall;
+		break;
+	default:
+		goto out;
+	}
+
+	regs->nip -= 4;
+	regs->result = 0;
 out:
 	return rc;
 }
-- 
1.6.0.6

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list