Commit 5a7fdcab authored by Jordan Niethe's avatar Jordan Niethe Committed by Michael Ellerman

powerpc/xmon: Use bitwise calculations in_breakpoint_table()

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: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: default avatarJordan Niethe <jniethe5@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Reviewed-by: default avatarAlistair Popple <alistair@popple.id.au>
Link: https://lore.kernel.org/r/20200506034050.24806-5-jniethe5@gmail.com
parent 4eff2b4f
...@@ -857,8 +857,8 @@ static struct bpt *in_breakpoint_table(unsigned long nip, unsigned long *offp) ...@@ -857,8 +857,8 @@ static struct bpt *in_breakpoint_table(unsigned long nip, unsigned long *offp)
off = nip - (unsigned long)bpt_table; off = nip - (unsigned long)bpt_table;
if (off >= sizeof(bpt_table)) if (off >= sizeof(bpt_table))
return NULL; return NULL;
*offp = off % BPT_SIZE; *offp = off & (BPT_SIZE - 1);
if (*offp != 0 && *offp != 4) if (off & 3)
return NULL; return NULL;
return bpts + (off / BPT_SIZE); return bpts + (off / BPT_SIZE);
} }
......
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