[PATCH] arm kgdb: fix breakpoint for thumb2

Johannes Stezenbach js at sig21.net
Mon Feb 14 03:05:56 PST 2022


On Mon, Feb 14, 2022 at 10:13:43AM +0000, Russell King (Oracle) wrote:
> On Mon, Feb 14, 2022 at 10:59:49AM +0100, Johannes Stezenbach wrote:
> > Entering kdb via SysRq-G with CONFIG_THUMB2_KERNEL=y
> > on Cortex-A7 in Qemu results in an Ooops, and it is
> > not possible to continue because of "Catastrophic error detected".
> > The root cause is using an arm breakpoint instruction in
> > thumb code.
> 
> This sounds like a bug in qemu.
> 
> 0xe7ffdeXX is two 16-bit instructions:
> 
>    0:   e7ff            b.n     2 <.text+0x2>
>    2:   def1            udf     #241    ; 0xf1
> 
> 0xe7ff is a branch to the UDF instruction.
> 
> 0xdeXX is a UDF (Permanently undefined) instruction which should raise a
> undefined instruction trap. As per the Arm ARM on UDF: "Permanently
> Undefined generates an Undefined Instruction exception."
> 
> The encoding is also a 32-bit UDF instruction:
> 
>    0:   e7ffdef1        udf     #64993  ; 0xfde1
> 
> which is exactly why these opcodes were chosen - so we can instrument
> both ARM and Thumb code without caring which it is.
> 
> Qemu needs fixing if it complains about this.

My apologies for the incomplete problem description.

Qemu is not complaining at all and correctly raises the invalid
instruction exception. But the kgdb_compiled_brkpt_hook undef_hook
only sees the 0xdef1 part and thus does not match.


Johannes



More information about the linux-arm-kernel mailing list