Commit eb18549a authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] Single-stepping emulated instructions

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: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f89b5127
...@@ -466,6 +466,18 @@ SingleStepException(struct pt_regs *regs) ...@@ -466,6 +466,18 @@ SingleStepException(struct pt_regs *regs)
_exception(SIGTRAP, &info, regs); _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) static void dummy_perf(struct pt_regs *regs)
{ {
} }
...@@ -487,10 +499,8 @@ AlignmentException(struct pt_regs *regs) ...@@ -487,10 +499,8 @@ AlignmentException(struct pt_regs *regs)
fixed = fix_alignment(regs); fixed = fix_alignment(regs);
if (fixed == 1) { if (fixed == 1) {
if (!user_mode(regs))
PPCDBG(PPCDBG_ALIGNFIXUP, "fix alignment at %lx\n",
regs->nip);
regs->nip += 4; /* skip over emulated instruction */ regs->nip += 4; /* skip over emulated instruction */
emulate_single_step(regs);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment