[AArch64] Set default values for stack-clash and do basic validation in back-end. [Patch (5/6)]

Message ID 20180711112251.GA15936@arm.com
State New
Headers show
  • [AArch64] Set default values for stack-clash and do basic validation in back-end. [Patch (5/6)]
Related show

Commit Message

Tamar Christina July 11, 2018, 11:22 a.m.
Hi All,

This patch enforces that the default guard size for stack-clash protection for
AArch64 be 64KB unless the user has overriden it via configure in which case
the user value is used as long as that value is within the valid range.

It also does some basic validation to ensure that the guard size is only 4KB or
64KB and also enforces that for aarch64 the stack-clash probing interval is
equal to the guard size.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
Target was tested with stack clash on and off by default.

Ok for trunk?


2018-07-11  Tamar Christina  <tamar.christina@arm.com>

	PR target/86486
	* config/aarch64/aarch64.c (aarch64_override_options_internal):
	Add validation for stack-clash parameters.



diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ae3c2fb85256b1e95e2242f3f16a027e918ba368..e62d8a92ff53128e5e10ffd3b52eb8898869b756 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -10905,6 +10905,36 @@  aarch64_override_options_internal (struct gcc_options *opts)
+  /* If the user hasn't change it via configure then set the default to 64 KB
+     for the backend.  */
+      maybe_set_param_value (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE, 16,
+			    opts->x_param_values,
+			    global_options_set.x_param_values);
+  /* Validate the guard size.  */
+  if (guard_size != 12 && guard_size != 16)
+      error ("only values 12 (4 KB) and 16 (64 KB) are supported for guard "
+	     "size.  Given value %d (%llu KB) is out of range.\n",
+	     guard_size, (1ULL << guard_size) / 1024ULL);
+  /* Enforce that interval is the same size as size so the mid-end does the
+     right thing.  */
+			 guard_size,
+			 opts->x_param_values,
+			 global_options_set.x_param_values);
+  /* The maybe_set calls won't update the value if the user has explicitly set
+     one.  Which means we need to validate that probing interval and guard size
+     are equal.  */
+  int probe_interval
+  if (guard_size != probe_interval)
+    error ("stack clash guard size '%d' must be equal to probing interval "
+	   "'%d'\n", guard_size, probe_interval);
   /* Enable sw prefetching at specified optimization level for
      CPUS that have prefetch.  Lower optimization level threshold by 1
      when profiling is enabled.  */