linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	"David S. Miller" <davem@davemloft.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: [GIT PULL] Crypto Fixes for 5.6
Date: Fri, 20 Mar 2020 17:53:46 -0600	[thread overview]
Message-ID: <CAHmME9pME41uHvhu5f_JGZbUNCuG0YVgRkBUQF9wtTO6YnMijw@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wjbTF2iw3EbKgfiRRq_keb4fHwLO8xJyRXbfK3Q7cscuQ@mail.gmail.com>

Funny, I always thought it was like that "for a good reason" that I
just didn't know about -- assumedly something having to do with a
difference between config time and compile time. I agree with you that
everything gets so much cleaner if we can do this in Kconfig. I've put
together the patch pasted below, which appears to work well. I'll work
on replumbing the other stuff and will send a series off to the list
hopefully not before too long.

From 12375354ddb4c8b1c75663312a9b6d9b9bc5f520 Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Fri, 20 Mar 2020 17:49:36 -0600
Subject: [PATCH] x86: probe assembler instead of kconfig instead of makefile

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.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 arch/x86/Kconfig           |  2 ++
 arch/x86/Kconfig.assembler | 33 +++++++++++++++++++++++++++++++++
 arch/x86/Makefile          | 22 ----------------------
 3 files changed, 35 insertions(+), 22 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..809adcf6f7c3
--- /dev/null
+++ b/arch/x86/Kconfig.assembler
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+
+config AS_CFI
+ def_bool $(as-instr,.cfi_startproc\n.cfi_rel_offset
rsp$(comma)0\n.cfi_endproc) if 64BIT
+ def_bool $(as-instr,.cfi_startproc\n.cfi_rel_offset
esp$(comma)0\n.cfi_endproc) if !64BIT
+
+config AS_CFI_SIGNAL_FRAME
+ def_bool $(as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc)
+
+config AS_CFI_SECTIONS
+ def_bool $(as-instr,.cfi_sections .debug_frame)
+
+config AS_SSSE3
+ def_bool $(as-instr,pshufb %xmm0$(comma)%xmm0)
+
+config AS_AVX
+ def_bool $(as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2)
+
+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 %r10$(comma)%r10)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 513a55562d75..b65ec63c7db7 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -177,28 +177,6 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
  KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
 endif

-# Stackpointer is addressed different for 32 bit and 64 bit x86
-sp-$(CONFIG_X86_32) := esp
-sp-$(CONFIG_X86_64) := rsp
-
-# do binutils support CFI?
-cfi := $(call as-instr,.cfi_startproc\n.cfi_rel_offset
$(sp-y)$(comma)0\n.cfi_endproc,-DCONFIG_AS_CFI=1)
-# is .cfi_signal_frame supported too?
-cfi-sigframe := $(call
as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1)
-cfi-sections := $(call as-instr,.cfi_sections
.debug_frame,-DCONFIG_AS_CFI_SECTIONS=1)
-
-# does binutils support specific instructions?
-asinstr += $(call as-instr,pshufb %xmm0$(comma)%xmm0,-DCONFIG_AS_SSSE3=1)
-avx_instr := $(call as-instr,vxorps
%ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1)
-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 += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr)
$(avx_instr) $(avx2_instr) $(avx512_instr) $(sha1_ni_instr)
$(sha256_ni_instr) $(adx_instr)
-KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr)
$(avx_instr) $(avx2_instr) $(avx512_instr) $(sha1_ni_instr)
$(sha256_ni_instr) $(adx_instr)
-
 KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)

 #
-- 
2.25.1

  parent reply	other threads:[~2020-03-20 23:54 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-16  8:49 [GIT PULL] Crypto Update for 5.4 Herbert Xu
2019-09-18 19:55 ` pr-tracker-bot
2019-09-23  5:05 ` [GIT PULL] Crypto Fixes " Herbert Xu
2019-09-23 16:50   ` pr-tracker-bot
2019-10-10 12:38   ` Herbert Xu
2019-10-10 15:45     ` pr-tracker-bot
2019-11-17  1:00     ` Herbert Xu
2019-11-17  2:35       ` pr-tracker-bot
2019-12-02  6:20   ` [GIT PULL] Crypto Fixes for 5.5 Herbert Xu
2019-12-03  1:30     ` pr-tracker-bot
2019-12-14  8:47     ` Herbert Xu
2019-12-14 22:05       ` pr-tracker-bot
2020-01-15 15:08       ` Herbert Xu
2020-01-15 19:35         ` pr-tracker-bot
2020-02-13  3:32         ` [GIT PULL] Crypto Fixes for 5.6 Herbert Xu
2020-02-13 22:40           ` pr-tracker-bot
2020-02-24  6:00           ` Herbert Xu
2020-02-24 20:25             ` pr-tracker-bot
2020-03-12 11:57             ` Herbert Xu
2020-03-12 16:40               ` Linus Torvalds
2020-03-13  5:27                 ` Masahiro Yamada
2020-03-20 23:53                 ` Jason A. Donenfeld [this message]
2020-03-21 15:43                   ` Linus Torvalds
2020-03-21  0:49                 ` [PATCH RFC 0/3] x86: probe for assembler capabilities in Kconfig Jason A. Donenfeld
2020-03-21  0:49                   ` [PATCH RFC 1/3] x86: probe assembler instead of kconfig instead of makefile Jason A. Donenfeld
2020-03-21  0:49                   ` [PATCH RFC 2/3] crypto: x86 - rework configuration based on Kconfig Jason A. Donenfeld
2020-03-21  0:49                   ` [PATCH RFC 3/3] crypto: curve25519 - do not pollute dispatcher based on assembler Jason A. Donenfeld
2020-03-12 17:05               ` [GIT PULL] Crypto Fixes for 5.6 pr-tracker-bot
2020-03-23 22:54               ` Herbert Xu
2020-03-23 23:05                 ` pr-tracker-bot
2020-04-08  6:15           ` [GIT PULL] Crypto Fixes for 5.7 Herbert Xu
2020-04-09  4:55             ` pr-tracker-bot
2020-04-29  5:54             ` Herbert Xu
2020-04-29 16:50               ` pr-tracker-bot
2020-05-06  5:10               ` Herbert Xu
2020-05-06 17:25                 ` pr-tracker-bot
2020-06-11  4:05             ` [GIT PULL] Crypto Fixes for 5.8 Herbert Xu
2020-06-11 18:25               ` pr-tracker-bot
2020-06-21  8:23               ` Herbert Xu
2020-06-21 17:10                 ` pr-tracker-bot
2020-06-29  2:16                 ` Herbert Xu
2020-06-29 17:15                   ` pr-tracker-bot
2020-08-14 13:18               ` [GIT PULL] Crypto Fixes for 5.9 Herbert Xu
2020-08-14 20:34                 ` pr-tracker-bot
2019-11-25  3:45 ` [GIT PULL] Crypto Update for 5.5 Herbert Xu
2019-11-26  4:25   ` pr-tracker-bot
2020-01-28  5:03   ` [GIT PULL] Crypto Update for 5.6 Herbert Xu
2020-01-29  0:30     ` pr-tracker-bot
2020-04-01  4:27     ` [GIT PULL] Crypto Update for 5.7 Herbert Xu
2020-04-01 22:35       ` pr-tracker-bot
2020-06-01  2:45       ` [GIT PULL] Crypto Update for 5.8 Herbert Xu
2020-06-01 19:35         ` pr-tracker-bot

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=CAHmME9pME41uHvhu5f_JGZbUNCuG0YVgRkBUQF9wtTO6YnMijw@mail.gmail.com \
    --to=jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=yamada.masahiro@socionext.com \
    --subject='Re: [GIT PULL] Crypto Fixes for 5.6' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).