[PATCH][PPC64] Single-stepping emulated instructions

From: Paul Mackerras
Date: Tue Jun 08 2004 - 07:10:38 EST


Occasionally the ppc64 kernel emulates a usermode instruction, for
example in the alignment exception handler. Kumar Gala pointed out
(in the context of the ppc32 kernel) that if the instruction was being
single-stepped, and we end up emulating the instruction, we should
then send the process a SIGTRAP as if it had not been emulated and the
process had then taken a single-step exception. This patch implements
this for ppc64.

Signed-off-by: Paul Mackerras <paulus@xxxxxxxxx>

diff -urN linux-2.5/arch/ppc64/kernel/traps.c b/arch/ppc64/kernel/traps.c
--- linux-2.5/arch/ppc64/kernel/traps.c 2004-06-08 21:37:05.344964616 +1000
+++ b/arch/ppc64/kernel/traps.c 2004-06-08 15:31:36.000000000 +1000
@@ -500,6 +500,18 @@
_exception(SIGTRAP, &info, regs);
}

+/*
+ * After we have successfully emulated an instruction, we have to
+ * check if the instruction was being single-stepped, and if so,
+ * pretend we got a single-step exception. This was pointed out
+ * by Kumar Gala. -- paulus
+ */
+static inline void emulate_single_step(struct pt_regs *regs)
+{
+ if (regs->msr & MSR_SE)
+ SingleStepException(regs);
+}
+
static void dummy_perf(struct pt_regs *regs)
{
}
@@ -521,10 +533,8 @@
fixed = fix_alignment(regs);

if (fixed == 1) {
- if (!user_mode(regs))
- PPCDBG(PPCDBG_ALIGNFIXUP, "fix alignment at %lx\n",
- regs->nip);
regs->nip += 4; /* skip over emulated instruction */
+ emulate_single_step(regs);
return;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/