From nobody Tue Dec 2 02:06:08 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 2001F341AC7 for ; Fri, 21 Nov 2025 09:54:15 +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=1763718856; cv=none; b=hOcaKeh6Ie9AP9zyYx2l+u/oWZ99VH9M8/M3UkfF5QbB7gbhp8zj17EgDdghXW+ciB0woV5z9RF05FqhMiT1+mdgksy9t+zaH2SvifzTuR9uzsOPtBSMQc1SLKzzUHvcJxb5tcZkc8B9ctYRe4tMaH72j5E1CcKmxvlB6Pzm1vI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763718856; c=relaxed/simple; bh=C5sbEHKn6jcm4a+ljXx4lv7bk1N4cK2tB9CmkF4/AxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EChTvRFJomVUsLNCEBeW92htx2lB8NF2XWLZSjKrdY66lmMNx3eK8HL1NO1xgsGns6RVGxCZDXYtOmJ7M5PQ5dvqcRa0SqFj3QMDRrUNygdc0uiK0Ljy9VpwPCIxMnYe/FsSHXaagj1RrvO3R9+ow4Ba7NapCe3m6osKUDbdMpA= 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=gaMPQk+S; 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="gaMPQk+S" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5AL1uOCj030167; Fri, 21 Nov 2025 09:54:08 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=5BxR5 ActR3/A0/oKEIN3mwVnhgUTFl3OMMf2gKjR7Bs=; b=gaMPQk+SH3pddhFp3zoF7 vz8ReY+0R3b9VYmXfDaiWqi5Ds6Gtg2J3/ixeKHpfwGwBuNUhxcMbyiB2EKUkC1+ 8Z+II4C1yAFEDkNa3WtKVju/d/mnqL6S16pwPOXXKxWZ53zlkVl/qMJtEkHMSVfR 5iHfWZ4rGXadTiaa3vtsa1sApxEX7syf5Rk4Ic0SMGGDzw7O/m3Tn6ZLXWtIpNIo SJMCymvl4jTiDTC3XC7hsUDB2pd98R0/WxKJG4lRCfvBW0WsibgoyWvshPhsmotv HapKvX5kugwabhH5UsFFDZMf8aUV8sSFCtb/KxjYfSVIS/qaX4PCn4kmargrnLYN A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4aejbc2nee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:54:08 +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 5AL98xOn004483; Fri, 21 Nov 2025 09:54:07 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 4aefyd4up8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Nov 2025 09:54:07 +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 5AL9rgUU021648; Fri, 21 Nov 2025 09:54:07 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-14; Fri, 21 Nov 2025 09:54:07 +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 13/30] objtool: Identify the different types of alternatives Date: Fri, 21 Nov 2025 10:53:23 +0100 Message-ID: <20251121095340.464045-14-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-Proofpoint-GUID: KMp9_1-Nl64ikUPRN-ih_GEwbLkOhP7W X-Authority-Analysis: v=2.4 cv=JZyxbEKV c=1 sm=1 tr=0 ts=692036c0 cx=c_pps a=XiAAW1AwiKB2Y8Wsi+sD2Q==:117 a=XiAAW1AwiKB2Y8Wsi+sD2Q==:17 a=6UeiqGixMTsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=RDt3PK5YzZswrGw8on0A:9 X-Proofpoint-ORIG-GUID: KMp9_1-Nl64ikUPRN-ih_GEwbLkOhP7W X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTE1MDAzMiBTYWx0ZWRfX8Ua01Ko1sKzW KFfLJTxl608UVkL6unCJn7RUYh48WqvET9MwwFpyq/6rp0MQNSRf3O8xjVFXaDeWkgooVMrM1fz DwaXx78/++1nRjp+InSI+5jzk8P1+F5J+Hw5CRseTIIFIDD2DfGUlPLSmz2orfu5AqydSBit8Am 5RC7WR7j94n5g3M2KTAYKVdBMQJ5nKZJNfOMOv2iQ48f4n5bQdPwX9EgxMYUJz4uTo2HqZi2gnW osHdE4opdradaVlf8rdZNXLS5RLVBftalDm9kbk+/mJp5hVLN8GQdmJJxruIZe7n2im1XfnNKjR ix6iJt4e/e1umxkPLeqSMHcaPzAgIP8SeYi0Fz9rOz9/t/A//Ev9RobY9noiihEiIfiLRkoQoFq HocTIkYXjOW+Mp4oA55mXocoEpiL5g== Content-Type: text/plain; charset="utf-8" Alternative code, including jump table and exception table, is represented with the same struct alternative structure. But there is no obvious way to identify whether the struct represents alternative instructions, a jump table or an exception table. So add a type to struct alternative to clearly identify the type of alternative. Signed-off-by: Alexandre Chartre --- tools/objtool/check.c | 13 ++++++++----- tools/objtool/include/objtool/check.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e12dba144731f..20630df83e85c 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -27,11 +27,6 @@ #include #include =20 -struct alternative { - struct alternative *next; - struct instruction *insn; -}; - static unsigned long nr_cfi, nr_cfi_reused, nr_cfi_cache; =20 static struct cfi_init_state initial_func_cfi; @@ -1945,6 +1940,7 @@ static int add_special_section_alts(struct objtool_fi= le *file) struct list_head special_alts; struct instruction *orig_insn, *new_insn; struct special_alt *special_alt, *tmp; + enum alternative_type alt_type; struct alternative *alt; =20 if (special_get_alts(file->elf, &special_alts)) @@ -1980,9 +1976,15 @@ static int add_special_section_alts(struct objtool_f= ile *file) if (handle_group_alt(file, special_alt, orig_insn, &new_insn)) return -1; =20 + alt_type =3D ALT_TYPE_INSTRUCTIONS; + } else if (special_alt->jump_or_nop) { if (handle_jump_alt(file, special_alt, orig_insn, &new_insn)) return -1; + + alt_type =3D ALT_TYPE_JUMP_TABLE; + } else { + alt_type =3D ALT_TYPE_EX_TABLE; } =20 alt =3D calloc(1, sizeof(*alt)); @@ -1993,6 +1995,7 @@ static int add_special_section_alts(struct objtool_fi= le *file) =20 alt->insn =3D new_insn; alt->next =3D orig_insn->alts; + alt->type =3D alt_type; orig_insn->alts =3D alt; =20 list_del(&special_alt->list); diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/= objtool/check.h index fde958683485f..cbf4af58e29b2 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -38,6 +38,18 @@ struct alt_group { bool ignore; }; =20 +enum alternative_type { + ALT_TYPE_INSTRUCTIONS, + ALT_TYPE_JUMP_TABLE, + ALT_TYPE_EX_TABLE, +}; + +struct alternative { + struct alternative *next; + struct instruction *insn; + enum alternative_type type; +}; + #define INSN_CHUNK_BITS 8 #define INSN_CHUNK_SIZE (1 << INSN_CHUNK_BITS) #define INSN_CHUNK_MAX (INSN_CHUNK_SIZE - 1) --=20 2.43.5