From nobody Tue Dec 2 02:30:41 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 E11D33A1D02 for ; Wed, 19 Nov 2025 14:34:12 +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=1763562855; cv=none; b=IpUeMQnWWZnkI27M9qbKAKUrUGm8Wd6TOHrImBs3AlhYG3NtlB8Uz67jVY4gjS6Q0B/fphVgRF9hJhqSTXBHH9A2PjQvm2agpNlap0oahmLj1bur1wWxzbKq/4CjoDGLoxbi5Nx4zDw9QeiPSYE+OnWsGAffMGgT+XLu5SS/UNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763562855; c=relaxed/simple; bh=j0UFQe/zatzGyV/XI0TBtLjfIPSfPmjVlSCrJkq8fwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fo6y5uZR+qsLgjsMyzFjI/IuBxonujPDBqT+bBjhLCJsV6t8ahl6k5CxKtwyb4HWfaZLWBiId/pefiUBD25YGre7oSeveQ21jThPRRHzmG2c7jpQ1Yl8aE9KFdbznCWMTL7EiMqVGZhnTF5RhYf4guTdH0MW511yEeP2TThQWCw= 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=AHqWv1zz; 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="AHqWv1zz" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AJER6uX000805; Wed, 19 Nov 2025 14:33:42 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=/kuhG To8sDWyQRCvOpw7TWxtCfp+nNZhJlYPvbbuVwk=; b=AHqWv1zzDmm3szhou9LVL rk3GS0UowtmyLZPNv+0wn5L6qErj0rzs+dq4vtkzWqDDHlI3KtsvhtuEAKDd7DU5 J0uAiRi35iNgKfFI/uSl+XC/87LSNCrxKOZsDil9EXVuYbee2bPnMqIMctILNVdh miRMH1FYdDNlrW5EzBs2vVBkqQ434d7L4vzr2Qd1r0uDGx0qUkuEngVgK37bD3Is 9PjZFJwr8r8zW2dgO60q8M174V/R0YealQlJ+VvO+XQ65rem5lrwpAWjnEJSrsod jHg6uzUjzGP3NVDGDYlObssxLfxAz9F50Y3B1rv4a0I9pAjoL20+IYa40DSLtcg1 g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aejbbfa0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 14:33:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 5AJD692w002638; Wed, 19 Nov 2025 14:33:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyans4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Nov 2025 14:33:41 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 5AJEWnnw022495; Wed, 19 Nov 2025 14:33:40 GMT Received: from laptop-dell-latitude7430.nl.oracle.com (dhcp-10-154-160-110.vpn.oracle.com [10.154.160.110]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 4aefyanr5p-28; Wed, 19 Nov 2025 14:33:40 +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 v5 27/30] objtool: Improve naming of group alternatives Date: Wed, 19 Nov 2025 15:32:44 +0100 Message-ID: <20251119143247.3944213-28-alexandre.chartre@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20251119143247.3944213-1-alexandre.chartre@oracle.com> References: <20251119143247.3944213-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-19_04,2025-11-18_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2510240000 definitions=main-2511190116 X-Authority-Analysis: v=2.4 cv=BoqQAIX5 c=1 sm=1 tr=0 ts=691dd546 b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=NTSbjWyVqMqnbLcvqKcA:9 X-Proofpoint-ORIG-GUID: wnMqkxdbzYDv-QU3V9o5J55GoDT9LN4p X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfX51tVoCU2vzRr /i2tI+VI5IiterRMQl4uHQuPUi/RLfZWIGjMeyOuFvfDeCJp9TlCAvHGTJfvDiMeTXzyuFgRVpF NI9jzCvFZfHyj1qSZppNaGkOwB4ElC45YtDkgY57axug6KUKGioD3vjlO5qJ0Zx9qrhovE1XqMk VCYWnIuZ8GDBxEX2dRmtucFtb+tvF9q2ND/REBMMfC3Cii0p1R4mTZlLJ8Dfd9FmPbN5oyXmgBH QfNVr2+fycTu0+JtFQCFDRsAzSZcL/OL/1D6JySLP6TnLmNhZz1xfM/zDhSNurgGhkCWtV0dyEc /z9WRi7U6P/q4OXQidvWAc6YLU/k+KntgfwBmjH9s96RT6BKsxftqJXcqzk0OwH9b7/4Y14Pv7I 9WH0aV44CDwxuteoLgKjqqXb3XOdMQ== X-Proofpoint-GUID: wnMqkxdbzYDv-QU3V9o5J55GoDT9LN4p Content-Type: text/plain; charset="utf-8" Improve the naming of group alternatives by showing the feature name and flags used by the alternative. Signed-off-by: Alexandre Chartre --- tools/objtool/disas.c | 58 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c index f8917c8405d32..731c4495b53c7 100644 --- a/tools/objtool/disas.c +++ b/tools/objtool/disas.c @@ -9,6 +9,7 @@ #include #include #include +#include #include =20 #include @@ -60,6 +61,21 @@ struct disas_alt { #define DALT_GROUP(dalt) (DALT_INSN(dalt)->alt_group) #define DALT_ALTID(dalt) ((dalt)->orig_insn->offset) =20 +#define ALT_FLAGS_SHIFT 16 +#define ALT_FLAG_NOT (1 << 0) +#define ALT_FLAG_DIRECT_CALL (1 << 1) +#define ALT_FEATURE_MASK ((1 << ALT_FLAGS_SHIFT) - 1) + +static int alt_feature(unsigned int ft_flags) +{ + return (ft_flags & ALT_FEATURE_MASK); +} + +static int alt_flags(unsigned int ft_flags) +{ + return (ft_flags >> ALT_FLAGS_SHIFT); +} + /* * Wrapper around asprintf() to allocate and format a string. * Return the allocated string or NULL on error. @@ -635,7 +651,12 @@ const char *disas_alt_type_name(struct instruction *in= sn) */ char *disas_alt_name(struct alternative *alt) { + char pfx[4] =3D { 0 }; char *str =3D NULL; + const char *name; + int feature; + int flags; + int num; =20 switch (alt->type) { =20 @@ -649,13 +670,37 @@ char *disas_alt_name(struct alternative *alt) =20 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. + * This is a non-default group alternative. Create a name + * based on the feature and flags associated with this + * alternative. Use either the feature name (it is available) + * or the feature number. And add a prefix to show the flags + * used. + * + * Prefix flags characters: + * + * '!' alternative used when feature not enabled + * '+' direct call alternative + * '?' unknown flag */ - asprintf(&str, "ALTERNATIVE %lx.%lx", - alt->insn->alt_group->orig_group->first_insn->offset, - alt->insn->alt_group->first_insn->offset); + + feature =3D alt->insn->alt_group->feature; + num =3D alt_feature(feature); + flags =3D alt_flags(feature); + str =3D pfx; + + if (flags & ~(ALT_FLAG_NOT | ALT_FLAG_DIRECT_CALL)) + *str++ =3D '?'; + if (flags & ALT_FLAG_DIRECT_CALL) + *str++ =3D '+'; + if (flags & ALT_FLAG_NOT) + *str++ =3D '!'; + + name =3D arch_cpu_feature_name(num); + if (!name) + str =3D strfmt("%sFEATURE 0x%X", pfx, num); + else + str =3D strfmt("%s%s", pfx, name); + break; } =20 @@ -892,6 +937,7 @@ static void *disas_alt(struct disas_context *dctx, WARN("%s has more alternatives than supported", alt_name); break; } + dalt =3D &dalts[i]; err =3D disas_alt_init(dalt, orig_insn, alt); if (err) { --=20 2.43.5