From: sashiko-bot@kernel.org
To: "Leo Yan" <leo.yan@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 10/14] perf cs-etm: Synthesize exception entries separately from branches
Date: Wed, 23 Sep 2026 16:36:04 +0000 [thread overview]
Message-ID: <20260923163605.3962C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260923-perf_cs_etm_fix_non_taken-v2-10-6ab8c07a5455@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf: miscalculation of ETMv3 SVC/HYP source addresses
--
commit 29b742481ea9116881bdfbed14f1f45c6d6ded76
Author: Leo Yan <leo.yan@arm.com>
perf cs-etm: Synthesize exception entries separately from branches
This commit modifies the handling of ARM CoreSight ETM trace exception
entries, synthesizing them separately from branches. It derives exception
source PCs from the preferred return address rather than attributing the
exception to the last completed instruction.
> diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
> index 48e8c355a3e49..83a851bdd87bf 100644
> --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
> +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
[ ... ]
> @@ -524,8 +525,34 @@ cs_etm_decoder__buffer_exception(struct cs_etm_queue *etmq,
> packet->exception_number = elem->exception_number;
> if (elem->context.el_valid)
> packet->el = elem->context.exception_level;
> - if (elem->excep_ret_addr)
> - packet->end_addr = elem->en_addr;
> +
> + /* RESET has no defined preferred return address. */
> + if (!elem->excep_ret_addr ||
> + packet->exception_number == CS_ETMV4_EXC_RESET)
> + return ret;
> +
> + packet->end_addr = elem->en_addr;
> +
> + /*
> + * T32 calls can be two or four bytes, requiring an instruction read
> + * before end_addr to determine their size. Keep end_addr for the
> + * frontend's SVC check and leave start_addr unknown for its fallback.
> + */
> + if (packet->isa != CS_ETM_ISA_A32 && packet->isa != CS_ETM_ISA_A64)
> + return ret;
> +
> + /*
> + * For A32 and A64, exception calls execute a four-byte SVC, HVC or
> + * SMC and save the following PC. Other exceptions use the interrupted
> + * or faulting PC, including traps on those instructions.
> + *
> + * With a shared branch target, no instruction has completed
> + * at the target, so last_instr_size remains zero.
> + */
> + if (elem->exception_number == CS_ETMV4_EXC_CALL)
[Severity: Medium]
Does cs_etm_decoder__buffer_exception() miscalculate the instruction size for
ETMv3 SVC and HYP call exceptions here?
By only checking against CS_ETMV4_EXC_CALL, it appears to miss the
corresponding ETMv3 call exception values (CS_ETMV3_EXC_SVC=10,
CS_ETMV3_EXC_HYP=3). When tracing ETMv3 with an SVC or HYP exception that
provides an excep_ret_addr, this would result in a 0-byte instruction size
and a misattributed source address in the trace output.
> + last_instr_size = 4;
> + packet->start_addr = packet->end_addr - last_instr_size;
> + packet->last_instr_size = last_instr_size;
>
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923-perf_cs_etm_fix_non_taken-v2-0-6ab8c07a5455@arm.com?part=10
next prev parent reply other threads:[~2026-09-23 16:36 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 15:21 [PATCH v2 00/14] perf cs-etm: Fix bogus branch samples on exceptions Leo Yan
2026-09-23 15:21 ` [PATCH v2 01/14] perf sample: Allow decoders to supply branch return addresses Leo Yan
2026-09-23 15:29 ` sashiko-bot
2026-09-24 13:00 ` Adrian Hunter
2026-09-23 15:21 ` [PATCH v2 02/14] perf intel-pt: Preserve return addresses for asynchronous branches Leo Yan
2026-09-23 15:43 ` sashiko-bot
2026-09-24 13:00 ` Adrian Hunter
2026-09-23 15:21 ` [PATCH v2 03/14] perf cs-etm: Break branch history when instruction memory is unavailable Leo Yan
2026-09-23 15:46 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 04/14] perf cs-etm: Centralize packet ISA initialization Leo Yan
2026-09-23 15:50 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 05/14] perf cs-etm: Use the recorded instruction size for A32 and A64 Leo Yan
2026-09-23 16:01 ` sashiko-bot
2026-09-29 13:55 ` James Clark
2026-09-23 15:21 ` [PATCH v2 06/14] perf cs-etm: Mark branches that were not taken Leo Yan
2026-09-23 16:09 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 07/14] perf cs-etm: Factor out final instruction sample synthesis Leo Yan
2026-09-23 16:13 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 08/14] perf cs-etm: Centralize branch sample synthesis checks Leo Yan
2026-09-23 16:18 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 09/14] perf cs-etm: Classify exception calls using the exception packet Leo Yan
2026-09-23 16:24 ` sashiko-bot
2026-09-29 14:08 ` James Clark
2026-09-23 15:21 ` [PATCH v2 10/14] perf cs-etm: Synthesize exception entries separately from branches Leo Yan
2026-09-23 16:36 ` sashiko-bot [this message]
2026-09-23 15:21 ` [PATCH v2 11/14] perf tests: Check CoreSight IRQ entry and exit Leo Yan
2026-09-23 16:40 ` sashiko-bot
2026-09-29 12:22 ` James Clark
2026-09-23 15:21 ` [PATCH v2 12/14] perf tests: Check CoreSight syscall " Leo Yan
2026-09-23 16:46 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 13/14] perf tests: Check CoreSight abort " Leo Yan
2026-09-23 16:49 ` sashiko-bot
2026-09-23 15:21 ` [PATCH v2 14/14] perf tests: Check CoreSight emulated instruction " Leo Yan
2026-09-23 16:56 ` sashiko-bot
2026-09-29 14:41 ` [PATCH v2 00/14] perf cs-etm: Fix bogus branch samples on exceptions James Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923163605.3962C1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox