Skip to content

Commit

Permalink
powerpc/xmon: Use bitwise calculations in_breakpoint_table()
Browse files Browse the repository at this point in the history
A modulo operation is used for calculating the current offset from a
breakpoint within the breakpoint table. As instruction lengths are
always a power of 2, this can be replaced with a bitwise 'and'. The
current check for word alignment can be replaced with checking that the
lower 2 bits are not set.

Suggested-by: Christophe Leroy <[email protected]>
Signed-off-by: Jordan Niethe <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Reviewed-by: Alistair Popple <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
iamjpn authored and mpe committed May 18, 2020
1 parent 4eff2b4 commit 5a7fdca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/powerpc/xmon/xmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ static struct bpt *in_breakpoint_table(unsigned long nip, unsigned long *offp)
off = nip - (unsigned long)bpt_table;
if (off >= sizeof(bpt_table))
return NULL;
*offp = off % BPT_SIZE;
if (*offp != 0 && *offp != 4)
*offp = off & (BPT_SIZE - 1);
if (off & 3)
return NULL;
return bpts + (off / BPT_SIZE);
}
Expand Down

0 comments on commit 5a7fdca

Please sign in to comment.