arm-trusted-firmware/include/lib
Joel Hutton 9edd891279 Initial Spectre V1 mitigations (CVE-2017-5753).
Initial Spectre Variant 1 mitigations (CVE-2017-5753).
A potential speculative data leak was found in PSCI code, this depends
on a non-robust implementation of the `plat_get_core_pos_by_mpidr()`
function. This is considered very low-risk. This patch adds a macro to
mitigate this. Note not all code paths could be analyzed with current
tools.

Add a macro which makes a variable 'speculation safe', using the
 __builtin_speculation_safe_value function of GCC and llvm. This will be
available in GCC 9, and is planned for llvm, but is not currently in
mainline GCC or llvm. In order to implement this mitigation the compiler
must support this builtin. Support is indicated by the
__HAVE_SPECULATION_SAFE_VALUE flag.

The -mtrack-speculation option maintains a 'tracker' register, which
determines if the processor is in false speculation at any point. This
adds instructions and increases code size, but avoids the performance
impact of a hard barrier.

Without the -mtrack-speculation option, __builtin_speculation_safe_value
expands to a

    ISB
    DSB SY

sequence after a conditional branch, before the
speculation safe variable is used. With -mtrack-speculation a

    CSEL tracker, tracker, XZR, [cond];
    AND safeval,tracker;
    CSDB

sequence is added instead, clearing the vulnerable variable by
AND'ing it with the tracker register, which is zero during speculative
execution. [cond] are the status flags which will only be true during
speculative execution. For more information on
__builtin_speculation_safe_value and the -mtrack-speculation option see
https://developer.arm.com/support/arm-security-updates/speculative-processor-vulnerability/compiler-support-for-mitigations

The -mtracking option was not added, as the performance impact of the
mitigation is low, and there is only one occurence.

Change-Id: Ic9e66d1f4a5155e42e3e4055594974c230bfba3c
Signed-off-by: Joel Hutton <Joel.Hutton@Arm.com>
2018-11-26 13:22:14 +00:00
..
aarch32 Synchronise arch.h and arch_helpers.h with TF-A-Tests 2018-11-26 09:06:52 +00:00
aarch64 Synchronise arch.h and arch_helpers.h with TF-A-Tests 2018-11-26 09:06:52 +00:00
cpus Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
el3_runtime Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
extensions Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
libc Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
libfdt libfdt: Downgrade to version 1.4.6-9 2018-10-30 13:42:13 +00:00
pmf Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
psci psci: put __dead2 attribute after void in plat_psci_ops 2018-11-09 18:21:51 +01:00
xlat_tables xlat v2: Support mapping regions with allocated VA 2018-11-22 13:29:45 +00:00
zlib Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
bakery_lock.h bakery: Fix MISRA defects 2018-11-01 14:15:39 +00:00
cassert.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
coreboot.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
mmio.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
object_pool.h Introduce object pool allocator 2018-10-11 16:11:18 +02:00
optee_utils.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
runtime_instr.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
semihosting.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
smccc.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
smccc_v1.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
smccc_v2.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
spinlock.h bakery: Fix MISRA defects 2018-11-01 14:15:39 +00:00
utils.h Standardise header guards across codebase 2018-11-08 10:20:19 +00:00
utils_def.h Initial Spectre V1 mitigations (CVE-2017-5753). 2018-11-26 13:22:14 +00:00