mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@linaro.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Mike Leach <mike.leach@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Suyash Mahar <smahar@meta.com>, Amir Ayupov <aaupov@fb.com>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 10/14] perf cs-etm: Synthesize exception entries separately from branches
Date: Fri, 13 Nov 2026 10:59:28 +0000	[thread overview]
Message-ID: <20261113105928.GN9176@e132581.arm.com> (raw)
In-Reply-To: <CAP-5=fUMwOb6Gj+5DOu9-yNmthDz5ghAqrzmZ4ACX0g+9WB59w@mail.gmail.com>

Hi Ian,

On Thu, Nov 12, 2026 at 11:07:55PM -0800, Ian Rogers wrote:

[...]

> Hi Leo,
> 
> After commit 9648f9fc3525 ("perf cs-etm: Synthesize exception entries
> separately from branches") in perf-tools-next, perf's build-test
> (`make -C tools/perf O=/tmp/build CORESIGHT=1`, i.e. `make_with_coresight_O`)
> with GCC 15.2.0 (`gcc (Debian 15.2.0-14) 15.2.0`, `-O3`) fails with:
> 
>   In function ‘cs_etm__t32_instr_size’,
>       inlined from ‘cs_etm__instr_size’ at util/cs-etm.c:1390:10,
>       inlined from ‘cs_etm__copy_insn’ at util/cs-etm.c:1572:21:
>   util/cs-etm.c:1381:28: error: ‘instrBytes’ may be used uninitialized
>  [-Werror=maybe-uninitialized]
>    1381 |         return ((instrBytes[1] & 0xF8) >= 0xE8) ? 4 : 2;
>             |                  ~~~~~~~~~~^~~
>   util/cs-etm.c: In function ‘cs_etm__copy_insn’:
>   util/cs-etm.c:1372:12: note: ‘instrBytes’ declared here
>    1372 |         u8 instrBytes[2];
>             |            ^~~~~~~~~~
> 
> The uninitialized `instrBytes` in cs_etm__t32_instr_size() is actually
> pre-existing from commit a7ee4d625ede ("perf cs-etm: Support for ARM
> A32/T32 instruction sets in CoreSight trace"): cs_etm__frontend_mem_access()
> (via __cs_etm__mem_access()) can return 0 without writing to instrBytes
> when thread__find_map(), map__dso(), or dso__data_read_offset() fails.
> The changes around cs_etm__copy_insn() in this patch just shifted GCC's
> -O3 inlining enough for it to inline __cs_etm__mem_access() and spot the
> uninitialized read of instrBytes[1].
> 
> Zero-initializing `u8 instrBytes[2] = {};` (similar to instr16/instr32 in
> cs_etm__is_svc_instr()) or checking that cs_etm__frontend_mem_access() read
> ARRAY_SIZE(instrBytes) bytes before inspecting instrBytes[1] should fix it.

See the series to fix the issue:
https://lore.kernel.org/linux-perf-users/20261113-perf_fix_gcc15_failure-v1-0-eae592c5ff64@arm.com/T/#mcbc1b4ce7284c9575b273d504354ac733bcf39aa

Thanks for sharing the log and analysis.

  reply	other threads:[~2026-11-13 10:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 15:13 [PATCH v3 00/14] perf cs-etm: Fix bogus branch samples on exceptions Leo Yan
2026-10-30 15:13 ` [PATCH v3 01/14] perf sample: Allow decoders to supply branch return addresses Leo Yan
2026-10-30 15:13 ` [PATCH v3 02/14] perf intel-pt: Preserve return addresses for asynchronous branches Leo Yan
2026-10-30 15:13 ` [PATCH v3 03/14] perf cs-etm: Break branch history when instruction memory is unavailable Leo Yan
2026-10-30 15:13 ` [PATCH v3 04/14] perf cs-etm: Centralize packet ISA initialization Leo Yan
2026-10-30 15:13 ` [PATCH v3 05/14] perf cs-etm: Use the recorded instruction size for A32 and A64 Leo Yan
2026-10-30 15:13 ` [PATCH v3 06/14] perf cs-etm: Mark branches that were not taken Leo Yan
2026-10-30 15:13 ` [PATCH v3 07/14] perf cs-etm: Factor out final instruction sample synthesis Leo Yan
2026-10-30 15:13 ` [PATCH v3 08/14] perf cs-etm: Centralize branch sample synthesis checks Leo Yan
2026-10-30 15:13 ` [PATCH v3 09/14] perf cs-etm: Classify exception calls using the exception packet Leo Yan
2026-10-30 15:13 ` [PATCH v3 10/14] perf cs-etm: Synthesize exception entries separately from branches Leo Yan
2026-11-13  7:07   ` Ian Rogers
2026-11-13 10:59     ` Leo Yan [this message]
2026-10-30 15:13 ` [PATCH v3 11/14] perf tests: Check CoreSight IRQ entry and exit Leo Yan
2026-10-30 15:13 ` [PATCH v3 12/14] perf tests: Check CoreSight syscall " Leo Yan
2026-10-30 15:13 ` [PATCH v3 13/14] perf tests: Check CoreSight abort " Leo Yan
2026-10-30 15:13 ` [PATCH v3 14/14] perf tests: Check CoreSight emulated instruction " Leo Yan
2026-11-02 10:30 ` [PATCH v3 00/14] perf cs-etm: Fix bogus branch samples on exceptions James Clark
2026-11-06 21:32 ` Namhyung Kim

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=20261113105928.GN9176@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=aaupov@fb.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mike.leach@arm.com \
    --cc=namhyung@kernel.org \
    --cc=smahar@meta.com \
    --cc=suzuki.poulose@arm.com \
    /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

all inboxes | Powered by JetHome®