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=1796215452; b=TZMg+3I60qxGuMaYPFNOAgysWKwO9a+v7whSiOhf6r478Y6ntWu/8alnnGea1TBvAeQG 4a7O7gkurU/eS+iRZdaDBVFwX4e1tnNCftjTF9OtIaCbJsTBETFYRUhQhcaE8RErTkDUR +1tnRhnga2u++FaINydMzSKoyb4o4UiIuq5XG7oMh3ara3rcZjC8r+JJV8+SRb4TqE3NW Z3Za6QtmqDcK2MR/a6oa/6y/QlgpjRQNtsQvmtqp1zu/F9seiGB+MR6AcRiBcXaD4t4Da 2iD++b7q7HfzJx83zSsyiNDjHYNXhiKqHGvo9bvubo239nJbo9WJsPAYStxLJ7CZUhA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796215452; 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-Info:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-ORIG-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=BuYDMtRutJNCy6yTx22HznRhYe+P6Ia9dnYHMMbUrzo=; b=0fZLrt916+oo+h6GVyINfFH2uCFzQiWSd9Th+SiVBI7FZbxAL3ajbd6a2b7shG6zqEIE nqh6kJrwsCLlTVQ8uwwyak3+T4LmmiQEUFwhhOPcKJesFZ7UWJ1zyIlTC9zlHHrfpHHZZ n9NFB55bXk9PiXqXBsOPYPiwQbwUbpfSkrR/pUkzRgBCnRTlcbkrOg57mQZo6z9XjsxvK fq+JBZUEuNOPREiZZn1ftLyaLd/KKRBM2Deq2D0DOgPiUffB+Kcwz3S6PuPQJ8u8lAW4/ 3zR7P2yNwKwR4YRonbRjnt/0KSyHOGxNabxsoiD6cdpfs+gxuvAW8IZ/9sT3fuj+mPQ== 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=FIQ7eRXQ; 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 5DE43606A31A for ; Wed, 2 Dec 2026 12:44:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5DE43606A31A 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=FIQ7eRXQ Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2AM4nN197532; Wed, 2 Dec 2026 12:43:58 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=BuYDMtRutJNCy6yTx 22HznRhYe+P6Ia9dnYHMMbUrzo=; b=FIQ7eRXQi+SCdypL4CJli3OKFM2lsNC5h wzXCmUva3MeDGDfoUG70yPuXAGb0+m9KBmICg8HLt6t+8FiACijURAJDRsBX1tdS uDFkp316QWl1QFMspfvAXNca0HUMMZSwXHvGVt2WQ5BZ9LOJUwzMMrmOy40xaA1+ liFJK1Ujp6IJiHXXGXKIS98av7jxuXJ/FF8jFKY656M7zXV2nwalMetOA897nQcT 4IxWrwN/DFGBbehW0Tk+2ZSPHtkFAT7LnJ2MZpgvAu5m7+t18YwHBgUf/FGkpAJq TPxAh4aIVt7zl75wBEIJqMsYv8reojgWycJzKoS4rI3SR9G7YXoOg== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7mckhx95-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 12:43:58 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2BSxbK2799670; Wed, 2 Dec 2026 12:43:57 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4j9v5w5173-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 12:43:57 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B2ChoIl24511090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Dec 2026 12:43:50 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5629C20040; Wed, 2 Dec 2026 12:43:50 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6008220049; Wed, 2 Dec 2026 12:43:46 +0000 (GMT) Received: from localhost.localdomain (unknown [9.39.21.253]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Dec 2026 12:43:46 +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 Subject: [PATCH V2 2/2] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Date: Wed, 2 Dec 2026 18:13:37 +0530 Message-Id: <20261202124337.10434-2-atrajeev@linux.ibm.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20261202124337.10434-1-atrajeev@linux.ibm.com> References: <20261202124337.10434-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-Info: AW1haW4tMjYxMjAyMDA1MCBTYWx0ZWRfX3PUHZN3jSaLJ o4KG/9tOQ4hQoZJyHnqkbpRd/J0QwCjoUQB62CaQRzMIO761zECOj368l3JwXDSYVorduiRVnCd vjpbnBnlAI8MieASs5pH3uj+JYMK8lY= X-Authority-Analysis: v=2.4 cv=MtfHeGae c=1 sm=1 tr=0 ts=6b10128e cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=DoC30laBzZxZZUyvvWwA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA1MCBTYWx0ZWRfX87LeyOA+cCNH AD7bR3DeBhYRGpHvv+9T7PQiv97UKkyVvqdpV47XIlGfLBKTW1xZf4d2XIrygEojN0Wre/d9CYP TP2Ru9xd1zy6WpcMnhyR6qne6VQBkE7r8VibTuloCT2oRocFEy41Oq4N/eslyc0bAgs7oy/8pVg gbPlzdZq8EHp9K6ch3jkPhWBNslWx1Ign+jTcpPnlKmC5sbK7CKtQTSfoKeDSB7JTvNreC38fDW CUv90vwOeyEh1Y2iPOygmVU53y1cAbxdJEbiSK6hR0/M1hTlVzPcGcN+0x3l9LSCF4RsIODz+Sm D4WPtJy7qW7WVGNKtiZ100TzXK1FO/1AzKXJkn3cvo5SY+3GH8TrclWcHeyCgYVZzQR6Swh0drJ mYQeggWd2JYwnFtdKClOQFELWk7mjBvH962YXseEVtUqvxDCzETEA/61jQ9uRdxiVbNkjmn8kgH SKYlJBQy9e8vEoPLmMQ== X-Proofpoint-GUID: Sh3pHCZqz2fVgpxFe8rNcMv8wAkihcRX X-Proofpoint-ORIG-GUID: UcBU171IyVvDfMXq8apm-UWaM80-gz3q 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_02,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020050 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 as a valid case in disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and set the instruction name to an empty heap-allocated string instead, allowing parsing to continue to the next line. Also point the operands at the (empty) end of the line, since disasm_line__parse() is what normally sets them and the instruction printing callbacks print them with "%s". check_ppc_insn() names raw instructions from their opcode when the name is empty, and so replaces the empty string allocated above. Free it first, to not leak it. Reported-by: Narendra Nalli Reported-by: Vijay Puliyala Signed-off-by: Athira Rajeev --- Changelog: V1 -> V2: Addressed review comment from Sashiko. Set the operand value and also free the instruction name before picking from opcode value tools/perf/util/annotate-arch/annotate-powerpc.c | 5 ++++- tools/perf/util/disasm.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/annotate-arch/annotate-powerpc.c b/tools/perf/util/annotate-arch/annotate-powerpc.c index 00b93296fc94..896c74a349f0 100644 --- a/tools/perf/util/annotate-arch/annotate-powerpc.c +++ b/tools/perf/util/annotate-arch/annotate-powerpc.c @@ -300,6 +300,7 @@ const struct ins_ops *check_ppc_insn(struct disasm_line *dl) */ if (!strlen(dl->ins.name)) { sprintf(name_insn, "%d", opcode); + free((void *)dl->ins.name); dl->ins.name = strdup(name_insn); } return &load_store_ops; @@ -307,8 +308,10 @@ const struct ins_ops *check_ppc_insn(struct disasm_line *dl) /* 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)) + if (!strlen(dl->ins.name)) { + free((void *)dl->ins.name); dl->ins.name = strdup(ret->name); + } return &load_store_ops; } else { mem_insns_31_opcode.value = PPC_22_30(raw_insn); diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index a1787a9c4bfd..32e91b95ee72 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -908,16 +908,28 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar if (name_raw_insn[0] == '\0') return -1; - if (disasm) { + if (disasm && name[0] != '\0') { ret = disasm_line__parse(name, namep, rawp); } else { /* * The name is freed in disasm_line__free() and may be replaced * by check_ppc_insn(), so it must be heap allocated. + * + * 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; + if (disasm) + *rawp = name; /* the '\0' at the end of dl->al.line */ } tmp_raw_insn = strndup(name_raw_insn, 11); -- 2.52.0