OSDN Git Service

ARM: make isa_mode macro more robust and fix for v7-M
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 16 Dec 2013 09:24:46 +0000 (10:24 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Mon, 3 Feb 2014 10:46:39 +0000 (11:46 +0100)
commit3f18b1bf599d3d13cd81fdf6bf869c458772adfe
tree4129c93afad2293865a0eaff0b2b0a44c96295c0
parent38dbfb59d1175ef458d006556061adeaa8751b72
ARM: make isa_mode macro more robust and fix for v7-M

The definition of isa_mode hardcodes the values to shift PSR_J_BIT and
PSR_T_BIT to move them to bits 1 and 0 respectively. Instead use __ffs to
calculate the shift from the #define already used for masking.

This is relevant on v7-M as there PSR_T_BIT is 0x01000000 instead of
0x00000020 for V7-[AR] and earlier. Because of that isa_mode produced
values >= 0x80000 which are unsuitable to index into isa_modes[4] there
and so made __show_regs read from undefined memory which resulted in
hangs and crashes.

Moreover isa_mode is wrong for v7-M even after this robustness fix as
there is no J-bit in the PSR register. So hardcode isa_mode to "Thumb"
for v7-M.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
arch/arm/include/asm/ptrace.h