From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796232079; b=pVMavcY9NHA3HpVY/+YnCGtnL6JcOxwqraIhVIfUSNmTaGSDUL5SNJr7lV4HzRkeIOos yanAUcrOHyEIDWdRv7CHoh7LIPxETC7UxpbIjfeseIPuKIXiUjTtDjP8D7Ecx0mgJM3Id Qo/zaDLTzNyfEUzECSSapo0eVnla1eg7ftn2FvCtrJ1+D5+kGs6iEtgKIg2whPDPoxyS8 +EfXFkRKqG79nH2/Spuijqn2C7sOz0ix6mZLLlvunwdfA+ipjEL62BDncnk2Yfh0uJvPK Jyv0H4GzBUZVFm+3dHFdVQPCVggny6g7s/OW3MdwB6V+YIq5A+UXOfrt6pkH9WoSLvw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796232079; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=DPsB3VrtJ9qw4lADE5XIucdEhXonC/XYc5RDZoTF9DI=; b=GrdmEmsUKeGpgWP8RLriJ+cRq/wqnTpaxjeIfraanNNYfbxKgMHqfuDIBWv04b08+AaP 3rFZlsmd1Gal6CffiERTy2IjOhKlJ24B19VZ5hgeSQCeUhaV8yx2rrUH1JUtOgJKX+urG 8UGesfZHL2x6+79RS/FhnEmvkFhIonWbkRdnUhDdegorDwMahaUmos0U9u51jCXBJNiuk M7cZ2NsEl60KWezSs8CYWbLFyta9dEzvoGys1vzOA6VtYDITOvmy6JsF/1mr4ClGt7gJ7 mrgYykQQPzSbCPKOwRnVdXy/skFcA0bF69mHmT71vytUM3M/kKaeIqVA4Gka9q27MmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=rRIzwRtm; arc=none smtp.remote-ip=148.163.158.5 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA74C606A327 for ; Wed, 2 Dec 2026 17:21:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BA74C606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=rRIzwRtm Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2H4kGR3988990; Wed, 2 Dec 2026 17:21:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=DPsB3VrtJ9qw4lADE 5XIucdEhXonC/XYc5RDZoTF9DI=; b=rRIzwRtmKWHuG8mjY9+yi8R4cZphT4gCs 5N+CsfgTc1l6z95jZi9lM4SuXTmWFymkm3Y6eK0HVF340+mYdeh2NOe1HP7YtbtZ R360NtMXppyIzdCZ3G9CgzNbIye41fcp68D+8F11IpLHmB4W4EX0oa5sLSLRxmiu uHRgTMQXpy0dfbnvBHqvmZI7bxOqCeDp4A/oueeNWB7w3vPijDkvG44kCjFxH+ED ev7CNcZAWU9uNe4OPidwrPIUcVxE2Tyb51Ed/Vk2if51WS9e+lhbX7QB+tCH5mOK yndcNnlu/HyVzmlHKf4Xl3HUrHBUgOF47dfkvjacafrr9RFnS/ngQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7nchtvy3-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 17:21:07 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2H4G8w343374; Wed, 2 Dec 2026 17:21:07 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ja2uv4enk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 17:21:07 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B2HL0Eu52691258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Dec 2026 17:21:00 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64FDE2004B; Wed, 2 Dec 2026 17:21:00 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 410DD20040; Wed, 2 Dec 2026 17:20:56 +0000 (GMT) Received: from localhost.localdomain (unknown [9.39.21.253]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Dec 2026 17:20:56 +0000 (GMT) From: Athira Rajeev To: acme@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, james.clark@linaro.org, tmricht@linux.ibm.com, maddy@linux.ibm.com, irogers@google.com, namhyung@kernel.org, bradley.morgan@linux.dev Cc: linux-perf-users@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, atrajeev@linux.ibm.com, hbathini@linux.vnet.ibm.com, tejas05@linux.ibm.com, tshah@linux.ibm.com, Narendra Nalli , Vijay Puliyala , sashiko-bot@kernel.org Subject: [PATCH V3 2/2] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Date: Wed, 2 Dec 2026 22:50:48 +0530 Message-Id: <20261202172048.99786-2-atrajeev@linux.ibm.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20261202172048.99786-1-atrajeev@linux.ibm.com> References: <20261202172048.99786-1-atrajeev@linux.ibm.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA2OCBTYWx0ZWRfX+OsRYHK0/cBc aMxPQ3SLjTU71NegR4bAmhLKGNOxtiqr20Lv7g3gwp6V3AUOa93fLVC3LTEnJzsDmHivIbyoJH8 XrEX+i64Gd8Ky8rm3HCWGAk1uvcRIGuoOHfKEseG9JPMEISH8RQLGHIRrTs2Wc3YJAEwuKR57Vh B6bjtp6eHs8rmgePTmUD5BBfCUEBD1Vv50ojL3MncgqdcvvAWItGmZAyXou2gnfi8SNM2sIb9GS bvroStEh26rtSG6OLu79Yo3vYn47LmNypOPKN1x+o+2eG3DwkJ3N2zrku299ZnbWh7Pabs+D6y0 X/Xb4lKkt/z4T3dwkw+n/grxS3RPzP81LQ+23kcNrspPSTFq+2s2KU/tC+cZiVUOkQ19IuECFGK VQas623wDFVh5Rd/XkBgCZc+Z9WhDHiooIY8v3DFdl5Wnl8i5wKbAyoa6KfPHCZF/UKGPeBheZD ItA4KILmgNdzC01CjRA== X-Authority-Analysis: v=2.4 cv=Tt5zFzXh c=1 sm=1 tr=0 ts=6b105384 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=VRQZmECyoGWey3ygjYwA:9 X-Proofpoint-ORIG-GUID: fCfrF66tvRLj2uFJqlPvP6eb1A7QJiR9 X-Proofpoint-GUID: Zx7MatgOrDJUbgf1Wu_EiQiB_bff9Rj4 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA2OCBTYWx0ZWRfX9+3Y3GhxiniJ 95YV5GMHcGd/VBp6EvC2LQgEFM2rHvpdxp7D6HWSTBBGJ3sZ77/s/y5l9P7RlM56iUKiVzApeXN xVrZfrxDdEbcQtb38Sd4Bc04HPPrRXQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_04,2026-12-02_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 spamscore=0 bulkscore=0 clxscore=1015 adultscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020068 Power10 introduces prefixed instructions that are 8 bytes wide. objdump emits these as two lines: the first carries both the raw bytes and the mnemonic, while the second carries only the raw bytes of the second word with no mnemonic: 1020900c: 0b 00 10 06 pla r31,757280 # 102c1e2c 10209010: 20 8e e0 3b disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic portion of the line. disasm_line__parse() returns -1 when the name string is empty, which causes disasm_line__new() to return NULL, which causes symbol__parse_objdump_line() to return -1, which immediately breaks the objdump output parsing loop in symbol__disassemble_objdump(). The result is that annotation of any function containing a prefixed instruction stops at the continuation word and all subsequent instructions in the function are lost. Fix this by treating an empty mnemonic (after the 11-byte raw hex prefix) as a valid case in disasm_line__parse_powerpc(): skip the call to disasm_line__parse(), set the instruction name to an empty heap-allocated string, and point operands at the empty end of the line so printing callbacks can safely render "%s". In check_ppc_insn(), skip decoding raw_insn when dl->ins.name is empty and dl->ops.raw is non-NULL (indicating an objdump continuation line rather than a raw disassembly line), so the 32-bit suffix word is not misclassified as a standalone instruction. Also free the previous empty dl->ins.name when check_ppc_insn() replaces it in raw mode. Fixes: 4c3f09e35ca9 ("perf annotate: Return errors from disasm_line__parse_powerpc()") Reported-by: Narendra Nalli Reported-by: Vijay Puliyala Reported-by: sashiko-bot@kernel.org Signed-off-by: Athira Rajeev --- Changelog: V2 -> V3: Addressed review comments from Sashiko: - Avoid out-of-bounds read past dl->al.line when strlen(name_raw_insn) < RAW_BYTES. - Skip opcode classification in check_ppc_insn() for objdump continuation lines (where dl->ins.name is empty and dl->ops.raw != NULL). - Include in annotate-powerpc.c, check strdup() return values, and free old dl->ins.name across all replacement branches. - Add Fixes: tag. V1 -> V2: Addressed review comment from Sashiko. Set the operand value and also free the instruction name before picking from opcode value .../util/annotate-arch/annotate-powerpc.c | 37 +++++++++++++++++-- tools/perf/util/disasm.c | 26 ++++++++++++- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/annotate-arch/annotate-powerpc.c b/tools/perf/util/annotate-arch/annotate-powerpc.c index 00b93296fc94..c4cb19f99849 100644 --- a/tools/perf/util/annotate-arch/annotate-powerpc.c +++ b/tools/perf/util/annotate-arch/annotate-powerpc.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include @@ -289,6 +290,13 @@ const struct ins_ops *check_ppc_insn(struct disasm_line *dl) }; char name_insn[32]; + /* + * An empty instruction name with non-NULL raw operands comes from + * an objdump Power10 prefixed instruction continuation word; do not decode it. + */ + if (!strlen(dl->ins.name) && dl->ops.raw) + return NULL; + /* * Instructions with opcode 32 to 63 are memory * instructions in powerpc @@ -299,16 +307,28 @@ const struct ins_ops *check_ppc_insn(struct disasm_line *dl) * opcode to be used in insn-stat */ if (!strlen(dl->ins.name)) { + char *name; + sprintf(name_insn, "%d", opcode); - dl->ins.name = strdup(name_insn); + name = strdup(name_insn); + if (name) { + free((void *)dl->ins.name); + dl->ins.name = name; + } } return &load_store_ops; } else if (opcode == 31) { /* Check for memory instructions with opcode 31 */ ret = bsearch(&mem_insns_31_opcode, ins_array, ARRAY_SIZE(ins_array), sizeof(ins_array[0]), cmp_offset); if (ret) { - if (!strlen(dl->ins.name)) - dl->ins.name = strdup(ret->name); + if (!strlen(dl->ins.name)) { + char *name = strdup(ret->name); + + if (name) { + free((void *)dl->ins.name); + dl->ins.name = name; + } + } return &load_store_ops; } else { mem_insns_31_opcode.value = PPC_22_30(raw_insn); @@ -324,8 +344,17 @@ const struct ins_ops *check_ppc_insn(struct disasm_line *dl) mem_insns_31_opcode.value = opcode; ret = bsearch(&mem_insns_31_opcode, arithmetic_two_ops, ARRAY_SIZE(arithmetic_two_ops), sizeof(arithmetic_two_ops[0]), cmp_offset); - if (ret != NULL) + if (ret != NULL) { + if (!strlen(dl->ins.name)) { + char *name = strdup(ret->name); + + if (name) { + free((void *)dl->ins.name); + dl->ins.name = name; + } + } return &arithmetic_ops; + } } return NULL; diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 169fc5acbfc5..724e819f9320 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -898,7 +898,7 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar const char **namep = &dl->ins.name; char **rawp = &dl->ops.raw; char *tmp_raw_insn, *name_raw_insn = skip_spaces(line); - char *name = skip_spaces(name_raw_insn + RAW_BYTES); + char *name; int disasm = 0; int ret = 0; @@ -909,7 +909,29 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar return -1; if (disasm) { - ret = disasm_line__parse(name, namep, rawp); + if (strlen(name_raw_insn) < RAW_BYTES) + return -1; + + name = skip_spaces(name_raw_insn + RAW_BYTES); + if (name[0] != '\0') { + ret = disasm_line__parse(name, namep, rawp); + } else { + /* + * Power10 prefixed instructions are 8 bytes and objdump emits + * the second word on its own line with raw bytes but no + * mnemonic, e.g.: + * 1020900c: 0b 00 10 06 pla r31,757280 + * 10209010: 20 8e e0 3b + * + * Treat a missing mnemonic as an empty instruction name with + * empty operands rather than a parse failure, so that parsing + * continues past it. + */ + *namep = strdup(""); + if (*namep == NULL) + return -1; + *rawp = name; /* the '\0' at the end of dl->al.line */ + } } else { /* * The name is freed in disasm_line__free() and may be replaced -- 2.52.0