mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/arm32: Invalidate icache on guest exist for Cortex-A15
In order to avoid aliasing attacks against the branch predictor on Cortex A-15, let's invalidate the BTB on guest exit, which can only be done by invalidating the icache (with ACTLR[0] being set). We use the same hack as for A12/A17 to perform the vector decoding. This is based on Linux patch from the kpti branch in [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Julien Grall <julien.grall@linaro.org> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
1 parent
05e0690d03
commit
665c4b6aa7
2 files changed
+34
No files matched your search
@@ -162,6 +162,26 @@ GLOBAL(hyp_traps_vector)
|
||||
|
||||
#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
|
||||
|
||||
.align 5
|
||||
GLOBAL(hyp_traps_vector_ic_inv)
|
||||
/*
|
||||
* We encode the exception entry in the bottom 3 bits of
|
||||
* SP, and we have to guarantee to be 8 bytes aligned.
|
||||
*/
|
||||
add sp, sp, #1 /* Reset 7 */
|
||||
add sp, sp, #1 /* Undef 6 */
|
||||
add sp, sp, #1 /* Hypervisor call 5 */
|
||||
add sp, sp, #1 /* Prefetch abort 4 */
|
||||
add sp, sp, #1 /* Data abort 3 */
|
||||
add sp, sp, #1 /* Hypervisor 2 */
|
||||
add sp, sp, #1 /* IRQ 1 */
|
||||
nop /* FIQ 0 */
|
||||
|
||||
mcr p15, 0, r0, c7, c5, 0 /* ICIALLU */
|
||||
isb
|
||||
|
||||
b decode_vectors
|
||||
|
||||
.align 5
|
||||
GLOBAL(hyp_traps_vector_bp_inv)
|
||||
/*
|
||||
@@ -180,6 +200,7 @@ GLOBAL(hyp_traps_vector_bp_inv)
|
||||
mcr p15, 0, r0, c7, c5, 6 /* BPIALL */
|
||||
isb
|
||||
|
||||
decode_vectors:
|
||||
.macro vect_br val, targ
|
||||
eor sp, sp, #\val
|
||||
tst sp, #7
|
||||
|
||||
@@ -180,6 +180,7 @@ static int enable_psci_bp_hardening(void *data)
|
||||
DEFINE_PER_CPU_READ_MOSTLY(const char *, bp_harden_vecs);
|
||||
|
||||
extern char hyp_traps_vector_bp_inv[];
|
||||
extern char hyp_traps_vector_ic_inv[];
|
||||
|
||||
static void __maybe_unused
|
||||
install_bp_hardening_vecs(const struct arm_cpu_capabilities *entry,
|
||||
@@ -205,6 +206,13 @@ static int enable_bp_inv_hardening(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int enable_ic_inv_hardening(void *data)
|
||||
{
|
||||
install_bp_hardening_vecs(data, hyp_traps_vector_ic_inv,
|
||||
"execute ICIALLU");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define MIDR_RANGE(model, min, max) \
|
||||
@@ -302,6 +310,11 @@ static const struct arm_cpu_capabilities arm_errata[] = {
|
||||
MIDR_ALL_VERSIONS(MIDR_CORTEX_A17),
|
||||
.enable = enable_bp_inv_hardening,
|
||||
},
|
||||
{
|
||||
.capability = ARM_HARDEN_BRANCH_PREDICTOR,
|
||||
MIDR_ALL_VERSIONS(MIDR_CORTEX_A15),
|
||||
.enable = enable_ic_inv_hardening,
|
||||
},
|
||||
#endif
|
||||
{},
|
||||
};
|
||||
|
||||