Skip to contentSkip to conversation

ckpt/powerpc: handle syscall restart

PATCH Applied Nathan Lynch 2 participants 2 messages Feb 26, 2010 – Mar 1, 2010 1 message not in the archive PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ckpt/powerpc: handle syscall restart

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.

---
 arch/powerpc/kernel/checkpoint.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
arch/powerpc/kernel/checkpoint.c +25 -0
index 2634011..cd384df 100644
@@ -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;
 }
Signature · 1 line
1.6.0.6

A message that is not in the archive (sent off-list or not yet received): 1267214073-32348-1-git-send-email-ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org

Applied
#2 lore raw

Applied, thanks.

Quoted 46 lines · Nathan Lynch

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.

---
 arch/powerpc/kernel/checkpoint.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
arch/powerpc/kernel/checkpoint.c +25 -0
index 2634011..cd384df 100644
@@ -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;
 }