Blame SOURCES/gcc8-harden-3.patch

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