diff mbox series

[v2,08/16] x86: replace arch macros from compiler with CONFIG_X86_{32,64}

Message ID 20200326080104.27286-9-masahiroy@kernel.org (mailing list archive)
State New, archived
Headers show
Series x86, crypto: remove always-defined CONFIG_AS_* and cosolidate Kconfig/Makefiles | expand

Commit Message

Masahiro Yamada March 26, 2020, 8 a.m. UTC
If the intention is to check i386/x86_64 excluding UML, testing
CONFIG_X86_{32,64} is simpler.

The reason for checking __i386__ / __x86_64__ was perhaps because
lib/raid6/algos.c is built not only for the kernel but also for
testing the library code from userspace.

However, lib/raid6/test/Makefile passes -DCONFIG_X86_{32,64} for
this case. So, I do not see a reason to not use CONFIG option here.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---

Changes in v2: None

 kernel/signal.c   | 2 +-
 lib/raid6/algos.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Masahiro Yamada March 31, 2020, 2:40 a.m. UTC | #1
On Thu, Mar 26, 2020 at 5:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> If the intention is to check i386/x86_64 excluding UML, testing
> CONFIG_X86_{32,64} is simpler.
>
> The reason for checking __i386__ / __x86_64__ was perhaps because
> lib/raid6/algos.c is built not only for the kernel but also for
> testing the library code from userspace.
>
> However, lib/raid6/test/Makefile passes -DCONFIG_X86_{32,64} for
> this case. So, I do not see a reason to not use CONFIG option here.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> ---


Sorry, this patch broke UML builds.

https://lkml.org/lkml/2020/3/27/618



I will drop this patch for tomorrow's linux-next.



CONFIG_X86 is not defined for ARCH=um.
So, I still think it is OK to replace one complicated line
in lib/raid6/x86.h

   #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__)

with:

   #ifdef CONFIG_X86




Also, I slightly prefer

   #if defined(CONFIG_X86_32) && !defined(CONFIG_UML)

to

   #if defined(__i386__) && !defined(__arch_um__)



But, we do not need to rush this now.


This patch does not affect the rest of this series.

Thanks.





> Changes in v2: None
>
>  kernel/signal.c   | 2 +-
>  lib/raid6/algos.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 5b2396350dd1..db557e1629e5 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1246,7 +1246,7 @@ static void print_fatal_signal(int signr)
>         struct pt_regs *regs = signal_pt_regs();
>         pr_info("potentially unexpected fatal signal %d.\n", signr);
>
> -#if defined(__i386__) && !defined(__arch_um__)
> +#ifdef CONFIG_X86_32
>         pr_info("code at %08lx: ", regs->ip);
>         {
>                 int i;
> diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
> index df08664d3432..b5a02326cfb7 100644
> --- a/lib/raid6/algos.c
> +++ b/lib/raid6/algos.c
> @@ -29,7 +29,7 @@ struct raid6_calls raid6_call;
>  EXPORT_SYMBOL_GPL(raid6_call);
>
>  const struct raid6_calls * const raid6_algos[] = {
> -#if defined(__i386__) && !defined(__arch_um__)
> +#ifdef CONFIG_X86_32
>  #ifdef CONFIG_AS_AVX512
>         &raid6_avx512x2,
>         &raid6_avx512x1,
> @@ -45,7 +45,7 @@ const struct raid6_calls * const raid6_algos[] = {
>         &raid6_mmxx2,
>         &raid6_mmxx1,
>  #endif
> -#if defined(__x86_64__) && !defined(__arch_um__)
> +#ifdef CONFIG_X86_64
>  #ifdef CONFIG_AS_AVX512
>         &raid6_avx512x4,
>         &raid6_avx512x2,
> --
> 2.17.1
>
Jason A. Donenfeld March 31, 2020, 4:38 a.m. UTC | #2
On Mon, Mar 30, 2020 at 8:42 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Also, I slightly prefer
>
>    #if defined(CONFIG_X86_32) && !defined(CONFIG_UML)
>
> to
>
>    #if defined(__i386__) && !defined(__arch_um__)

I would much prefer that too.

At some point it'd be nice to see this whole mess cleaned up with UML.
I've seen this a few places -- UML thinks its x86, except where it's
not, and then there are problems. For example, a lot of SIMD related
code has this.

Jason
diff mbox series

Patch

diff --git a/kernel/signal.c b/kernel/signal.c
index 5b2396350dd1..db557e1629e5 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1246,7 +1246,7 @@  static void print_fatal_signal(int signr)
 	struct pt_regs *regs = signal_pt_regs();
 	pr_info("potentially unexpected fatal signal %d.\n", signr);
 
-#if defined(__i386__) && !defined(__arch_um__)
+#ifdef CONFIG_X86_32
 	pr_info("code at %08lx: ", regs->ip);
 	{
 		int i;
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index df08664d3432..b5a02326cfb7 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -29,7 +29,7 @@  struct raid6_calls raid6_call;
 EXPORT_SYMBOL_GPL(raid6_call);
 
 const struct raid6_calls * const raid6_algos[] = {
-#if defined(__i386__) && !defined(__arch_um__)
+#ifdef CONFIG_X86_32
 #ifdef CONFIG_AS_AVX512
 	&raid6_avx512x2,
 	&raid6_avx512x1,
@@ -45,7 +45,7 @@  const struct raid6_calls * const raid6_algos[] = {
 	&raid6_mmxx2,
 	&raid6_mmxx1,
 #endif
-#if defined(__x86_64__) && !defined(__arch_um__)
+#ifdef CONFIG_X86_64
 #ifdef CONFIG_AS_AVX512
 	&raid6_avx512x4,
 	&raid6_avx512x2,