All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, "Jason A . Donenfeld" <Jason@zx2c4.com>,
	clang-built-linux@googlegroups.com,
	Masahiro Yamada <masahiroy@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 10/16] x86: probe assembler capabilities via kconfig instead of makefile
Date: Thu, 26 Mar 2020 17:00:58 +0900	[thread overview]
Message-ID: <20200326080104.27286-11-masahiroy@kernel.org> (raw)
In-Reply-To: <20200326080104.27286-1-masahiroy@kernel.org>

From: "Jason A. Donenfeld" <Jason@zx2c4.com>

Doing this probing inside of the Makefiles means we have a maze of
ifdefs inside the source code and child Makefiles that need to make
proper decisions on this too. Instead, we do it at Kconfig time, like
many other compiler and assembler options, which allows us to set up the
dependencies normally for full compilation units. In the process, the
ADX test changes to use %eax instead of %r10 so that it's valid in both
32-bit and 64-bit mode.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2: None

 arch/x86/Kconfig           |  2 ++
 arch/x86/Kconfig.assembler | 17 +++++++++++++++++
 arch/x86/Makefile          | 10 ----------
 3 files changed, 19 insertions(+), 10 deletions(-)
 create mode 100644 arch/x86/Kconfig.assembler

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index beea77046f9b..707673227837 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2935,3 +2935,5 @@ config HAVE_ATOMIC_IOMAP
 source "drivers/firmware/Kconfig"
 
 source "arch/x86/kvm/Kconfig"
+
+source "arch/x86/Kconfig.assembler"
diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler
new file mode 100644
index 000000000000..91230bf11a14
--- /dev/null
+++ b/arch/x86/Kconfig.assembler
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+
+config AS_AVX2
+	def_bool $(as-instr,vpbroadcastb %xmm0$(comma)%ymm1)
+
+config AS_AVX512
+	def_bool $(as-instr,vpmovm2b %k1$(comma)%zmm5)
+
+config AS_SHA1_NI
+	def_bool $(as-instr,sha1msg1 %xmm0$(comma)%xmm1)
+
+config AS_SHA256_NI
+	def_bool $(as-instr,sha256msg1 %xmm0$(comma)%xmm1)
+
+config AS_ADX
+	def_bool $(as-instr,adox %eax$(comma)%eax)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index f32ef7b8d5ca..b65ec63c7db7 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -177,16 +177,6 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
 	KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif
 
-# does binutils support specific instructions?
-avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)
-avx512_instr :=$(call as-instr,vpmovm2b %k1$(comma)%zmm5,-DCONFIG_AS_AVX512=1)
-sha1_ni_instr :=$(call as-instr,sha1msg1 %xmm0$(comma)%xmm1,-DCONFIG_AS_SHA1_NI=1)
-sha256_ni_instr :=$(call as-instr,sha256msg1 %xmm0$(comma)%xmm1,-DCONFIG_AS_SHA256_NI=1)
-adx_instr := $(call as-instr,adox %r10$(comma)%r10,-DCONFIG_AS_ADX=1)
-
-KBUILD_AFLAGS += $(avx2_instr) $(avx512_instr) $(sha1_ni_instr) $(sha256_ni_instr) $(adx_instr)
-KBUILD_CFLAGS += $(avx2_instr) $(avx512_instr) $(sha1_ni_instr) $(sha256_ni_instr) $(adx_instr)
-
 KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
 
 #
-- 
2.17.1


  parent reply	other threads:[~2020-03-26  8:03 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26  8:00 [PATCH v2 00/16] x86, crypto: remove always-defined CONFIG_AS_* and cosolidate Kconfig/Makefiles Masahiro Yamada
2020-03-26  8:00 ` [Intel-gfx] " Masahiro Yamada
2020-03-26  8:00 ` Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 01/16] lib/raid6/test: fix build on distros whose /bin/sh is not bash Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 02/16] x86: remove unneeded defined(__ASSEMBLY__) check from asm/dwarf2.h Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 03/16] x86: remove always-defined CONFIG_AS_CFI Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 04/16] x86: remove unneeded (CONFIG_AS_)CFI_SIGNAL_FRAME Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 05/16] x86: remove always-defined CONFIG_AS_CFI_SECTIONS Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 06/16] x86: remove always-defined CONFIG_AS_SSSE3 Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 07/16] x86: remove always-defined CONFIG_AS_AVX Masahiro Yamada
2020-03-26  8:00 ` [PATCH v2 08/16] x86: replace arch macros from compiler with CONFIG_X86_{32,64} Masahiro Yamada
2020-03-31  2:40   ` Masahiro Yamada
2020-03-31  4:38     ` Jason A. Donenfeld
2020-03-26  8:00 ` [PATCH v2 09/16] drm/i915: remove always-defined CONFIG_AS_MOVNTDQA Masahiro Yamada
2020-03-26  8:00   ` [Intel-gfx] " Masahiro Yamada
2020-03-26  8:00   ` Masahiro Yamada
2020-03-26  8:24   ` Jani Nikula
2020-03-26  8:24     ` [Intel-gfx] " Jani Nikula
2020-03-26  8:24     ` Jani Nikula
2020-03-26  8:24     ` Jani Nikula
2020-03-26  8:00 ` Masahiro Yamada [this message]
2020-03-26 17:49   ` [PATCH v2 10/16] x86: probe assembler capabilities via kconfig instead of makefile Nick Desaulniers
2020-03-26 19:53     ` Jason A. Donenfeld
2020-03-26 20:00       ` Nick Desaulniers
2020-03-26  8:00 ` [PATCH v2 11/16] x86: add comments about the binutils version to support code in as-instr Masahiro Yamada
2020-03-26 17:50   ` Nick Desaulniers
2020-03-26  8:01 ` [PATCH v2 12/16] crypto: x86 - rework configuration based on Kconfig Masahiro Yamada
2020-03-26  8:01 ` [PATCH v2 13/16] crypto: curve25519 - do not pollute dispatcher based on assembler Masahiro Yamada
2020-03-26  8:01 ` [PATCH v2 14/16] Documentation/changes: Raise minimum supported binutils version to 2.23 Masahiro Yamada
2020-03-26  8:01 ` [PATCH v2 15/16] x86: update AS_* macros to binutils >=2.23, supporting ADX and AVX2 Masahiro Yamada
2020-03-26 17:55   ` Nick Desaulniers
2020-03-26 17:55     ` Nick Desaulniers
2020-03-26 19:48     ` Jason A. Donenfeld
2020-03-26 19:48       ` Jason A. Donenfeld
2020-03-26 19:58       ` Nick Desaulniers
2020-03-26 19:58         ` Nick Desaulniers
2020-03-26 20:26         ` [PATCH] " Jason A. Donenfeld
2020-03-26 20:29           ` Nick Desaulniers
2020-03-26 20:50           ` Masahiro Yamada
2020-03-26  8:01 ` [PATCH v2 16/16] crypto: x86 - clean up poly1305-x86_64-cryptogams.S by 'make clean' Masahiro Yamada
2020-03-26  8:12 ` [PATCH v2 00/16] x86, crypto: remove always-defined CONFIG_AS_* and cosolidate Kconfig/Makefiles Jason A. Donenfeld
2020-03-26  8:12   ` [Intel-gfx] " Jason A. Donenfeld
2020-03-26  9:22   ` Ingo Molnar
2020-03-26  9:22     ` [Intel-gfx] " Ingo Molnar
2020-03-26  9:22     ` Ingo Molnar
2020-03-26 20:43     ` Masahiro Yamada
2020-03-26 20:43       ` [Intel-gfx] " Masahiro Yamada
2020-03-26 20:43       ` Masahiro Yamada
2020-03-26 20:46       ` Jason A. Donenfeld
2020-03-26 20:46         ` [Intel-gfx] " Jason A. Donenfeld
2020-03-26 21:12         ` Masahiro Yamada
2020-03-26 21:12           ` [Intel-gfx] " Masahiro Yamada
2020-03-26 21:12           ` Masahiro Yamada

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=20200326080104.27286-11-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=bp@alien8.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=hpa@zytor.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 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.