From nobody Mon Feb 9 07:39:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8007CEB64DA for ; Thu, 22 Jun 2023 10:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbjFVKzh (ORCPT ); Thu, 22 Jun 2023 06:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbjFVKzV (ORCPT ); Thu, 22 Jun 2023 06:55:21 -0400 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C56D1FC1 for ; Thu, 22 Jun 2023 03:55:18 -0700 (PDT) Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4Qmy1z2rnNz9sRn; Thu, 22 Jun 2023 12:55:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V2sTXnLGuWS1; Thu, 22 Jun 2023 12:55:03 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Qmy1v6Sspz9sRs; Thu, 22 Jun 2023 12:54:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DA12C8B763; Thu, 22 Jun 2023 12:54:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Xnxzm3g9CkGg; Thu, 22 Jun 2023 12:54:59 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.232.14]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3732F8B77C; Thu, 22 Jun 2023 12:54:59 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.16.1) with ESMTPS id 35MAssr72382583 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 22 Jun 2023 12:54:54 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.17.1/8.17.1/Submit) id 35MAssQM2382582; Thu, 22 Jun 2023 12:54:54 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Michael Ellerman , Nicholas Piggin , Josh Poimboeuf , Peter Zijlstra , Sathvika Vasireddy , Naveen N Rao Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 08/14] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc Date: Thu, 22 Jun 2023 12:54:30 +0200 Message-Id: <85a0e5fde0c36219332a74871ef4699008ec7edb.1687430631.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1687431272; l=2995; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=oDQ+yu2c80GlkN1xTGQWllMn8lTFly+buQPlZ9vYv6s=; b=6vfsq3Ai6s9XeMQ1kxtJ6r3TF2kx85UhChrMJNVC4mdQ8sLprQlge6yFmcRWx40NJePTmHT3I XfRCVc4YhaAB1BLREE9Z8hKbzZY5Mz6XVdJI3m/cPrUXr8TtPxzAFbs X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" struct jump_entry { s32 code; s32 target; long key; }; It means that the size of the third argument depends on whether we are building a 32 bits or 64 bits kernel. Therefore JUMP_ENTRY_SIZE must depend on elf_class_addrsize(elf). To allow that, entries[] table must be initialised at runtime. This is easily done by moving it into its only user which is special_get_alts(). Signed-off-by: Christophe Leroy Acked-by: Peter Zijlstra (Intel) --- .../arch/powerpc/include/arch/special.h | 2 +- tools/objtool/special.c | 55 +++++++++---------- 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/tools/objtool/arch/powerpc/include/arch/special.h b/tools/objt= ool/arch/powerpc/include/arch/special.h index ffef9ada7133..ede05633c2e4 100644 --- a/tools/objtool/arch/powerpc/include/arch/special.h +++ b/tools/objtool/arch/powerpc/include/arch/special.h @@ -6,7 +6,7 @@ #define EX_ORIG_OFFSET 0 #define EX_NEW_OFFSET 4 =20 -#define JUMP_ENTRY_SIZE 16 +#define JUMP_ENTRY_SIZE (8 + elf_class_addrsize(elf)) /* 12 on PPC32, 16 o= n PPC64 */ #define JUMP_ORIG_OFFSET 0 #define JUMP_NEW_OFFSET 4 #define JUMP_KEY_OFFSET 8 diff --git a/tools/objtool/special.c b/tools/objtool/special.c index baa85c31526b..4015c1cd0fe1 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -26,34 +26,6 @@ struct special_entry { unsigned char key; /* jump_label key */ }; =20 -static const struct special_entry entries[] =3D { - { - .sec =3D ".altinstructions", - .group =3D true, - .size =3D ALT_ENTRY_SIZE, - .orig =3D ALT_ORIG_OFFSET, - .orig_len =3D ALT_ORIG_LEN_OFFSET, - .new =3D ALT_NEW_OFFSET, - .new_len =3D ALT_NEW_LEN_OFFSET, - .feature =3D ALT_FEATURE_OFFSET, - }, - { - .sec =3D "__jump_table", - .jump_or_nop =3D true, - .size =3D JUMP_ENTRY_SIZE, - .orig =3D JUMP_ORIG_OFFSET, - .new =3D JUMP_NEW_OFFSET, - .key =3D JUMP_KEY_OFFSET, - }, - { - .sec =3D "__ex_table", - .size =3D EX_ENTRY_SIZE, - .orig =3D EX_ORIG_OFFSET, - .new =3D EX_NEW_OFFSET, - }, - {}, -}; - void __weak arch_handle_alternative(unsigned short feature, struct special= _alt *alt) { } @@ -144,6 +116,33 @@ int special_get_alts(struct elf *elf, struct list_head= *alts) unsigned int nr_entries; struct special_alt *alt; int idx, ret; + const struct special_entry entries[] =3D { + { + .sec =3D ".altinstructions", + .group =3D true, + .size =3D ALT_ENTRY_SIZE, + .orig =3D ALT_ORIG_OFFSET, + .orig_len =3D ALT_ORIG_LEN_OFFSET, + .new =3D ALT_NEW_OFFSET, + .new_len =3D ALT_NEW_LEN_OFFSET, + .feature =3D ALT_FEATURE_OFFSET, + }, + { + .sec =3D "__jump_table", + .jump_or_nop =3D true, + .size =3D JUMP_ENTRY_SIZE, + .orig =3D JUMP_ORIG_OFFSET, + .new =3D JUMP_NEW_OFFSET, + .key =3D JUMP_KEY_OFFSET, + }, + { + .sec =3D "__ex_table", + .size =3D EX_ENTRY_SIZE, + .orig =3D EX_ORIG_OFFSET, + .new =3D EX_NEW_OFFSET, + }, + {}, + }; =20 INIT_LIST_HEAD(alts); =20 --=20 2.40.1