arm-trusted-firmware/lib/psci
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 xlat v2: Flush xlat tables after being modified 2018-08-07 12:47:12 +01:00
aarch64 Remove all other deprecated interfaces and files 2018-09-28 15:31:53 +01:00
psci_common.c PSCI: Do not flush cache when unneeded 2018-10-10 13:07:56 -05:00
psci_lib.mk mem_protect: Add mem_protect API 2017-09-25 13:32:20 +01:00
psci_main.c psci: platform control of SYSTEM_SUSPEND entry 2018-10-11 12:57:49 +02:00
psci_mem_protect.c PSCI: Fix MISRA defects in MEM_PROTECT 2018-07-24 09:19:22 +01:00
psci_off.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00
psci_on.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00
psci_private.h psci: Use bool in internal interfaces 2018-08-02 15:08:18 +01:00
psci_setup.c Mark BL31 initialization functions 2018-10-03 11:47:30 +01:00
psci_stat.c Initial Spectre V1 mitigations (CVE-2017-5753). 2018-11-26 13:22:14 +00:00
psci_suspend.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00
psci_system_off.c PSCI: Fix MISRA defects in ON/OFF/SUSPEND/SYSTEM_OFF 2018-07-24 09:19:04 +01:00