[11,0/5] x86: Backport straight-line-speculation mitigation

Message ID 20220131185528.619688-1-hjl.tools@gmail.com
Headers
Series x86: Backport straight-line-speculation mitigation |

Message

H.J. Lu Jan. 31, 2022, 6:55 p.m. UTC
  Backport -mindirect-branch-cs-prefix:

commit 48a4ae26c225eb018ecb59f131e2c4fd4f3cf89a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Oct 27 06:27:15 2021 -0700

    x86: Add -mindirect-branch-cs-prefix

    Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
    indirect thunk with branch target in r8-r15 registers so that the call
    and jmp instruction length is 6 bytes to allow them to be replaced with
    "lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.

commit 63738e176726d31953deb03f7e32cf8b760735ac
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Oct 27 07:48:54 2021 -0700

    x86: Add -mharden-sls=[none|all|return|indirect-branch]

    Add -mharden-sls= to mitigate against straight line speculation (SLS)
    for function return and indirect branch by adding an INT3 instruction
    after function return and indirect branch.

and followup commits to support Linux kernel commits:

commit e463a09af2f0677b9485a7e8e4e70b396b2ffb6f
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Sat Dec 4 14:43:44 2021 +0100

    x86: Add straight-line-speculation mitigation

commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Fri Nov 19 17:50:25 2021 +0100

    x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds

H.J. Lu (5):
  x86: Remove "%!" before ret
  x86: Add -mharden-sls=[none|all|return|indirect-branch]
  x86: Add -mindirect-branch-cs-prefix
  x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
  x86: Generate INT3 for __builtin_eh_return

 gcc/config/i386/i386-opts.h                   |  7 ++++
 gcc/config/i386/i386.c                        | 38 +++++++++++++------
 gcc/config/i386/i386.md                       |  2 +-
 gcc/config/i386/i386.opt                      | 24 ++++++++++++
 gcc/doc/invoke.texi                           | 18 ++++++++-
 gcc/testsuite/gcc.target/i386/harden-sls-1.c  | 14 +++++++
 gcc/testsuite/gcc.target/i386/harden-sls-2.c  | 14 +++++++
 gcc/testsuite/gcc.target/i386/harden-sls-3.c  | 14 +++++++
 gcc/testsuite/gcc.target/i386/harden-sls-4.c  | 16 ++++++++
 gcc/testsuite/gcc.target/i386/harden-sls-5.c  | 17 +++++++++
 gcc/testsuite/gcc.target/i386/harden-sls-6.c  | 18 +++++++++
 .../i386/indirect-thunk-cs-prefix-1.c         | 14 +++++++
 .../i386/indirect-thunk-cs-prefix-2.c         | 15 ++++++++
 13 files changed, 198 insertions(+), 13 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-3.c
 create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-4.c
 create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-5.c
 create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-6.c
 create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-2.c
  

Comments

Richard Biener Feb. 1, 2022, 7:21 a.m. UTC | #1
On Mon, Jan 31, 2022 at 7:56 PM H.J. Lu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Backport -mindirect-branch-cs-prefix:

LGTM in case a x86 maintainer also acks this.  Can you amend
the 10.3 release gcc-11/changes.html notes accordingly?

Thanks,
Richard.

> commit 48a4ae26c225eb018ecb59f131e2c4fd4f3cf89a
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Wed Oct 27 06:27:15 2021 -0700
>
>     x86: Add -mindirect-branch-cs-prefix
>
>     Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
>     indirect thunk with branch target in r8-r15 registers so that the call
>     and jmp instruction length is 6 bytes to allow them to be replaced with
>     "lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.
>
> commit 63738e176726d31953deb03f7e32cf8b760735ac
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Wed Oct 27 07:48:54 2021 -0700
>
>     x86: Add -mharden-sls=[none|all|return|indirect-branch]
>
>     Add -mharden-sls= to mitigate against straight line speculation (SLS)
>     for function return and indirect branch by adding an INT3 instruction
>     after function return and indirect branch.
>
> and followup commits to support Linux kernel commits:
>
> commit e463a09af2f0677b9485a7e8e4e70b396b2ffb6f
> Author: Peter Zijlstra <peterz@infradead.org>
> Date:   Sat Dec 4 14:43:44 2021 +0100
>
>     x86: Add straight-line-speculation mitigation
>
> commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d
> Author: Peter Zijlstra <peterz@infradead.org>
> Date:   Fri Nov 19 17:50:25 2021 +0100
>
>     x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
>
> H.J. Lu (5):
>   x86: Remove "%!" before ret
>   x86: Add -mharden-sls=[none|all|return|indirect-branch]
>   x86: Add -mindirect-branch-cs-prefix
>   x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
>   x86: Generate INT3 for __builtin_eh_return
>
>  gcc/config/i386/i386-opts.h                   |  7 ++++
>  gcc/config/i386/i386.c                        | 38 +++++++++++++------
>  gcc/config/i386/i386.md                       |  2 +-
>  gcc/config/i386/i386.opt                      | 24 ++++++++++++
>  gcc/doc/invoke.texi                           | 18 ++++++++-
>  gcc/testsuite/gcc.target/i386/harden-sls-1.c  | 14 +++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-2.c  | 14 +++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-3.c  | 14 +++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-4.c  | 16 ++++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-5.c  | 17 +++++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-6.c  | 18 +++++++++
>  .../i386/indirect-thunk-cs-prefix-1.c         | 14 +++++++
>  .../i386/indirect-thunk-cs-prefix-2.c         | 15 ++++++++
>  13 files changed, 198 insertions(+), 13 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-2.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-3.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-4.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-5.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-6.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-2.c
>
> --
> 2.34.1
>
  
H.J. Lu Feb. 1, 2022, 4:59 p.m. UTC | #2
On Mon, Jan 31, 2022 at 11:21 PM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Mon, Jan 31, 2022 at 7:56 PM H.J. Lu via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > Backport -mindirect-branch-cs-prefix:
>
> LGTM in case a x86 maintainer also acks this.  Can you amend
> the 10.3 release gcc-11/changes.html notes accordingly?

Did you mean 11.3?

Here is the patch for gcc-12/changes.html:

https://gcc.gnu.org/pipermail/gcc-patches/2022-February/589600.html

> Thanks,
> Richard.
>
> > commit 48a4ae26c225eb018ecb59f131e2c4fd4f3cf89a
> > Author: H.J. Lu <hjl.tools@gmail.com>
> > Date:   Wed Oct 27 06:27:15 2021 -0700
> >
> >     x86: Add -mindirect-branch-cs-prefix
> >
> >     Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
> >     indirect thunk with branch target in r8-r15 registers so that the call
> >     and jmp instruction length is 6 bytes to allow them to be replaced with
> >     "lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.
> >
> > commit 63738e176726d31953deb03f7e32cf8b760735ac
> > Author: H.J. Lu <hjl.tools@gmail.com>
> > Date:   Wed Oct 27 07:48:54 2021 -0700
> >
> >     x86: Add -mharden-sls=[none|all|return|indirect-branch]
> >
> >     Add -mharden-sls= to mitigate against straight line speculation (SLS)
> >     for function return and indirect branch by adding an INT3 instruction
> >     after function return and indirect branch.
> >
> > and followup commits to support Linux kernel commits:
> >
> > commit e463a09af2f0677b9485a7e8e4e70b396b2ffb6f
> > Author: Peter Zijlstra <peterz@infradead.org>
> > Date:   Sat Dec 4 14:43:44 2021 +0100
> >
> >     x86: Add straight-line-speculation mitigation
> >
> > commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d
> > Author: Peter Zijlstra <peterz@infradead.org>
> > Date:   Fri Nov 19 17:50:25 2021 +0100
> >
> >     x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
> >
> > H.J. Lu (5):
> >   x86: Remove "%!" before ret
> >   x86: Add -mharden-sls=[none|all|return|indirect-branch]
> >   x86: Add -mindirect-branch-cs-prefix
> >   x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
> >   x86: Generate INT3 for __builtin_eh_return
> >
> >  gcc/config/i386/i386-opts.h                   |  7 ++++
> >  gcc/config/i386/i386.c                        | 38 +++++++++++++------
> >  gcc/config/i386/i386.md                       |  2 +-
> >  gcc/config/i386/i386.opt                      | 24 ++++++++++++
> >  gcc/doc/invoke.texi                           | 18 ++++++++-
> >  gcc/testsuite/gcc.target/i386/harden-sls-1.c  | 14 +++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-2.c  | 14 +++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-3.c  | 14 +++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-4.c  | 16 ++++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-5.c  | 17 +++++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-6.c  | 18 +++++++++
> >  .../i386/indirect-thunk-cs-prefix-1.c         | 14 +++++++
> >  .../i386/indirect-thunk-cs-prefix-2.c         | 15 ++++++++
> >  13 files changed, 198 insertions(+), 13 deletions(-)
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-1.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-2.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-3.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-4.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-5.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-6.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-1.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-2.c
> >
> > --
> > 2.34.1
> >
  
Richard Biener Feb. 2, 2022, 9:22 a.m. UTC | #3
On Tue, Feb 1, 2022 at 5:59 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, Jan 31, 2022 at 11:21 PM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On Mon, Jan 31, 2022 at 7:56 PM H.J. Lu via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > >
> > > Backport -mindirect-branch-cs-prefix:
> >
> > LGTM in case a x86 maintainer also acks this.  Can you amend
> > the 10.3 release gcc-11/changes.html notes accordingly?
>
> Did you mean 11.3?

Yes, of course.

> Here is the patch for gcc-12/changes.html:
>
> https://gcc.gnu.org/pipermail/gcc-patches/2022-February/589600.html
>
> > Thanks,
> > Richard.
> >
> > > commit 48a4ae26c225eb018ecb59f131e2c4fd4f3cf89a
> > > Author: H.J. Lu <hjl.tools@gmail.com>
> > > Date:   Wed Oct 27 06:27:15 2021 -0700
> > >
> > >     x86: Add -mindirect-branch-cs-prefix
> > >
> > >     Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
> > >     indirect thunk with branch target in r8-r15 registers so that the call
> > >     and jmp instruction length is 6 bytes to allow them to be replaced with
> > >     "lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.
> > >
> > > commit 63738e176726d31953deb03f7e32cf8b760735ac
> > > Author: H.J. Lu <hjl.tools@gmail.com>
> > > Date:   Wed Oct 27 07:48:54 2021 -0700
> > >
> > >     x86: Add -mharden-sls=[none|all|return|indirect-branch]
> > >
> > >     Add -mharden-sls= to mitigate against straight line speculation (SLS)
> > >     for function return and indirect branch by adding an INT3 instruction
> > >     after function return and indirect branch.
> > >
> > > and followup commits to support Linux kernel commits:
> > >
> > > commit e463a09af2f0677b9485a7e8e4e70b396b2ffb6f
> > > Author: Peter Zijlstra <peterz@infradead.org>
> > > Date:   Sat Dec 4 14:43:44 2021 +0100
> > >
> > >     x86: Add straight-line-speculation mitigation
> > >
> > > commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d
> > > Author: Peter Zijlstra <peterz@infradead.org>
> > > Date:   Fri Nov 19 17:50:25 2021 +0100
> > >
> > >     x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
> > >
> > > H.J. Lu (5):
> > >   x86: Remove "%!" before ret
> > >   x86: Add -mharden-sls=[none|all|return|indirect-branch]
> > >   x86: Add -mindirect-branch-cs-prefix
> > >   x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
> > >   x86: Generate INT3 for __builtin_eh_return
> > >
> > >  gcc/config/i386/i386-opts.h                   |  7 ++++
> > >  gcc/config/i386/i386.c                        | 38 +++++++++++++------
> > >  gcc/config/i386/i386.md                       |  2 +-
> > >  gcc/config/i386/i386.opt                      | 24 ++++++++++++
> > >  gcc/doc/invoke.texi                           | 18 ++++++++-
> > >  gcc/testsuite/gcc.target/i386/harden-sls-1.c  | 14 +++++++
> > >  gcc/testsuite/gcc.target/i386/harden-sls-2.c  | 14 +++++++
> > >  gcc/testsuite/gcc.target/i386/harden-sls-3.c  | 14 +++++++
> > >  gcc/testsuite/gcc.target/i386/harden-sls-4.c  | 16 ++++++++
> > >  gcc/testsuite/gcc.target/i386/harden-sls-5.c  | 17 +++++++++
> > >  gcc/testsuite/gcc.target/i386/harden-sls-6.c  | 18 +++++++++
> > >  .../i386/indirect-thunk-cs-prefix-1.c         | 14 +++++++
> > >  .../i386/indirect-thunk-cs-prefix-2.c         | 15 ++++++++
> > >  13 files changed, 198 insertions(+), 13 deletions(-)
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-1.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-2.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-3.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-4.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-5.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-6.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-1.c
> > >  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-2.c
> > >
> > > --
> > > 2.34.1
> > >
>
>
>
> --
> H.J.
  
Hongtao Liu Feb. 16, 2022, 7:01 a.m. UTC | #4
On Tue, Feb 1, 2022 at 2:55 AM H.J. Lu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Backport -mindirect-branch-cs-prefix:
>
> commit 48a4ae26c225eb018ecb59f131e2c4fd4f3cf89a
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Wed Oct 27 06:27:15 2021 -0700
>
>     x86: Add -mindirect-branch-cs-prefix
>
>     Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
>     indirect thunk with branch target in r8-r15 registers so that the call
>     and jmp instruction length is 6 bytes to allow them to be replaced with
>     "lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.
>
> commit 63738e176726d31953deb03f7e32cf8b760735ac
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Wed Oct 27 07:48:54 2021 -0700
>
>     x86: Add -mharden-sls=[none|all|return|indirect-branch]
>
>     Add -mharden-sls= to mitigate against straight line speculation (SLS)
>     for function return and indirect branch by adding an INT3 instruction
>     after function return and indirect branch.
>
> and followup commits to support Linux kernel commits:
>
> commit e463a09af2f0677b9485a7e8e4e70b396b2ffb6f
> Author: Peter Zijlstra <peterz@infradead.org>
> Date:   Sat Dec 4 14:43:44 2021 +0100
>
>     x86: Add straight-line-speculation mitigation
>
> commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d
> Author: Peter Zijlstra <peterz@infradead.org>
> Date:   Fri Nov 19 17:50:25 2021 +0100
>
>     x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
>
> H.J. Lu (5):
>   x86: Remove "%!" before ret
>   x86: Add -mharden-sls=[none|all|return|indirect-branch]
>   x86: Add -mindirect-branch-cs-prefix
>   x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
>   x86: Generate INT3 for __builtin_eh_return
The patch LGTM.
>
>  gcc/config/i386/i386-opts.h                   |  7 ++++
>  gcc/config/i386/i386.c                        | 38 +++++++++++++------
>  gcc/config/i386/i386.md                       |  2 +-
>  gcc/config/i386/i386.opt                      | 24 ++++++++++++
>  gcc/doc/invoke.texi                           | 18 ++++++++-
>  gcc/testsuite/gcc.target/i386/harden-sls-1.c  | 14 +++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-2.c  | 14 +++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-3.c  | 14 +++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-4.c  | 16 ++++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-5.c  | 17 +++++++++
>  gcc/testsuite/gcc.target/i386/harden-sls-6.c  | 18 +++++++++
>  .../i386/indirect-thunk-cs-prefix-1.c         | 14 +++++++
>  .../i386/indirect-thunk-cs-prefix-2.c         | 15 ++++++++
>  13 files changed, 198 insertions(+), 13 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-2.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-3.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-4.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-5.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-6.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-2.c
>
> --
> 2.34.1
>
  
H.J. Lu Feb. 16, 2022, 1:30 p.m. UTC | #5
On Tue, Feb 15, 2022 at 10:52 PM Hongtao Liu <crazylht@gmail.com> wrote:
>
> On Tue, Feb 1, 2022 at 2:55 AM H.J. Lu via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > Backport -mindirect-branch-cs-prefix:
> >
> > commit 48a4ae26c225eb018ecb59f131e2c4fd4f3cf89a
> > Author: H.J. Lu <hjl.tools@gmail.com>
> > Date:   Wed Oct 27 06:27:15 2021 -0700
> >
> >     x86: Add -mindirect-branch-cs-prefix
> >
> >     Add -mindirect-branch-cs-prefix to add CS prefix to call and jmp to
> >     indirect thunk with branch target in r8-r15 registers so that the call
> >     and jmp instruction length is 6 bytes to allow them to be replaced with
> >     "lfence; call *%r8-r15" or "lfence; jmp *%r8-r15" at run-time.
> >
> > commit 63738e176726d31953deb03f7e32cf8b760735ac
> > Author: H.J. Lu <hjl.tools@gmail.com>
> > Date:   Wed Oct 27 07:48:54 2021 -0700
> >
> >     x86: Add -mharden-sls=[none|all|return|indirect-branch]
> >
> >     Add -mharden-sls= to mitigate against straight line speculation (SLS)
> >     for function return and indirect branch by adding an INT3 instruction
> >     after function return and indirect branch.
> >
> > and followup commits to support Linux kernel commits:
> >
> > commit e463a09af2f0677b9485a7e8e4e70b396b2ffb6f
> > Author: Peter Zijlstra <peterz@infradead.org>
> > Date:   Sat Dec 4 14:43:44 2021 +0100
> >
> >     x86: Add straight-line-speculation mitigation
> >
> > commit 68cf4f2a72ef8786e6b7af6fd9a89f27ac0f520d
> > Author: Peter Zijlstra <peterz@infradead.org>
> > Date:   Fri Nov 19 17:50:25 2021 +0100
> >
> >     x86: Use -mindirect-branch-cs-prefix for RETPOLINE builds
> >
> > H.J. Lu (5):
> >   x86: Remove "%!" before ret
> >   x86: Add -mharden-sls=[none|all|return|indirect-branch]
> >   x86: Add -mindirect-branch-cs-prefix
> >   x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp
> >   x86: Generate INT3 for __builtin_eh_return
> The patch LGTM.

I am pushing this patch set into GCC 11 branch.

Thanks.

> >
> >  gcc/config/i386/i386-opts.h                   |  7 ++++
> >  gcc/config/i386/i386.c                        | 38 +++++++++++++------
> >  gcc/config/i386/i386.md                       |  2 +-
> >  gcc/config/i386/i386.opt                      | 24 ++++++++++++
> >  gcc/doc/invoke.texi                           | 18 ++++++++-
> >  gcc/testsuite/gcc.target/i386/harden-sls-1.c  | 14 +++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-2.c  | 14 +++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-3.c  | 14 +++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-4.c  | 16 ++++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-5.c  | 17 +++++++++
> >  gcc/testsuite/gcc.target/i386/harden-sls-6.c  | 18 +++++++++
> >  .../i386/indirect-thunk-cs-prefix-1.c         | 14 +++++++
> >  .../i386/indirect-thunk-cs-prefix-2.c         | 15 ++++++++
> >  13 files changed, 198 insertions(+), 13 deletions(-)
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-1.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-2.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-3.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-4.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-5.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/harden-sls-6.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-1.c
> >  create mode 100644 gcc/testsuite/gcc.target/i386/indirect-thunk-cs-prefix-2.c
> >
> > --
> > 2.34.1
> >
>
>
> --
> BR,
> Hongtao