xen/arm32: Add skeleton to harden branch predictor aliasing attacks
authorJulien Grall <julien.grall@linaro.org>
Fri, 2 Feb 2018 14:19:22 +0000 (14:19 +0000)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 2 Feb 2018 19:34:54 +0000 (11:34 -0800)
commit9bd4463b5c7cc026a07b9bbd41a6a7122a95647e
tree315bf7e46881dd3f4b964c9652e7fbcb1b2f9416
parent00268cc91270c7b0aa3a1906bf7e7702db9c61c1
xen/arm32: Add skeleton to harden branch predictor aliasing attacks

Aliasing attacked against CPU branch predictors can allow an attacker to
redirect speculative control flow on some CPUs and potentially divulge
information from one context to another.

This patch adds initiatial skeleton code behind a new Kconfig option
to enable implementation-specific mitigations against these attacks
for CPUs that are affected.

Most of mitigations will have to be applied when entering to the
hypervisor from the guest context.

Because the attack is against branch predictor, it is not possible to
safely use branch instruction before the mitigation is applied.
Therefore this has to be done in the vector entry before jump to the
helper handling a given exception.

However, on arm32, each vector contain a single instruction. This means
that the hardened vector tables may rely on the state of registers that
does not hold when in the hypervisor (e.g SP is 8 bytes aligned).
Therefore hypervisor code running with guest vectors table should be
minimized and always have IRQs and SErrors masked to reduce the risk to
use them.

This patch provides an infrastructure to switch vector tables before
entering to the guest and when leaving it.

Note that alternative could have been used, but older Xen (4.8 or
earlier) doesn't have support. So avoid using alternative to ease
backporting.

This is part of XSA-254.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/Kconfig
xen/arch/arm/arm32/entry.S
xen/arch/arm/cpuerrata.c