diff mbox series

x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp

Message ID 20220106185744.1561567-1-hjl.tools@gmail.com
State New
Headers show
Series x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp | expand

Commit Message

H.J. Lu Jan. 6, 2022, 6:57 p.m. UTC
Indirect branch also includes indirect call instructions.  Rename
-harden-sls=indirect-branch to -harden-sls=indirect-jmp to match its
intended behavior.

	PR target/102952
	* config/i386/i386-opts.h (harden_sls): Replace
	harden_sls_indirect_branch with harden_sls_indirect_jmp.
	* config/i386/i386.c (ix86_output_jmp_thunk_or_indirect):
	Likewise.
	(ix86_output_indirect_jmp): Likewise.
	(ix86_output_call_insn): Likewise.
	* config/i386/i386.opt: Replace indirect-branch with
	indirect-jmp.  Replace harden_sls_indirect_branch with
	harden_sls_indirect_jmp.
	* doc/invoke.texi (-harden-sls=): Replace indirect-branch with
	indirect-jmp.
---
 gcc/config/i386/i386-opts.h | 4 ++--
 gcc/config/i386/i386.c      | 6 +++---
 gcc/config/i386/i386.opt    | 2 +-
 gcc/doc/invoke.texi         | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

Comments

Uros Bizjak Jan. 6, 2022, 7:06 p.m. UTC | #1
On Thu, Jan 6, 2022 at 7:57 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Indirect branch also includes indirect call instructions.  Rename
> -harden-sls=indirect-branch to -harden-sls=indirect-jmp to match its
> intended behavior.
>
>         PR target/102952
>         * config/i386/i386-opts.h (harden_sls): Replace
>         harden_sls_indirect_branch with harden_sls_indirect_jmp.
>         * config/i386/i386.c (ix86_output_jmp_thunk_or_indirect):
>         Likewise.
>         (ix86_output_indirect_jmp): Likewise.
>         (ix86_output_call_insn): Likewise.
>         * config/i386/i386.opt: Replace indirect-branch with
>         indirect-jmp.  Replace harden_sls_indirect_branch with
>         harden_sls_indirect_jmp.
>         * doc/invoke.texi (-harden-sls=): Replace indirect-branch with
>         indirect-jmp.

OK.

Thanks,
Uros.

> ---
>  gcc/config/i386/i386-opts.h | 4 ++--
>  gcc/config/i386/i386.c      | 6 +++---
>  gcc/config/i386/i386.opt    | 2 +-
>  gcc/doc/invoke.texi         | 4 ++--
>  4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h
> index b31f9506c35..8f71e89fa9a 100644
> --- a/gcc/config/i386/i386-opts.h
> +++ b/gcc/config/i386/i386-opts.h
> @@ -124,8 +124,8 @@ enum instrument_return {
>  enum harden_sls {
>    harden_sls_none = 0,
>    harden_sls_return = 1 << 0,
> -  harden_sls_indirect_branch = 1 << 1,
> -  harden_sls_all = harden_sls_return | harden_sls_indirect_branch
> +  harden_sls_indirect_jmp = 1 << 1,
> +  harden_sls_all = harden_sls_return | harden_sls_indirect_jmp
>  };
>
>  #endif
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 1a964fe00f4..835ec2cafcb 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -16037,7 +16037,7 @@ ix86_output_jmp_thunk_or_indirect (const char *thunk_name, const int regno)
>        fprintf (asm_out_file, "\tjmp\t");
>        assemble_name (asm_out_file, thunk_name);
>        putc ('\n', asm_out_file);
> -      if ((ix86_harden_sls & harden_sls_indirect_branch))
> +      if ((ix86_harden_sls & harden_sls_indirect_jmp))
>         fputs ("\tint3\n", asm_out_file);
>      }
>    else
> @@ -16263,7 +16263,7 @@ ix86_output_indirect_jmp (rtx call_op)
>      }
>    else
>      output_asm_insn ("%!jmp\t%A0", &call_op);
> -  return (ix86_harden_sls & harden_sls_indirect_branch) ? "int3" : "";
> +  return (ix86_harden_sls & harden_sls_indirect_jmp) ? "int3" : "";
>  }
>
>  /* Output return instrumentation for current function if needed.  */
> @@ -16430,7 +16430,7 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
>         {
>           output_asm_insn (xasm, &call_op);
>           if (!direct_p
> -             && (ix86_harden_sls & harden_sls_indirect_branch))
> +             && (ix86_harden_sls & harden_sls_indirect_jmp))
>             return "int3";
>         }
>        return "";
> diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
> index e69955bd1a8..eb829d13d40 100644
> --- a/gcc/config/i386/i386.opt
> +++ b/gcc/config/i386/i386.opt
> @@ -1144,7 +1144,7 @@ EnumValue
>  Enum(harden_sls) String(return) Value(harden_sls_return)
>
>  EnumValue
> -Enum(harden_sls) String(indirect-branch) Value(harden_sls_indirect_branch)
> +Enum(harden_sls) String(indirect-jmp) Value(harden_sls_indirect_jmp)
>
>  EnumValue
>  Enum(harden_sls) String(all) Value(harden_sls_all)
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 04820656ffa..6b84228f142 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -32507,8 +32507,8 @@ Force indirect call and jump via register.
>  @opindex mharden-sls
>  Generate code to mitigate against straight line speculation (SLS) with
>  @var{choice}.  The default is @samp{none} which disables all SLS
> -hardening.  @samp{return} enables SLS hardening for function return.
> -@samp{indirect-branch} enables SLS hardening for indirect branch.
> +hardening.  @samp{return} enables SLS hardening for function returns.
> +@samp{indirect-jmp} enables SLS hardening for indirect jumps.
>  @samp{all} enables all SLS hardening.
>
>  @item -mindirect-branch-cs-prefix
> --
> 2.33.1
>
diff mbox series

Patch

diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h
index b31f9506c35..8f71e89fa9a 100644
--- a/gcc/config/i386/i386-opts.h
+++ b/gcc/config/i386/i386-opts.h
@@ -124,8 +124,8 @@  enum instrument_return {
 enum harden_sls {
   harden_sls_none = 0,
   harden_sls_return = 1 << 0,
-  harden_sls_indirect_branch = 1 << 1,
-  harden_sls_all = harden_sls_return | harden_sls_indirect_branch
+  harden_sls_indirect_jmp = 1 << 1,
+  harden_sls_all = harden_sls_return | harden_sls_indirect_jmp
 };
 
 #endif
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1a964fe00f4..835ec2cafcb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -16037,7 +16037,7 @@  ix86_output_jmp_thunk_or_indirect (const char *thunk_name, const int regno)
       fprintf (asm_out_file, "\tjmp\t");
       assemble_name (asm_out_file, thunk_name);
       putc ('\n', asm_out_file);
-      if ((ix86_harden_sls & harden_sls_indirect_branch))
+      if ((ix86_harden_sls & harden_sls_indirect_jmp))
 	fputs ("\tint3\n", asm_out_file);
     }
   else
@@ -16263,7 +16263,7 @@  ix86_output_indirect_jmp (rtx call_op)
     }
   else
     output_asm_insn ("%!jmp\t%A0", &call_op);
-  return (ix86_harden_sls & harden_sls_indirect_branch) ? "int3" : "";
+  return (ix86_harden_sls & harden_sls_indirect_jmp) ? "int3" : "";
 }
 
 /* Output return instrumentation for current function if needed.  */
@@ -16430,7 +16430,7 @@  ix86_output_call_insn (rtx_insn *insn, rtx call_op)
 	{
 	  output_asm_insn (xasm, &call_op);
 	  if (!direct_p
-	      && (ix86_harden_sls & harden_sls_indirect_branch))
+	      && (ix86_harden_sls & harden_sls_indirect_jmp))
 	    return "int3";
 	}
       return "";
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index e69955bd1a8..eb829d13d40 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -1144,7 +1144,7 @@  EnumValue
 Enum(harden_sls) String(return) Value(harden_sls_return)
 
 EnumValue
-Enum(harden_sls) String(indirect-branch) Value(harden_sls_indirect_branch)
+Enum(harden_sls) String(indirect-jmp) Value(harden_sls_indirect_jmp)
 
 EnumValue
 Enum(harden_sls) String(all) Value(harden_sls_all)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 04820656ffa..6b84228f142 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -32507,8 +32507,8 @@  Force indirect call and jump via register.
 @opindex mharden-sls
 Generate code to mitigate against straight line speculation (SLS) with
 @var{choice}.  The default is @samp{none} which disables all SLS
-hardening.  @samp{return} enables SLS hardening for function return.
-@samp{indirect-branch} enables SLS hardening for indirect branch.
+hardening.  @samp{return} enables SLS hardening for function returns.
+@samp{indirect-jmp} enables SLS hardening for indirect jumps.
 @samp{all} enables all SLS hardening.
 
 @item -mindirect-branch-cs-prefix