From: Peter Zijlstra <peterz@infradead.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Sathvika Vasireddy <sv@linux.ibm.com>,
Naveen N Rao <naveen@kernel.org>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 08/14] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc
Date: Thu, 22 Jun 2023 13:44:43 +0200 [thread overview]
Message-ID: <20230622114443.GJ4253@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <85a0e5fde0c36219332a74871ef4699008ec7edb.1687430631.git.christophe.leroy@csgroup.eu>
On Thu, Jun 22, 2023 at 12:54:30PM +0200, Christophe Leroy wrote:
> 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 <christophe.leroy@csgroup.eu>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
However, it doesn't apply to tip/objtool/core because Josh went and
renamed a bunch of things including elf_class_addrsize(). It's now
elf_addr_siize().
> ---
> .../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/objtool/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
>
> -#define JUMP_ENTRY_SIZE 16
> +#define JUMP_ENTRY_SIZE (8 + elf_class_addrsize(elf)) /* 12 on PPC32, 16 on 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 */
> };
>
> -static const struct special_entry entries[] = {
> - {
> - .sec = ".altinstructions",
> - .group = true,
> - .size = ALT_ENTRY_SIZE,
> - .orig = ALT_ORIG_OFFSET,
> - .orig_len = ALT_ORIG_LEN_OFFSET,
> - .new = ALT_NEW_OFFSET,
> - .new_len = ALT_NEW_LEN_OFFSET,
> - .feature = ALT_FEATURE_OFFSET,
> - },
> - {
> - .sec = "__jump_table",
> - .jump_or_nop = true,
> - .size = JUMP_ENTRY_SIZE,
> - .orig = JUMP_ORIG_OFFSET,
> - .new = JUMP_NEW_OFFSET,
> - .key = JUMP_KEY_OFFSET,
> - },
> - {
> - .sec = "__ex_table",
> - .size = EX_ENTRY_SIZE,
> - .orig = EX_ORIG_OFFSET,
> - .new = 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[] = {
> + {
> + .sec = ".altinstructions",
> + .group = true,
> + .size = ALT_ENTRY_SIZE,
> + .orig = ALT_ORIG_OFFSET,
> + .orig_len = ALT_ORIG_LEN_OFFSET,
> + .new = ALT_NEW_OFFSET,
> + .new_len = ALT_NEW_LEN_OFFSET,
> + .feature = ALT_FEATURE_OFFSET,
> + },
> + {
> + .sec = "__jump_table",
> + .jump_or_nop = true,
> + .size = JUMP_ENTRY_SIZE,
> + .orig = JUMP_ORIG_OFFSET,
> + .new = JUMP_NEW_OFFSET,
> + .key = JUMP_KEY_OFFSET,
> + },
> + {
> + .sec = "__ex_table",
> + .size = EX_ENTRY_SIZE,
> + .orig = EX_ORIG_OFFSET,
> + .new = EX_NEW_OFFSET,
> + },
> + {},
> + };
>
> INIT_LIST_HEAD(alts);
>
> --
> 2.40.1
>
next prev parent reply other threads:[~2023-06-22 11:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 10:54 [PATCH v2 00/14] powerpc/objtool: uaccess validation for PPC32 (v2) Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 01/14] powerpc/kuap: Avoid unnecessary reads of MD_AP Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 02/14] powerpc/kuap: Avoid useless jump_label on empty function Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 03/14] powerpc/kuap: Refactor static branch for disabling kuap Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 04/14] powerpc/kuap: Make disabling KUAP at boottime impossible except on book3s/64 Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 05/14] powerpc/kuap: KUAP enabling/disabling functions must be __always_inline Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 06/14] Revert "powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto" Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 07/14] objtool: Allow an architecture to disable objtool on ASM files Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 08/14] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like powerpc Christophe Leroy
2023-06-22 11:44 ` Peter Zijlstra [this message]
2023-06-22 10:54 ` [PATCH v2 09/14] objtool: Add INSN_RETURN_CONDITIONAL Christophe Leroy
2023-06-22 11:45 ` Peter Zijlstra
2023-06-22 10:54 ` [PATCH v2 10/14] objtool: Add support for relative switch tables Christophe Leroy
2023-06-22 11:48 ` Peter Zijlstra
2023-06-23 15:09 ` Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 11/14] objtool: Remove too strict constraint in jump table search Christophe Leroy
2023-06-22 11:48 ` Peter Zijlstra
2023-06-22 10:54 ` [PATCH v2 12/14] objtool: Add support for more complex UACCESS control Christophe Leroy
2023-06-22 11:49 ` Peter Zijlstra
2023-06-22 10:54 ` [PATCH v2 13/14] powerpc/bug: Annotate reachable after warning trap Christophe Leroy
2023-06-22 10:54 ` [PATCH v2 14/14] powerpc: Implement UACCESS validation on PPC32 Christophe Leroy
2023-06-22 11:56 ` Peter Zijlstra
2023-06-23 16:03 ` Christophe Leroy
2023-06-22 19:16 ` kernel test robot
2023-06-22 20:07 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230622114443.GJ4253@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=christophe.leroy@csgroup.eu \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=sv@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox