Skip to content

Etm4 t32 return address fix#92

Open
sayhal01 wants to merge 1 commit into
Linaro:masterfrom
sayhal01:etm4-t32-return-address-fix
Open

Etm4 t32 return address fix#92
sayhal01 wants to merge 1 commit into
Linaro:masterfrom
sayhal01:etm4-t32-return-address-fix

Conversation

@sayhal01

Copy link
Copy Markdown

opencsd: etm4: handle exception return addresses inside T32 instructions

When processing an exception packet, the ETMv4 decoder traces to the
preferred exception return address using traceInstrToWP(). For M-profile
devices, the preferred exception return address may lie within a
restartable or interrupt-continuable 32-bit T32 instruction.

The decoder advances by instruction boundaries while searching for the
target address. When the preferred return address lies inside a 32-bit
Thumb instruction, the address is skipped and never matched directly,
causing tracing to continue past the exception return point and emit an
incorrect instruction range.

Detect this case and treat the preferred return address as reached when
it falls within the current decoded Thumb-2 instruction, ensuring the
instruction range reported before the exception matches the expected
execution flow.

Add regression snapshot tests covering exception return addresses at an
instruction boundary, within a 32-bit T32 instruction, and at the next
instruction boundary to validate the behaviour and prevent future
regressions.

Signed-off-by: Your Name your.email@example.com

@sayhal01 sayhal01 force-pushed the etm4-t32-return-address-fix branch 2 times, most recently from 6f2b1a6 to fdbdaae Compare June 11, 2026 19:54
For M-profile tracing, the preferred exception return address may lie
within a restartable 32-bit T32 instruction.

The decoder searches for the preferred return address at instruction
boundaries. When the address lies within a 32-bit Thumb instruction, it
can be skipped, causing tracing to continue past the exception return
point and emit an incorrect instruction range.

Detect this case and stop tracing at the preferred return address when
it falls within the current Thumb-2 instruction.

Add regression snapshot tests covering exception return addresses at an
instruction boundary, within a 32-bit T32 instruction, and at the next
instruction boundary to validate the behaviour and prevent future
regressions.

Signed-off-by: Sayani Halder <sayani.halder@arm.com>
@sayhal01 sayhal01 force-pushed the etm4-t32-return-address-fix branch from fdbdaae to 6d5bf90 Compare June 11, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant