gcc7-x86-Add-mindirect-branch-cs-prefix.patch, gcc7-x86-Generate-INT3-for-__builtin_eh_return.patch and gcc7-x86-Rename-harden-sls-indirect-branch-to-harden-sls-.patch to backport -mharden-sls support. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gcc7?expand=0&rev=227
110 lines
4.0 KiB
Diff
110 lines
4.0 KiB
Diff
From 2a67bbb0597001e42e37e2ea6eac5721df703eb4 Mon Sep 17 00:00:00 2001
|
|
From: "H.J. Lu" <hjl.tools@gmail.com>
|
|
Date: Wed, 5 Jan 2022 16:33:16 -0800
|
|
Subject: [PATCH 3/4] x86: Rename -harden-sls=indirect-branch to
|
|
-harden-sls=indirect-jmp
|
|
To: gcc-patches@gcc.gnu.org
|
|
|
|
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.
|
|
|
|
(cherry picked from commit ed8060950c64f2e449aaf90e438aa26d0d9d0b31)
|
|
---
|
|
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 fb2d6ccdd40..1daa73b190b 100644
|
|
--- a/gcc/config/i386/i386-opts.h
|
|
+++ b/gcc/config/i386/i386-opts.h
|
|
@@ -121,8 +121,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 10b6f710d5a..83d59941acf 100644
|
|
--- a/gcc/config/i386/i386.c
|
|
+++ b/gcc/config/i386/i386.c
|
|
@@ -28881,7 +28881,7 @@ ix86_output_jmp_thunk_or_indirect (const char *thunk_name,
|
|
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
|
|
@@ -29132,7 +29132,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 function return. CALL_OP is the jump target. Add a REP
|
|
@@ -29316,7 +29316,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 16dea090995..8093f0c0c7f 100644
|
|
--- a/gcc/config/i386/i386.opt
|
|
+++ b/gcc/config/i386/i386.opt
|
|
@@ -975,7 +975,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 ca3dc7ee636..7a9a7084884 100644
|
|
--- a/gcc/doc/invoke.texi
|
|
+++ b/gcc/doc/invoke.texi
|
|
@@ -25748,8 +25748,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.34.1
|
|
|