Blame SOURCES/gcc8-harden-3.patch

6d6b46
From 621de498ee19e1f2642eebde707430254c0459c0 Mon Sep 17 00:00:00 2001
6d6b46
From: "H.J. Lu" <hjl.tools@gmail.com>
6d6b46
Date: Wed, 5 Jan 2022 16:33:16 -0800
6d6b46
Subject: [PATCH 3/4] x86: Rename -harden-sls=indirect-branch to
6d6b46
 -harden-sls=indirect-jmp
6d6b46
6d6b46
Indirect branch also includes indirect call instructions.  Rename
6d6b46
-harden-sls=indirect-branch to -harden-sls=indirect-jmp to match its
6d6b46
intended behavior.
6d6b46
6d6b46
	PR target/102952
6d6b46
	* config/i386/i386-opts.h (harden_sls): Replace
6d6b46
	harden_sls_indirect_branch with harden_sls_indirect_jmp.
6d6b46
	* config/i386/i386.c (ix86_output_jmp_thunk_or_indirect):
6d6b46
	Likewise.
6d6b46
	(ix86_output_indirect_jmp): Likewise.
6d6b46
	(ix86_output_call_insn): Likewise.
6d6b46
	* config/i386/i386.opt: Replace indirect-branch with
6d6b46
	indirect-jmp.  Replace harden_sls_indirect_branch with
6d6b46
	harden_sls_indirect_jmp.
6d6b46
	* doc/invoke.texi (-harden-sls=): Replace indirect-branch with
6d6b46
	indirect-jmp.
6d6b46
6d6b46
(cherry picked from commit ed8060950c64f2e449aaf90e438aa26d0d9d0b31)
6d6b46
---
6d6b46
 gcc/config/i386/i386-opts.h | 4 ++--
6d6b46
 gcc/config/i386/i386.c      | 6 +++---
6d6b46
 gcc/config/i386/i386.opt    | 2 +-
6d6b46
 gcc/doc/invoke.texi         | 4 ++--
6d6b46
 4 files changed, 8 insertions(+), 8 deletions(-)
6d6b46
6d6b46
diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h
6d6b46
index 34718b6d52c..47facc254cd 100644
6d6b46
--- a/gcc/config/i386/i386-opts.h
6d6b46
+++ b/gcc/config/i386/i386-opts.h
6d6b46
@@ -122,8 +122,8 @@ enum indirect_branch {
6d6b46
 enum harden_sls {
6d6b46
   harden_sls_none = 0,
6d6b46
   harden_sls_return = 1 << 0,
6d6b46
-  harden_sls_indirect_branch = 1 << 1,
6d6b46
-  harden_sls_all = harden_sls_return | harden_sls_indirect_branch
6d6b46
+  harden_sls_indirect_jmp = 1 << 1,
6d6b46
+  harden_sls_all = harden_sls_return | harden_sls_indirect_jmp
6d6b46
 };
6d6b46
 
6d6b46
 #endif
6d6b46
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
6d6b46
index 8442dd0daea..3bc14e20105 100644
6d6b46
--- a/gcc/config/i386/i386.c
6d6b46
+++ b/gcc/config/i386/i386.c
6d6b46
@@ -28736,7 +28736,7 @@ ix86_output_jmp_thunk_or_indirect (const char *thunk_name,
6d6b46
 	}
6d6b46
       assemble_name (asm_out_file, thunk_name);
6d6b46
       putc ('\n', asm_out_file);
6d6b46
-      if ((ix86_harden_sls & harden_sls_indirect_branch))
6d6b46
+      if ((ix86_harden_sls & harden_sls_indirect_jmp))
6d6b46
 	fputs ("\tint3\n", asm_out_file);
6d6b46
     }
6d6b46
   else
6d6b46
@@ -28991,7 +28991,7 @@ ix86_output_indirect_jmp (rtx call_op)
6d6b46
     }
6d6b46
   else
6d6b46
     output_asm_insn ("%!jmp\t%A0", &call_op);
6d6b46
-  return (ix86_harden_sls & harden_sls_indirect_branch) ? "int3" : "";
6d6b46
+  return (ix86_harden_sls & harden_sls_indirect_jmp) ? "int3" : "";
6d6b46
 }
6d6b46
 
6d6b46
 /* Output function return.  CALL_OP is the jump target.  Add a REP
6d6b46
@@ -29178,7 +29178,7 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op)
6d6b46
 	{
6d6b46
 	  output_asm_insn (xasm, &call_op);
6d6b46
 	  if (!direct_p
6d6b46
-	      && (ix86_harden_sls & harden_sls_indirect_branch))
6d6b46
+	      && (ix86_harden_sls & harden_sls_indirect_jmp))
6d6b46
 	    return "int3";
6d6b46
 	}
6d6b46
       return "";
6d6b46
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
6d6b46
index 9f67ef558dc..7a5c7b9369a 100644
6d6b46
--- a/gcc/config/i386/i386.opt
6d6b46
+++ b/gcc/config/i386/i386.opt
6d6b46
@@ -1075,7 +1075,7 @@ EnumValue
6d6b46
 Enum(harden_sls) String(return) Value(harden_sls_return)
6d6b46
 
6d6b46
 EnumValue
6d6b46
-Enum(harden_sls) String(indirect-branch) Value(harden_sls_indirect_branch)
6d6b46
+Enum(harden_sls) String(indirect-jmp) Value(harden_sls_indirect_jmp)
6d6b46
 
6d6b46
 EnumValue
6d6b46
 Enum(harden_sls) String(all) Value(harden_sls_all)
6d6b46
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
6d6b46
index 605cd4b93f1..20d8e3fd782 100644
6d6b46
--- a/gcc/doc/invoke.texi
6d6b46
+++ b/gcc/doc/invoke.texi
6d6b46
@@ -28041,8 +28041,8 @@ Force indirect call and jump via register.
6d6b46
 @opindex mharden-sls
6d6b46
 Generate code to mitigate against straight line speculation (SLS) with
6d6b46
 @var{choice}.  The default is @samp{none} which disables all SLS
6d6b46
-hardening.  @samp{return} enables SLS hardening for function return.
6d6b46
-@samp{indirect-branch} enables SLS hardening for indirect branch.
6d6b46
+hardening.  @samp{return} enables SLS hardening for function returns.
6d6b46
+@samp{indirect-jmp} enables SLS hardening for indirect jumps.
6d6b46
 @samp{all} enables all SLS hardening.
6d6b46
 
6d6b46
 @item -mindirect-branch-cs-prefix
6d6b46
-- 
6d6b46
2.36.1
6d6b46