Skip to content

Commit 5e8ebd8

Browse files
zx2c4masahir0y
authored andcommitted
x86: probe assembler capabilities via 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. 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 <[email protected]> Acked-by: Ingo Molnar <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 8192e55 commit 5e8ebd8

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

arch/x86/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,3 +2931,5 @@ config HAVE_ATOMIC_IOMAP
29312931
source "drivers/firmware/Kconfig"
29322932

29332933
source "arch/x86/kvm/Kconfig"
2934+
2935+
source "arch/x86/Kconfig.assembler"

arch/x86/Kconfig.assembler

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Copyright (C) 2020 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
3+
4+
config AS_AVX2
5+
def_bool $(as-instr,vpbroadcastb %xmm0$(comma)%ymm1)
6+
7+
config AS_AVX512
8+
def_bool $(as-instr,vpmovm2b %k1$(comma)%zmm5)
9+
10+
config AS_SHA1_NI
11+
def_bool $(as-instr,sha1msg1 %xmm0$(comma)%xmm1)
12+
13+
config AS_SHA256_NI
14+
def_bool $(as-instr,sha256msg1 %xmm0$(comma)%xmm1)
15+
16+
config AS_ADX
17+
def_bool $(as-instr,adox %eax$(comma)%eax)

arch/x86/Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,6 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1)
177177
KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,)
178178
endif
179179

180-
# does binutils support specific instructions?
181-
avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)
182-
avx512_instr :=$(call as-instr,vpmovm2b %k1$(comma)%zmm5,-DCONFIG_AS_AVX512=1)
183-
sha1_ni_instr :=$(call as-instr,sha1msg1 %xmm0$(comma)%xmm1,-DCONFIG_AS_SHA1_NI=1)
184-
sha256_ni_instr :=$(call as-instr,sha256msg1 %xmm0$(comma)%xmm1,-DCONFIG_AS_SHA256_NI=1)
185-
adx_instr := $(call as-instr,adox %r10$(comma)%r10,-DCONFIG_AS_ADX=1)
186-
187-
KBUILD_AFLAGS += $(avx2_instr) $(avx512_instr) $(sha1_ni_instr) $(sha256_ni_instr) $(adx_instr)
188-
KBUILD_CFLAGS += $(avx2_instr) $(avx512_instr) $(sha1_ni_instr) $(sha256_ni_instr) $(adx_instr)
189-
190180
KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
191181

192182
#

net/netfilter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ nf_tables-objs := nf_tables_core.o nf_tables_api.o nft_chain_filter.o \
8383
nft_set_pipapo.o
8484

8585
ifdef CONFIG_X86_64
86-
ifneq (,$(findstring -DCONFIG_AS_AVX2=1,$(KBUILD_CFLAGS)))
86+
ifdef CONFIG_AS_AVX2
8787
nf_tables-objs += nft_set_pipapo_avx2.o
8888
endif
8989
endif

0 commit comments

Comments
 (0)