aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2018-10-01 13:03:31 +0000
committerTamar Christina <tnfchris@gcc.gnu.org>2018-10-01 13:03:31 +0000
commitfbe9af5042f7c09bc00c105ef1a30ac7149171e4 (patch)
treeff7274453dc6ffacd117f066e0a1eebb7e81e800 /gcc
parent630b1e3a187dc843958e8966345da6191226b8e2 (diff)
downloadgcc-fbe9af5042f7c09bc00c105ef1a30ac7149171e4.zip
gcc-fbe9af5042f7c09bc00c105ef1a30ac7149171e4.tar.gz
gcc-fbe9af5042f7c09bc00c105ef1a30ac7149171e4.tar.bz2
Set default values for stack-clash and do basic validation in back-end.
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. gcc/ PR target/86486 * config/aarch64/aarch64.c (aarch64_override_options_internal): Add validation for stack-clash parameters and set defaults. From-SVN: r264753
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/aarch64/aarch64.c31
2 files changed, 37 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4d6ee32..0eafc63f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,12 @@
2018-10-01 Tamar Christina <tamar.christina@arm.com>
PR target/86486
+ * config/aarch64/aarch64.c (aarch64_override_options_internal):
+ Add validation for stack-clash parameters and set defaults.
+
+2018-10-01 Tamar Christina <tamar.christina@arm.com>
+
+ PR target/86486
* configure.ac: Add stack-clash-protection-guard-size.
* doc/install.texi: Document it.
* config.in (DEFAULT_STK_CLASH_GUARD_SIZE): New.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 2352407..fc42354 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -10992,6 +10992,37 @@ aarch64_override_options_internal (struct gcc_options *opts)
opts->x_param_values,
global_options_set.x_param_values);
+ /* If the user hasn't changed it via configure then set the default to 64 KB
+ for the backend. */
+ maybe_set_param_value (PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE,
+ DEFAULT_STK_CLASH_GUARD_SIZE == 0
+ ? 16 : DEFAULT_STK_CLASH_GUARD_SIZE,
+ opts->x_param_values,
+ global_options_set.x_param_values);
+
+ /* Validate the guard size. */
+ int guard_size = PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_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.",
+ guard_size, (1ULL << guard_size) / 1024ULL);
+
+ /* Enforce that interval is the same size as size so the mid-end does the
+ right thing. */
+ maybe_set_param_value (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL,
+ 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
+ = PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL);
+ if (guard_size != probe_interval)
+ error ("stack clash guard size '%d' must be equal to probing interval "
+ "'%d'", 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. */