mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS
@ 2024-06-12  5:02 Masahiro Yamada
  2024-06-12  9:19 ` Dmitry Safonov
  2024-06-20 18:03 ` [tip: x86/build] x86/kconfig: Add " tip-bot2 for Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2024-06-12  5:02 UTC (permalink / raw)
  To: linux-kbuild, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86
  Cc: linux-kernel, H . Peter Anvin, Dmitry Safonov, Masahiro Yamada,
	Mike Rapoport (IBM),
	Rick Edgecombe, Yu-cheng Yu

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")
Reported-by: Dmitry Safonov <0x7f454c46@gmail.com>
Closes: https://lore.kernel.org/all/20240612-as-instr-opt-wrussq-v2-1-bd950f7eead7@gmail.com/
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 arch/x86/Kconfig.assembler | 2 +-
 scripts/Kconfig.include    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler
index 59aedf32c4ea..6d20a6ce0507 100644
--- a/arch/x86/Kconfig.assembler
+++ b/arch/x86/Kconfig.assembler
@@ -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
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index 3ee8ecfb8c04..3500a3d62f0d 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS
  2024-06-12  5:02 [PATCH] x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS Masahiro Yamada
@ 2024-06-12  9:19 ` Dmitry Safonov
  2024-06-20 18:03 ` [tip: x86/build] x86/kconfig: Add " tip-bot2 for Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Safonov @ 2024-06-12  9:19 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-kbuild, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, linux-kernel, H . Peter Anvin,
	Mike Rapoport (IBM),
	Rick Edgecombe, Yu-cheng Yu

On Wed, 12 Jun 2024 at 06:03, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> 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")
> Reported-by: Dmitry Safonov <0x7f454c46@gmail.com>
> Closes: https://lore.kernel.org/all/20240612-as-instr-opt-wrussq-v2-1-bd950f7eead7@gmail.com/
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

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

Tested-by: Dmitry Safonov <0x7f454c46@gmail.com>

> ---
>
>  arch/x86/Kconfig.assembler | 2 +-
>  scripts/Kconfig.include    | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler
> index 59aedf32c4ea..6d20a6ce0507 100644
> --- a/arch/x86/Kconfig.assembler
> +++ b/arch/x86/Kconfig.assembler
> @@ -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
> diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
> index 3ee8ecfb8c04..3500a3d62f0d 100644
> --- a/scripts/Kconfig.include
> +++ b/scripts/Kconfig.include
> @@ -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
>
-- 
             Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: x86/build] x86/kconfig: Add as-instr64 macro to properly evaluate AS_WRUSS
  2024-06-12  5:02 [PATCH] x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS Masahiro Yamada
  2024-06-12  9:19 ` Dmitry Safonov
@ 2024-06-20 18:03 ` tip-bot2 for Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Masahiro Yamada @ 2024-06-20 18:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Dmitry Safonov, Masahiro Yamada, Borislav Petkov (AMD),
	x86, linux-kernel

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 <masahiroy@kernel.org>
AuthorDate:    Wed, 12 Jun 2024 14:02:55 +09:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
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.

Fixes: 18e66b695e78 ("x86/shstk: Add Kconfig option for shadow stack")
Closes: https://lore.kernel.org/all/20240612-as-instr-opt-wrussq-v2-1-bd950f7eead7@gmail.com/
Reported-by: Dmitry Safonov <0x7f454c46@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Dmitry Safonov <0x7f454c46@gmail.com>
Link: https://lore.kernel.org/r/20240612050257.3670768-1-masahiroy@kernel.org
---
 arch/x86/Kconfig.assembler | 2 +-
 scripts/Kconfig.include    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig.assembler b/arch/x86/Kconfig.assembler
index 59aedf3..6d20a6c 100644
--- a/arch/x86/Kconfig.assembler
+++ b/arch/x86/Kconfig.assembler
@@ -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
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index 3ee8ecf..3500a3d 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-20 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-12  5:02 [PATCH] x86/kconfig: add as-instr64 macro to properly evaluate AS_WRUSS Masahiro Yamada
2024-06-12  9:19 ` Dmitry Safonov
2024-06-20 18:03 ` [tip: x86/build] x86/kconfig: Add " tip-bot2 for Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®