+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
+ * config/s390/s390.md ("allocate_stack"): Call
+ anti_adjust_stack_and_probe_stack_clash when stack clash
+ protection is enabled.
+ * explow.c (anti_adjust_stack_and_probe_stack_clash): Remove
+ prototype. Remove static.
+ * explow.h (anti_adjust_stack_and_probe_stack_clash): Add
+ prototype.
+
2020-05-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
* config/rs6000/altivec.h (vec_extractl): New #define.
rtx temp = gen_reg_rtx (Pmode);
emit_move_insn (temp, s390_back_chain_rtx ());
- anti_adjust_stack (operands[1]);
+
+ if (flag_stack_clash_protection)
+ anti_adjust_stack_and_probe_stack_clash (operands[1]);
+ else
+ anti_adjust_stack (operands[1]);
+
emit_move_insn (s390_back_chain_rtx (), temp);
emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
#include "output.h"
static rtx break_out_memory_refs (rtx);
-static void anti_adjust_stack_and_probe_stack_clash (rtx);
/* Truncate and perhaps sign-extend C as appropriate for MODE. */
allocate/probe beyond that because this probing style does not
guarantee signal handling capability if the guard is hit. */
-static void
+void
anti_adjust_stack_and_probe_stack_clash (rtx size)
{
/* First ensure SIZE is Pmode. */
/* Add some bytes to the stack while probing it. An rtx says how many. */
extern void anti_adjust_stack_and_probe (rtx, bool);
+/* Add some bytes to the stack while probing it. An rtx says how
+ many. Add additional probes to prevent stack clashing attacks. */
+extern void anti_adjust_stack_and_probe_stack_clash (rtx);
+
/* Support for building allocation/probing loops for stack-clash
protection of dyamically allocated stack space. */
extern void compute_stack_clash_protection_loop_data (rtx *, rtx *, rtx *,
+2020-05-14 Andreas Krebbel <krebbel@linux.ibm.com>
+
+ * gcc.target/s390/stack-clash-3.c: New test.
+
2020-05-13 Kelvin Nilsen <kelvin@gcc.gnu.org>
* gcc.target/powerpc/vec-extracth-0.c: New.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=z900 -fstack-clash-protection -mbackchain" } */
+
+extern void bar (char *);
+
+void
+foo ()
+{
+ char * mem = __builtin_alloca (20000);
+ bar (mem);
+}
+
+/* For alloca a common code routine emits the probes. Make sure the
+ "probe_stack" expander is used in that case. We want to use mem
+ compares instead of stores. */
+/* { dg-final { scan-assembler-times "cg\t" 5 { target lp64 } } } */
+/* { dg-final { scan-assembler-times "c\t" 5 { target { ! lp64 } } } } */