[PATCH v1 09/12] perf cs-etm: Fall back to the recorded instruction size on a failed read
Arnaldo Carvalho de Melo
acme at kernel.org
Fri Nov 13 07:05:50 PST 2026
From: Arnaldo Carvalho de Melo <acme at redhat.com>
cs_etm__t32_instr_size() reads the instruction bytes from the traced
program's memory to tell a 16-bit from a 32-bit T32 instruction, but it
ignores cs_etm__frontend_mem_access() failing, which happens when the
DSO or its debug data is missing, and then reads the uninitialized
buffer. GCC 16 warns about it and build-test fails with -Werror.
Use the instruction size recorded by the decoder, as the A32/A64 path
already does, when the read doesn't return the full two bytes.
Fixes: a7ee4d625ede4f62 ("perf cs-etm: Support for ARM A32/T32 instruction sets in CoreSight trace")
Cc: James Clark <james.clark at linaro.org>
Cc: Leo Yan <leo.yan at arm.com>
Cc: Mike Leach <mike.leach at arm.com>
Cc: Robert Walker <robert.walker at arm.com>
Cc: Suzuki K Poulose <suzuki.poulose at arm.com>
Cc: coresight at lists.linaro.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>
---
tools/perf/util/cs-etm.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 3e01b401ca6f3a08..5d53ed74ae8835a9 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -1370,9 +1370,12 @@ static inline int cs_etm__t32_instr_size(struct cs_etm_queue *etmq,
struct cs_etm_packet *packet, u64 addr)
{
u8 instrBytes[2];
+ u32 len;
- cs_etm__frontend_mem_access(etmq, tidq, packet, addr,
- ARRAY_SIZE(instrBytes), instrBytes);
+ len = cs_etm__frontend_mem_access(etmq, tidq, packet, addr,
+ ARRAY_SIZE(instrBytes), instrBytes);
+ if (len != ARRAY_SIZE(instrBytes))
+ return packet->last_instr_size;
/*
* T32 instruction size is indicated by bits[15:11] of the first
* 16-bit word of the instruction: 0b11101, 0b11110 and 0b11111
--
2.56.0
More information about the linux-arm-kernel
mailing list