Skip to content

Commit

Permalink
powerpc/xmon: Don't allow breakpoints on suffixes
Browse files Browse the repository at this point in the history
Do not allow placing xmon breakpoints on the suffix of a prefix
instruction.

Signed-off-by: Jordan Niethe <[email protected]>
[mpe: Don't split printf strings across lines]
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
iamjpn authored and mpe committed May 18, 2020
1 parent 785b79d commit c9c831a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions arch/powerpc/xmon/xmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,8 @@ static struct bpt *new_breakpoint(unsigned long a)
static void insert_bpts(void)
{
int i;
struct ppc_inst instr;
struct bpt *bp;
struct ppc_inst instr, instr2;
struct bpt *bp, *bp2;

bp = bpts;
for (i = 0; i < NBPTS; ++i, ++bp) {
Expand All @@ -908,6 +908,29 @@ static void insert_bpts(void)
bp->enabled = 0;
continue;
}
/*
* Check the address is not a suffix by looking for a prefix in
* front of it.
*/
if (mread_instr(bp->address - 4, &instr2) == 8) {
printf("Breakpoint at %lx is on the second word of a prefixed instruction, disabling it\n",
bp->address);
bp->enabled = 0;
continue;
}
/*
* We might still be a suffix - if the prefix has already been
* replaced by a breakpoint we won't catch it with the above
* test.
*/
bp2 = at_breakpoint(bp->address - 4);
if (bp2 && ppc_inst_prefixed(ppc_inst_read(bp2->instr))) {
printf("Breakpoint at %lx is on the second word of a prefixed instruction, disabling it\n",
bp->address);
bp->enabled = 0;
continue;
}

patch_instruction(bp->instr, instr);
patch_instruction((void *)bp->instr + ppc_inst_len(instr),
ppc_inst(bpinstr));
Expand Down

0 comments on commit c9c831a

Please sign in to comment.