From nobody Wed Feb 5 16:03:46 2025 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F132A1DD9AB for ; Wed, 15 Jan 2025 22:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.235.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736981410; cv=none; b=mYShEj+HaHysCapmQa4N9GRilc7vbD9yXt/xjui6QgMtiYGfKix4eadEgK3EYgVjC3rbC2qugiXlmPerWpC+LtMeFOCNZ3zVmGMgmrPu9QvMsh7dplL4zbMH8dwW9T8gMlF0e5/dgyR8MZHHnQnzV/J6d1abxxbURIiPwrUpH8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736981410; c=relaxed/simple; bh=AtXgcZWCVAZG0ZZoJAL+afYs9xez+Wa0PGBF3/snVyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gawFDq119AiTg3oS7zADKeLajL+fZY+q5R2CiTx0Lfpf6du7tB2SCS61I9Le2vIXoHqWBfs61n2GRhIFKqWi51lymxG4/0kJbhZbtt9jDTzDtQIDneI3ISbZ1n3KglJN705h5NCf9OCCwOmHNYJctE/5qiLodxdveeRld0gXYOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.235.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4YYLcN15h3z9sSH; Wed, 15 Jan 2025 23:43:00 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PVQMaZJXyjmg; Wed, 15 Jan 2025 23:43:00 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4YYLcN0CBlz9sSC; Wed, 15 Jan 2025 23:43:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E884F8B77A; Wed, 15 Jan 2025 23:42:59 +0100 (CET) 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 Yuwf72boS7Cs; Wed, 15 Jan 2025 23:42:59 +0100 (CET) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.202.221]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 7D9BA8B774; Wed, 15 Jan 2025 23:42:57 +0100 (CET) From: Christophe Leroy To: Josh Poimboeuf , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Julien Thierry , Miroslav Benes , Raphael Gault , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Madhavan Srinivasan Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, llvm@lists.linux.dev Subject: [PATCH v5 04/15] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc Date: Wed, 15 Jan 2025 23:42:44 +0100 Message-ID: <908df81a11d6d48353a096256f2acdc1833f1cec.1736955567.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1736980963; l=3047; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=AtXgcZWCVAZG0ZZoJAL+afYs9xez+Wa0PGBF3/snVyw=; b=uFyZIHlQUiQ6PHRcVu0ANbt9OkrkHoVXRQu5q7KeplRbinQ0BEFg6fJwnxZNzWZt8ZPNnVXvU 8F8ARmg4IRNBHbCiTjUe3qAJW26UH3ogb/rWzzIfr8VlON8Z0x3X9fq X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable 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..b17802dcf436 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_addr_size(elf)) /* 12 on PPC32, 16 on PPC= 64 */ #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 097a69db82a0..7780ed8a084a 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.47.0