lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 22 Jun 2023 13:44:43 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Christophe Leroy <christophe.leroy@...roup.eu>
Cc:     Michael Ellerman <mpe@...erman.id.au>,
        Nicholas Piggin <npiggin@...il.com>,
        Josh Poimboeuf <jpoimboe@...nel.org>,
        Sathvika Vasireddy <sv@...ux.ibm.com>,
        Naveen N Rao <naveen@...nel.org>,
        linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v2 08/14] objtool: Fix JUMP_ENTRY_SIZE for bi-arch like
 powerpc

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@...roup.eu>

Acked-by: Peter Zijlstra (Intel) <peterz@...radead.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ