aarch64: New Straight Line Speculation (SLS) mitigation flags
authorMatthew Malcomson <matthew.malcomson@arm.com>
Thu, 9 Jul 2020 08:11:58 +0000 (09:11 +0100)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Thu, 9 Jul 2020 08:11:58 +0000 (09:11 +0100)
commita9ba2a9b77bec7eacaf066801f22d1c366a2bc86
treea9c871fba0e6c6b389f025c54aac4151540aa020
parent2a39c42a42cdea4a8962b9e140b88e0051894f38
aarch64: New Straight Line Speculation (SLS) mitigation flags

Here we introduce the flags that will be used for straight line speculation.

The new flag introduced is `-mharden-sls=`.
This flag can take arguments of `none`, `all`, or a comma seperated list of one
or more of `retbr` or `blr`.
`none` indicates no special mitigation of the straight line speculation
vulnerability.
`all` requests all mitigations currently implemented.
`retbr` requests that the RET and BR instructions have a speculation barrier
inserted after them.
`blr` requests that BLR instructions are replaced by a BL to a function stub
using a BR with a speculation barrier after it.

Setting this on a per-function basis using attributes or the like is not
enabled, but may be in the future.

gcc/ChangeLog:

2020-06-02  Matthew Malcomson  <matthew.malcomson@arm.com>

* config/aarch64/aarch64-protos.h (aarch64_harden_sls_retbr_p):
New.
(aarch64_harden_sls_blr_p): New.
* config/aarch64/aarch64.c (enum aarch64_sls_hardening_type):
New.
(aarch64_harden_sls_retbr_p): New.
(aarch64_harden_sls_blr_p): New.
(aarch64_validate_sls_mitigation): New.
(aarch64_override_options): Parse options for SLS mitigation.
* config/aarch64/aarch64.opt (-mharden-sls): New option.
* doc/invoke.texi: Document new option.
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/aarch64.opt
gcc/doc/invoke.texi