Skip to contentSkip to conversation

x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS

PATCH Applied Masahiro Yamada 3 participants 3 messages Jun 12, 2024 – Jun 20, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS

Some instructions are only available on the 64-bit architecture.

Bi-arch compilers that default to -m32 need the explicit -m64 option to evaluate them properly.

Fixes 18e66b695e78 ("x86/shstk: Add Kconfig option for shadow stack")

---

 arch/x86/Kconfig.assembler | 2 +-
 scripts/Kconfig.include    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/Kconfig.assembler +1 -1
index 59aedf32c4ea..6d20a6ce0507 100644
@@ -36,6 +36,6 @@ config AS_VPCLMULQDQ
 	  Supported by binutils >= 2.30 and LLVM integrated assembler
 
 config AS_WRUSS
-	def_bool $(as-instr,wrussq %rax$(comma)(%rbx))
+	def_bool $(as-instr64,wrussq %rax$(comma)(%rbx))
 	help
 	  Supported by binutils >= 2.31 and LLVM integrated assembler
scripts/Kconfig.include +2 -1
index 3ee8ecfb8c04..3500a3d62f0d 100644
@@ -33,7 +33,8 @@ ld-option = $(success,$(LD) -v $(1))
 
 # $(as-instr,<instr>)
 # Return y if the assembler supports <instr>, n otherwise
-as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) $(2) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)
+as-instr64 = $(as-instr,$(1),$(m64-flag))
 
 # check if $(CC) and $(LD) exist
 $(error-if,$(failure,command -v $(CC)),C compiler '$(CC)' not found)
Signature · 1 line
2.43.0
Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Masahiro Yamada

Some instructions are only available on the 64-bit architecture.

Bi-arch compilers that default to -m32 need the explicit -m64 option to evaluate them properly.

Fixes 18e66b695e78 ("x86/shstk: Add Kconfig option for shadow stack")

Thank you Masahiro, this works as well!
I guess I went on too generic path without an actual requirement for that.

Quoted 35 lines

---

 arch/x86/Kconfig.assembler | 2 +-
 scripts/Kconfig.include    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/Kconfig.assembler +1 -1
index 59aedf32c4ea..6d20a6ce0507 100644
@@ -36,6 +36,6 @@ config AS_VPCLMULQDQ
          Supported by binutils >= 2.30 and LLVM integrated assembler
 
 config AS_WRUSS
-       def_bool $(as-instr,wrussq %rax$(comma)(%rbx))
+       def_bool $(as-instr64,wrussq %rax$(comma)(%rbx))
        help
          Supported by binutils >= 2.31 and LLVM integrated assembler
scripts/Kconfig.include +2 -2
index 3ee8ecfb8c04..3500a3d62f0d 100644
@@ -33,7 +33,8 @@ ld-option = $(success,$(LD) -v $(1))
 
 # $(as-instr,<instr>)
 # Return y if the assembler supports <instr>, n otherwise
-as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) $(2) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)
+as-instr64 = $(as-instr,$(1),$(m64-flag))
 
 # check if $(CC) and $(LD) exist
 $(error-if,$(failure,command -v $(CC)),C compiler '$(CC)' not found)
--

2.43.0

Signature · 1 line
             Dmitry
#2 lore raw

[tip: x86/build] x86/kconfig: Add as-instr64 macro to properly evaluate AS_WRUSS

In reply to Masahiro Yamada
The following commit has been merged into the x86/build branch of tip:

The following commit has been merged into the x86/build branch of tip:

Commit-ID:     469169803d52a5d8f0dc781090638e851a7d22b1
Gitweb:        https://git.kernel.org/tip/469169803d52a5d8f0dc781090638e851a7d22b1
Author:        Masahiro Yamada <[email protected]>
AuthorDate:    Wed, 12 Jun 2024 14:02:55 +09:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 20 Jun 2024 19:48:18 +02:00

x86/kconfig: Add as-instr64 macro to properly evaluate AS_WRUSS

Some instructions are only available on the 64-bit architecture.

Bi-arch compilers that default to -m32 need the explicit -m64 option to evaluate them properly.

---
 arch/x86/Kconfig.assembler | 2 +-
 scripts/Kconfig.include    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/Kconfig.assembler +1 -1
index 59aedf3..6d20a6c 100644
@@ -36,6 +36,6 @@ config AS_VPCLMULQDQ
 	  Supported by binutils >= 2.30 and LLVM integrated assembler
 
 config AS_WRUSS
-	def_bool $(as-instr,wrussq %rax$(comma)(%rbx))
+	def_bool $(as-instr64,wrussq %rax$(comma)(%rbx))
 	help
 	  Supported by binutils >= 2.31 and LLVM integrated assembler
scripts/Kconfig.include +2 -1
index 3ee8ecf..3500a3d 100644
@@ -33,7 +33,8 @@ ld-option = $(success,$(LD) -v $(1))
 
 # $(as-instr,<instr>)
 # Return y if the assembler supports <instr>, n otherwise
-as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) $(2) -Wa$(comma)--fatal-warnings -c -x assembler-with-cpp -o /dev/null -)
+as-instr64 = $(as-instr,$(1),$(m64-flag))
 
 # check if $(CC) and $(LD) exist
 $(error-if,$(failure,command -v $(CC)),C compiler '$(CC)' not found)