From: Tamar Christina Date: Mon, 1 Oct 2018 13:03:31 +0000 (+0000) Subject: Set default values for stack-clash and do basic validation in back-end. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fbe9af5042f7c09bc00c105ef1a30ac7149171e4;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d6ee32846d..0eafc63fb69 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-10-01 Tamar Christina + + 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 PR target/86486 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 23524072064..fc423549590 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. */