All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions
@ 2021-11-08 11:42 ` Mark Rutland
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2021-11-08 11:42 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Ard Biesheuvel, Borislav Petkov, Catalin Marinas,
	Thomas Gleixner, Will Deacon

The format of the arm64 and x86 exception table entries is essentially
the same as of commits:

  46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
  d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")

Both use a 12-byte entry consisting of two 32-bit relative offsets and
32 bits of (absolute) data, and their sort functions are identical aside
from commentary, with arm64 saying:

   /* Don't touch the fixup type or data */

... and x86 saying:

  /* Don't touch the fixup type */

Unify the two behind a common sort_relative_table_with_data() function,
retaining the arm64 commentary.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 scripts/sorttable.c | 36 +++---------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index b7c2ad71f9cf..ca9db62bf766 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -231,7 +231,7 @@ static void sort_relative_table(char *extab_image, int image_size)
 	}
 }
 
-static void arm64_sort_relative_table(char *extab_image, int image_size)
+static void sort_relative_table_with_data(char *extab_image, int image_size)
 {
 	int i = 0;
 
@@ -259,34 +259,6 @@ static void arm64_sort_relative_table(char *extab_image, int image_size)
 	}
 }
 
-static void x86_sort_relative_table(char *extab_image, int image_size)
-{
-	int i = 0;
-
-	while (i < image_size) {
-		uint32_t *loc = (uint32_t *)(extab_image + i);
-
-		w(r(loc) + i, loc);
-		w(r(loc + 1) + i + 4, loc + 1);
-		/* Don't touch the fixup type */
-
-		i += sizeof(uint32_t) * 3;
-	}
-
-	qsort(extab_image, image_size / 12, 12, compare_relative_table);
-
-	i = 0;
-	while (i < image_size) {
-		uint32_t *loc = (uint32_t *)(extab_image + i);
-
-		w(r(loc) - i, loc);
-		w(r(loc + 1) - (i + 4), loc + 1);
-		/* Don't touch the fixup type */
-
-		i += sizeof(uint32_t) * 3;
-	}
-}
-
 static void s390_sort_relative_table(char *extab_image, int image_size)
 {
 	int i;
@@ -364,15 +336,13 @@ static int do_file(char const *const fname, void *addr)
 
 	switch (r2(&ehdr->e_machine)) {
 	case EM_386:
+	case EM_AARCH64:
 	case EM_X86_64:
-		custom_sort = x86_sort_relative_table;
+		custom_sort = sort_relative_table_with_data;
 		break;
 	case EM_S390:
 		custom_sort = s390_sort_relative_table;
 		break;
-	case EM_AARCH64:
-		custom_sort = arm64_sort_relative_table;
-		break;
 	case EM_PARISC:
 	case EM_PPC:
 	case EM_PPC64:
-- 
2.11.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions
@ 2021-11-08 11:42 ` Mark Rutland
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2021-11-08 11:42 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Mark Rutland, Ard Biesheuvel, Borislav Petkov, Catalin Marinas,
	Thomas Gleixner, Will Deacon

The format of the arm64 and x86 exception table entries is essentially
the same as of commits:

  46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
  d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")

Both use a 12-byte entry consisting of two 32-bit relative offsets and
32 bits of (absolute) data, and their sort functions are identical aside
from commentary, with arm64 saying:

   /* Don't touch the fixup type or data */

... and x86 saying:

  /* Don't touch the fixup type */

Unify the two behind a common sort_relative_table_with_data() function,
retaining the arm64 commentary.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
 scripts/sorttable.c | 36 +++---------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index b7c2ad71f9cf..ca9db62bf766 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -231,7 +231,7 @@ static void sort_relative_table(char *extab_image, int image_size)
 	}
 }
 
-static void arm64_sort_relative_table(char *extab_image, int image_size)
+static void sort_relative_table_with_data(char *extab_image, int image_size)
 {
 	int i = 0;
 
@@ -259,34 +259,6 @@ static void arm64_sort_relative_table(char *extab_image, int image_size)
 	}
 }
 
-static void x86_sort_relative_table(char *extab_image, int image_size)
-{
-	int i = 0;
-
-	while (i < image_size) {
-		uint32_t *loc = (uint32_t *)(extab_image + i);
-
-		w(r(loc) + i, loc);
-		w(r(loc + 1) + i + 4, loc + 1);
-		/* Don't touch the fixup type */
-
-		i += sizeof(uint32_t) * 3;
-	}
-
-	qsort(extab_image, image_size / 12, 12, compare_relative_table);
-
-	i = 0;
-	while (i < image_size) {
-		uint32_t *loc = (uint32_t *)(extab_image + i);
-
-		w(r(loc) - i, loc);
-		w(r(loc + 1) - (i + 4), loc + 1);
-		/* Don't touch the fixup type */
-
-		i += sizeof(uint32_t) * 3;
-	}
-}
-
 static void s390_sort_relative_table(char *extab_image, int image_size)
 {
 	int i;
@@ -364,15 +336,13 @@ static int do_file(char const *const fname, void *addr)
 
 	switch (r2(&ehdr->e_machine)) {
 	case EM_386:
+	case EM_AARCH64:
 	case EM_X86_64:
-		custom_sort = x86_sort_relative_table;
+		custom_sort = sort_relative_table_with_data;
 		break;
 	case EM_S390:
 		custom_sort = s390_sort_relative_table;
 		break;
-	case EM_AARCH64:
-		custom_sort = arm64_sort_relative_table;
-		break;
 	case EM_PARISC:
 	case EM_PPC:
 	case EM_PPC64:
-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions
  2021-11-08 11:42 ` Mark Rutland
@ 2021-11-16 10:04   ` Will Deacon
  -1 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2021-11-16 10:04 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-kernel, linux-arm-kernel, Ard Biesheuvel, Borislav Petkov,
	Catalin Marinas, Thomas Gleixner

On Mon, Nov 08, 2021 at 11:42:20AM +0000, Mark Rutland wrote:
> The format of the arm64 and x86 exception table entries is essentially
> the same as of commits:
> 
>   46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
>   d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")
> 
> Both use a 12-byte entry consisting of two 32-bit relative offsets and
> 32 bits of (absolute) data, and their sort functions are identical aside
> from commentary, with arm64 saying:
> 
>    /* Don't touch the fixup type or data */
> 
> ... and x86 saying:
> 
>   /* Don't touch the fixup type */
> 
> Unify the two behind a common sort_relative_table_with_data() function,
> retaining the arm64 commentary.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  scripts/sorttable.c | 36 +++---------------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

Will

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions
@ 2021-11-16 10:04   ` Will Deacon
  0 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2021-11-16 10:04 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-kernel, linux-arm-kernel, Ard Biesheuvel, Borislav Petkov,
	Catalin Marinas, Thomas Gleixner

On Mon, Nov 08, 2021 at 11:42:20AM +0000, Mark Rutland wrote:
> The format of the arm64 and x86 exception table entries is essentially
> the same as of commits:
> 
>   46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
>   d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")
> 
> Both use a 12-byte entry consisting of two 32-bit relative offsets and
> 32 bits of (absolute) data, and their sort functions are identical aside
> from commentary, with arm64 saying:
> 
>    /* Don't touch the fixup type or data */
> 
> ... and x86 saying:
> 
>   /* Don't touch the fixup type */
> 
> Unify the two behind a common sort_relative_table_with_data() function,
> retaining the arm64 commentary.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  scripts/sorttable.c | 36 +++---------------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions
  2021-11-08 11:42 ` Mark Rutland
@ 2021-11-25 11:04   ` Mark Rutland
  -1 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2021-11-25 11:04 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Ard Biesheuvel, Borislav Petkov, Catalin Marinas,
	Thomas Gleixner, Will Deacon, Ingo Molnar, Peter Zijlstra,
	Jisheng Zhang

[Adding Ingo and Peter]

TIP folk, is this something you'd be happy to pick up?

arm64 and x86 simply raced to add the same logic to sorttable.c for v5.16-rc1,
and it'd be nice to clean those up for v5.16-rc3 or so, since the riscv folk
want to use the same logic for v5.17 or so:

  https://lore.kernel.org/r/20211118192605.57e06d6b@xhacker

Will's acked this patch in the reply at:

  https://lore.kernel.org/r/20211116100406.GA9851@willie-the-truck

Thanks
Mark.

On Mon, Nov 08, 2021 at 11:42:20AM +0000, Mark Rutland wrote:
> The format of the arm64 and x86 exception table entries is essentially
> the same as of commits:
> 
>   46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
>   d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")
> 
> Both use a 12-byte entry consisting of two 32-bit relative offsets and
> 32 bits of (absolute) data, and their sort functions are identical aside
> from commentary, with arm64 saying:
> 
>    /* Don't touch the fixup type or data */
> 
> ... and x86 saying:
> 
>   /* Don't touch the fixup type */
> 
> Unify the two behind a common sort_relative_table_with_data() function,
> retaining the arm64 commentary.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  scripts/sorttable.c | 36 +++---------------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)
> 
> diff --git a/scripts/sorttable.c b/scripts/sorttable.c
> index b7c2ad71f9cf..ca9db62bf766 100644
> --- a/scripts/sorttable.c
> +++ b/scripts/sorttable.c
> @@ -231,7 +231,7 @@ static void sort_relative_table(char *extab_image, int image_size)
>  	}
>  }
>  
> -static void arm64_sort_relative_table(char *extab_image, int image_size)
> +static void sort_relative_table_with_data(char *extab_image, int image_size)
>  {
>  	int i = 0;
>  
> @@ -259,34 +259,6 @@ static void arm64_sort_relative_table(char *extab_image, int image_size)
>  	}
>  }
>  
> -static void x86_sort_relative_table(char *extab_image, int image_size)
> -{
> -	int i = 0;
> -
> -	while (i < image_size) {
> -		uint32_t *loc = (uint32_t *)(extab_image + i);
> -
> -		w(r(loc) + i, loc);
> -		w(r(loc + 1) + i + 4, loc + 1);
> -		/* Don't touch the fixup type */
> -
> -		i += sizeof(uint32_t) * 3;
> -	}
> -
> -	qsort(extab_image, image_size / 12, 12, compare_relative_table);
> -
> -	i = 0;
> -	while (i < image_size) {
> -		uint32_t *loc = (uint32_t *)(extab_image + i);
> -
> -		w(r(loc) - i, loc);
> -		w(r(loc + 1) - (i + 4), loc + 1);
> -		/* Don't touch the fixup type */
> -
> -		i += sizeof(uint32_t) * 3;
> -	}
> -}
> -
>  static void s390_sort_relative_table(char *extab_image, int image_size)
>  {
>  	int i;
> @@ -364,15 +336,13 @@ static int do_file(char const *const fname, void *addr)
>  
>  	switch (r2(&ehdr->e_machine)) {
>  	case EM_386:
> +	case EM_AARCH64:
>  	case EM_X86_64:
> -		custom_sort = x86_sort_relative_table;
> +		custom_sort = sort_relative_table_with_data;
>  		break;
>  	case EM_S390:
>  		custom_sort = s390_sort_relative_table;
>  		break;
> -	case EM_AARCH64:
> -		custom_sort = arm64_sort_relative_table;
> -		break;
>  	case EM_PARISC:
>  	case EM_PPC:
>  	case EM_PPC64:
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions
@ 2021-11-25 11:04   ` Mark Rutland
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2021-11-25 11:04 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Ard Biesheuvel, Borislav Petkov, Catalin Marinas,
	Thomas Gleixner, Will Deacon, Ingo Molnar, Peter Zijlstra,
	Jisheng Zhang

[Adding Ingo and Peter]

TIP folk, is this something you'd be happy to pick up?

arm64 and x86 simply raced to add the same logic to sorttable.c for v5.16-rc1,
and it'd be nice to clean those up for v5.16-rc3 or so, since the riscv folk
want to use the same logic for v5.17 or so:

  https://lore.kernel.org/r/20211118192605.57e06d6b@xhacker

Will's acked this patch in the reply at:

  https://lore.kernel.org/r/20211116100406.GA9851@willie-the-truck

Thanks
Mark.

On Mon, Nov 08, 2021 at 11:42:20AM +0000, Mark Rutland wrote:
> The format of the arm64 and x86 exception table entries is essentially
> the same as of commits:
> 
>   46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics")
>   d6e2cc5647753825 ("arm64: extable: add `type` and `data` fields")
> 
> Both use a 12-byte entry consisting of two 32-bit relative offsets and
> 32 bits of (absolute) data, and their sort functions are identical aside
> from commentary, with arm64 saying:
> 
>    /* Don't touch the fixup type or data */
> 
> ... and x86 saying:
> 
>   /* Don't touch the fixup type */
> 
> Unify the two behind a common sort_relative_table_with_data() function,
> retaining the arm64 commentary.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Will Deacon <will@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  scripts/sorttable.c | 36 +++---------------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)
> 
> diff --git a/scripts/sorttable.c b/scripts/sorttable.c
> index b7c2ad71f9cf..ca9db62bf766 100644
> --- a/scripts/sorttable.c
> +++ b/scripts/sorttable.c
> @@ -231,7 +231,7 @@ static void sort_relative_table(char *extab_image, int image_size)
>  	}
>  }
>  
> -static void arm64_sort_relative_table(char *extab_image, int image_size)
> +static void sort_relative_table_with_data(char *extab_image, int image_size)
>  {
>  	int i = 0;
>  
> @@ -259,34 +259,6 @@ static void arm64_sort_relative_table(char *extab_image, int image_size)
>  	}
>  }
>  
> -static void x86_sort_relative_table(char *extab_image, int image_size)
> -{
> -	int i = 0;
> -
> -	while (i < image_size) {
> -		uint32_t *loc = (uint32_t *)(extab_image + i);
> -
> -		w(r(loc) + i, loc);
> -		w(r(loc + 1) + i + 4, loc + 1);
> -		/* Don't touch the fixup type */
> -
> -		i += sizeof(uint32_t) * 3;
> -	}
> -
> -	qsort(extab_image, image_size / 12, 12, compare_relative_table);
> -
> -	i = 0;
> -	while (i < image_size) {
> -		uint32_t *loc = (uint32_t *)(extab_image + i);
> -
> -		w(r(loc) - i, loc);
> -		w(r(loc + 1) - (i + 4), loc + 1);
> -		/* Don't touch the fixup type */
> -
> -		i += sizeof(uint32_t) * 3;
> -	}
> -}
> -
>  static void s390_sort_relative_table(char *extab_image, int image_size)
>  {
>  	int i;
> @@ -364,15 +336,13 @@ static int do_file(char const *const fname, void *addr)
>  
>  	switch (r2(&ehdr->e_machine)) {
>  	case EM_386:
> +	case EM_AARCH64:
>  	case EM_X86_64:
> -		custom_sort = x86_sort_relative_table;
> +		custom_sort = sort_relative_table_with_data;
>  		break;
>  	case EM_S390:
>  		custom_sort = s390_sort_relative_table;
>  		break;
> -	case EM_AARCH64:
> -		custom_sort = arm64_sort_relative_table;
> -		break;
>  	case EM_PARISC:
>  	case EM_PPC:
>  	case EM_PPC64:
> -- 
> 2.11.0
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-25 11:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08 11:42 [PATCH] scripts/sorttable: Unify arm64 & x86 sort functions Mark Rutland
2021-11-08 11:42 ` Mark Rutland
2021-11-16 10:04 ` Will Deacon
2021-11-16 10:04   ` Will Deacon
2021-11-25 11:04 ` Mark Rutland
2021-11-25 11:04   ` Mark Rutland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.