Skip to content

Commit c9c831a

Browse files
iamjpnmpe
authored andcommitted
powerpc/xmon: Don't allow breakpoints on suffixes
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]
1 parent 785b79d commit c9c831a

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

arch/powerpc/xmon/xmon.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ static struct bpt *new_breakpoint(unsigned long a)
889889
static void insert_bpts(void)
890890
{
891891
int i;
892-
struct ppc_inst instr;
893-
struct bpt *bp;
892+
struct ppc_inst instr, instr2;
893+
struct bpt *bp, *bp2;
894894

895895
bp = bpts;
896896
for (i = 0; i < NBPTS; ++i, ++bp) {
@@ -908,6 +908,29 @@ static void insert_bpts(void)
908908
bp->enabled = 0;
909909
continue;
910910
}
911+
/*
912+
* Check the address is not a suffix by looking for a prefix in
913+
* front of it.
914+
*/
915+
if (mread_instr(bp->address - 4, &instr2) == 8) {
916+
printf("Breakpoint at %lx is on the second word of a prefixed instruction, disabling it\n",
917+
bp->address);
918+
bp->enabled = 0;
919+
continue;
920+
}
921+
/*
922+
* We might still be a suffix - if the prefix has already been
923+
* replaced by a breakpoint we won't catch it with the above
924+
* test.
925+
*/
926+
bp2 = at_breakpoint(bp->address - 4);
927+
if (bp2 && ppc_inst_prefixed(ppc_inst_read(bp2->instr))) {
928+
printf("Breakpoint at %lx is on the second word of a prefixed instruction, disabling it\n",
929+
bp->address);
930+
bp->enabled = 0;
931+
continue;
932+
}
933+
911934
patch_instruction(bp->instr, instr);
912935
patch_instruction((void *)bp->instr + ppc_inst_len(instr),
913936
ppc_inst(bpinstr));

0 commit comments

Comments
 (0)