]> xenbits.xensource.com Git - xen.git/commit
xen/arm64: Add skeleton to harden the branch predictor aliasing attacks
authorJulien Grall <julien.grall@linaro.org>
Tue, 16 Jan 2018 14:23:36 +0000 (14:23 +0000)
committerStefano Stabellini <sstabellini@kernel.org>
Wed, 17 Jan 2018 21:44:57 +0000 (13:44 -0800)
commit4c4fddc166cf528aca49540bcc9ee4f196b01dac
tree73ceb2224dadd575469ac7b9287c32279b7eba6d
parentba73070af43a38d200413f446d6a718e108867b6
xen/arm64: Add skeleton to harden the 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 initial skeleton code behind a new Kconfig option to
enable implementation-specific mitigations against these attacks for
CPUs that are affected.

Most of the mitigations will have to be applied when entering to the
hypervisor from the guest context. For safety, it is applied at every
exception entry. So there are potential for optimizing when receiving
an exception at the same level.

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.

On Arm64, each vector can hold 32 instructions. This leave us 31
instructions for the mitigation. The last one is the branch instruction
to the helper.

Because a platform may have CPUs with different micro-architectures,
per-CPU vector table needs to be provided. Realistically, only a few
different mitigations will be necessary. So provide a small set of
vector tables. They will be re-used and patch with the mitigations
on-demand.

This is based on the work done in Linux (see [1]).

This is part of XSA-254.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
branch ktpi

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/Kconfig
xen/arch/arm/arm64/Makefile
xen/arch/arm/arm64/bpi.S [new file with mode: 0644]
xen/arch/arm/cpuerrata.c
xen/arch/arm/traps.c
xen/include/asm-arm/cpuerrata.h
xen/include/asm-arm/cpufeature.h
xen/include/asm-arm/processor.h