From nobody Tue Dec 2 02:04:15 2025 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A5FF342145 for ; Fri, 21 Nov 2025 09:54:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.177.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718859; cv=none; b=JLLNefBabB1ZRxtc2+MMes/2PVVjUweBYtM6f2kurkJupDKI7UmGXgKLcqoz5gOPjfbgYKiDVfQNbSeJMwfRMVOcLmsmd3n03FdunG+KDcqz4URJkF2Q0LAUj0vKeJkVgoDwoNcNaxyHIonommoyM5PdKrKMxm5I02zWb+cSDbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718859; c=relaxed/simple; bh=4r2fnDbYLsWGf8TBITmoF2L6L72mfBIVJdl15PRCAQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t9eYoIpTK2fHwQOqcZvlXR7JLQSSl0OmjjgFTyQhDhF/+AV7WOI//cIuFwXBphjMSKcNXRwkEFhXU576Qt2VqpM4VAEwwoxgHif9j2+sEnNoFC90yPdg+b4z5gbkL3PL4l8PT122ba7+ahlY4k5pHrMg1Lpdr44iP5vyTlkPnKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=qvA1/kzj; arc=none smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="qvA1/kzj" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL1v4aD001757; Fri, 21 Nov 2025 09:54:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2025-04-25; bh=WAU7Y N4+oqekL6Xpra6xul3Ker5oQk+wV5NYbPpSYfs=; b=qvA1/kzjomD2Ry2A8ZFKO djEPSkyovVn6cA9L9HNuICdqvGqu3+OaTMGJzv3ZDEI00K0kw/rgHQh9RC1ykzSK RD9XEhWR1Tjw4bpz147R1nUaMENIHPTf8iTOazXQA9TV18iYhQSpF9Z3tC3/z4mB ZcS287Qf39g2zLxgQs+P3dN+fMSmnb0tkD5yIHRhE+44mkZb0l1Bi3r9UTeJx+gD C+oxK1BHrIpxA2qAKrhAW73Abyi2Xn1GjgKlmR8fL+BDELTbribTkAOr0O1EPm0U umY1B8I9ImWMbG6Y7PTD6qCq4T7DVONqhVesA8useX6VRPjNQdkcCQhhv29VTRRi w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aej90ax08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:54:10 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL71lif004488; Fri, 21 Nov 2025 09:54:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyd4uqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:54:09 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AL9rgUW021648; Fri, 21 Nov 2025 09:54:09 GMT Received: from laptop-dell-latitude7430.nl.oracle.com (dhcp-10-154-175-150.vpn.oracle.com [10.154.175.150]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4aefyd4ub2-15; Fri, 21 Nov 2025 09:54:08 +0000 From: Alexandre Chartre To: linux-kernel@vger.kernel.org, mingo@kernel.org, jpoimboe@kernel.org, peterz@infradead.org, david.laight.linux@gmail.com Cc: alexandre.chartre@oracle.com Subject: [PATCH v6 14/30] objtool: Add functions to better name alternatives Date: Fri, 21 Nov 2025 10:53:24 +0100 Message-ID: <20251121095340.464045-15-alexandre.chartre@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251121095340.464045-1-alexandre.chartre@oracle.com> References: <20251121095340.464045-1-alexandre.chartre@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-21_03,2025-11-20_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 mlxscore=0 bulkscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511210075 X-Authority-Analysis: v=2.4 cv=OMAqHCaB c=1 sm=1 tr=0 ts=692036c2 cx=c_pps a=XiAAW1AwiKB2Y8Wsi+sD2Q==:117 a=XiAAW1AwiKB2Y8Wsi+sD2Q==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=20KFwNOVAAAA:8 a=ejOSxiM7Qr7sFksKtvQA:9 X-Proofpoint-ORIG-GUID: 1SDRpGshSggyml6Jk47Wi5e7flmuFoEn X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMSBTYWx0ZWRfX75J84tXDoJbE mntGQCriBUIfVcXxH1UihsGycN6CcWJqfZ9/k5hx/enevKKfogaXjWBoPUOsSple8qYaxkvVOI0 IWrRVa0cVgTZ4CPrqkNF+rVUM9JlXCMklyL8LHIuNddOkkABnYMrFheRqq/CadTyBEDBrdEZ1sd +gOM6vVh2K2lhcKC8VIGNpdevuaDyB6yzTW4/ljK2ymfzVXbtRcFAK4ZZY326PXTj8wP3E+4tQM 32ah65k1RPksIFVU4RTfcgphiKDs7i1oYiGI8mJ8BwY6AVaqWmCjGfGE4HK+/Xo3ed7D3KUDP2k DrJ+Arg8aJNN+3Wo8dPDUJgfMWo6w6XvPy65a4eUhOJhCV0qlQlLPF30D5GlQkT5nf2PsypqWBj tifcK55ldQaP71M6TNEF8pcF2MDMuA== X-Proofpoint-GUID: 1SDRpGshSggyml6Jk47Wi5e7flmuFoEn Content-Type: text/plain; charset="utf-8" Add the disas_alt_name() and disas_alt_type_name() to provide a name and a type name for an alternative. This will be used to better name alternatives when tracing their execution. Signed-off-by: Alexandre Chartre --- tools/objtool/disas.c | 72 +++++++++++++++++++++++++++ tools/objtool/include/objtool/disas.h | 12 +++++ 2 files changed, 84 insertions(+) diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c index 0ca6e6c8559fd..b53be240825da 100644 --- a/tools/objtool/disas.c +++ b/tools/objtool/disas.c @@ -3,6 +3,8 @@ * Copyright (C) 2015-2017 Josh Poimboeuf */ =20 +#define _GNU_SOURCE + #include #include #include @@ -450,6 +452,76 @@ size_t disas_insn(struct disas_context *dctx, struct i= nstruction *insn) return disasm(insn->offset, &dctx->info); } =20 +/* + * Provide a name for the type of alternatives present at the + * specified instruction. + * + * An instruction can have alternatives with different types, for + * example alternative instructions and an exception table. In that + * case the name for the alternative instructions type is used. + * + * Return NULL if the instruction as no alternative. + */ +const char *disas_alt_type_name(struct instruction *insn) +{ + struct alternative *alt; + const char *name; + + name =3D NULL; + for (alt =3D insn->alts; alt; alt =3D alt->next) { + if (alt->type =3D=3D ALT_TYPE_INSTRUCTIONS) { + name =3D "alternative"; + break; + } + + switch (alt->type) { + case ALT_TYPE_EX_TABLE: + name =3D "ex_table"; + break; + case ALT_TYPE_JUMP_TABLE: + name =3D "jump_table"; + break; + default: + name =3D "unknown"; + break; + } + } + + return name; +} + +/* + * Provide a name for an alternative. + */ +char *disas_alt_name(struct alternative *alt) +{ + char *str =3D NULL; + + switch (alt->type) { + + case ALT_TYPE_EX_TABLE: + str =3D strdup("EXCEPTION"); + break; + + case ALT_TYPE_JUMP_TABLE: + str =3D strdup("JUMP"); + break; + + case ALT_TYPE_INSTRUCTIONS: + /* + * This is a non-default group alternative. Create a unique + * name using the offset of the first original and alternative + * instructions. + */ + asprintf(&str, "ALTERNATIVE %lx.%lx", + alt->insn->alt_group->orig_group->first_insn->offset, + alt->insn->alt_group->first_insn->offset); + break; + } + + return str; +} + /* * Disassemble a function. */ diff --git a/tools/objtool/include/objtool/disas.h b/tools/objtool/include/= objtool/disas.h index 5db75d06f2197..8959d4c455622 100644 --- a/tools/objtool/include/objtool/disas.h +++ b/tools/objtool/include/objtool/disas.h @@ -6,6 +6,7 @@ #ifndef _DISAS_H #define _DISAS_H =20 +struct alternative; struct disas_context; struct disassemble_info; =20 @@ -24,6 +25,8 @@ void disas_print_info(FILE *stream, struct instruction *i= nsn, int depth, void disas_print_insn(FILE *stream, struct disas_context *dctx, struct instruction *insn, int depth, const char *format, ...); +char *disas_alt_name(struct alternative *alt); +const char *disas_alt_type_name(struct instruction *insn); =20 #else /* DISAS */ =20 @@ -61,6 +64,15 @@ static inline void disas_print_info(FILE *stream, struct= instruction *insn, static inline void disas_print_insn(FILE *stream, struct disas_context *dc= tx, struct instruction *insn, int depth, const char *format, ...) {} +static inline char *disas_alt_name(struct alternative *alt) +{ + return NULL; +} + +static inline const char *disas_alt_type_name(struct instruction *insn) +{ + return NULL; +} =20 #endif /* DISAS */ =20 --=20 2.43.5