linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
@ 2021-11-18 18:54 Peter Zijlstra
  2021-11-18 22:08 ` Nick Desaulniers
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2021-11-18 18:54 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, H.J. Lu, ndesaulniers


In order to further enable commit:

  bbe2df3f6b6d ("x86/alternative: Try inline spectre_v2=retpoline,amd")

add the new GCC flag -mindirect-branch-cs-prefix:

  https://gcc.gnu.org/g:2196a681d7810ad8b227bf983f38ba716620545e

to RETPOLINE=y builds. This should allow fully inlining retpoline,amd
for GCC builds.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile b/Makefile
index 9e12c14ea0fb..5fd5b5f091ae 100644
--- a/Makefile
+++ b/Makefile
@@ -690,6 +690,7 @@ endif
 
 ifdef CONFIG_CC_IS_GCC
 RETPOLINE_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
+RETPOLINE_CFLAGS	+= $(call cc-option,-mindirect-branch-cs-prefix)
 RETPOLINE_VDSO_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
 endif
 ifdef CONFIG_CC_IS_CLANG

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

* Re: [PATCH] x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
  2021-11-18 18:54 [PATCH] x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds Peter Zijlstra
@ 2021-11-18 22:08 ` Nick Desaulniers
  2021-11-19 15:11   ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Desaulniers @ 2021-11-18 22:08 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: x86, linux-kernel, H.J. Lu, llvm, linux-toolchains, Masahiro Yamada

On Thu, Nov 18, 2021 at 10:54 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
>
> In order to further enable commit:
>
>   bbe2df3f6b6d ("x86/alternative: Try inline spectre_v2=retpoline,amd")
>
> add the new GCC flag -mindirect-branch-cs-prefix:
>
>   https://gcc.gnu.org/g:2196a681d7810ad8b227bf983f38ba716620545e
>
> to RETPOLINE=y builds. This should allow fully inlining retpoline,amd
> for GCC builds.

Do you mind adding the following link tags:

Link: https://gcc.gnu.org/g:2196a681d7810ad8b227bf983f38ba716620545e
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102952
Link: https://bugs.llvm.org/show_bug.cgi?id=52323

If the feature would be helpful to implement in Clang, would you mind
keeping the cc-option, but moving the check outside of the `ifdef
CONFIG_CC_IS_GCC` block? That way, we don't need to revisit the
Makefile?

(Tangential: I wonder why RETPOLINE_CFLAGS aren't defined in
arch/x86/Makefile; they seem to be x86 specific at the moment).

With the above link tags, and with or without moving this outside the
gcc-specific guard:
Acked-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/Makefile b/Makefile
> index 9e12c14ea0fb..5fd5b5f091ae 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -690,6 +690,7 @@ endif
>
>  ifdef CONFIG_CC_IS_GCC
>  RETPOLINE_CFLAGS       := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
> +RETPOLINE_CFLAGS       += $(call cc-option,-mindirect-branch-cs-prefix)
>  RETPOLINE_VDSO_CFLAGS  := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
>  endif
>  ifdef CONFIG_CC_IS_CLANG



-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
  2021-11-18 22:08 ` Nick Desaulniers
@ 2021-11-19 15:11   ` Peter Zijlstra
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2021-11-19 15:11 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: x86, linux-kernel, H.J. Lu, llvm, linux-toolchains, Masahiro Yamada

On Thu, Nov 18, 2021 at 02:08:04PM -0800, Nick Desaulniers wrote:
> On Thu, Nov 18, 2021 at 10:54 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> >
> > In order to further enable commit:
> >
> >   bbe2df3f6b6d ("x86/alternative: Try inline spectre_v2=retpoline,amd")
> >
> > add the new GCC flag -mindirect-branch-cs-prefix:
> >
> >   https://gcc.gnu.org/g:2196a681d7810ad8b227bf983f38ba716620545e
> >
> > to RETPOLINE=y builds. This should allow fully inlining retpoline,amd
> > for GCC builds.
> 
> Do you mind adding the following link tags:
> 
> Link: https://gcc.gnu.org/g:2196a681d7810ad8b227bf983f38ba716620545e
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102952
> Link: https://bugs.llvm.org/show_bug.cgi?id=52323

My scripts will strip that, they only like to have a Link to to the
actual email as posted. I can put in the URLs, the first is already in
the Changelog.

> If the feature would be helpful to implement in Clang, would you mind
> keeping the cc-option, but moving the check outside of the `ifdef
> CONFIG_CC_IS_GCC` block? That way, we don't need to revisit the
> Makefile?

I was thinking that clang would want to name it differently to be
consistent with their own retpoline flags, something like:

  -mretpoline-cs-prefix

> (Tangential: I wonder why RETPOLINE_CFLAGS aren't defined in
> arch/x86/Makefile; they seem to be x86 specific at the moment).

Yeah, I think there was hoping that other archs would find it useful,
but so far x86 is the only one having grown them things. I can move them
I suppose. If ever another arch grows them we can reconsider.

> With the above link tags, and with or without moving this outside the
> gcc-specific guard:
> Acked-by: Nick Desaulniers <ndesaulniers@google.com>

Thanks, let me repost as two patches.

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

end of thread, other threads:[~2021-11-19 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 18:54 [PATCH] x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds Peter Zijlstra
2021-11-18 22:08 ` Nick Desaulniers
2021-11-19 15:11   ` Peter Zijlstra

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).